From bbe0f81c2be4ac4177d0ea6b62dc14125302c5ba Mon Sep 17 00:00:00 2001 From: Andrew Udvare Date: Sat, 27 Feb 2010 18:20:20 +0000 Subject: [PATCH] Implementation of global shortcuts dialog, no settings saved yet; Start of fix for issue #6 --- src/mainwindow.cpp | 3 + src/mainwindow.h | 2 + src/mainwindow.ui | 10 ++ src/shortcutsdialog.cpp | 36 +++++ src/shortcutsdialog.h | 26 ++++ src/shortcutsdialog.ui | 323 ++++++++++++++++++++++++++++++++++++++++ src/src.pro | 9 +- 7 files changed, 406 insertions(+), 3 deletions(-) create mode 100644 src/shortcutsdialog.cpp create mode 100644 src/shortcutsdialog.h create mode 100644 src/shortcutsdialog.ui diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 632bd712c..c3cc5bec6 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -13,6 +13,7 @@ #include "edittagdialog.h" #include "multiloadingindicator.h" #include "settingsdialog.h" +#include "shortcutsdialog.h" #include "libraryconfigdialog.h" #include "about.h" #include "addstreamdialog.h" @@ -52,6 +53,7 @@ MainWindow::MainWindow(QWidget *parent) library_(new Library(player_->GetEngine(), this)), settings_dialog_(new SettingsDialog(this)), add_stream_dialog_(new AddStreamDialog(this)), + shortcuts_dialog_(new ShortcutsDialog(this)), playlist_menu_(new QMenu(this)), library_sort_model_(new QSortFilterProxyModel(this)), track_position_timer_(new QTimer(this)) @@ -111,6 +113,7 @@ MainWindow::MainWindow(QWidget *parent) connect(ui_.action_add_media, SIGNAL(triggered()), SLOT(AddMedia())); connect(ui_.action_add_stream, SIGNAL(triggered()), SLOT(AddStream())); connect(ui_.action_hide_tray_icon, SIGNAL(triggered()), SLOT(HideShowTrayIcon())); + connect(ui_.action_global_shortcuts, SIGNAL(triggered()), shortcuts_dialog_, SLOT(show())); // Give actions to buttons ui_.forward_button->setDefaultAction(ui_.action_next_track); diff --git a/src/mainwindow.h b/src/mainwindow.h index ff1dae520..614965282 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -21,6 +21,7 @@ class MultiLoadingIndicator; class SettingsDialog; class About; class AddStreamDialog; +class ShortcutsDialog; class QSortFilterProxyModel; class SystemTrayIcon; @@ -102,6 +103,7 @@ class MainWindow : public QMainWindow { SettingsDialog* settings_dialog_; AddStreamDialog* add_stream_dialog_; + ShortcutsDialog* shortcuts_dialog_; QMenu* playlist_menu_; QAction* playlist_play_pause_; diff --git a/src/mainwindow.ui b/src/mainwindow.ui index a588dacab..6c6f702c1 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -467,6 +467,7 @@ Settings + @@ -696,6 +697,15 @@ &Hide tray icon + + + + :/configure.png:/configure.png + + + Configure &Global Shortcuts... + + diff --git a/src/shortcutsdialog.cpp b/src/shortcutsdialog.cpp new file mode 100644 index 000000000..7f6bf7ffe --- /dev/null +++ b/src/shortcutsdialog.cpp @@ -0,0 +1,36 @@ +#include "shortcutsdialog.h" + +const char* ShortcutsDialog::kSettingsGroup = "Shortcuts"; +ShortcutsDialog::ShortcutsDialog(QWidget* parent) + : QDialog(parent) { + ui_.setupUi(this); + ui_.shortcut_options->setEnabled(false); + + // Load settings + // Check if settings exist first, if not create them + // TODO: How do we store the button values? Numbers, strings, especially when it comes to combinations? + + connect(ui_.button_defaults, SIGNAL(clicked()), SLOT(DefaultShortcuts())); + connect(ui_.button_save, SIGNAL(clicked()), SLOT(SaveShortcuts())); + connect(ui_.button_cancel, SIGNAL(clicked()), SLOT(CancelEvent())); +} + +/** + * Reset shortcuts to defaults (none for now). + */ +void ShortcutsDialog::DefaultShortcuts() { +} + +/** + * Save the shortcuts and close the window + */ +void ShortcutsDialog::SaveShortcuts() { + close(); +} + +/** + * Reset settings to original values taken from settings file and then close the window. + */ +void ShortcutsDialog::CancelEvent() { + close(); +} diff --git a/src/shortcutsdialog.h b/src/shortcutsdialog.h new file mode 100644 index 000000000..055db1bb9 --- /dev/null +++ b/src/shortcutsdialog.h @@ -0,0 +1,26 @@ +#ifndef SHORTCUTSDIALOG_H +#define SHORTCUTSDIALOG_H + +#include +#include + +#include "ui_shortcutsdialog.h" + +class ShortcutsDialog : public QDialog { + Q_OBJECT + + public: + ShortcutsDialog(QWidget* parent = 0); + + private slots: + void DefaultShortcuts(); + void SaveShortcuts(); + void CancelEvent(); + + private: + Ui::ShortcutsDialog ui_; + QSettings settings_; + static const char* kSettingsGroup; +}; + +#endif // SHORTCUTSDIALOG_H \ No newline at end of file diff --git a/src/shortcutsdialog.ui b/src/shortcutsdialog.ui new file mode 100644 index 000000000..7bd21e234 --- /dev/null +++ b/src/shortcutsdialog.ui @@ -0,0 +1,323 @@ + + + ShortcutsDialog + + + + 0 + 0 + 485 + 361 + + + + Configure Shortcuts + + + + + 10 + 10 + 461 + 221 + + + + QAbstractItemView::NoEditTriggers + + + true + + + Qt::SolidLine + + + false + + + 116 + + + 24 + + + false + + + true + + + false + + + true + + + false + + + 24 + + + 116 + + + + Play + + + + + Pause + + + + + Play/Pause + + + + + Stop + + + + + Stop Playing After Current Track + + + + + Next Track + + + + + Previous Track + + + + + Increase Volume + + + + + Decrease Volume + + + + + Mute Volume + + + + + Seek Forwards + + + + + Seek Backwards + + + + + Shortcut + + + + + Alternate + + + + + + + 10 + 330 + 80 + 26 + + + + &Defaults + + + + + + 300 + 330 + 80 + 26 + + + + &OK + + + + + + 390 + 330 + 80 + 26 + + + + &Cancel + + + + + true + + + + 10 + 240 + 461 + 81 + + + + Shortcut for Selected Action + + + + true + + + + 10 + 30 + 91 + 22 + + + + &None + + + + + + 110 + 30 + 93 + 22 + + + + De&fault + + + + + + 220 + 30 + 111 + 22 + + + + &Custom + + + + + false + + + + 340 + 30 + 101 + 26 + + + + Non&e + + + + + + 10 + 60 + 431 + 16 + + + + Default key: + + + + + + tableWidget + radio_none + radio_default + radio_custom + button_custom + button_save + button_cancel + button_defaults + + + + + radio_custom + clicked(bool) + button_custom + setEnabled(bool) + + + 299 + 273 + + + 378 + 286 + + + + + radio_default + clicked(bool) + button_custom + setDisabled(bool) + + + 175 + 281 + + + 418 + 276 + + + + + radio_none + clicked(bool) + button_custom + setDisabled(bool) + + + 79 + 276 + + + 431 + 290 + + + + + diff --git a/src/src.pro b/src/src.pro index c7bb6aee4..c4446265e 100644 --- a/src/src.pro +++ b/src/src.pro @@ -55,7 +55,8 @@ SOURCES += main.cpp \ albumcoverfetcher.cpp \ addstreamdialog.cpp \ savedradio.cpp \ - stylesheetloader.cpp + stylesheetloader.cpp \ + shortcutsdialog.cpp HEADERS += mainwindow.h \ player.h \ library.h \ @@ -111,7 +112,8 @@ HEADERS += mainwindow.h \ albumcoverfetcher.h \ addstreamdialog.h \ savedradio.h \ - stylesheetloader.h + stylesheetloader.h \ + shortcutsdialog.h FORMS += mainwindow.ui \ libraryconfig.ui \ fileview.ui \ @@ -124,7 +126,8 @@ FORMS += mainwindow.ui \ libraryconfigdialog.ui \ lastfmconfigdialog.ui \ about.ui \ - addstreamdialog.ui + addstreamdialog.ui \ + shortcutsdialog.ui RESOURCES += ../data/data.qrc \ translations.qrc OTHER_FILES += ../data/schema.sql \