[multimedia/kid3] /: Option "Select file on play" in "User Actions" settings tab

Urs Fleisch null at kde.org
Sat Feb 11 15:22:08 GMT 2023


Git commit 1a778c5d3ac522b3d51ea01df4d4b61d6cd0faf6 by Urs Fleisch.
Committed on 11/02/2023 at 15:21.
Pushed by ufleisch into branch 'master'.

Option "Select file on play" in "User Actions" settings tab

BUG 465431

M  +3    -0    doc/en/index.docbook
M  +14   -0    src/core/config/guiconfig.cpp
M  +13   -0    src/core/config/guiconfig.h
M  +15   -0    src/core/model/kid3application.cpp
M  +6    -0    src/core/model/kid3application.h
M  +6    -0    src/gui/dialogs/configdialogpages.cpp
M  +2    -0    src/gui/dialogs/configdialogpages.h
M  +1    -4    src/gui/forms/basemainwindow.cpp

https://invent.kde.org/multimedia/kid3/commit/1a778c5d3ac522b3d51ea01df4d4b61d6cd0faf6

diff --git a/doc/en/index.docbook b/doc/en/index.docbook
index 0b6e34c3..291ea47d 100644
--- a/doc/en/index.docbook
+++ b/doc/en/index.docbook
@@ -434,6 +434,9 @@ see <link linkend="edit-playlist">Edit Playlist</link>.
 in the <guilabel>User Actions</guilabel> tab of
 <link linkend="configure-kid3">Configure &kid3;</link>. The playback on double
 click can also be activated there.
+</para><para>
+When <guilabel>Select file on play</guilabel> is activated, the currently
+played track is automatically selected in the file list.
 </para></listitem>
 </itemizedlist>
 </para>
diff --git a/src/core/config/guiconfig.cpp b/src/core/config/guiconfig.cpp
index ff8450ae..4808b61a 100644
--- a/src/core/config/guiconfig.cpp
+++ b/src/core/config/guiconfig.cpp
@@ -44,6 +44,7 @@ GuiConfig::GuiConfig()
     m_hideFile(false),
     m_hidePicture(false),
     m_playOnDoubleClick(false),
+    m_selectFileOnPlayEnabled(false),
     m_playToolBarVisible(false),
     m_fileListCustomColumnWidthsEnabled(true),
     m_dirListCustomColumnWidthsEnabled(true)
@@ -70,6 +71,8 @@ void GuiConfig::writeToConfig(ISettings* config) const
   config->setValue(QLatin1String("HidePicture"), QVariant(m_hidePicture));
   config->setValue(QLatin1String("PlayOnDoubleClick"),
                    QVariant(m_playOnDoubleClick));
+  config->setValue(QLatin1String("SelectFileOnPlayEnabled"),
+                   QVariant(m_selectFileOnPlayEnabled));
   config->setValue(QLatin1String("PlayToolBarVisible"),
                    QVariant(m_playToolBarVisible));
   config->setValue(QLatin1String("FileListVisibleColumns"),
@@ -135,6 +138,9 @@ void GuiConfig::readFromConfig(ISettings* config)
                                 m_hidePicture).toBool();
   m_playOnDoubleClick = config->value(QLatin1String("PlayOnDoubleClick"),
                                       m_playOnDoubleClick).toBool();
+  m_selectFileOnPlayEnabled =
+      config->value(QLatin1String("SelectFileOnPlayEnabled"),
+                    m_selectFileOnPlayEnabled).toBool();
   m_playToolBarVisible = config->value(QLatin1String("PlayToolBarVisible"),
                                        m_playToolBarVisible).toBool();
   m_fileListVisibleColumns = stringListToIntList(
@@ -341,6 +347,14 @@ void GuiConfig::setPlayOnDoubleClick(bool playOnDoubleClick)
   }
 }
 
