summaryrefslogtreecommitdiffstats
path: root/src/library
diff options
context:
space:
mode:
authorJan Holthuis <jan.holthuis@ruhr-uni-bochum.de>2020-04-15 11:09:22 +0200
committerGitHub <noreply@github.com>2020-04-15 11:09:22 +0200
commit1acfda2e1ab3f5fea51036b67a58e0928716b544 (patch)
treea09ab5558c1ff53b23a0050e636b120a801d77de /src/library
parent84f73984ab786cc5b13133e035e36662eb6418b6 (diff)
parent5599cd348bb73c12d08eeb5b9635c83d5e3a972d (diff)
Merge pull request #2628 from ronso0/lib-button-states
fix GUI states of Library feature buttons
Diffstat (limited to 'src/library')
-rw-r--r--src/library/autodj/dlgautodj.cpp8
-rw-r--r--src/library/dlganalysis.cpp14
-rw-r--r--src/library/dlganalysis.ui3
-rw-r--r--src/library/recording/dlgrecording.cpp66
-rw-r--r--src/library/recording/dlgrecording.h6
-rw-r--r--src/library/recording/dlgrecording.ui12
6 files changed, 63 insertions, 46 deletions
diff --git a/src/library/autodj/dlgautodj.cpp b/src/library/autodj/dlgautodj.cpp
index f3227031f0..c0f32ea068 100644
--- a/src/library/autodj/dlgautodj.cpp
+++ b/src/library/autodj/dlgautodj.cpp
@@ -82,7 +82,10 @@ DlgAutoDJ::DlgAutoDJ(
// Do not set this because it disables auto-scrolling
//m_pTrackTableView->setDragDropMode(QAbstractItemView::InternalMove);
- connect(pushButtonAutoDJ, &QPushButton::toggled, this, &DlgAutoDJ::toggleAutoDJButton);
+ connect(pushButtonAutoDJ,
+ &QPushButton::clicked,
+ this,
+ &DlgAutoDJ::toggleAutoDJButton);
setupActionButton(pushButtonFadeNow, &DlgAutoDJ::fadeNowButton, tr("Fade"));
setupActionButton(pushButtonSkipNext, &DlgAutoDJ::skipNextButton, tr("Skip"));
@@ -173,7 +176,7 @@ DlgAutoDJ::DlgAutoDJ(
&DlgAutoDJ::slotTransitionModeChanged);
connect(pushButtonRepeatPlaylist,
- &QPushButton::toggled,
+ &QPushButton::clicked,
this,
&DlgAutoDJ::slotRepeatPlaylistChanged);
if (m_bShowButtonText) {
@@ -192,6 +195,7 @@ DlgAutoDJ::DlgAutoDJ(
&AutoDJProcessor::transitionTimeChanged,
this,
&DlgAutoDJ::transitionTimeChanged);
+
connect(m_pAutoDJProcessor,
&AutoDJProcessor::autoDJStateChanged,
this,
diff --git a/src/library/dlganalysis.cpp b/src/library/dlganalysis.cpp
index 01007b8ccc..bd1b064112 100644
--- a/src/library/dlganalysis.cpp
+++ b/src/library/dlganalysis.cpp
@@ -59,15 +59,14 @@ DlgAnalysis::DlgAnalysis(WLibrary* parent,
&QRadioButton::clicked,
this,
&DlgAnalysis::showAllSongs);
-
- // TODO(rryan): This triggers a library search before the UI has even
- // started up. Accounts for 0.2% of skin creation time. Get rid of this!
- radioButtonRecentlyAdded->click();
+ // Don't click those radio buttons now reduce skin loading time.
+ // 'RecentlyAdded' is clicked in onShow()
connect(pushButtonAnalyze,
&QPushButton::clicked,
this,
&DlgAnalysis::analyze);
+ pushButtonAnalyze->setEnabled(false);
connect(pushButtonSelectAll,
&QPushButton::clicked,
@@ -96,6 +95,10 @@ DlgAnalysis::DlgAnalysis(WLibrary* parent,
}
void DlgAnalysis::onShow() {
+ if (!radioButtonRecentlyAdded->isChecked() &&
+ !radioButtonAllSongs->isChecked()) {
+ radioButtonRecentlyAdded->click();
+ }
// Refresh table
// There might be new tracks dropped to other views
m_pAnalysisLibraryTableModel->select();
@@ -170,10 +173,11 @@ void DlgAnalysis::slotAnalysisActive(bool bActive) {
//qDebug() << this << "slotAnalysisActive" << bActive;
m_bAnalysisActive = bActive;
if (bActive) {
- pushButtonAnalyze->setEnabled(true);
+ pushButtonAnalyze->setChecked(true);
pushButtonAnalyze->setText(tr("Stop Analysis"));
labelProgress->setEnabled(true);
} else {
+ pushButtonAnalyze->setChecked(false);
pushButtonAnalyze->setText(tr("Analyze"));
labelProgress->setText("");
labelProgress->setEnabled(false);
diff --git a/src/library/dlganalysis.ui b/src/library/dlganalysis.ui
index e07bc1c92a..395800c14f 100644
--- a/src/library/dlganalysis.ui
+++ b/src/library/dlganalysis.ui
@@ -84,6 +84,9 @@
<property name="text">
<string>Analyze</string>
</property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
</widget>
</item>
<item>
diff --git a/src/library/recording/dlgrecording.cpp b/src/library/recording/dlgrecording.cpp
index 763528dfcd..8a6e698eeb 100644
--- a/src/library/recording/dlgrecording.cpp
+++ b/src/library/recording/dlgrecording.cpp
@@ -57,7 +57,8 @@ DlgRecording::DlgRecording(
connect(m_pRecordingManager,
&RecordingManager::isRecording,
this,
- &DlgRecording::slotRecordingEnabled);
+ &DlgRecording::slotRecordingStateChanged);
+
connect(m_pRecordingManager,
&RecordingManager::bytesRecorded,
this,
@@ -84,11 +85,17 @@ DlgRecording::DlgRecording(
m_pTrackTableView->loadTrackModel(&m_proxyModel);
connect(pushButtonRecording,
- &QPushButton::toggled,
+ &QPushButton::clicked,
this,
- &DlgRecording::toggleRecording);
- label->setText("");
- label->setEnabled(false);
+ &DlgRecording::slotRecButtonClicked);
+
+ labelRecPrefix->hide();
+ labelRecFilename->hide();
+ labelRecStatistics->hide();
+ labelRecPrefix->setText(tr("Recording to file:"));
+
+ // Sync GUI with recording state, also refreshes labels
+ slotRecordingStateChanged(m_pRecordingManager->isRecordingActive());
}
DlgRecording::~DlgRecording() {
@@ -139,28 +146,24 @@ void DlgRecording::moveSelection(int delta) {
m_pTrackTableView->moveSelection(delta);
}
-void DlgRecording::toggleRecording(bool toggle) {
+void DlgRecording::slotRecButtonClicked(bool toggle) {
Q_UNUSED(toggle);
- if (!m_pRecordingManager->isRecordingActive()) //If recording is enabled
- {
- //pushButtonRecording->setText(tr("Stop Recording"));
- m_pRecordingManager->startRecording();
- }
- else if(m_pRecordingManager->isRecordingActive()) //If we disable recording
- {
- //pushButtonRecording->setText(tr("Start Recording"));
- m_pRecordingManager->stopRecording();
- }
+ m_pRecordingManager->slotToggleRecording(1);
}
-void DlgRecording::slotRecordingEnabled(bool isRecording) {
+void DlgRecording::slotRecordingStateChanged(bool isRecording) {
if (isRecording) {
- pushButtonRecording->setText((tr("Stop Recording")));
- label->setEnabled(true);
+ pushButtonRecording->setChecked(true);
+ pushButtonRecording->setText(tr("Stop Recording"));
+ labelRecPrefix->show();
+ labelRecFilename->show();
+ labelRecStatistics->show();
} else {
- pushButtonRecording->setText((tr("Start Recording")));
- label->setText("");
- label->setEnabled(false);
+ pushButtonRecording->setChecked(false);
+ pushButtonRecording->setText(tr("Start Recording"));
+ labelRecPrefix->hide();
+ labelRecFilename->hide();
+ labelRecStatistics->hide();
}
//This will update the recorded track table view
m_browseModel.setPath(m_recordingDir);
@@ -170,20 +173,21 @@ void DlgRecording::slotRecordingEnabled(bool isRecording) {
void DlgRecording::slotBytesRecorded(int bytes) {
double megabytes = bytes / 1048576.0;
m_bytesRecordedStr = QString::number(megabytes,'f',2);
- refreshLabel();
+ refreshLabels();
}
// gets recorded duration and update label
void DlgRecording::slotDurationRecorded(QString durationRecorded) {
m_durationRecordedStr = durationRecorded;
- refreshLabel();
+ refreshLabels();
}
// update label besides start/stop button
-void DlgRecording::refreshLabel() {
- QString text = tr("Recording to file: %1 (%2 MiB written in %3)")
- .arg(m_pRecordingManager->getRecordingFile())
- .arg(m_bytesRecordedStr)
- .arg(m_durationRecordedStr);
- label->setText(text);
- }
+void DlgRecording::refreshLabels() {
+ QString recFile = m_pRecordingManager->getRecordingFile();
+ QString recData = QString(QStringLiteral("(") + tr("%1 MiB written in %2") + QStringLiteral(")"))
+ .arg(m_bytesRecordedStr)
+ .arg(m_durationRecordedStr);
+ labelRecFilename->setText(recFile);
+ labelRecStatistics->setText(recData);
+}
diff --git a/src/library/recording/dlgrecording.h b/src/library/recording/dlgrecording.h
index 3cb73a86e9..1e00224064 100644
--- a/src/library/recording/dlgrecording.h
+++ b/src/library/recording/dlgrecording.h
@@ -37,8 +37,7 @@ class DlgRecording : public QWidget, public Ui::DlgRecording, public virtual Lib
inline const QString currentSearch() { return m_proxyModel.currentSearch(); }
public slots:
- void toggleRecording(bool toggle);
- void slotRecordingEnabled(bool);
+ void slotRecordingStateChanged(bool);
void slotBytesRecorded(int);
void refreshBrowseModel();
void slotRestoreSearch();
@@ -56,7 +55,8 @@ class DlgRecording : public QWidget, public Ui::DlgRecording, public virtual Lib
ProxyTrackModel m_proxyModel;
QString m_recordingDir;
- void refreshLabel();
+ void refreshLabels();
+ void slotRecButtonClicked(bool checked);
QString m_bytesRecordedStr;
QString m_durationRecordedStr;
diff --git a/src/library/recording/dlgrecording.ui b/src/library/recording/dlgrecording.ui
index c0b0fd90e5..efdf9e7fd8 100644
--- a/src/library/recording/dlgrecording.ui
+++ b/src/library/recording/dlgrecording.ui
@@ -57,11 +57,13 @@
</widget>
</item>
<item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Status:</string>
- </property>
- </widget>
+ <widget class="QLabel" name="labelRecPrefix"/>
+ </item>
+ <item>
+ <widget class="QLabel" name="labelRecFilename"/>
+ </item>
+ <item>
+ <widget class="QLabel" name="labelRecStatistics"/>
</item>
<item>
<spacer name="horizontalSpacer">