Adding shorcuts for navigating over the tabs. Fixes issue 1568
This commit is contained in:
parent
2f88d8b355
commit
6653d740fc
|
@ -104,7 +104,8 @@ PlaylistView* PlaylistContainer::view() const {
|
|||
}
|
||||
|
||||
void PlaylistContainer::SetActions(
|
||||
QAction* new_playlist, QAction* save_playlist, QAction* load_playlist) {
|
||||
QAction* new_playlist, QAction* save_playlist, QAction* load_playlist,
|
||||
QAction* next_playlist, QAction* previous_playlist) {
|
||||
ui_->create_new->setDefaultAction(new_playlist);
|
||||
ui_->save->setDefaultAction(save_playlist);
|
||||
ui_->load->setDefaultAction(load_playlist);
|
||||
|
@ -114,6 +115,8 @@ void PlaylistContainer::SetActions(
|
|||
connect(new_playlist, SIGNAL(triggered()), SLOT(NewPlaylist()));
|
||||
connect(save_playlist, SIGNAL(triggered()), SLOT(SavePlaylist()));
|
||||
connect(load_playlist, SIGNAL(triggered()), SLOT(LoadPlaylist()));
|
||||
connect(next_playlist, SIGNAL(triggered()), SLOT(GoToNextPlaylistTab()));
|
||||
connect(previous_playlist, SIGNAL(triggered()), SLOT(GoToPreviousPlaylistTab()));
|
||||
}
|
||||
|
||||
void PlaylistContainer::SetManager(PlaylistManager *manager) {
|
||||
|
@ -295,6 +298,23 @@ void PlaylistContainer::SavePlaylist(int id = -1) {
|
|||
manager_->Save(id == -1 ? manager_->current_id() : id, filename);
|
||||
}
|
||||
|
||||
void PlaylistContainer::GoToNextPlaylistTab() {
|
||||
// Get the next tab' id
|
||||
int id_next =
|
||||
ui_->tab_bar->id_of((ui_->tab_bar->currentIndex()+1)%ui_->tab_bar->count());
|
||||
// Switch to next tab
|
||||
manager_->SetCurrentPlaylist(id_next);
|
||||
}
|
||||
|
||||
void PlaylistContainer::GoToPreviousPlaylistTab() {
|
||||
// Get the next tab' id
|
||||
int id_previous =
|
||||
ui_->tab_bar->id_of((ui_->tab_bar->currentIndex()+ui_->tab_bar->count()-1)
|
||||
% ui_->tab_bar->count());
|
||||
// Switch to next tab
|
||||
manager_->SetCurrentPlaylist(id_previous);
|
||||
}
|
||||
|
||||
void PlaylistContainer::Save() {
|
||||
if (starting_up_)
|
||||
return;
|
||||
|
|
|
@ -41,7 +41,8 @@ public:
|
|||
static const char* kSettingsGroup;
|
||||
|
||||
void SetActions(QAction* new_playlist, QAction* save_playlist,
|
||||
QAction* load_playlist);
|
||||
QAction* load_playlist, QAction* next_playlist, QAction*
|
||||
previous_playlist);
|
||||
void SetManager(PlaylistManager* manager);
|
||||
|
||||
PlaylistView* view() const;
|
||||
|
@ -65,6 +66,8 @@ private slots:
|
|||
void LoadPlaylist();
|
||||
void SavePlaylist() { SavePlaylist(-1); }
|
||||
void SavePlaylist(int id);
|
||||
void GoToNextPlaylistTab();
|
||||
void GoToPreviousPlaylistTab();
|
||||
|
||||
void SetViewModel(Playlist* playlist);
|
||||
void PlaylistAdded(int id, const QString& name);
|
||||
|
|
|
@ -177,6 +177,14 @@ void PlaylistTabBar::set_current_id(int id) {
|
|||
setCurrentIndex(index_of(id));
|
||||
}
|
||||
|
||||
int PlaylistTabBar::id_of(int index) const {
|
||||
if (index<0 || index>count()) {
|
||||
qWarning() << "Playlist tab index requested is out of bounds!";
|
||||
return 0;
|
||||
}
|
||||
return tabData(index).toInt();
|
||||
}
|
||||
|
||||
void PlaylistTabBar::set_icon_by_id(int id, const QIcon &icon) {
|
||||
setTabIcon(index_of(id), icon);
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ public:
|
|||
// indexes change).
|
||||
int index_of(int id) const;
|
||||
int current_id() const;
|
||||
int id_of(int index) const;
|
||||
|
||||
// Utility functions that use IDs rather than indexes
|
||||
void set_current_id(int id);
|
||||
|
|
|
@ -351,6 +351,17 @@ MainWindow::MainWindow(
|
|||
background_streams_, SLOT(AllGloryToTheHypnotoad(bool)));
|
||||
connect(ui_->action_queue_manager, SIGNAL(triggered()), SLOT(ShowQueueManager()));
|
||||
|
||||
// Playlist view actions
|
||||
ui_->action_next_playlist->setShortcuts(QList<QKeySequence>()
|
||||
<< QKeySequence::fromString("Ctrl+Tab")
|
||||
<< QKeySequence::fromString("Ctrl+PgDown"));
|
||||
ui_->action_previous_playlist->setShortcuts(QList<QKeySequence>()
|
||||
<< QKeySequence::fromString("Ctrl+Shift+Tab")
|
||||
<< QKeySequence::fromString("Ctrl+PgUp"));
|
||||
// Actions for switching tabs will be global to the entire window, so adding them here
|
||||
addAction(ui_->action_next_playlist);
|
||||
addAction(ui_->action_previous_playlist);
|
||||
|
||||
// Give actions to buttons
|
||||
ui_->forward_button->setDefaultAction(ui_->action_next_track);
|
||||
ui_->back_button->setDefaultAction(ui_->action_previous_track);
|
||||
|
@ -361,7 +372,9 @@ MainWindow::MainWindow(
|
|||
ui_->scrobbling_button->setDefaultAction(ui_->action_toggle_scrobbling);
|
||||
ui_->clear_playlist_button->setDefaultAction(ui_->action_clear_playlist);
|
||||
ui_->playlist->SetActions(ui_->action_new_playlist, ui_->action_save_playlist,
|
||||
ui_->action_load_playlist);
|
||||
ui_->action_load_playlist,
|
||||
ui_->action_next_playlist, /* These two actions aren't associated */
|
||||
ui_->action_previous_playlist /* to a button but to the main window */ );
|
||||
|
||||
|
||||
#ifdef ENABLE_VISUALISATIONS
|
||||
|
|
|
@ -749,6 +749,16 @@
|
|||
<string>Ctrl+Shift+O</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_next_playlist">
|
||||
<property name="text">
|
||||
<string>Go to next playlist tab</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_previous_playlist">
|
||||
<property name="text">
|
||||
<string>Go to previous playlist tab</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_update_library">
|
||||
<property name="text">
|
||||
<string>Update changed library folders</string>
|
||||
|
|
Loading…
Reference in New Issue