+void GuiConfig::setSelectFileOnPlayEnabled(bool selectFileOnPlayEnabled)
+{
+  if (m_selectFileOnPlayEnabled != selectFileOnPlayEnabled) {
+    m_selectFileOnPlayEnabled = selectFileOnPlayEnabled;
+    emit selectFileOnPlayEnabledChanged(m_selectFileOnPlayEnabled);
+  }
+}
+
 void GuiConfig::setPlayToolBarVisible(bool playToolBarVisible)
 {
   if (m_playToolBarVisible != playToolBarVisible) {
diff --git a/src/core/config/guiconfig.h b/src/core/config/guiconfig.h
index feeb131d..791be8b6 100644
--- a/src/core/config/guiconfig.h
+++ b/src/core/config/guiconfig.h
@@ -87,6 +87,9 @@ class KID3_CORE_EXPORT GuiConfig : public StoredConfig<GuiConfig> {
   /** true to play file on double click */
   Q_PROPERTY(bool playOnDoubleClick READ playOnDoubleClick
              WRITE setPlayOnDoubleClick NOTIFY playOnDoubleClickChanged)
+  /** true to select file on play */
+  Q_PROPERTY(bool selectFileOnPlayEnabled READ selectFileOnPlayEnabled
+             WRITE setSelectFileOnPlayEnabled NOTIFY selectFileOnPlayEnabledChanged)
   /** true if play tool bar is visible */
   Q_PROPERTY(bool playToolBarVisible READ playToolBarVisible
              WRITE setPlayToolBarVisible NOTIFY playToolBarVisibleChanged)
@@ -228,6 +231,12 @@ public:
   /** Set if play file on double click is enabled. */
   void setPlayOnDoubleClick(bool playOnDoubleClick);
 
+  /** Check if select file on play is enabled. */
+  bool selectFileOnPlayEnabled() const { return m_selectFileOnPlayEnabled; }
+
+  /** Enable select file on play. */
+  void setSelectFileOnPlayEnabled(bool selectFileOnPlayEnabled);
+
   /** Check if play tool bar is visible. */
   bool playToolBarVisible() const { return m_playToolBarVisible; }
 
@@ -298,6 +307,9 @@ signals:
   /** Emitted when @a playOnDoubleClick changed. */
   void playOnDoubleClickChanged(bool playOnDoubleClick);
 
+  /** Emitted when @a selectFileOnPlayEnabled changed. */
+  void selectFileOnPlayEnabledChanged(bool selectFileOnPlayEnabled);
+
   /** Emitted when @a playToolBarVisible changed. */
   void playToolBarVisibleChanged(bool playToolBarVisible);
 
@@ -327,6 +339,7 @@ private:
   bool m_hideTag[Frame::Tag_NumValues];
   bool m_hidePicture;
   bool m_playOnDoubleClick;
+  bool m_selectFileOnPlayEnabled;
   bool m_playToolBarVisible;
   bool m_fileListCustomColumnWidthsEnabled;
   bool m_dirListCustomColumnWidthsEnabled;
diff --git a/src/core/model/kid3application.cpp b/src/core/model/kid3application.cpp
index 88a144b1..2f21b75f 100644
--- a/src/core/model/kid3application.cpp
+++ b/src/core/model/kid3application.cpp
@@ -3994,6 +3994,21 @@ void Kid3Application::setPictureData(const QByteArray& data)
   }
 }
 
+/**
+ * Update state when file is about to be played.
+ * @param filePath path to file
+ */
+void Kid3Application::onAboutToPlay(const QString& filePath)
+{
+#ifdef Q_OS_WIN32
+  // Phonon on Windows cannot play if the file is open.
+  closeFileHandle(filePath);
+#endif
+  if (GuiConfig::instance().selectFileOnPlayEnabled()) {
+    selectFile(filePath);
+  }
+}
+
 /**
  * Close the file handle of a tagged file.
  * @param filePath path to file
diff --git a/src/core/model/kid3application.h b/src/core/model/kid3application.h
index 082806a9..f5d266e5 100644
--- a/src/core/model/kid3application.h
+++ b/src/core/model/kid3application.h
@@ -1289,6 +1289,12 @@ public slots:
   void deactivateMprisInterface();
 #endif
 
+  /**
+   * Update state when file is about to be played.
+   * @param filePath path to file
+   */
+  void onAboutToPlay(const QString& filePath);
+
   /**
    * Close the file handle of a tagged file.
    * @param filePath path to file
diff --git a/src/gui/dialogs/configdialogpages.cpp b/src/gui/dialogs/configdialogpages.cpp
index d0339213..7070d0a5 100644
--- a/src/gui/dialogs/configdialogpages.cpp
+++ b/src/gui/dialogs/configdialogpages.cpp
@@ -148,6 +148,7 @@ ConfigDialogPages::ConfigDialogPages(IPlatformTools* platformTools,
   m_customFramesEditModel(nullptr),
   m_quickAccessTagsModel(nullptr), m_starRatingMappingsModel(nullptr),
   m_trackNameComboBox(nullptr), m_playOnDoubleClickCheckBox(nullptr),
+  m_selectFileOnPlayCheckBox(nullptr),
   m_commandsTable(nullptr), m_commandsTableModel(nullptr),
   m_browserLineEdit(nullptr), m_proxyCheckBox(nullptr),
   m_proxyLineEdit(nullptr), m_proxyAuthenticationCheckBox(nullptr),
@@ -538,12 +539,15 @@ QWidget* ConfigDialogPages::createActionsPage()
                                               actionsPage);
   m_playOnDoubleClickCheckBox =
       new QCheckBox(tr("&Play on double click"), commandsGroupBox);
+  m_selectFileOnPlayCheckBox =
+      new QCheckBox(tr("&Select file on play"), commandsGroupBox);
   m_commandsTableModel = new CommandsTableModel(commandsGroupBox);
   m_commandsTable = new ConfigTable(m_commandsTableModel, commandsGroupBox);
   m_commandsTable->setHorizontalResizeModes(
     m_commandsTableModel->getHorizontalResizeModes());
   auto commandsLayout = new QVBoxLayout;
   commandsLayout->addWidget(m_playOnDoubleClickCheckBox);
+  commandsLayout->addWidget(m_selectFileOnPlayCheckBox);
   commandsLayout->addWidget(m_commandsTable);
   commandsGroupBox->setLayout(commandsLayout);
   vlayout->addWidget(commandsGroupBox);
@@ -734,6 +738,7 @@ void ConfigDialogPages::setConfigs(
   }
   m_browserLineEdit->setText(networkCfg.browser());
   m_playOnDoubleClickCheckBox->setChecked(guiCfg.playOnDoubleClick());
+  m_selectFileOnPlayCheckBox->setChecked(guiCfg.selectFileOnPlayEnabled());
   m_proxyCheckBox->setChecked(networkCfg.useProxy());
   m_proxyLineEdit->setText(networkCfg.proxy());
   m_proxyAuthenticationCheckBox->setChecked(networkCfg.useProxyAuthentication());
@@ -848,6 +853,7 @@ void ConfigDialogPages::getConfig() const
   tagCfg.setRiffTrackName(m_trackNameComboBox->currentText());
   networkCfg.setBrowser(m_browserLineEdit->text());
   guiCfg.setPlayOnDoubleClick(m_playOnDoubleClickCheckBox->isChecked());
+  guiCfg.setSelectFileOnPlayEnabled(m_selectFileOnPlayCheckBox->isChecked());
   networkCfg.setUseProxy(m_proxyCheckBox->isChecked());
   networkCfg.setProxy(m_proxyLineEdit->text());
   networkCfg.setUseProxyAuthentication(m_proxyAuthenticationCheckBox->isChecked());
diff --git a/src/gui/dialogs/configdialogpages.h b/src/gui/dialogs/configdialogpages.h
index 21549b52..025a7d7b 100644
--- a/src/gui/dialogs/configdialogpages.h
+++ b/src/gui/dialogs/configdialogpages.h
@@ -199,6 +199,8 @@ private:
   QComboBox* m_trackNameComboBox;
   /** Play on double click checkbox */
   QCheckBox* m_playOnDoubleClickCheckBox;
+  /** Select file on play checkbox */
+  QCheckBox* m_selectFileOnPlayCheckBox;
   /** Commands table */
   ConfigTable* m_commandsTable;
   /** Commands table model */
diff --git a/src/gui/forms/basemainwindow.cpp b/src/gui/forms/basemainwindow.cpp
index 062629a2..ee9e3025 100644
--- a/src/gui/forms/basemainwindow.cpp
+++ b/src/gui/forms/basemainwindow.cpp
@@ -1251,11 +1251,8 @@ void BaseMainWindowImpl::showPlayToolBar()
       connect(m_playToolBar, &PlayToolBar::closed,
               m_app, &Kid3Application::deactivateMprisInterface);
 #endif
-#ifdef Q_OS_WIN32
-      // Phonon on Windows cannot play if the file is open.
       connect(m_playToolBar, &PlayToolBar::aboutToPlay,
-              m_app, &Kid3Application::closeFileHandle);
-#endif
+              m_app, &Kid3Application::onAboutToPlay);
     }
   }
   m_playToolBar->show();


More information about the kde-doc-english mailing list