| 1 | // For license of this file, see <project-root-folder>/LICENSE.md. |
| 2 | |
| 3 | #include "gui/settings/settingsshortcuts.h" |
| 4 | |
| 5 | #include "dynamic-shortcuts/dynamicshortcuts.h" |
| 6 | #include "miscellaneous/application.h" |
| 7 | #include "miscellaneous/iconfactory.h" |
| 8 | |
| 9 | SettingsShortcuts::SettingsShortcuts(Settings* settings, QWidget* parent) |
| 10 | : SettingsPanel(settings, parent), m_ui(new Ui::SettingsShortcuts) { |
| 11 | m_ui->setupUi(this); |
| 12 | connect(m_ui->m_shortcuts, &DynamicShortcutsWidget::setupChanged, this, &SettingsShortcuts::dirtifySettings); |
| 13 | } |
| 14 | |
| 15 | SettingsShortcuts::~SettingsShortcuts() { |
| 16 | delete m_ui; |
| 17 | } |
| 18 | |
| 19 | QIcon SettingsShortcuts::icon() const { |
| 20 | return qApp->icons()->fromTheme(QSL("configure-shortcuts"), QSL("keyboard")); |
| 21 | } |
| 22 | |
| 23 | void SettingsShortcuts::loadSettings() { |
| 24 | onBeginLoadSettings(); |
| 25 | m_ui->m_shortcuts->populate(qApp->userAndExtraActions()); |
| 26 | onEndLoadSettings(); |
| 27 | } |
| 28 | |
| 29 | void SettingsShortcuts::saveSettings() { |
| 30 | onBeginSaveSettings(); |
| 31 | m_ui->m_shortcuts->updateShortcuts(); |
| 32 | DynamicShortcuts::save(qApp->userAndExtraActions()); |
| 33 | onEndSaveSettings(); |
| 34 | } |