From 59690b8ab4f3e4c2cea0467f40e858080943dd62 Mon Sep 17 00:00:00 2001 From: Zhao Yuhang <2546789017@qq.com> Date: ćšć, 14 12æ 2023 20:45:33 +0800 Subject: [PATCH] tweak --- examples/shared/widgetframe/windowbar.cpp | 6 +-- src/widgets/widgetwindowagent.cpp | 9 +--- examples/mainwindow/main.cpp | 2 src/core/contexts/qtwindowcontext.cpp | 3 - examples/shared/widgetframe/windowbutton.cpp | 6 +-- examples/mainwindow/mainwindow.cpp | 33 ++++++++-------- src/core/contexts/win32windowcontext.cpp | 2 src/quick/quickwindowagent.cpp | 9 +--- 8 files changed, 29 insertions(+), 41 deletions(-) diff --git a/examples/mainwindow/main.cpp b/examples/mainwindow/main.cpp index 8813a60..8bbaab3 100644 --- a/examples/mainwindow/main.cpp +++ b/examples/mainwindow/main.cpp @@ -21,7 +21,7 @@ #ifdef Q_OS_WINDOWS a.setFont([]() { - QFont f("Microsoft YaHei"); + QFont f(QStringLiteral("Microsoft YaHei UI")); f.setPixelSize(15); return f; }()); diff --git a/examples/mainwindow/mainwindow.cpp b/examples/mainwindow/mainwindow.cpp index da44b23..3566081 100644 --- a/examples/mainwindow/mainwindow.cpp +++ b/examples/mainwindow/mainwindow.cpp @@ -32,15 +32,15 @@ installWindowAgent(); auto clockWidget = new ClockWidget(); - clockWidget->setObjectName("clock-widget"); + clockWidget->setObjectName(QStringLiteral("clock-widget")); clockWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setCentralWidget(clockWidget); - if (QFile qss(":/dark-style.qss"); qss.open(QIODevice::ReadOnly | QIODevice::Text)) { + if (QFile qss(QStringLiteral(":/dark-style.qss")); qss.open(QIODevice::ReadOnly | QIODevice::Text)) { setStyleSheet(QString::fromUtf8(qss.readAll())); } - setWindowTitle("Example MainWindow"); + setWindowTitle(tr("Example MainWindow")); resize(640, 480); } @@ -80,8 +80,7 @@ }); } -MainWindow::~MainWindow() { -} +MainWindow::~MainWindow() = default; bool MainWindow::event(QEvent *event) { switch (event->type()) { @@ -113,41 +112,41 @@ auto menuBar = []() { auto menuBar = new QMenuBar(); - auto file = new QMenu("File(&F)", menuBar); - file->addAction(new QAction("New(&N)", menuBar)); - file->addAction(new QAction("Open(&O)", menuBar)); + auto file = new QMenu(tr("File(&F)"), menuBar); + file->addAction(new QAction(tr("New(&N)"), menuBar)); + file->addAction(new QAction(tr("Open(&O)"), menuBar)); - auto edit = new QMenu("Edit(&E)", menuBar); - edit->addAction(new QAction("Undo(&U)", menuBar)); - edit->addAction(new QAction("Redo(&R)", menuBar)); + auto edit = new QMenu(tr("Edit(&E)"), menuBar); + edit->addAction(new QAction(tr("Undo(&U)"), menuBar)); + edit->addAction(new QAction(tr("Redo(&R)"), menuBar)); menuBar->addMenu(file); menuBar->addMenu(edit); return menuBar; }(); - menuBar->setObjectName("win-menu-bar"); + menuBar->setObjectName(QStringLiteral("win-menu-bar")); auto titleLabel = new QLabel(); titleLabel->setAlignment(Qt::AlignCenter); - titleLabel->setObjectName("win-title-label"); + titleLabel->setObjectName(QStringLiteral("win-title-label")); auto iconButton = new QWK::WindowButton(); - iconButton->setObjectName("icon-button"); + iconButton->setObjectName(QStringLiteral("icon-button")); iconButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); auto minButton = new QWK::WindowButton(); - minButton->setObjectName("min-button"); + minButton->setObjectName(QStringLiteral("min-button")); minButton->setProperty("system-button", true); minButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); auto maxButton = new QWK::WindowButton(); maxButton->setCheckable(true); - maxButton->setObjectName("max-button"); + maxButton->setObjectName(QStringLiteral("max-button")); maxButton->setProperty("system-button", true); maxButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); auto closeButton = new QWK::WindowButton(); - closeButton->setObjectName("close-button"); + closeButton->setObjectName(QStringLiteral("close-button")); closeButton->setProperty("system-button", true); closeButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); diff --git a/examples/shared/widgetframe/windowbar.cpp b/examples/shared/widgetframe/windowbar.cpp index 2e1f60e..51a2d3e 100644 --- a/examples/shared/widgetframe/windowbar.cpp +++ b/examples/shared/widgetframe/windowbar.cpp @@ -12,8 +12,7 @@ autoIcon = false; } - WindowBarPrivate::~WindowBarPrivate() { - } + WindowBarPrivate::~WindowBarPrivate() = default; void WindowBarPrivate::init() { Q_Q(WindowBar); @@ -54,8 +53,7 @@ WindowBar::WindowBar(QWidget *parent) : WindowBar(*new WindowBarPrivate(), parent) { } - WindowBar::~WindowBar() { - } + WindowBar::~WindowBar() = default; QMenuBar *WindowBar::menuBar() const { Q_D(const WindowBar); diff --git a/examples/shared/widgetframe/windowbutton.cpp b/examples/shared/widgetframe/windowbutton.cpp index 7d21cb2..657289c 100644 --- a/examples/shared/widgetframe/windowbutton.cpp +++ b/examples/shared/widgetframe/windowbutton.cpp @@ -6,11 +6,9 @@ namespace QWK { - WindowButtonPrivate::WindowButtonPrivate() { - } + WindowButtonPrivate::WindowButtonPrivate() = default; - WindowButtonPrivate::~WindowButtonPrivate() { - } + WindowButtonPrivate::~WindowButtonPrivate() = default; void WindowButtonPrivate::init() { } diff --git a/src/core/contexts/qtwindowcontext.cpp b/src/core/contexts/qtwindowcontext.cpp index ea2bba5..ee5d27d 100644 --- a/src/core/contexts/qtwindowcontext.cpp +++ b/src/core/contexts/qtwindowcontext.cpp @@ -43,8 +43,7 @@ QtWindowContext::QtWindowContext() : AbstractWindowContext() { } - QtWindowContext::~QtWindowContext() { - } + QtWindowContext::~QtWindowContext() = default; QString QtWindowContext::key() const { return QStringLiteral("qt"); diff --git a/src/core/contexts/win32windowcontext.cpp b/src/core/contexts/win32windowcontext.cpp index 161903e..0f7b6f7 100644 --- a/src/core/contexts/win32windowcontext.cpp +++ b/src/core/contexts/win32windowcontext.cpp @@ -800,7 +800,7 @@ case ShowSystemMenuHook: { const auto &pos = *static_cast<const QPoint *>(data); auto hWnd = reinterpret_cast<HWND>(m_windowHandle->winId()); - showSystemMenu2(hWnd, qpoint2point(pos), false, + showSystemMenu2(hWnd, qpoint2point(QHighDpi::toNativeGlobalPosition(pos, m_windowHandle)), false, m_delegate->isHostSizeFixed(m_host)); return; } diff --git a/src/quick/quickwindowagent.cpp b/src/quick/quickwindowagent.cpp index 9422f65..2e69f76 100644 --- a/src/quick/quickwindowagent.cpp +++ b/src/quick/quickwindowagent.cpp @@ -8,11 +8,9 @@ namespace QWK { - QuickWindowAgentPrivate::QuickWindowAgentPrivate() { - } + QuickWindowAgentPrivate::QuickWindowAgentPrivate() = default; - QuickWindowAgentPrivate::~QuickWindowAgentPrivate() { - } + QuickWindowAgentPrivate::~QuickWindowAgentPrivate() = default; void QuickWindowAgentPrivate::init() { } @@ -21,8 +19,7 @@ : QuickWindowAgent(*new QuickWindowAgentPrivate(), parent) { } - QuickWindowAgent::~QuickWindowAgent() { - } + QuickWindowAgent::~QuickWindowAgent() = default; bool QuickWindowAgent::setup(QQuickWindow *window) { Q_ASSERT(window); diff --git a/src/widgets/widgetwindowagent.cpp b/src/widgets/widgetwindowagent.cpp index ff76aef..fc21be4 100644 --- a/src/widgets/widgetwindowagent.cpp +++ b/src/widgets/widgetwindowagent.cpp @@ -9,11 +9,9 @@ namespace QWK { - WidgetWindowAgentPrivate::WidgetWindowAgentPrivate() { - } + WidgetWindowAgentPrivate::WidgetWindowAgentPrivate() = default; - WidgetWindowAgentPrivate::~WidgetWindowAgentPrivate() { - } + WidgetWindowAgentPrivate::~WidgetWindowAgentPrivate() = default; void WidgetWindowAgentPrivate::init() { } @@ -22,8 +20,7 @@ : WidgetWindowAgent(*new WidgetWindowAgentPrivate(), parent) { } - WidgetWindowAgent::~WidgetWindowAgent() { - } + WidgetWindowAgent::~WidgetWindowAgent() = default; bool WidgetWindowAgent::setup(QWidget *w) { Q_ASSERT(w); -- Gitblit v1.9.1