Skip to content

Commit

Permalink
Support timeline in window (multi-monitor)
Browse files Browse the repository at this point in the history
  • Loading branch information
rodlie committed Nov 3, 2023
1 parent ba6c997 commit e476568
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
47 changes: 45 additions & 2 deletions src/app/GUI/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ MainWindow::MainWindow(Document& document,
, mAutoSaveTimer(nullptr)
, mAboutWidget(nullptr)
, mAboutWindow(nullptr)
, mTimelineWindow(nullptr)
, mTimelineWindowAct(nullptr)
{
Q_ASSERT(!sInstance);
sInstance = this;
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -1245,14 +1266,27 @@ void MainWindow::openAboutWindow()
mAboutWindow = new Window(this,
mAboutWidget,
tr("About"),
"AboutWindow",
QString("AboutWindow"),
false,
false);
mAboutWindow->setMinimumSize(640, 480);
}
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);
Expand Down Expand Up @@ -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(); }

Expand Down
4 changes: 4 additions & 0 deletions src/app/GUI/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e476568

Please sign in to comment.