From f17f6d7b87cf25d31bc138cc9f483445bb171573 Mon Sep 17 00:00:00 2001 From: Arno Date: Mon, 6 Mar 2017 07:01:09 +0100 Subject: Set appropriate window title --- beetplayer.cpp | 5 +++++ playerwidget.cpp | 16 +++++++++++----- playerwidget.h | 2 ++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/beetplayer.cpp b/beetplayer.cpp index 82b749a..99d5a92 100644 --- a/beetplayer.cpp +++ b/beetplayer.cpp @@ -32,8 +32,13 @@ BeetPlayer::BeetPlayer(QWidget *parent, Qt::WindowFlags f) : QMainWindow(parent, connect(mPlayerWidget, SIGNAL(numFilesChanged(int)), this, SLOT(setNumFiles(int))); connect(mPlayerWidget, SIGNAL(playListLengthChanged(quint64)), this, SLOT(setPlayListLength(quint64))); connect(mPlayerWidget, SIGNAL(message(QString)), this, SLOT(setMessage(QString))); + connect(mPlayerWidget, SIGNAL(setWinTitle(QString)), this, SLOT(setWindowTitle(QString))); createStatusbar(); setCentralWidget(mPlayerWidget); + splash.showMessage(tr("Populating..."), Qt::AlignHCenter, Qt::yellow); + qApp->processEvents(); + mPlayerWidget->doStop(); + mPlayerWidget->doPopulateByArtist(); } void BeetPlayer::openDatabase(){ diff --git a/playerwidget.cpp b/playerwidget.cpp index da2f6bf..3bcdd33 100644 --- a/playerwidget.cpp +++ b/playerwidget.cpp @@ -53,10 +53,10 @@ void PlayerWidget::setupGui(){ QToolBar *viewTB = new QToolBar; QActionGroup *viewAG = new QActionGroup(this); viewAG->setExclusive(true); - QAction *viewByArtistA = new QAction(QIcon(":/artist.png"), tr("View by artist"), this); - viewByArtistA->setCheckable(true); - viewAG->addAction(viewByArtistA); - connect(viewByArtistA, SIGNAL(triggered()), this, SLOT(doPopulateByArtist())); + mViewByArtistA = new QAction(QIcon(":/artist.png"), tr("View by artist"), this); + mViewByArtistA->setCheckable(true); + viewAG->addAction(mViewByArtistA); + connect(mViewByArtistA, SIGNAL(triggered()), this, SLOT(doPopulateByArtist())); QAction *viewByAlbumA = new QAction(QIcon(":/album.png"), tr("View by album"), this); viewByAlbumA->setCheckable(true); viewAG->addAction(viewByAlbumA); @@ -191,7 +191,6 @@ void PlayerWidget::setupGui(){ QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(splitter); setLayout(mainLayout); - viewByArtistA->trigger(); } void PlayerWidget::createActions(){ @@ -560,12 +559,16 @@ void PlayerWidget::doStop(){ mPlayer->stop(); mStopA->setChecked(true); emit playModeChanged(tr("Stopped")); + QString winTitle = QString(tr("%1 [Stopped]")).arg(qApp->applicationName()); + emit setWinTitle(winTitle); } void PlayerWidget::doPause(){ mPlayer->pause(); mPauseA->setChecked(true); emit playModeChanged(tr("Paused")); + QString winTitle = QString(tr("%1 [Paused]")).arg(qApp->applicationName()); + emit setWinTitle(winTitle); } void PlayerWidget::recurse(const QModelIndex &parent){ @@ -616,6 +619,7 @@ void PlayerWidget::doPopulateByArtist(){ QStandardItem *root = mViewModel->invisibleRootItem(); populateByArtist(root, QString()); qApp->restoreOverrideCursor(); + mViewByArtistA->setChecked(true); emit viewModeChanged(tr("Artist")); } @@ -813,6 +817,8 @@ void PlayerWidget::play(const QString &fullPath){ mCurrentTE->append(QString("%1 %2:%3").arg(tr("Length:"), -20).arg(minutes, 2, 10, QChar('0')).arg(seconds, 2, 10, QChar('0'))); QString msg = QString("File: %1").arg(fullPath); emit message(msg); + QString winTitle = QString(tr("%1 [%2 - %3 - %4]")).arg(qApp->applicationName()).arg(artist).arg(album).arg(title); + emit setWinTitle(winTitle); mPlayer->play(); mPlayA->setChecked(true); emit playModeChanged(tr("Playing")); diff --git a/playerwidget.h b/playerwidget.h index 5713cd0..4458777 100644 --- a/playerwidget.h +++ b/playerwidget.h @@ -60,6 +60,7 @@ class PlayerWidget : public QWidget { void numFilesChanged(int numFiles); void playListLengthChanged(quint64 secs); void message(const QString &msg); + void setWinTitle(const QString &title); private: void setupGui(); @@ -93,6 +94,7 @@ class PlayerWidget : public QWidget { QAction *mStopA; QAction *mPauseA; QAction *mSearchA; + QAction *mViewByArtistA; qint64 mDurSecs; quint64 mPlayListLength; }; -- cgit v1.2.3-70-g09d2