From e476568d6971e77ee16802a80a6ae89c7b4432d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Sat, 4 Nov 2023 00:08:00 +0100 Subject: [PATCH] Support timeline in window (multi-monitor) --- src/app/GUI/mainwindow.cpp | 47 ++++++++++++++++++++++++++++++++++++-- src/app/GUI/mainwindow.h | 4 ++++ 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/src/app/GUI/mainwindow.cpp b/src/app/GUI/mainwindow.cpp index b76cd0214..c39a177e7 100755 --- a/src/app/GUI/mainwindow.cpp +++ b/src/app/GUI/mainwindow.cpp @@ -139,6 +139,8 @@ MainWindow::MainWindow(Document& document, , mAutoSaveTimer(nullptr) , mAboutWidget(nullptr) , mAboutWindow(nullptr) + , mTimelineWindow(nullptr) + , mTimelineWindowAct(nullptr) { Q_ASSERT(!sInstance); sInstance = this; @@ -1047,7 +1049,26 @@ void MainWindow::setupMenuBar() viewTimelineAct->setChecked(true); viewTimelineAct->setShortcut(QKeySequence(Qt::Key_T)); connect(viewTimelineAct, &QAction::triggered, - this, [this](bool triggered) { mTimeline->setVisible(triggered); }); + this, [this](bool triggered) { + if (mTimelineWindowAct->isChecked()) { + openTimelineWindow(); + } else { mTimeline->setVisible(triggered); } + }); + + mTimelineWindowAct = mViewMenu->addAction(tr("Timeline Window")); + mTimelineWindowAct->setCheckable(true); + connect(mTimelineWindowAct, &QAction::triggered, + this, [this](bool triggered) { + if (!triggered) { + statusBar()->showMessage(tr("Restart Friction to apply"), 5000); + // TODO: move widget from window to main ui without restart + } else { + openTimelineWindow(); + } + AppSupport::setSettings("ui", + "TimelineWindow", + triggered); + }); /*mPanelsMenu = mViewMenu->addMenu(tr("Docks", "MenuBar_View")); @@ -1245,7 +1266,7 @@ void MainWindow::openAboutWindow() mAboutWindow = new Window(this, mAboutWidget, tr("About"), - "AboutWindow", + QString("AboutWindow"), false, false); mAboutWindow->setMinimumSize(640, 480); @@ -1253,6 +1274,19 @@ void MainWindow::openAboutWindow() mAboutWindow->focusWindow(); } +void MainWindow::openTimelineWindow() +{ + if (!mTimelineWindow) { + mTimelineWindow = new Window(this, + mTimeline, + tr("Timeline"), + QString("TimelineWindow"), + true, + true); + } + mTimelineWindow->focusWindow(); +} + void MainWindow::openWelcomeDialog() { mStackWidget->setCurrentIndex(mStackIndexWelcome); @@ -2001,11 +2035,20 @@ void MainWindow::readSettings(const QString &openProject) bool isFull = AppSupport::getSettings("ui", "fullScreen", false).toBool(); + bool isTimelineWindow = AppSupport::getSettings("ui", + "TimelineWindow", + false).toBool(); mViewFullScreenAct->blockSignals(true); mViewFullScreenAct->setChecked(isFull); mViewFullScreenAct->blockSignals(false); + mTimelineWindowAct->blockSignals(true); + mTimelineWindowAct->setChecked(isTimelineWindow); + mTimelineWindowAct->blockSignals(false); + + if (isTimelineWindow) { openTimelineWindow(); } + if (isFull) { showFullScreen(); } else if (isMax) { showMaximized(); } diff --git a/src/app/GUI/mainwindow.h b/src/app/GUI/mainwindow.h index 30bff45d7..8441998ba 100755 --- a/src/app/GUI/mainwindow.h +++ b/src/app/GUI/mainwindow.h @@ -391,6 +391,10 @@ class MainWindow : public QMainWindow Window *mAboutWindow; void openAboutWindow(); + Window *mTimelineWindow; + QAction *mTimelineWindowAct; + void openTimelineWindow(); + protected: void keyPressEvent(QKeyEvent *event); bool eventFilter(QObject *obj, QEvent *e);