-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add right click menu on WOverview to edit hotcue label & color
This is much easier to use and discover than finding the track in the library, right clicking it, opening the track Properties window, and going to the Cuepoints tab.
- Loading branch information
Showing
5 changed files
with
155 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#include <QInputDialog> | ||
|
||
#include "widget/cuemenu.h" | ||
#include "util/color/color.h" | ||
|
||
CueMenu::CueMenu(QWidget *parent) | ||
: QMenu(parent) { | ||
m_pEditLabel = new QAction(tr("Edit label")); | ||
addAction(m_pEditLabel); | ||
connect(m_pEditLabel, &QAction::triggered, this, &CueMenu::slotEditLabel); | ||
|
||
m_pColorMenu = new QMenu(this); | ||
m_pColorMenu->setTitle(tr("Set color")); | ||
addMenu(m_pColorMenu); | ||
|
||
for (const auto& pColor : Color::kPredefinedColorsSet.allColors) { | ||
if (*pColor == *Color::kPredefinedColorsSet.noColor) { | ||
continue; | ||
} | ||
|
||
QAction* pColorAction = new QAction(pColor->m_sDisplayName); | ||
QPixmap pixmap(80, 80); | ||
pixmap.fill(pColor->m_defaultRgba); | ||
pColorAction->setIcon(QIcon(pixmap)); | ||
|
||
m_pColorMenuActions.append(pColorAction); | ||
m_pColorMenu->addAction(pColorAction); | ||
connect(pColorAction, &QAction::triggered, this, [pColor, this]() { | ||
changeCueColor(pColor); | ||
}); | ||
} | ||
|
||
m_pRemoveCue = new QAction(tr("Remove")); | ||
addAction(m_pRemoveCue); | ||
connect(m_pRemoveCue, &QAction::triggered, this, &CueMenu::slotRemoveCue); | ||
} | ||
|
||
CueMenu::~CueMenu() { | ||
delete m_pEditLabel; | ||
for (auto& pAction : m_pColorMenuActions) { | ||
delete pAction; | ||
} | ||
delete m_pColorMenu; | ||
delete m_pRemoveCue; | ||
} | ||
|
||
void CueMenu::slotEditLabel() { | ||
VERIFY_OR_DEBUG_ASSERT(m_pCue != nullptr) { | ||
return; | ||
} | ||
bool okay = false; | ||
QString newLabel = QInputDialog::getText(this, tr("Edit cue label"), | ||
tr("Cue label"), QLineEdit::Normal, | ||
m_pCue->getLabel(), &okay); | ||
if (okay) { | ||
m_pCue->setLabel(newLabel); | ||
} | ||
} | ||
|
||
void CueMenu::changeCueColor(PredefinedColorPointer pColor) { | ||
VERIFY_OR_DEBUG_ASSERT(m_pCue != nullptr) { | ||
return; | ||
} | ||
VERIFY_OR_DEBUG_ASSERT(pColor != nullptr) { | ||
return; | ||
} | ||
m_pCue->setColor(pColor); | ||
} | ||
|
||
void CueMenu::slotRemoveCue() { | ||
VERIFY_OR_DEBUG_ASSERT(m_pCue != nullptr) { | ||
return; | ||
} | ||
VERIFY_OR_DEBUG_ASSERT(m_pTrack != nullptr) { | ||
return; | ||
} | ||
m_pTrack->removeCue(m_pCue); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#pragma once | ||
|
||
#include <QMenu> | ||
|
||
#include "track/track.h" | ||
#include "track/cue.h" | ||
|
||
class CueMenu : public QMenu { | ||
Q_OBJECT | ||
public: | ||
CueMenu(QWidget *parent = nullptr); | ||
~CueMenu() override; | ||
|
||
void setCue(CuePointer pCue) { | ||
m_pCue = pCue; | ||
} | ||
|
||
void setTrack(TrackPointer pTrack) { | ||
m_pTrack = pTrack; | ||
} | ||
|
||
private slots: | ||
void slotEditLabel(); | ||
void slotRemoveCue(); | ||
|
||
private: | ||
// This is not a Qt slot because it is connected via a lambda. | ||
void changeCueColor(PredefinedColorPointer pColor); | ||
|
||
CuePointer m_pCue; | ||
TrackPointer m_pTrack; | ||
|
||
QAction* m_pEditLabel; | ||
QMenu* m_pColorMenu; | ||
QList<QAction*> m_pColorMenuActions; | ||
QAction* m_pRemoveCue; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters