Skip to content

Commit

Permalink
Merge pull request #2628 from ronso0/lib-button-states
Browse files Browse the repository at this point in the history
fix GUI states of Library feature buttons
  • Loading branch information
Holzhaus committed Apr 15, 2020
2 parents 84f7398 + 5599cd3 commit 1acfda2
Show file tree
Hide file tree
Showing 12 changed files with 140 additions and 89 deletions.
29 changes: 20 additions & 9 deletions res/skins/Deere/style.qss
Original file line number Diff line number Diff line change
Expand Up @@ -583,15 +583,6 @@ WLibrary QRadioButton::indicator:unchecked {
#DlgAnalysis > QPushButton:focus,
#fadeModeCombobox:focus,
#DlgAutoDJ QSpinBox:focus {
border: 1px solid #bbb;
outline: none;
}
#DlgMissing > QPushButton:checked:focus,
#DlgHidden > QPushButton:checked:focus,
#DlgAutoDJ > QPushButton:checked:focus,
#DlgRecording > QPushButton:checked:focus,
#DlgAnalysis > QPushButton:checked:focus {
border: 1px solid #d2d2d2;
outline: none;
}

Expand Down Expand Up @@ -656,6 +647,25 @@ QPushButton#pushButtonRepeatPlaylist {
}
/* AutoDJ button icons */

/* Recording info */
#labelRecPrefix,
#labelRecFilename,
#labelRecStatistics {
text-transform: none;
padding: 3px 0px 0px 0px;
margin: 0px;
}
#labelRecPrefix {
margin-left: 3px;
}
#labelRecFilename {
font-weight: bold;
}
#labelRecPrefix,
#labelRecStatistics {
font-weight: normal;
}

/* Scroll bars */
#LibraryContainer QScrollBar:horizontal,
WEffectSelector QAbstractScrollArea QScrollBar:horizontal,
Expand Down Expand Up @@ -811,6 +821,7 @@ WLibrary QLabel,
WLibrary QPushButton {
font-family: "Open Sans";
font-size: 12px;
font-weight: bold;
text-transform: uppercase;
}

Expand Down
38 changes: 19 additions & 19 deletions res/skins/LateNight/style.qss
Original file line number Diff line number Diff line change
Expand Up @@ -506,26 +506,14 @@ QHeaderView::down-arrow {
#DlgAutoDJ > QPushButton:focus,
#DlgRecording > QPushButton:focus,
#DlgAnalysis > QPushButton:focus {
border-width: 2px 2px 2px 2px;
border-image: url(skin:buttons_classic/btn_embedded_library.svg) 2 2 2 2;
outline: none;
}
#DlgAnalysis > QPushButton:checked:focus,
#DlgMissing > QPushButton:checked:focus,
#DlgHidden > QPushButton:checked:focus,
#DlgAutoDJ > QPushButton:checked:focus,
#DlgRecording > QPushButton:checked:focus,
#DlgAnalysis > QPushButton:checked:focus {
border-width: 2px 2px 2px 2px;
border-image: url(skin:buttons_classic/btn_embedded_library_active.svg) 2 2 2 2;
outline: none;
}
#DlgMissing > QPushButton:pressed,
#DlgHidden > QPushButton:pressed,
#DlgAutoDJ > QPushButton:pressed,
#DlgRecording > QPushButton:pressed,
#DlgAnalysis > QPushButton:pressed {
border-image: url(skin:buttons_classic/btn_embedded_library_pressed.svg) 2 2 2 2;
border-image: url(skin:buttons_classic/btn_embedded_library_active.svg) 2 2 2 2;
color: #d2d2d2;
}
#DlgMissing > QPushButton:!enabled,
Expand Down Expand Up @@ -2342,7 +2330,8 @@ WLibrary QRadioButton {
}

/* Additional space for QLabels */
WLibrary QLabel {
#DlgAnalysis QLabel,
#DlgAutoDJ QLabel {
margin: 2px 5px 5px 1px;
}

Expand All @@ -2363,7 +2352,7 @@ WLibrary QRadioButton::indicator:unchecked {
#DlgAutoDJ > QPushButton,
#DlgRecording > QPushButton,
#DlgAnalysis > QPushButton {
margin: 0px 4px 3px 2px;
margin: 0px 6px 3px 0px;
padding: 0px;
height: 20px;
}
Expand All @@ -2373,12 +2362,10 @@ WLibrary QRadioButton::indicator:unchecked {
#DlgAnalysis > QPushButton {
padding: 0px 5px;
}
/* Focus highlight is set via border-image at the top */
/* Space in between 'Enable AutoDJ' and transition time spinbox */
QPushButton#pushButtonAutoDJ {
margin-left: 0px;
min-width: 40px;
}
/* Space in between 'Enable AutoDJ' and transition time spinbox */
#DlgAutoDJ > #horizontalSpacer {
width: 100px;
}
Expand All @@ -2391,7 +2378,20 @@ WLibrary QRadioButton::indicator:unchecked {
margin-left: 12px;
}


#labelRecPrefix,
#labelRecFilename,
#labelRecStatistics {
text-transform: none;
font-size: 13px;
padding: 0px 0px 3px 0px;
}
#labelRecFilename {
font-weight: bold;
}
#labelRecPrefix,
#labelRecStatistics {
font-weight: normal;
}

#LibraryContainer QTreeView {
show-decoration-selected: 0;
Expand Down
8 changes: 8 additions & 0 deletions res/skins/Shade/style.qss
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,14 @@ QPushButton#pushButtonRepeatPlaylist {
}
/* AutoDJ button icons */

#labelRecFilename {
font-weight: bold;
}
#labelRecPrefix,
#labelRecStatistics {
font-weight: normal;
}

#HotcueButton {
background-color: #aab2b7;
}
12 changes: 10 additions & 2 deletions res/skins/Tango/style.qss
Original file line number Diff line number Diff line change
Expand Up @@ -2766,13 +2766,21 @@ QPushButton#pushButtonRepeatPlaylist:!checked {
/* Push labels away from buttons at the right */
/* AutoDJ selection info */
QLabel#labelSelectionInfo,
/* Recording info */
#DlgRecording QLabel,
/* Analysis progress info */
QLabel#labelProgress {
margin: 0px 4px 5px 2px;
}

/* Recording info */
#labelRecFilename {
font-weight: bold;
margin: 0px 1px;
}
#labelRecPrefix,
#labelRecStatistics {
font-weight: normal;
}

/* Entire BPM cell */
/* Lock icon at the left */
#LibraryBPMButton::indicator:checked {
Expand Down
8 changes: 6 additions & 2 deletions src/library/autodj/dlgautodj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -173,7 +176,7 @@ DlgAutoDJ::DlgAutoDJ(
&DlgAutoDJ::slotTransitionModeChanged);

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

connect(m_pAutoDJProcessor,
&AutoDJProcessor::autoDJStateChanged,
this,
Expand Down
14 changes: 9 additions & 5 deletions src/library/dlganalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
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
66 changes: 35 additions & 31 deletions src/library/recording/dlgrecording.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ DlgRecording::DlgRecording(
connect(m_pRecordingManager,
&RecordingManager::isRecording,
this,
&DlgRecording::slotRecordingEnabled);
&DlgRecording::slotRecordingStateChanged);

connect(m_pRecordingManager,
&RecordingManager::bytesRecorded,
this,
Expand All @@ -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() {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
6 changes: 3 additions & 3 deletions src/library/recording/dlgrecording.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;

Expand Down
12 changes: 7 additions & 5 deletions src/library/recording/dlgrecording.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
Loading

0 comments on commit 1acfda2

Please sign in to comment.