]> Some of my projects - aniplayer-old.git/commitdiff
Display currently playing file name in window title.
authorAPTX <APTX@.(none)>
Thu, 24 Sep 2009 00:14:35 +0000 (02:14 +0200)
committerAPTX <APTX@.(none)>
Thu, 24 Sep 2009 00:14:35 +0000 (02:14 +0200)
src/videowindow.cpp
src/videowindow.h

index 463d5f1a3f5ad451c66c1d8219aab1676c764056..c3e3837d0085f2bc62eb25232be9892af4d79d1e 100644 (file)
@@ -163,7 +163,7 @@ VideoWindow::VideoWindow(QWidget *parent) : QMainWindow(parent)
        videoSceneMenu->volumeSlider()->setAudioOutput(videoPlayer->audioOutput());
 #endif
 
-       setWindowTitle(qApp->applicationName() + " v" + qApp->applicationVersion());
+       updateWindowTitle();
 
 #ifndef BROWSERPLUGIN_BUILD
        loadSettings();
@@ -269,6 +269,8 @@ void VideoWindow::open(const QString &file, bool closeOnStop)
 #endif
 
        m_closeOnStop = closeOnStop;
+
+       updateWindowTitle(fileInfo);
 }
 
 void VideoWindow::openUrl(const QString &urlstr)
@@ -733,6 +735,18 @@ void VideoWindow::loadSettings()
 #endif
 }
 
+void VideoWindow::updateWindowTitle(const QFileInfo &file)
+{
+       static const QString appTitle = qApp->applicationName() + QLatin1String(" v") + qApp->applicationVersion();
+       if (!file.exists())
+       {
+               setWindowTitle(appTitle);
+               return;
+       }
+       setWindowTitle(file.fileName() + QLatin1Char(' ') + QChar(0x2014) + QLatin1Char(' ') + appTitle);
+       setWindowFilePath(file.absoluteFilePath());
+}
+
 void VideoWindow::updateCursor()
 {
 #ifdef Q_WS_X11
index 22cbced1a82f3aaa28be1a439a6c611b44f4c9ab..0a5e03e84f73728c69db10f73e0e73c19c1367fd 100644 (file)
@@ -18,6 +18,7 @@
 #include <QKeySequence>
 #include <QMap>
 #include <QUrl>
+#include <QFileInfo>
 
 #ifdef BROWSERPLUGIN_BUILD
 #      include <QMetaClassInfo>
@@ -118,6 +119,7 @@ private:
        void saveSettings();
        void loadSettings();
 
+       void updateWindowTitle(const QFileInfo &file = QFileInfo());
        void updateCursor();
 
        Menu *menu;