Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
11 changes: 9 additions & 2 deletions src/core/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,10 +603,16 @@ MainWindow::MainWindow(Application *app,
// Playlist view actions
ui_->action_next_playlist->setShortcuts(QList<QKeySequence>() << QKeySequence::fromString(u"Ctrl+Tab"_s) << QKeySequence::fromString(u"Ctrl+PgDown"_s));
ui_->action_previous_playlist->setShortcuts(QList<QKeySequence>() << QKeySequence::fromString(u"Ctrl+Shift+Tab"_s) << QKeySequence::fromString(u"Ctrl+PgUp"_s));
ui_->action_last_playlist->setShortcut(QKeySequence::fromString(u"Ctrl+Shift+End"_s));
ui_->action_active_playlist->setShortcut(QKeySequence::fromString(u"Ctrl+Shift+Home"_s));
ui_->action_close_playlist->setShortcut(QKeySequence::fromString(u"Ctrl+W"_s));
Comment thread
Perdu marked this conversation as resolved.

// 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);
addAction(ui_->action_last_playlist);
addAction(ui_->action_active_playlist);
addAction(ui_->action_close_playlist);

// Give actions to buttons
ui_->forward_button->setDefaultAction(ui_->action_next_track);
Expand All @@ -616,7 +622,8 @@ MainWindow::MainWindow(Application *app,
ui_->button_scrobble->setDefaultAction(ui_->action_toggle_scrobbling);
ui_->button_love->setDefaultAction(ui_->action_love);

ui_->playlist->SetActions(ui_->action_new_playlist, ui_->action_load_playlist, ui_->action_save_playlist, ui_->action_clear_playlist, ui_->action_next_playlist, /* These two actions aren't associated */ ui_->action_previous_playlist /* to a button but to the main window */, ui_->action_save_all_playlists);
/* Some of these actions aren't associated to a button but to the main window */
ui_->playlist->SetActions(ui_->action_new_playlist, ui_->action_load_playlist, ui_->action_save_playlist, ui_->action_clear_playlist, ui_->action_next_playlist, ui_->action_previous_playlist, ui_->action_last_playlist, ui_->action_active_playlist, ui_->action_close_playlist, ui_->action_save_all_playlists);
// Add the shuffle and repeat action groups to the menu
ui_->action_shuffle_mode->setMenu(ui_->playlist_sequence->shuffle_menu());
ui_->action_repeat_mode->setMenu(ui_->playlist_sequence->repeat_menu());
Expand Down Expand Up @@ -1062,7 +1069,7 @@ MainWindow::MainWindow(Application *app,
ui_->action_toggle_show_sidebar->setChecked(show_sidebar);

QShortcut *close_window_shortcut = new QShortcut(this);
close_window_shortcut->setKey(Qt::CTRL | Qt::Key_W);
close_window_shortcut->setKey(Qt::CTRL | Qt::Key_H);
QObject::connect(close_window_shortcut, &QShortcut::activated, this, &MainWindow::ToggleHide);

QAction *action_focus_search = new QAction(this);
Expand Down
15 changes: 15 additions & 0 deletions src/core/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,21 @@
<string>Go to previous playlist tab</string>
</property>
</action>
<action name="action_last_playlist">
<property name="text">
<string>Go to last playlist tab</string>
</property>
</action>
<action name="action_active_playlist">
<property name="text">
<string>Go to active playlist tab</string>
</property>
</action>
<action name="action_close_playlist">
<property name="text">
<string>Close current playlist tab</string>
</property>
</action>
<action name="action_update_collection">
<property name="text">
<string>&amp;Update changed collection folders</string>
Expand Down
29 changes: 27 additions & 2 deletions src/playlist/playlistcontainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ PlaylistContainer::~PlaylistContainer() { delete ui_; }

PlaylistView *PlaylistContainer::view() const { return ui_->playlist; }

void PlaylistContainer::SetActions(QAction *new_playlist, QAction *load_playlist, QAction *save_playlist, QAction *clear_playlist, QAction *next_playlist, QAction *previous_playlist, QAction *save_all_playlists) {
void PlaylistContainer::SetActions(QAction *new_playlist, QAction *load_playlist, QAction *save_playlist, QAction *clear_playlist, QAction *next_playlist, QAction *previous_playlist, QAction *last_playlist, QAction *active_playlist, QAction *close_playlist, QAction *save_all_playlists) {

ui_->create_new->setDefaultAction(new_playlist);
ui_->load->setDefaultAction(load_playlist);
Expand All @@ -154,9 +154,11 @@ void PlaylistContainer::SetActions(QAction *new_playlist, QAction *load_playlist
QObject::connect(clear_playlist, &QAction::triggered, this, &PlaylistContainer::ClearPlaylist);
QObject::connect(next_playlist, &QAction::triggered, this, &PlaylistContainer::GoToNextPlaylistTab);
QObject::connect(previous_playlist, &QAction::triggered, this, &PlaylistContainer::GoToPreviousPlaylistTab);
QObject::connect(last_playlist, &QAction::triggered, this, &PlaylistContainer::GoToLastPlaylistTab);
QObject::connect(active_playlist, &QAction::triggered, this, &PlaylistContainer::GoToActivePlaylistTab);
QObject::connect(clear_playlist, &QAction::triggered, this, &PlaylistContainer::ClearPlaylist);
Comment thread
Perdu marked this conversation as resolved.
QObject::connect(save_all_playlists, &QAction::triggered, &*manager_, &PlaylistManager::SaveAllPlaylists);

QObject::connect(close_playlist, &QAction::triggered, &*ui_->tab_bar, &PlaylistTabBar::CloseCurrentTab);
}

void PlaylistContainer::SetManager(SharedPtr<PlaylistManager> manager) {
Expand Down Expand Up @@ -387,6 +389,29 @@ void PlaylistContainer::GoToPreviousPlaylistTab() {

}

void PlaylistContainer::GoToLastPlaylistTab() {

int id_last = ui_->tab_bar->id_of(ui_->tab_bar->count() - 1);
manager_->SetCurrentPlaylist(id_last);

}

void PlaylistContainer::GoToActivePlaylistTab() {

int id_current = manager_->active_id();
Comment thread
Perdu marked this conversation as resolved.

if (id_current == -1) {
// If there is no active playlist, fall back to the first tab (if any)
if (ui_->tab_bar->count() > 0) {
int first_id = ui_->tab_bar->id_of(0);
manager_->SetCurrentPlaylist(first_id);
}
} else {
manager_->SetCurrentPlaylist(id_current);
}

}

void PlaylistContainer::Save() {

if (starting_up_) return;
Expand Down
4 changes: 3 additions & 1 deletion src/playlist/playlistcontainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class PlaylistContainer : public QWidget {
explicit PlaylistContainer(QWidget *parent = nullptr);
~PlaylistContainer() override;

void SetActions(QAction *new_playlist, QAction *load_playlist, QAction *save_playlist, QAction *clear_playlist, QAction *next_playlist, QAction *previous_playlist, QAction *save_all_playlists);
void SetActions(QAction *new_playlist, QAction *load_playlist, QAction *save_playlist, QAction *clear_playlist, QAction *next_playlist, QAction *previous_playlist, QAction *last_playlist, QAction *active_playlist, QAction *close_playlist, QAction *save_all_playlists);
void SetManager(SharedPtr<PlaylistManager> manager);
void ReloadSettings();

Expand All @@ -81,6 +81,8 @@ class PlaylistContainer : public QWidget {
void ClearPlaylist();
void GoToNextPlaylistTab();
void GoToPreviousPlaylistTab();
void GoToLastPlaylistTab();
void GoToActivePlaylistTab();

void SetViewModel(Playlist *playlist, const int scroll_position);
void PlaylistAdded(const int id, const QString &name, bool favorite);
Expand Down
11 changes: 11 additions & 0 deletions src/playlist/playlisttabbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,17 @@ void PlaylistTabBar::CloseFromTabIndex(int index) {

}

void PlaylistTabBar::CloseCurrentTab() {

menu_index_ = this->index_of(this->current_id());
// Don't attempt to close if there is only one tab
if (this->count() == 1) return;

CloseSlot();

}


void PlaylistTabBar::SaveSlot() {

if (menu_index_ == -1) return;
Expand Down
1 change: 1 addition & 0 deletions src/playlist/playlisttabbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class PlaylistTabBar : public QTabBar {

void RemoveTab(const int id);
void InsertTab(const int id, const int index, const QString &text, const bool favorite);
void CloseCurrentTab();

Q_SIGNALS:
void CurrentIdChanged(const int id);
Expand Down