Changeset 79404 in vbox
- Timestamp:
- Jun 28, 2019 10:11:45 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 131645
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
r79398 r79404 19 19 #include <QApplication> 20 20 #include <QCheckBox> 21 #include <QColorDialog> 21 22 #include <QComboBox> 22 23 #include <QFile> 23 24 #include <QGroupBox> 24 25 #include <QInputDialog> 26 #include <QHeaderView> 25 27 #include <QLabel> 26 28 #include <QLineEdit> … … 502 504 bool showNumPad(); 503 505 void setShowNumPad(bool fShow); 506 507 const QColor &color(int iColorType) const; 508 void setColor(int iColorType, const QColor &color); 504 509 505 510 protected: … … 543 548 544 549 UISoftKeyboardKey *m_pKeyPressed; 545 QColor m_key DefaultColor;550 QColor m_keyBackgroundColor; 546 551 QColor m_keyHoverColor; 547 QColor m_ textDefaultColor;548 QColor m_ textPressedColor;552 QColor m_fontDefaultColor; 553 QColor m_fontPressedColor; 549 554 QColor m_keyEditColor; 550 555 QVector<UISoftKeyboardKey*> m_pressedModifiers; … … 667 672 Q_OBJECT; 668 673 674 public: 675 676 enum ColorTableRow 677 { 678 ColorTableRow_Background = 0, 679 ColorTableRow_Font, 680 ColorTableRow_Hover, 681 ColorTableRow_Edit, 682 ColorTableRow_Pressed, 683 ColorTableRow_Max 684 }; 685 669 686 signals: 670 687 671 688 void sigShowNumPad(bool fShow); 672 689 void sigShowOSMenuKeys(bool fShow); 690 void sigColorCellClicked(int iColorRow); 691 void sigCloseSettingsWidget(); 673 692 674 693 public: … … 677 696 void setShowOSMenuKeys(bool fShow); 678 697 void setShowNumPad(bool fShow); 698 void setTableItemColor(ColorTableRow tableRow, const QColor &color); 679 699 680 700 protected: … … 684 704 private slots: 685 705 706 void sltColorCellClicked(int row, int column); 686 707 687 708 private: … … 689 710 void prepareObjects(); 690 711 691 QCheckBox *m_pShowNumPadCheckBox; 692 QCheckBox *m_pShowOsMenuButtonsCheckBox; 712 QCheckBox *m_pShowNumPadCheckBox; 713 QCheckBox *m_pShowOsMenuButtonsCheckBox; 714 QGroupBox *m_pColorTableGroupBox; 693 715 QTableWidget *m_pColorSelectionTable; 716 QLabel *m_pTitleLabel; 717 QToolButton *m_pCloseButton; 694 718 }; 695 719 … … 1164 1188 pLayout->addWidget(m_pLayoutListWidget); 1165 1189 connect(m_pLayoutListWidget, &QListWidget::currentItemChanged, this, &UILayoutSelector::sltCurrentItemChanged); 1166 1190 m_pLayoutListWidget->setSelectionMode(QAbstractItemView::SingleSelection); 1167 1191 QHBoxLayout *pButtonsLayout = new QHBoxLayout; 1168 1192 pLayout->addLayout(pButtonsLayout); … … 1712 1736 , m_pKeyBeingEdited(0) 1713 1737 , m_pKeyPressed(0) 1714 , m_key DefaultColor(QColor(103, 128, 159))1738 , m_keyBackgroundColor(QColor(103, 128, 159)) 1715 1739 , m_keyHoverColor(QColor(108, 122, 137)) 1716 , m_ textDefaultColor(QColor(46, 49, 49))1717 , m_ textPressedColor(QColor(149, 165, 166))1740 , m_fontDefaultColor(QColor(46, 49, 49)) 1741 , m_fontPressedColor(QColor(149, 165, 166)) 1718 1742 , m_keyEditColor(QColor(249, 165, 166)) 1719 1743 , m_pCurrentKeyboardLayout(0) … … 1795 1819 painter.setBrush(QBrush(m_keyHoverColor)); 1796 1820 else 1797 painter.setBrush(QBrush(m_key DefaultColor));1821 painter.setBrush(QBrush(m_keyBackgroundColor)); 1798 1822 1799 1823 if (&key == m_pKeyPressed) 1800 painter.setPen(QPen(QColor(m_ textPressedColor), 2));1824 painter.setPen(QPen(QColor(m_fontPressedColor), 2)); 1801 1825 else 1802 painter.setPen(QPen(QColor(m_ textDefaultColor), 2));1826 painter.setPen(QPen(QColor(m_fontDefaultColor), 2)); 1803 1827 1804 1828 painter.drawPolygon(key.polygon()); … … 1810 1834 QColor ledColor; 1811 1835 if (key.state() == UIKeyState_NotPressed) 1812 ledColor = m_ textDefaultColor;1836 ledColor = m_fontDefaultColor; 1813 1837 else if (key.state() == UIKeyState_Pressed) 1814 1838 ledColor = QColor(0, 255, 0); … … 2005 2029 m_fShowNumPad = fShow; 2006 2030 update(); 2031 } 2032 2033 const QColor &UISoftKeyboardWidget::color(int iColorType) const 2034 { 2035 UISoftKeyboardSettingsWidget::ColorTableRow enmColorType = static_cast<UISoftKeyboardSettingsWidget::ColorTableRow>(iColorType); 2036 switch (enmColorType) 2037 { 2038 case UISoftKeyboardSettingsWidget::ColorTableRow_Background: 2039 return m_keyBackgroundColor; 2040 break; 2041 case UISoftKeyboardSettingsWidget::ColorTableRow_Edit: 2042 return m_keyEditColor; 2043 break; 2044 case UISoftKeyboardSettingsWidget::ColorTableRow_Font: 2045 return m_fontDefaultColor; 2046 break; 2047 case UISoftKeyboardSettingsWidget::ColorTableRow_Hover: 2048 return m_keyHoverColor; 2049 break; 2050 case UISoftKeyboardSettingsWidget::ColorTableRow_Pressed: 2051 return m_fontPressedColor; 2052 break; 2053 case UISoftKeyboardSettingsWidget::ColorTableRow_Max: 2054 default: 2055 return m_keyBackgroundColor; 2056 break; 2057 } 2058 return m_keyBackgroundColor; 2059 } 2060 2061 void UISoftKeyboardWidget::setColor(int iColorType, const QColor &color) 2062 { 2063 UISoftKeyboardSettingsWidget::ColorTableRow enmColorType = static_cast<UISoftKeyboardSettingsWidget::ColorTableRow>(iColorType); 2064 switch (enmColorType) 2065 { 2066 case UISoftKeyboardSettingsWidget::ColorTableRow_Background: 2067 m_keyBackgroundColor = color; 2068 break; 2069 case UISoftKeyboardSettingsWidget::ColorTableRow_Edit: 2070 m_keyEditColor = color; 2071 break; 2072 case UISoftKeyboardSettingsWidget::ColorTableRow_Font: 2073 m_fontDefaultColor = color; 2074 break; 2075 case UISoftKeyboardSettingsWidget::ColorTableRow_Hover: 2076 m_keyHoverColor = color; 2077 break; 2078 case UISoftKeyboardSettingsWidget::ColorTableRow_Pressed: 2079 m_fontPressedColor = color; 2080 break; 2081 case UISoftKeyboardSettingsWidget::ColorTableRow_Max: 2082 default: 2083 break; 2084 } 2007 2085 } 2008 2086 … … 2888 2966 , m_pShowNumPadCheckBox(0) 2889 2967 , m_pShowOsMenuButtonsCheckBox(0) 2968 , m_pColorTableGroupBox(0) 2890 2969 , m_pColorSelectionTable(0) 2970 , m_pTitleLabel(0) 2971 , m_pCloseButton(0) 2972 2891 2973 { 2892 2974 prepareObjects(); … … 2905 2987 } 2906 2988 2989 void UISoftKeyboardSettingsWidget::setTableItemColor(ColorTableRow tableRow, const QColor &color) 2990 { 2991 if (!m_pColorSelectionTable) 2992 return; 2993 QTableWidgetItem *pItem = m_pColorSelectionTable->item(tableRow, 1); 2994 if (!pItem) 2995 return; 2996 pItem->setBackground(color); 2997 m_pColorSelectionTable->update(); 2998 } 2999 2907 3000 void UISoftKeyboardSettingsWidget::retranslateUi() 2908 3001 { 3002 if (m_pTitleLabel) 3003 m_pTitleLabel->setText(UISoftKeyboard::tr("Keyboard Settings")); 3004 if (m_pCloseButton) 3005 { 3006 m_pCloseButton->setToolTip(UISoftKeyboard::tr("Close the layout list")); 3007 m_pCloseButton->setText("Close"); 3008 } 2909 3009 if (m_pShowNumPadCheckBox) 2910 3010 m_pShowNumPadCheckBox->setText(UISoftKeyboard::tr("Show NumPad")); 2911 3011 if (m_pShowOsMenuButtonsCheckBox) 2912 3012 m_pShowOsMenuButtonsCheckBox->setText(UISoftKeyboard::tr("Show OS/Menu Keys")); 2913 3013 if (m_pColorTableGroupBox) 3014 m_pColorTableGroupBox->setTitle(UISoftKeyboard::tr("Button Colors")); 3015 if (m_pColorSelectionTable) 3016 { 3017 QTableWidgetItem *pItem = m_pColorSelectionTable->itemAt(ColorTableRow_Background, 0); 3018 if (pItem) 3019 pItem->setText(UISoftKeyboard::tr("Button Background Color")); 3020 pItem = m_pColorSelectionTable->item(ColorTableRow_Font, 0); 3021 if (pItem) 3022 pItem->setText(UISoftKeyboard::tr("Button Font Color")); 3023 pItem = m_pColorSelectionTable->item(ColorTableRow_Hover, 0); 3024 if (pItem) 3025 pItem->setText(UISoftKeyboard::tr("Button Hover Color")); 3026 pItem = m_pColorSelectionTable->item(ColorTableRow_Edit, 0); 3027 if (pItem) 3028 pItem->setText(UISoftKeyboard::tr("Button Edit Color")); 3029 pItem = m_pColorSelectionTable->item(ColorTableRow_Pressed, 0); 3030 if (pItem) 3031 pItem->setText(UISoftKeyboard::tr("Pressed Button Color")); 3032 m_pColorSelectionTable->setToolTip(UISoftKeyboard::tr("Click on the corresponding table cells to modify colors")); 3033 } 2914 3034 } 2915 3035 … … 2919 3039 if (!pSettingsLayout) 2920 3040 return; 3041 3042 QHBoxLayout *pTitleLayout = new QHBoxLayout; 3043 m_pCloseButton = new QToolButton; 3044 m_pCloseButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); 3045 m_pCloseButton->setIcon(UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_DialogCancel)); 3046 m_pCloseButton->setAutoRaise(true); 3047 connect(m_pCloseButton, &QToolButton::clicked, this, &UISoftKeyboardSettingsWidget::sigCloseSettingsWidget); 3048 pTitleLayout->addWidget(m_pCloseButton); 3049 pTitleLayout->addStretch(2); 3050 m_pTitleLabel = new QLabel; 3051 pTitleLayout->addWidget(m_pTitleLabel); 3052 pSettingsLayout->addLayout(pTitleLayout, 0, 0, 1, 2); 3053 2921 3054 m_pShowNumPadCheckBox = new QCheckBox; 2922 3055 m_pShowOsMenuButtonsCheckBox = new QCheckBox; 2923 2924 pSettingsLayout->addWidget(m_pShowNumPadCheckBox, 0, 0, 1, 1); 2925 pSettingsLayout->addWidget(m_pShowOsMenuButtonsCheckBox, 1, 0, 1, 1); 2926 3056 pSettingsLayout->addWidget(m_pShowNumPadCheckBox, 1, 0, 1, 1); 3057 pSettingsLayout->addWidget(m_pShowOsMenuButtonsCheckBox, 2, 0, 1, 1); 2927 3058 connect(m_pShowNumPadCheckBox, &QCheckBox::toggled, this, &UISoftKeyboardSettingsWidget::sigShowNumPad); 2928 3059 connect(m_pShowOsMenuButtonsCheckBox, &QCheckBox::toggled, this, &UISoftKeyboardSettingsWidget::sigShowOSMenuKeys); 2929 3060 3061 /* A groupbox to host the color table widget: */ 3062 m_pColorTableGroupBox = new QGroupBox; 3063 QVBoxLayout *pTableGroupBoxLayout = new QVBoxLayout(m_pColorTableGroupBox); 3064 pSettingsLayout->addWidget(m_pColorTableGroupBox, 3, 0, 2, 1); 3065 3066 /* Creating and configuring the color table widget: */ 2930 3067 m_pColorSelectionTable = new QTableWidget; 2931 p SettingsLayout->addWidget(m_pShowOsMenuButtonsCheckBox, 2, 0, 2, 1);2932 m_pColorSelectionTable->setRowCount( 3);3068 pTableGroupBoxLayout->addWidget(m_pColorSelectionTable); 3069 m_pColorSelectionTable->setRowCount(ColorTableRow_Max); 2933 3070 m_pColorSelectionTable->setColumnCount(2); 2934 3071 m_pColorSelectionTable->horizontalHeader()->hide(); 3072 m_pColorSelectionTable->verticalHeader()->hide(); 3073 m_pColorSelectionTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); 3074 m_pColorSelectionTable->setEditTriggers(QAbstractItemView::NoEditTriggers); 3075 m_pColorSelectionTable->setFocusPolicy(Qt::NoFocus); 3076 m_pColorSelectionTable->setSelectionMode(QAbstractItemView::NoSelection); 3077 connect(m_pColorSelectionTable, &QTableWidget::cellClicked, this, &UISoftKeyboardSettingsWidget::sltColorCellClicked); 3078 3079 /* Create column 0 items: */ 3080 m_pColorSelectionTable->setItem(ColorTableRow_Background, 0, new QTableWidgetItem()); 3081 m_pColorSelectionTable->setItem(ColorTableRow_Font, 0, new QTableWidgetItem()); 3082 m_pColorSelectionTable->setItem(ColorTableRow_Hover, 0, new QTableWidgetItem()); 3083 m_pColorSelectionTable->setItem(ColorTableRow_Edit, 0, new QTableWidgetItem()); 3084 m_pColorSelectionTable->setItem(ColorTableRow_Pressed, 0, new QTableWidgetItem()); 3085 3086 /* Create column 1 items: */ 3087 for (int i = ColorTableRow_Background; i < ColorTableRow_Max; ++i) 3088 { 3089 QTableWidgetItem *pItem = new QTableWidgetItem(); 3090 m_pColorSelectionTable->setItem(static_cast<ColorTableRow>(i), 1, pItem); 3091 pItem->setIcon(UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowBack)); 3092 } 2935 3093 2936 3094 QSpacerItem *pSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding); 2937 3095 if (pSpacer) 2938 pSettingsLayout->addItem(pSpacer, 4, 0);3096 pSettingsLayout->addItem(pSpacer, 5, 0); 2939 3097 2940 3098 setLayout(pSettingsLayout); … … 2942 3100 } 2943 3101 3102 void UISoftKeyboardSettingsWidget::sltColorCellClicked(int row, int column) 3103 { 3104 if (column != 1 || row >= static_cast<int>(ColorTableRow_Max)) 3105 return; 3106 emit sigColorCellClicked(row); 3107 } 2944 3108 2945 3109 /********************************************************************************************************************************* … … 2975 3139 2976 3140 loadSettings(); 3141 configure(); 2977 3142 retranslateUi(); 2978 3143 } … … 3128 3293 if (m_pKeyboardWidget) 3129 3294 m_pKeyboardWidget->setShowNumPad(fShow); 3295 } 3296 3297 void UISoftKeyboard::sltHandleColorCellClick(int iColorRow) 3298 { 3299 if (!m_pKeyboardWidget || iColorRow >= static_cast<int>(UISoftKeyboardSettingsWidget::ColorTableRow_Max)) 3300 return; 3301 const QColor ¤tColor = m_pKeyboardWidget->color(iColorRow); 3302 QColorDialog colorDialog(currentColor, this); 3303 3304 if (colorDialog.exec() == QDialog::Rejected) 3305 return; 3306 QColor newColor = colorDialog.selectedColor(); 3307 if (currentColor == newColor) 3308 return; 3309 m_pKeyboardWidget->setColor(iColorRow, newColor); 3310 m_pSettingsWidget->setTableItemColor(static_cast<UISoftKeyboardSettingsWidget::ColorTableRow>(iColorRow), newColor); 3130 3311 } 3131 3312 … … 3200 3381 connect(m_pSettingsWidget, &UISoftKeyboardSettingsWidget::sigShowOSMenuKeys, this, &UISoftKeyboard::sltShowHideOSMenuKeys); 3201 3382 connect(m_pSettingsWidget, &UISoftKeyboardSettingsWidget::sigShowNumPad, this, &UISoftKeyboard::sltShowHideNumPad); 3383 connect(m_pSettingsWidget, &UISoftKeyboardSettingsWidget::sigColorCellClicked, this, &UISoftKeyboard::sltHandleColorCellClick); 3384 connect(m_pSettingsWidget, &UISoftKeyboardSettingsWidget::sigCloseSettingsWidget, this, &UISoftKeyboard::sltShowHideSettingsWidget); 3202 3385 } 3203 3386 … … 3239 3422 geometry.x(), geometry.y(), geometry.width(), geometry.height())); 3240 3423 setDialogGeometry(geometry); 3241 3424 } 3425 3426 void UISoftKeyboard::configure() 3427 { 3428 setWindowIcon(UIIconPool::iconSetFull(":/vm_show_logs_32px.png", ":/vm_show_logs_16px.png")); 3242 3429 if (m_pKeyboardWidget && m_pSettingsWidget) 3243 3430 { 3244 3431 m_pSettingsWidget->setShowOSMenuKeys(m_pKeyboardWidget->showOSMenuKeys()); 3245 3432 m_pSettingsWidget->setShowNumPad(m_pKeyboardWidget->showNumPad()); 3433 3434 for (int i = static_cast<int>(UISoftKeyboardSettingsWidget::ColorTableRow_Background); 3435 i < static_cast<int>(UISoftKeyboardSettingsWidget::ColorTableRow_Max); ++i) 3436 m_pSettingsWidget->setTableItemColor(static_cast<UISoftKeyboardSettingsWidget::ColorTableRow>(i), 3437 m_pKeyboardWidget->color(i)); 3246 3438 } 3247 3439 } -
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h
r79385 r79404 87 87 void sltShowHideOSMenuKeys(bool fShow); 88 88 void sltShowHideNumPad(bool fShow); 89 void sltHandleColorCellClick(int iColorRow); 89 90 90 91 private: … … 94 95 void saveSettings(); 95 96 void loadSettings(); 97 void configure(); 96 98 void updateStatusBarMessage(const QString &strLayoutName); 97 99 void updateLayoutSelector();
Note:
See TracChangeset
for help on using the changeset viewer.