Skip to content

Commit

Permalink
Show project profile in title bar (#1624)
Browse files Browse the repository at this point in the history
* Show project profile in title bar

As suggested here:
https://forum.shotcut.org/t/settings-video-mode/12790/2

* Show the project file path in the title bar

Length of the path+name is limited to 1/4 of the window width.
  • Loading branch information
bmatherly authored Jan 28, 2025
1 parent 7669e62 commit 5a04984
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ void MainWindow::connectUISignals()
connect(this, &MainWindow::producerOpened, this, &MainWindow::onProducerOpened);
connect(ui->mainToolBar, SIGNAL(visibilityChanged(bool)), SLOT(onToolbarVisibilityChanged(bool)));
ui->actionSave->setEnabled(false);
connect(this, &MainWindow::audioChannelsChanged, this, &MainWindow::updateWindowTitle);
connect(this, &MainWindow::producerOpened, this, &MainWindow::updateWindowTitle);
connect(this, &MainWindow::profileChanged, this, &MainWindow::updateWindowTitle);
}

void MainWindow::setupAndConnectUndoStack()
Expand Down Expand Up @@ -2291,19 +2294,33 @@ void MainWindow::configureVideoWidget()

void MainWindow::setCurrentFile(const QString &filename)
{
QString shownName = tr("Untitled");
if (filename == untitledFileName())
m_currentFile.clear();
else
m_currentFile = filename;
if (!m_currentFile.isEmpty())
shownName = QFileInfo(m_currentFile).fileName();
updateWindowTitle();
ui->actionShowProjectFolder->setDisabled(m_currentFile.isEmpty());
}

void MainWindow::updateWindowTitle()
{
QString shownName = tr("Untitled");
if (!m_currentFile.isEmpty()) {
shownName = QFileInfo(m_currentFile).filePath();
shownName = fontMetrics().elidedText(shownName, Qt::ElideLeft, width() / 4);
}
QString profileText = tr("%1x%2 %3fps %4ch").arg(
QString::number(MLT.profile().width(), 'f', 0),
QString::number(MLT.profile().height(), 'f', 0),
QString::number(MLT.profile().fps(), 'g', 2),
QString::number(Settings.playerAudioChannels(), 'f', 0));
#ifdef Q_OS_MAC
setWindowTitle(QStringLiteral("%1 - %2").arg(shownName).arg(qApp->applicationName()));
setWindowTitle(QStringLiteral("%1 - %2 - %3").arg(shownName).arg(profileText).arg(
qApp->applicationName()));
#else
setWindowTitle(QStringLiteral("%1[*] - %2").arg(shownName).arg(qApp->applicationName()));
setWindowTitle(QStringLiteral("%1[*] - %2 - %3").arg(shownName).arg(profileText).arg(
qApp->applicationName()));
#endif
ui->actionShowProjectFolder->setDisabled(m_currentFile.isEmpty());
}

void MainWindow::on_actionAbout_Shotcut_triggered()
Expand Down
1 change: 1 addition & 0 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class MainWindow : public QMainWindow
void writeSettings();
void configureVideoWidget();
void setCurrentFile(const QString &filename);
void updateWindowTitle();
void changeAudioChannels(bool checked, int channels);
void changeDeinterlacer(bool checked, const char *method);
void changeInterpolation(bool checked, const char *method);
Expand Down

0 comments on commit 5a04984

Please sign in to comment.