Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix GUI states of Library feature buttons #2628

Merged
merged 14 commits into from
Apr 15, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/library/autodj/dlgautodj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,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"));
Expand Down Expand Up @@ -171,7 +174,7 @@ DlgAutoDJ::DlgAutoDJ(
&DlgAutoDJ::slotTransitionModeChanged);

connect(pushButtonRepeatPlaylist,
&QPushButton::toggled,
&QPushButton::clicked,
this,
&DlgAutoDJ::slotRepeatPlaylistChanged);
if (m_bShowButtonText) {
Expand All @@ -190,6 +193,7 @@ DlgAutoDJ::DlgAutoDJ(
&AutoDJProcessor::transitionTimeChanged,
this,
&DlgAutoDJ::transitionTimeChanged);

connect(m_pAutoDJProcessor,
&AutoDJProcessor::autoDJStateChanged,
this,
Expand Down
4 changes: 3 additions & 1 deletion src/library/dlganalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ DlgAnalysis::DlgAnalysis(QWidget* parent,
&QPushButton::clicked,
this,
&DlgAnalysis::analyze);
pushButtonAnalyze->setEnabled(false);

connect(pushButtonSelectAll,
&QPushButton::clicked,
Expand Down Expand Up @@ -165,10 +166,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);
Expand Down
3 changes: 3 additions & 0 deletions src/library/dlganalysis.ui
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
<property name="text">
<string>Analyze</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
Expand Down
26 changes: 10 additions & 16 deletions src/library/recording/dlgrecording.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ DlgRecording::DlgRecording(QWidget* parent, UserSettingsPointer pConfig,
connect(m_pRecordingManager,
&RecordingManager::isRecording,
this,
&DlgRecording::slotRecordingEnabled);
&DlgRecording::slotRecordingStateChanged);
connect(m_pRecordingManager,
&RecordingManager::bytesRecorded,
this,
Expand All @@ -74,9 +74,10 @@ DlgRecording::DlgRecording(QWidget* parent, UserSettingsPointer pConfig,
m_pTrackTableView->loadTrackModel(&m_proxyModel);

connect(pushButtonRecording,
&QPushButton::toggled,
&QPushButton::clicked,
this,
&DlgRecording::toggleRecording);
&DlgRecording::slotRecButtonClicked);

label->setText("");
label->setEnabled(false);
}
Expand Down Expand Up @@ -129,25 +130,18 @@ 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(true);
}

void DlgRecording::slotRecordingEnabled(bool isRecording) {
void DlgRecording::slotRecordingStateChanged(bool isRecording) {
if (isRecording) {
pushButtonRecording->setChecked(true);
pushButtonRecording->setText((tr("Stop Recording")));
ronso0 marked this conversation as resolved.
Show resolved Hide resolved
label->setEnabled(true);
} else {
pushButtonRecording->setChecked(false);
pushButtonRecording->setText((tr("Start Recording")));
ronso0 marked this conversation as resolved.
Show resolved Hide resolved
label->setText("");
label->setEnabled(false);
Expand Down Expand Up @@ -176,4 +170,4 @@ void DlgRecording::refreshLabel() {
.arg(m_bytesRecordedStr)
.arg(m_durationRecordedStr);
label->setText(text);
}
}
4 changes: 2 additions & 2 deletions src/library/recording/dlgrecording.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,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();
Expand All @@ -56,6 +55,7 @@ class DlgRecording : public QWidget, public Ui::DlgRecording, public virtual Lib
QString m_recordingDir;

void refreshLabel();
void slotRecButtonClicked(bool checked);
QString m_bytesRecordedStr;
QString m_durationRecordedStr;

Expand Down
28 changes: 18 additions & 10 deletions src/recording/recordingmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ RecordingManager::RecordingManager(UserSettingsPointer pConfig, EngineMaster* pE
m_secondsRecorded(0),
m_secondsRecordedSplit(0) {
m_pToggleRecording = new ControlPushButton(ConfigKey(RECORDING_PREF_KEY, "toggle_recording"));
connect(m_pToggleRecording, SIGNAL(valueChanged(double)),
this, SLOT(slotToggleRecording(double)));
connect(m_pToggleRecording,
&ControlPushButton::valueChanged,
this,
&RecordingManager::slotToggleRecording);
m_recReadyCO = new ControlObject(ConfigKey(RECORDING_PREF_KEY, "status"));
m_recReady = new ControlProxy(m_recReadyCO->getKey(), this);

Expand All @@ -49,12 +51,18 @@ RecordingManager::RecordingManager(UserSettingsPointer pConfig, EngineMaster* pE
EngineSideChain* pSidechain = pEngine->getSideChain();
if (pSidechain) {
EngineRecord* pEngineRecord = new EngineRecord(m_pConfig);
connect(pEngineRecord, SIGNAL(isRecording(bool, bool)),
this, SLOT(slotIsRecording(bool, bool)));
connect(pEngineRecord, SIGNAL(bytesRecorded(int)),
this, SLOT(slotBytesRecorded(int)));
connect(pEngineRecord, SIGNAL(durationRecorded(quint64)),
this, SLOT(slotDurationRecorded(quint64)));
connect(pEngineRecord,
&EngineRecord::isRecording,
this,
&RecordingManager::slotIsRecording);
connect(pEngineRecord,
&EngineRecord::bytesRecorded,
this,
&RecordingManager::slotBytesRecorded);
connect(pEngineRecord,
&EngineRecord::durationRecorded,
this,
&RecordingManager::slotDurationRecorded);
pSidechain->addSideChainWorker(pEngineRecord);
}
}
Expand All @@ -81,8 +89,8 @@ void RecordingManager::slotSetRecording(bool recording) {
}
}

void RecordingManager::slotToggleRecording(double v) {
if (v > 0) {
void RecordingManager::slotToggleRecording(bool toggle) {
if (toggle) {
ronso0 marked this conversation as resolved.
Show resolved Hide resolved
if (isRecordingActive()) {
stopRecording();
} else {
Expand Down
4 changes: 1 addition & 3 deletions src/recording/recordingmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ class RecordingManager : public QObject
void slotBytesRecorded(int);
void slotDurationRecorded(quint64);
void slotSetRecording(bool recording);

private slots:
void slotToggleRecording(double v);
void slotToggleRecording(bool toggle);

private:
QString formatDateTimeForFilename(QDateTime dateTime) const;
Expand Down