Double clicking on empty space in the playlist tabbar makes a new playlist, and middle clicking a tab removes it
This commit is contained in:
parent
9baa1f74c7
commit
6a3c9aae0c
@ -40,6 +40,8 @@ void PlaylistTabBar::SetActions(
|
||||
menu_->insertAction(0, new_playlist);
|
||||
menu_->insertAction(0, save_playlist);
|
||||
menu_->insertAction(0, load_playlist);
|
||||
|
||||
new_ = new_playlist;
|
||||
}
|
||||
|
||||
void PlaylistTabBar::contextMenuEvent(QContextMenuEvent* e) {
|
||||
@ -50,6 +52,26 @@ void PlaylistTabBar::contextMenuEvent(QContextMenuEvent* e) {
|
||||
menu_->popup(e->globalPos());
|
||||
}
|
||||
|
||||
void PlaylistTabBar::mouseReleaseEvent(QMouseEvent* e) {
|
||||
if (e->button() == Qt::MidButton) {
|
||||
int index = tabAt(e->pos());
|
||||
if (index != -1) {
|
||||
emit Remove(tabData(index).toInt());
|
||||
}
|
||||
}
|
||||
|
||||
QTabBar::mouseReleaseEvent(e);
|
||||
}
|
||||
|
||||
void PlaylistTabBar::mouseDoubleClickEvent(QMouseEvent *e) {
|
||||
int index = tabAt(e->pos());
|
||||
if (index == -1) {
|
||||
new_->activate(QAction::Trigger);
|
||||
}
|
||||
|
||||
QTabBar::mouseDoubleClickEvent(e);
|
||||
}
|
||||
|
||||
void PlaylistTabBar::Rename() {
|
||||
if (menu_index_ == -1)
|
||||
return;
|
||||
|
@ -56,11 +56,14 @@ private slots:
|
||||
void TabMoved();
|
||||
|
||||
protected:
|
||||
void contextMenuEvent(QContextMenuEvent *);
|
||||
void contextMenuEvent(QContextMenuEvent* e);
|
||||
void mouseReleaseEvent(QMouseEvent* e);
|
||||
void mouseDoubleClickEvent(QMouseEvent* e);
|
||||
|
||||
private:
|
||||
QMenu* menu_;
|
||||
int menu_index_;
|
||||
QAction* new_;
|
||||
QAction* rename_;
|
||||
QAction* remove_;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user