Skip to content

Commit

Permalink
fix: Title bar disappear when open without args.
Browse files Browse the repository at this point in the history
适配紧凑模式引入问题,无参数打开相册标题栏消失。
调整初始化设置标题栏方式。

Log: Title bar disappear when open without args.
Influence: TitleBar
  • Loading branch information
rb-union authored and starhcq committed May 30, 2023
1 parent 9e6f819 commit e6a6e46
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/album/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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有效)
Expand Down
10 changes: 10 additions & 0 deletions src/album/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2129,6 +2129,14 @@ void MainWindow::startMonitor(const QList<QStringList> &paths, const QStringList
}
}

/**
@return 返回当前标题栏是否可见
*/
bool MainWindow::isTitleBarVisible() const
{
return m_bTitleBarVisible;
}

void MainWindow::wheelEvent(QWheelEvent *event)
{
if (DApplication::keyboardModifiers() == Qt::ControlModifier) {
Expand All @@ -2143,6 +2151,8 @@ void MainWindow::wheelEvent(QWheelEvent *event)

void MainWindow::setTitleBarHideden(bool hide)
{
m_bTitleBarVisible = !hide;

if (hide) {
titlebar()->setVisible(false);
setTitlebarShadowEnabled(false);
Expand Down
5 changes: 5 additions & 0 deletions src/album/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ class MainWindow : public DMainWindow, public ImageEngineImportObject
QJsonObject createShorcutJson();
//开始监控
void startMonitor(const QList<QStringList> &paths, const QStringList &albumNames, const QList<int> &UIDs);

bool isTitleBarVisible() const;

private:
void thumbnailZoomIn();
void thumbnailZoomOut();
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit e6a6e46

Please sign in to comment.