Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port deprecated Qt functionality #70

Merged
merged 6 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/configappearancewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void ConfigAppearanceWidget::setItemToolTip(QTableWidgetItem *item, const QFont
{
const QFontMetrics metrics(font);
ui.itemTable->setRowHeight(m_itemHighlighted, metrics.height() + m_itemMargin);
if (metrics.width(item->text()) >= ui.itemTable->contentsRect().width() - 30)
if (metrics.horizontalAdvance(item->text()) >= ui.itemTable->contentsRect().width() - 30)
item->setToolTip(item->text());
else
item->setToolTip(QString());
Expand Down
2 changes: 1 addition & 1 deletion app/linenumberwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void LineNumberWidget::paintEvent(QPaintEvent *event)
if (bottom >= event->rect().top()) {
for (int i = 0; i < userBookmarks.length(); ++i) {
if (userBookmarks.at(i) == lineNumber) {
painter.fillRect(2, top, fm.width(QLatin1Char('B')) + 4, lineHeight,
painter.fillRect(2, top, fm.horizontalAdvance(QLatin1Char('B')) + 4, lineHeight,
m_highlightBrush);
painter.setPen(m_highlightedTextPen);
painter.drawText(4, top, width() - 4, lineHeight, Qt::AlignLeft | Qt::AlignTop,
Expand Down
4 changes: 2 additions & 2 deletions app/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#endif

#include <QMenuBar>
#include <QScreen>
#include <QStatusBar>
#include <QtCore/QTextCodec>
#include <QtCore/QProcess>
Expand All @@ -44,7 +45,6 @@
#include <QtCore/QTimer>
#include <QtGui/QCloseEvent>
#include <QtGui/QDesktopServices>
#include <QtWidgets/QDesktopWidget>
#include <QtWidgets/QDockWidget>
#include <QtWidgets/QLabel>
#include <QtWidgets/QMessageBox>
Expand Down Expand Up @@ -955,7 +955,7 @@ void MainWindow::readSettings()

QSettings settings;
settings.beginGroup(QLatin1String("MainWindow"));
const int screenWidth = QApplication::desktop()->availableGeometry().width();
const int screenWidth = this->screen()->geometry().width();
QSize size;
if (screenWidth > 1200)
size = settings.value(QLatin1String("size"), QSize(1200, 600)).toSize();
Expand Down
4 changes: 2 additions & 2 deletions app/tikzcommandinserter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,8 @@ void TikzCommandInserter::addListWidgetItems(QListWidget *listWidget,
QString itemText = commandList.children.at(i).title;
item->setText(itemText.remove(QLatin1Char('&')));

item->setBackgroundColor(titleBg);
item->setTextColor(titleFg);
item->setBackground(titleBg);
item->setForeground(titleFg);
item->setFont(titleFont);

addListWidgetItems(listWidget, standardPalette, commandList.children.at(i));
Expand Down
5 changes: 3 additions & 2 deletions app/tikzeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ void TikzEditor::paintSpace(QPainter &painter, qreal x, qreal y, int spaceWidth)
void TikzEditor::printWhiteSpaces(QPainter &painter)
{
const QFontMetrics fontMetrics = QFontMetrics(document()->defaultFont());
const int spaceWidth = fontMetrics.width(QLatin1Char(' '));
const int spaceWidth = fontMetrics.horizontalAdvance(QLatin1Char(' '));
const int fontHeight = fontMetrics.height();
QTextCursor cursor = textCursor();

Expand Down Expand Up @@ -747,7 +747,8 @@ int TikzEditor::lineNumberAreaWidth()
++digits;
digits = qMax(4, digits) + 1;

return m_showLineNumberArea ? 3 + fontMetrics().width(QLatin1Char('9')) * digits : 0;
return m_showLineNumberArea ? 3 + fontMetrics().horizontalAdvance(QLatin1Char('9')) * digits
: 0;
}

void TikzEditor::updateLineNumberAreaWidth()
Expand Down
3 changes: 2 additions & 1 deletion app/tikzeditorview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ void TikzEditorView::setFont(const QFont &editorFont)
fm.setFontPointSize(editorFont.pointSize());
m_tikzEditor->setCurrentCharFormat(fm);

m_tikzEditor->setTabStopWidth(m_tikzEditor->fontMetrics().width(QLatin1String(" ")));
m_tikzEditor->setTabStopDistance(
m_tikzEditor->fontMetrics().horizontalAdvance(QLatin1String(" ")));
}

void TikzEditorView::createActions()
Expand Down
5 changes: 3 additions & 2 deletions common/tikzpreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <QDesktopWidget>
#include <QGraphicsProxyWidget>
#include <QMenu>
#include <QScreen>
#include <QScrollBar>
#include <QToolBar>

Expand Down Expand Up @@ -92,7 +93,7 @@ void TikzPreview::contextMenuEvent(QContextMenuEvent *event)

QSize TikzPreview::sizeHint() const
{
const int screenWidth = QApplication::desktop()->availableGeometry().width();
const int screenWidth = this->screen()->geometry().width();
if (screenWidth > 1200)
return QSize(500, 400);
else if (screenWidth > 1024)
Expand Down Expand Up @@ -404,7 +405,7 @@ void TikzPreview::setBackgroundColor(QColor color)
void TikzPreview::wheelEvent(QWheelEvent *event)
{
if (event->modifiers() == Qt::ControlModifier) {
if (event->delta() > 0)
if (event->angleDelta().y() > 0)
zoomIn();
else
zoomOut();
Expand Down
2 changes: 1 addition & 1 deletion common/tikzpreviewgenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ static QString createTempTikzFile(const QString &tikzFileBaseName, const QString
QTextStream tikzStream(&tikzFile);
codecProfile->configureStreamEncoding(tikzStream);

tikzStream << tikzCode << endl;
tikzStream << tikzCode << Qt::endl;
tikzStream.flush();

tikzFile.close();
Expand Down