Shortcut settings page cleanup.

- Group list and settings so they can be enabled/disabled together.
- Make default selection shortcut list. Previous behavior set options
  for the first item, but didn't highlight selection.
- Rename ItemClicked to CurrentItemChanged to reflect correct signal.
This commit is contained in:
Jim Broadus 2020-02-22 23:22:12 -08:00 committed by John Maguire
parent 2179027a6d
commit a8f656a933
3 changed files with 115 additions and 98 deletions

View File

@ -47,7 +47,7 @@ GlobalShortcutsSettingsPage::GlobalShortcutsSettingsPage(SettingsDialog* dialog)
connect(ui_->list, connect(ui_->list,
SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
SLOT(ItemClicked(QTreeWidgetItem*))); SLOT(CurrentItemChanged(QTreeWidgetItem*)));
connect(ui_->radio_none, SIGNAL(clicked()), SLOT(NoneClicked())); connect(ui_->radio_none, SIGNAL(clicked()), SLOT(NoneClicked()));
connect(ui_->radio_default, SIGNAL(clicked()), SLOT(DefaultClicked())); connect(ui_->radio_default, SIGNAL(clicked()), SLOT(DefaultClicked()));
connect(ui_->radio_custom, SIGNAL(clicked()), SLOT(ChangeClicked())); connect(ui_->radio_custom, SIGNAL(clicked()), SLOT(ChangeClicked()));
@ -86,7 +86,7 @@ void GlobalShortcutsSettingsPage::Load() {
} }
ui_->list->sortItems(0, Qt::AscendingOrder); ui_->list->sortItems(0, Qt::AscendingOrder);
ItemClicked(ui_->list->topLevelItem(0)); ui_->list->setCurrentItem(ui_->list->topLevelItem(0));
} }
for (const Shortcut& s : shortcuts_.values()) { for (const Shortcut& s : shortcuts_.values()) {
@ -121,7 +121,7 @@ void GlobalShortcutsSettingsPage::Save() {
dialog()->global_shortcuts_manager()->ReloadSettings(); dialog()->global_shortcuts_manager()->ReloadSettings();
} }
void GlobalShortcutsSettingsPage::ItemClicked(QTreeWidgetItem* item) { void GlobalShortcutsSettingsPage::CurrentItemChanged(QTreeWidgetItem* item) {
current_id_ = item->data(0, Qt::UserRole).toString(); current_id_ = item->data(0, Qt::UserRole).toString();
Shortcut& shortcut = shortcuts_[current_id_]; Shortcut& shortcut = shortcuts_[current_id_];

View File

@ -44,7 +44,7 @@ class GlobalShortcutsSettingsPage : public SettingsPage {
void Save(); void Save();
private slots: private slots:
void ItemClicked(QTreeWidgetItem*); void CurrentItemChanged(QTreeWidgetItem*);
void NoneClicked(); void NoneClicked();
void DefaultClicked(); void DefaultClicked();
void ChangeClicked(); void ChangeClicked();

View File

@ -21,7 +21,16 @@
<item> <item>
<widget class="QWidget" name="gnome_container" native="true"> <widget class="QWidget" name="gnome_container" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -53,7 +62,16 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -83,85 +101,97 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QTreeWidget" name="list"> <widget class="QWidget" name="list_container" native="true">
<property name="editTriggers"> <property name="minimumSize">
<set>QAbstractItemView::NoEditTriggers</set> <size>
<width>0</width>
<height>0</height>
</size>
</property> </property>
<property name="alternatingRowColors"> <layout class="QVBoxLayout" name="verticalLayout_2">
<bool>true</bool>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<column>
<property name="text">
<string comment="Category label">Action</string>
</property>
</column>
<column>
<property name="text">
<string>Shortcut</string>
</property>
</column>
</widget>
</item>
<item>
<widget class="QGroupBox" name="shortcut_options">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Shortcut for %1</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QRadioButton" name="radio_none"> <widget class="QTreeWidget" name="list">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<column>
<property name="text">
<string comment="Category label">Action</string>
</property>
</column>
<column>
<property name="text">
<string>Shortcut</string>
</property>
</column>
</widget>
</item>
<item>
<widget class="QGroupBox" name="shortcut_options">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="title">
<string>&amp;None</string> <string>Shortcut for %1</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radio_default">
<property name="text">
<string>De&amp;fault</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radio_custom">
<property name="text">
<string>&amp;Custom</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="change">
<property name="text">
<string>Change shortcut...</string>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="radio_none">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;None</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radio_default">
<property name="text">
<string>De&amp;fault</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radio_custom">
<property name="text">
<string>&amp;Custom</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="change">
<property name="text">
<string>Change shortcut...</string>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -170,6 +200,9 @@
</layout> </layout>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>gnome_checkbox</tabstop>
<tabstop>gnome_open</tabstop>
<tabstop>mac_open</tabstop>
<tabstop>list</tabstop> <tabstop>list</tabstop>
<tabstop>radio_none</tabstop> <tabstop>radio_none</tabstop>
<tabstop>radio_default</tabstop> <tabstop>radio_default</tabstop>
@ -183,7 +216,7 @@
<connection> <connection>
<sender>gnome_checkbox</sender> <sender>gnome_checkbox</sender>
<signal>toggled(bool)</signal> <signal>toggled(bool)</signal>
<receiver>list</receiver> <receiver>list_container</receiver>
<slot>setDisabled(bool)</slot> <slot>setDisabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
@ -191,24 +224,8 @@
<y>25</y> <y>25</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>82</x> <x>253</x>
<y>63</y> <y>247</y>
</hint>
</hints>
</connection>
<connection>
<sender>gnome_checkbox</sender>
<signal>toggled(bool)</signal>
<receiver>shortcut_options</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>244</x>
<y>26</y>
</hint>
<hint type="destinationlabel">
<x>122</x>
<y>298</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>