From e6a6e46a94eaac02cf2223ff5ab5962909e2ee1d Mon Sep 17 00:00:00 2001 From: renbin Date: Tue, 30 May 2023 17:33:48 +0800 Subject: [PATCH] fix: Title bar disappear when open without args. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 适配紧凑模式引入问题,无参数打开相册标题栏消失。 调整初始化设置标题栏方式。 Log: Title bar disappear when open without args. Influence: TitleBar --- src/album/main.cpp | 5 ++--- src/album/mainwindow.cpp | 10 ++++++++++ src/album/mainwindow.h | 5 +++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/album/main.cpp b/src/album/main.cpp index 1c6853f4..d1b0139b 100644 --- a/src/album/main.cpp +++ b/src/album/main.cpp @@ -162,14 +162,13 @@ int main(int argc, char *argv[]) }; Eventlogutils::GetInstance()->writeLogs(objStartEvent); MainWindow w; - bool titleVisible = w.titlebar()->isVisible(); dApp->setMainWindow(&w); w.show(); dAppNew->setMainWindow(&w); Dtk::Widget::moveToCenter(&w); - // show()会重置标题栏显示状态 - w.titlebar()->setVisible(titleVisible); + // show()会重置标题栏显示状态,根据缓存状态重新设置标题栏是否可见 + w.titlebar()->setVisible(w.isTitleBarVisible()); //#if (DTK_VERSION >= DTK_VERSION_CHECK(5, 5, 0, 0)) // dAppNew->ignoreVirtualKeyboard(&w); //禁止虚拟键盘顶起主界面标题栏(DTK5.5有效) diff --git a/src/album/mainwindow.cpp b/src/album/mainwindow.cpp index 7b18980f..c6bae473 100644 --- a/src/album/mainwindow.cpp +++ b/src/album/mainwindow.cpp @@ -2129,6 +2129,14 @@ void MainWindow::startMonitor(const QList &paths, const QStringList } } +/** + @return 返回当前标题栏是否可见 + */ +bool MainWindow::isTitleBarVisible() const +{ + return m_bTitleBarVisible; +} + void MainWindow::wheelEvent(QWheelEvent *event) { if (DApplication::keyboardModifiers() == Qt::ControlModifier) { @@ -2143,6 +2151,8 @@ void MainWindow::wheelEvent(QWheelEvent *event) void MainWindow::setTitleBarHideden(bool hide) { + m_bTitleBarVisible = !hide; + if (hide) { titlebar()->setVisible(false); setTitlebarShadowEnabled(false); diff --git a/src/album/mainwindow.h b/src/album/mainwindow.h index ac4ed6b6..292e9357 100644 --- a/src/album/mainwindow.h +++ b/src/album/mainwindow.h @@ -97,6 +97,9 @@ class MainWindow : public DMainWindow, public ImageEngineImportObject QJsonObject createShorcutJson(); //开始监控 void startMonitor(const QList &paths, const QStringList &albumNames, const QList &UIDs); + + bool isTitleBarVisible() const; + private: void thumbnailZoomIn(); void thumbnailZoomOut(); @@ -259,6 +262,8 @@ public slots: QShortcut *m_ReCtrlUp = nullptr; QShortcut *m_CtrlDown = nullptr; + bool m_bTitleBarVisible = true; // 标题栏是否可见标识 + MainWindow(const MainWindow &) = delete; MainWindow operator=(const MainWindow &) = delete;