Changeset 79089 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jun 11, 2019 1:03:19 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
r79082 r79089 64 64 UIKeyType_Modifier, 65 65 UIKeyType_Max 66 }; 67 68 /********************************************************************************************************************************* 69 * UISoftKeyEditor definition. * 70 *********************************************************************************************************************************/ 71 72 class UISoftKeyEditor : public QIWithRetranslateUI<QMainWindow> 73 { 74 Q_OBJECT; 75 76 public: 77 78 UISoftKeyEditor(QWidget *pParent = 0); 79 80 protected: 81 82 virtual void retranslateUi() /* override */; 83 84 private: 85 86 void prepareObjects(); 87 void prepareConnections(); 88 89 QGridLayout *m_pEditorLayout; 90 91 QLabel *m_pBaseCaptionLabel; 92 QLabel *m_pShiftCaptionLabel; 93 QLabel *m_pAltGrCaptionLabel; 94 95 QLineEdit *m_pBaseCaptionEdit; 96 QLineEdit *m_pShiftCaptionEdit; 97 QLineEdit *m_pAltGrCaptionEdit; 98 99 QPushButton *m_pOkButton; 100 QPushButton *m_pCancelButton; 66 101 }; 67 102 … … 196 231 { 197 232 Q_OBJECT; 233 enum Mode 234 { 235 Mode_KeyCapEdit, 236 Mode_Keyboard, 237 Mode_Max 238 }; 198 239 199 240 signals: … … 227 268 void sltHandleContextMenuRequest(const QPoint &point); 228 269 void sltHandleLoadLayout(QAction *pSenderAction); 229 void sltHandleKeyCapEdit();230 270 void sltHandleSaveKeyCapFile(); 231 271 void sltHandleLoadKeyCapFile(); 232 272 void sltHandleUnloadKeyCaps(); 233 void sltHandleKepC ApEditModeToggle(bool fToggle);273 void sltHandleKepCapEditModeToggle(bool fToggle); 234 274 235 275 private: … … 278 318 QAction *m_pLoadLayoutFileAction; 279 319 QAction *m_pLastSelectedLayout; 280 QAction *m_p ChangeKeyCapAction;320 QAction *m_pKeyCapEditModeToggleAction; 281 321 QLineEdit *m_pKeyCapEditor; 322 Mode m_enmMode; 282 323 }; 283 324 … … 326 367 QMap<int, QString> m_keyCapMap; 327 368 }; 369 370 /********************************************************************************************************************************* 371 * UISoftKeyEditor implementation. * 372 *********************************************************************************************************************************/ 373 374 UISoftKeyEditor::UISoftKeyEditor(QWidget *pParent /* = 0 */) 375 :QIWithRetranslateUI<QMainWindow>(pParent) 376 , m_pEditorLayout(0) 377 , m_pBaseCaptionLabel(0) 378 , m_pShiftCaptionLabel(0) 379 , m_pAltGrCaptionLabel(0) 380 , m_pBaseCaptionEdit(0) 381 , m_pShiftCaptionEdit(0) 382 , m_pAltGrCaptionEdit(0) 383 , m_pOkButton(0) 384 , m_pCancelButton(0) 385 { 386 prepareObjects(); 387 } 388 389 void UISoftKeyEditor::retranslateUi() 390 { 391 if (m_pBaseCaptionLabel) 392 m_pBaseCaptionLabel->setText(UISoftKeyboard::tr("Base Caption")); 393 394 395 if (m_pShiftCaptionLabel) 396 m_pShiftCaptionLabel->setText(UISoftKeyboard::tr("Shift Caption")); 397 398 if (m_pAltGrCaptionLabel) 399 m_pAltGrCaptionLabel->setText(UISoftKeyboard::tr("AltGr Caption")); 400 } 401 402 void UISoftKeyEditor::prepareObjects() 403 { 404 m_pEditorLayout = new QGridLayout; 405 406 if (!m_pEditorLayout) 407 return; 408 409 m_pBaseCaptionLabel = new QLabel; 410 m_pBaseCaptionEdit = new QLineEdit; 411 m_pBaseCaptionLabel->setBuddy(m_pBaseCaptionEdit); 412 413 m_pShiftCaptionLabel = new QLabel; 414 m_pShiftCaptionEdit = new QLineEdit; 415 m_pShiftCaptionLabel->setBuddy(m_pShiftCaptionEdit); 416 417 m_pAltGrCaptionLabel = new QLabel; 418 m_pAltGrCaptionEdit = new QLineEdit; 419 m_pAltGrCaptionLabel->setBuddy(m_pAltGrCaptionEdit); 420 421 setLayout(m_pEditorLayout); 422 423 retranslateUi(); 424 } 328 425 329 426 /********************************************************************************************************************************* … … 624 721 , m_pLoadLayoutFileAction(0) 625 722 , m_pLastSelectedLayout(0) 626 , m_pChangeKeyCapAction(0) 723 , m_pKeyCapEditModeToggleAction(0) 724 , m_enmMode(Mode_Keyboard) 627 725 { 628 726 … … 674 772 painter.setBrush(QBrush(m_keyDefaultColor)); 675 773 676 if ( &key == m_pKeyBeingEdited)774 if (m_enmMode == Mode_KeyCapEdit && &key == m_pKeyBeingEdited) 677 775 { 678 776 m_pKeyCapEditor->setFont(painterFont); … … 680 778 m_fScaleFactorX * key.keyGeometry().width(), m_fScaleFactorY * key.keyGeometry().height()); 681 779 m_pKeyCapEditor->show(); 682 780 m_pKeyCapEditor->setFocus(); 683 781 } 684 782 … … 725 823 return; 726 824 m_pKeyPressed = keyUnderMouse(pEvent); 727 handleKeyPress(m_pKeyPressed); 825 826 if (m_enmMode == Mode_Keyboard) 827 handleKeyPress(m_pKeyPressed); 828 else if (m_enmMode == Mode_KeyCapEdit) 829 { 830 /* If the editor is shown already for another key clicking away accepts the entered text: */ 831 if (m_pKeyBeingEdited && m_pKeyBeingEdited != m_pKeyUnderMouse) 832 { 833 printf("farkli %p\n", m_pKeyBeingEdited); 834 } 835 m_pKeyBeingEdited = m_pKeyUnderMouse; 836 if (m_pKeyBeingEdited && m_pKeyCapEditor) 837 m_pKeyCapEditor->setText(m_pKeyBeingEdited->keyCap()); 838 } 728 839 update(); 729 840 } … … 736 847 if (!m_pKeyPressed) 737 848 return; 738 handleKeyRelease(m_pKeyPressed); 849 850 if (m_enmMode == Mode_Keyboard) 851 handleKeyRelease(m_pKeyPressed); 852 853 update(); 739 854 m_pKeyPressed = 0; 740 update();741 855 } 742 856 … … 826 940 } 827 941 828 void UISoftKeyboardWidget::sltHandleKeyCapEdit()829 {830 m_pKeyBeingEdited = m_pKeyUnderMouse;831 if (m_pKeyBeingEdited && m_pKeyCapEditor)832 m_pKeyCapEditor->setText(m_pKeyBeingEdited->keyCap());833 }834 835 942 void UISoftKeyboardWidget::sltHandleSaveKeyCapFile() 836 943 { … … 909 1016 } 910 1017 911 void UISoftKeyboardWidget::sltHandleKepCApEditModeToggle(bool fToggle) 912 { 913 Q_UNUSED(fToggle); 1018 void UISoftKeyboardWidget::sltHandleKepCapEditModeToggle(bool fToggle) 1019 { 1020 if (fToggle) 1021 m_enmMode = Mode_KeyCapEdit; 1022 else 1023 m_enmMode = Mode_Keyboard; 914 1024 } 915 1025 … … 1019 1129 void UISoftKeyboardWidget::showContextMenu(const QPoint &globalPoint) 1020 1130 { 1021 m_pChangeKeyCapAction->setEnabled(m_pKeyUnderMouse && !m_pShowPositionsAction->isChecked());1022 1131 m_pContextMenu->exec(globalPoint); 1023 1132 update(); … … 1125 1234 m_pContextMenu = new QMenu(this); 1126 1235 /* Layout menu: */ 1127 QMenu *pLayoutMenu = m_pContextMenu->addMenu(UISoftKeyboard::tr("Load Layout"));1128 1236 m_pLayoutActionGroup = new QActionGroup(this); 1129 1237 m_pLayoutActionGroup->setExclusive(true); … … 1139 1247 m_pLoadLayoutFileAction = m_pLayoutActionGroup->addAction(UISoftKeyboard::tr("Load Layout File...")); 1140 1248 m_pLoadLayoutFileAction->setCheckable(true); 1141 pLayoutMenu->addActions(m_pLayoutActionGroup->actions());1249 m_pContextMenu->addActions(m_pLayoutActionGroup->actions()); 1142 1250 1143 1251 /* Keycaps menu: */ 1144 QMenu *pKeycapsMenu = m_pContextMenu->addMenu(UISoftKeyboard::tr("Keycaps"));1145 QAction *pKeyCapEditModeToggleAction = pKeycapsMenu->addAction(UISoftKeyboard::tr("Key captions editing mode"));1146 connect(pKeyCapEditModeToggleAction, &QAction::toggled, this, &UISoftKeyboardWidget::sltHandleKepCApEditModeToggle);1147 pKeyCapEditModeToggleAction->setCheckable(true);1148 pKeyCapEditModeToggleAction->setChecked(false); 1149 1150 m_pShowPositionsAction = pKeycapsMenu->addAction(UISoftKeyboard::tr("Show key positions instead of key caps"));1252 m_pKeyCapEditModeToggleAction = m_pContextMenu->addAction(UISoftKeyboard::tr("Key captions editing mode")); 1253 connect(m_pKeyCapEditModeToggleAction, &QAction::toggled, this, &UISoftKeyboardWidget::sltHandleKepCapEditModeToggle); 1254 m_pKeyCapEditModeToggleAction->setCheckable(true); 1255 m_pKeyCapEditModeToggleAction->setChecked(false); 1256 1257 #ifdef DEBUG 1258 m_pShowPositionsAction = m_pContextMenu->addAction(UISoftKeyboard::tr("Show key positions instead of key caps")); 1151 1259 m_pShowPositionsAction->setCheckable(true); 1152 1260 m_pShowPositionsAction->setChecked(false); 1153 1154 m_pChangeKeyCapAction = pKeycapsMenu->addAction(UISoftKeyboard::tr("Add/change key cap")); 1155 connect(m_pChangeKeyCapAction, &QAction::triggered, this, &UISoftKeyboardWidget::sltHandleKeyCapEdit); 1156 QAction *pSaveKeyCapFile = pKeycapsMenu->addAction(UISoftKeyboard::tr("Save key caps to file...")); 1261 #endif 1262 1263 QAction *pSaveKeyCapFile = m_pContextMenu->addAction(UISoftKeyboard::tr("Save key caps to file...")); 1157 1264 connect(pSaveKeyCapFile, &QAction::triggered, this, &UISoftKeyboardWidget::sltHandleSaveKeyCapFile); 1158 QAction *pLoadKeyCapFile = pKeycapsMenu->addAction(UISoftKeyboard::tr("Load key caps from file..."));1265 QAction *pLoadKeyCapFile = m_pContextMenu->addAction(UISoftKeyboard::tr("Load key caps from file...")); 1159 1266 connect(pLoadKeyCapFile, &QAction::triggered, this, &UISoftKeyboardWidget::sltHandleLoadKeyCapFile); 1160 QAction *pUnloadKeyCaps = pKeycapsMenu->addAction(UISoftKeyboard::tr("Unload key caps"));1267 QAction *pUnloadKeyCaps = m_pContextMenu->addAction(UISoftKeyboard::tr("Unload key caps")); 1161 1268 connect(pUnloadKeyCaps, &QAction::triggered, this, &UISoftKeyboardWidget::sltHandleUnloadKeyCaps); 1162 1269 } … … 1166 1273 if (m_fInKeyCapEditMode == fEnable) 1167 1274 return; 1168 1275 m_enmMode = Mode_KeyCapEdit; 1169 1276 } 1170 1277 … … 1478 1585 void UISoftKeyboard::retranslateUi() 1479 1586 { 1587 if (m_pSettingsButton) 1588 m_pSettingsButton->setToolTip(tr("Settings Menu")); 1480 1589 } 1481 1590 … … 1547 1656 this, &UISoftKeyboard::sltHandleStatusBarContextMenuRequest); 1548 1657 1658 statusBar()->setStyleSheet( "QStatusBar::item { border: 0px}" ); 1659 // QWidget *pStatusBarWidget = new QWidget; 1660 // QHBoxLayout *pStatusBarLayout = new QHBoxLayout(pStatusBarWidget); 1661 // pStatusBarLayout->setSpacing(0); 1662 // pStatusBarLayout->setContentsMargins(0, 0, 0, 0); 1663 1549 1664 m_pSettingsButton = new QToolButton; 1550 m_pSettingsButton->setIcon(UIIconPool::iconSet(":/ vm_settings_16px.png"));1665 m_pSettingsButton->setIcon(UIIconPool::iconSet(":/keyboard_settings_16px.png")); 1551 1666 m_pSettingsButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); 1552 1667 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize); … … 1555 1670 statusBar()->addPermanentWidget(m_pSettingsButton); 1556 1671 1672 QToolButton *pButton = new QToolButton; 1673 pButton->setIcon(UIIconPool::iconSet(":/hd_modify_16px.png")); 1674 pButton->setStyleSheet("QToolButton { border: 0px none black; margin: 0px 0px 0px 0px; } QToolButton::menu-indicator {image: none;}"); 1675 statusBar()->addPermanentWidget(pButton); 1676 1677 1678 1679 retranslateUi(); 1557 1680 } 1558 1681 -
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h
r79082 r79089 64 64 void sltHandleKeyCapFileChange(const QString &strKeyCapFileName); 65 65 void sltHandleStatusBarContextMenuRequest(const QPoint &point); 66 66 67 private: 67 68
Note:
See TracChangeset
for help on using the changeset viewer.