Changeset 44737 in vbox
- Timestamp:
- Feb 18, 2013 2:08:20 PM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.cpp
r44713 r44737 24 24 #include <QStyledItemDelegate> 25 25 #include <QItemEditorFactory> 26 #include <QTabWidget> 26 27 27 28 /* GUI includes: */ 29 #include "QIWidgetValidator.h" 28 30 #include "UIGlobalSettingsInput.h" 29 31 #include "UIShortcutPool.h" … … 34 36 /* Input page constructor: */ 35 37 UIGlobalSettingsInput::UIGlobalSettingsInput() 38 : m_pValidator(0) 36 39 { 37 40 /* Apply UI decorations: */ 38 41 Ui::UIGlobalSettingsInput::setupUi(this); 39 42 40 /* Set the new shortcut for the eraze-host-combo button: */ 41 m_pResetHostCombinationButton->setShortcut(QKeySequence()); 42 new QShortcut(QKeySequence(Qt::Key_Delete), m_pResetHostCombinationButton, SLOT(animateClick())); 43 new QShortcut(QKeySequence(Qt::Key_Backspace), m_pResetHostCombinationButton, SLOT(animateClick())); 43 /* Create selector model/table: */ 44 m_pSelectorModel = new UIHotKeyTableModel(this, UIActionPoolType_Selector); 45 m_pSelectorTable = new UIHotKeyTable(m_pSelectorModel); 46 /* Create machine model/table: */ 47 m_pMachineModel = new UIHotKeyTableModel(this, UIActionPoolType_Runtime); 48 m_pMachineTable = new UIHotKeyTable(m_pMachineModel); 49 50 /* Create tab widget layout: */ 51 QVBoxLayout *pVerticalLayout = new QVBoxLayout; 52 pVerticalLayout->setContentsMargins(0, 0, 0, 0); 53 pVerticalLayout->setSpacing(1); 54 55 /* Create tab widget: */ 56 m_pTabWidget = new QTabWidget(this); 57 m_pTabWidget->setMinimumWidth(400); 58 m_pTabWidget->insertTab(UIHotKeyTableIndex_Selector, m_pSelectorTable, QString()); 59 m_pTabWidget->insertTab(UIHotKeyTableIndex_Machine, m_pMachineTable, QString()); 60 pVerticalLayout->addWidget(m_pTabWidget); 61 62 /* Create filter edit: */ 63 m_pFilterEditor = new QLineEdit(this); 64 connect(m_pFilterEditor, SIGNAL(textChanged(const QString &)), 65 this, SLOT(sltHandleFilterTextChange())); 66 pVerticalLayout->addWidget(m_pFilterEditor); 67 68 /* Add vertical layout into main one: */ 69 m_pMainLayout->addLayout(pVerticalLayout, 0, 0); 44 70 45 71 /* Apply language settings: */ … … 54 80 UISettingsPageGlobal::fetchData(data); 55 81 56 /* Load to cache: */ 57 m_cache.m_strHostCombo = m_settings.hostCombo(); 82 /* Load host-combo shortcut to cache: */ 83 m_cache.m_shortcuts << UIShortcutCacheItem(UIHostCombo::hostComboCacheKey(), tr("Host Combo"), m_settings.hostCombo(), QString()); 84 /* Load all other shortcuts to cache: */ 85 const QMap<QString, UIShortcut>& shortcuts = gShortcutPool->shortcuts(); 86 const QList<QString> shortcutKeys = shortcuts.keys(); 87 foreach (const QString &strShortcutKey, shortcutKeys) 88 { 89 const UIShortcut &shortcut = shortcuts[strShortcutKey]; 90 m_cache.m_shortcuts << UIShortcutCacheItem(strShortcutKey, VBoxGlobal::removeAccelMark(shortcut.description()), 91 shortcut.sequence().toString(QKeySequence::NativeText), 92 shortcut.defaultSequence().toString(QKeySequence::NativeText)); 93 } 94 /* Load other things to cache: */ 58 95 m_cache.m_fAutoCapture = m_settings.autoCapture(); 59 96 … … 67 104 { 68 105 /* Fetch from cache: */ 69 m_pHostKeyEditor->setCombo(m_cache.m_strHostCombo); 106 m_pSelectorModel->load(m_cache.m_shortcuts); 107 m_pMachineModel->load(m_cache.m_shortcuts); 70 108 m_pEnableAutoGrabCheckbox->setChecked(m_cache.m_fAutoCapture); 109 110 /* Revalidate if possible: */ 111 if (m_pValidator) 112 m_pValidator->revalidate(); 71 113 } 72 114 … … 76 118 { 77 119 /* Upload to cache: */ 78 m_cache.m_strHostCombo = m_pHostKeyEditor->combo().toString(); 120 m_pSelectorModel->save(m_cache.m_shortcuts); 121 m_pMachineModel->save(m_cache.m_shortcuts); 79 122 m_cache.m_fAutoCapture = m_pEnableAutoGrabCheckbox->isChecked(); 80 123 } … … 87 130 UISettingsPageGlobal::fetchData(data); 88 131 89 /* Save from cache: */ 90 m_settings.setHostCombo(m_cache.m_strHostCombo); 132 /* Save host-combo shortcut from cache: */ 133 UIShortcutCacheItem fakeHostComboItem(UIHostCombo::hostComboCacheKey(), QString(), QString(), QString()); 134 int iIndexOfHostComboItem = m_cache.m_shortcuts.indexOf(fakeHostComboItem); 135 if (iIndexOfHostComboItem != -1) 136 m_settings.setHostCombo(m_cache.m_shortcuts[iIndexOfHostComboItem].currentSequence); 137 /* Iterate over cached shortcuts: */ 138 QMap<QString, QString> sequences; 139 foreach (const UIShortcutCacheItem &item, m_cache.m_shortcuts) 140 sequences.insert(item.key, item.currentSequence); 141 /* Save shortcut sequences from cache: */ 142 gShortcutPool->setOverrides(sequences); 143 /* Save other things from cache: */ 91 144 m_settings.setAutoCapture(m_cache.m_fAutoCapture); 92 145 … … 95 148 } 96 149 150 void UIGlobalSettingsInput::setValidator(QIWidgetValidator *pValidator) 151 { 152 m_pValidator = pValidator; 153 connect(m_pSelectorModel, SIGNAL(sigRevalidationRequired()), m_pValidator, SLOT(revalidate())); 154 connect(m_pMachineModel, SIGNAL(sigRevalidationRequired()), m_pValidator, SLOT(revalidate())); 155 } 156 157 bool UIGlobalSettingsInput::revalidate(QString &strWarning, QString &strTitle) 158 { 159 /* Check for unique shortcuts: */ 160 if (!m_pSelectorModel->isAllShortcutsUnique()) 161 { 162 strTitle += ": " + VBoxGlobal::removeAccelMark(m_pTabWidget->tabText(UIHotKeyTableIndex_Selector)); 163 strWarning = tr("there are duplicated shortcuts found."); 164 return false; 165 } 166 else if (!m_pMachineModel->isAllShortcutsUnique()) 167 { 168 strTitle += ": " + VBoxGlobal::removeAccelMark(m_pTabWidget->tabText(UIHotKeyTableIndex_Machine)); 169 strWarning = tr("there are duplicated shortcuts found."); 170 return false; 171 } 172 173 return true; 174 } 175 97 176 /* Navigation stuff: */ 98 177 void UIGlobalSettingsInput::setOrderAfter(QWidget *pWidget) 99 178 { 100 setTabOrder(pWidget, m_pHostKeyEditor); 101 setTabOrder(m_pHostKeyEditor, m_pResetHostCombinationButton); 102 setTabOrder(m_pResetHostCombinationButton, m_pEnableAutoGrabCheckbox); 179 setTabOrder(pWidget, m_pTabWidget); 180 setTabOrder(m_pTabWidget, m_pEnableAutoGrabCheckbox); 103 181 } 104 182 … … 107 185 { 108 186 /* Translate uic generated strings: */ 109 Ui::UIGlobalSettingsInput::retranslateUi (this); 187 Ui::UIGlobalSettingsInput::retranslateUi(this); 188 189 /* Translate tab-widget labels: */ 190 m_pTabWidget->setTabText(UIHotKeyTableIndex_Selector, tr("&VirtualBox Manager")); 191 m_pTabWidget->setTabText(UIHotKeyTableIndex_Machine, tr("Virtual &Machine")); 192 m_pSelectorTable->setWhatsThis(tr("Lists all the available shortcuts " 193 "which can be configured.")); 194 m_pMachineTable->setWhatsThis(tr("Lists all the available shortcuts " 195 "which can be configured.")); 196 m_pFilterEditor->setWhatsThis(tr("Allows to filter the shortcuts list.")); 197 } 198 199 /* Filtering stuff: */ 200 void UIGlobalSettingsInput::sltHandleFilterTextChange() 201 { 202 m_pSelectorModel->setFilter(m_pFilterEditor->text()); 203 m_pMachineModel->setFilter(m_pFilterEditor->text()); 110 204 } 111 205 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.h
r44662 r44737 29 29 #include "UIActionPool.h" 30 30 31 /* Forward declartions: */ 32 class QTabWidget; 33 class QLineEdit; 34 class UIHotKeyTableModel; 35 class UIHotKeyTable; 36 31 37 /* Global settings / Input page / Cache / Shortcut cache item: */ 32 38 struct UIShortcutCacheItem … … 103 109 struct UISettingsCacheGlobalInput 104 110 { 105 QString m_strHostCombo;111 UIShortcutCache m_shortcuts; 106 112 bool m_fAutoCapture; 107 113 }; … … 133 139 void saveFromCacheTo(QVariant &data); 134 140 141 /* Validation stuff: */ 142 void setValidator(QIWidgetValidator *pValidator); 143 bool revalidate(QString &strWarning, QString &strTitle); 144 135 145 /* Navigation stuff: */ 136 146 void setOrderAfter(QWidget *pWidget); … … 139 149 void retranslateUi(); 140 150 151 private slots: 152 153 /* Handler: Filtering stuff: */ 154 void sltHandleFilterTextChange(); 155 141 156 private: 142 157 143 158 /* Cache: */ 159 QIWidgetValidator *m_pValidator; 144 160 UISettingsCacheGlobalInput m_cache; 161 QTabWidget *m_pTabWidget; 162 QLineEdit *m_pFilterEditor; 163 UIHotKeyTableModel *m_pSelectorModel; 164 UIHotKeyTable *m_pSelectorTable; 165 UIHotKeyTableModel *m_pMachineModel; 166 UIHotKeyTable *m_pMachineTable; 167 }; 168 169 /* Hot-key table indexes: */ 170 enum UIHotKeyTableIndex 171 { 172 UIHotKeyTableIndex_Selector = 0, 173 UIHotKeyTableIndex_Machine = 1 145 174 }; 146 175 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.ui
r44655 r44737 27 27 <number>0</number> 28 28 </property> 29 <item row="0" column="0"> 30 <spacer> 31 <property name="orientation"> 32 <enum>Qt::Horizontal</enum> 33 </property> 34 <property name="sizeType"> 35 <enum>QSizePolicy::Fixed</enum> 36 </property> 37 <property name="sizeHint" stdset="0"> 38 <size> 39 <width>40</width> 40 <height>20</height> 41 </size> 42 </property> 43 </spacer> 44 </item> 45 <item row="0" column="1"> 46 <widget class="QLabel" name="m_pHostKeyLabel"> 47 <property name="text"> 48 <string>Host &Key:</string> 49 </property> 50 <property name="buddy"> 51 <cstring>m_pHostKeyEditor</cstring> 52 </property> 53 </widget> 54 </item> 55 <item row="0" column="2"> 56 <widget class="UIHostComboEditor" name="m_pHostKeyEditor"> 57 <property name="whatsThis"> 58 <string>Displays the key used as a Host Key in the VM window. Activate the entry field and press a new Host Key. Note that alphanumeric, cursor movement and editing keys cannot be used.</string> 59 </property> 60 <property name="sizePolicy"> 61 <sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum"> 62 <horstretch>0</horstretch> 63 <verstretch>0</verstretch> 64 </sizepolicy> 65 </property> 66 </widget> 67 </item> 68 <item row="0" column="3"> 69 <widget class="UIResetButton" name="m_pResetHostCombinationButton"> 70 <property name="focusPolicy"> 71 <enum>Qt::StrongFocus</enum> 72 </property> 73 <property name="toolTip"> 74 <string>Reset host combination</string> 75 </property> 76 <property name="whatsThis"> 77 <string>Resets the key combination used as the host combination in the VM window.</string> 78 </property> 79 </widget> 80 </item> 81 <item row="1" column="2" colspan="2"> 29 <item row="1" column="0"> 82 30 <widget class="QCheckBox" name="m_pEnableAutoGrabCheckbox"> 83 31 <property name="whatsThis"> … … 89 37 </widget> 90 38 </item> 91 <item row="2" column="0" colspan="4">92 <spacer>93 <property name="orientation">94 <enum>Qt::Vertical</enum>95 </property>96 <property name="sizeHint" stdset="0">97 <size>98 <width>0</width>99 <height>0</height>100 </size>101 </property>102 </spacer>103 </item>104 39 </layout> 105 40 </widget> 106 <customwidgets> 107 <customwidget> 108 <class>UIHostComboEditor</class> 109 <extends>QLineEdit</extends> 110 <header>UIHostComboEditor.h</header> 111 </customwidget> 112 <customwidget> 113 <class>UIResetButton</class> 114 <extends>QAbstractButton</extends> 115 <header>UISpecialControls.h</header> 116 </customwidget> 117 </customwidgets> 41 <customwidgets/> 118 42 <resources/> 119 <connections> 120 <connection> 121 <sender>m_pResetHostCombinationButton</sender> 122 <signal>clicked(bool)</signal> 123 <receiver>m_pHostKeyEditor</receiver> 124 <slot>sltClear()</slot> 125 <hints> 126 <hint type="sourcelabel"> 127 <x>111</x> 128 <y>19</y> 129 </hint> 130 <hint type="destinationlabel"> 131 <x>124</x> 132 <y>61</y> 133 </hint> 134 </hints> 135 </connection> 136 </connections> 43 <connections/> 137 44 </ui> -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHostComboEditor.cpp
r44663 r44737 310 310 /* Configure widget: */ 311 311 setAttribute(Qt::WA_NativeWindow); 312 setAlignment(Qt::AlignCenter);313 312 setContextMenuPolicy(Qt::NoContextMenu); 314 313 connect(this, SIGNAL(selectionChanged()), this, SLOT(sltDeselect()));
Note:
See TracChangeset
for help on using the changeset viewer.