Changeset 79434 in vbox for trunk/src/VBox
- Timestamp:
- Jul 1, 2019 11:31:44 AM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.cpp
r78680 r79434 206 206 /* Soft Keyboard: */ 207 207 const char *UIExtraDataDefs::GUI_SoftKeyboard_DialogGeometry = "GUI/SoftKeyboardDialogGeometry"; 208 const char *UIExtraDataDefs::GUI_SoftKeyboard_ColorTheme = "GUI/SoftKeyboardDialogGeometry"; 208 209 209 210 /* File Manager options: */ -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h
r79250 r79434 385 385 * @{ */ 386 386 extern const char *GUI_SoftKeyboard_DialogGeometry; 387 extern const char *GUI_SoftKeyboard_ColorTheme; 387 388 /** @} */ 388 389 -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp
r79365 r79434 4308 4308 } 4309 4309 4310 void UIExtraDataManager::setSoftKeyboardColorTheme(const QStringList &colorStringList) 4311 { 4312 setExtraDataStringList(GUI_SoftKeyboard_ColorTheme, colorStringList); 4313 } 4314 4315 QStringList UIExtraDataManager::softKeyboardColorTheme() 4316 { 4317 return extraDataStringList(GUI_SoftKeyboard_ColorTheme); 4318 } 4319 4310 4320 void UIExtraDataManager::setFileManagerOptions(bool fListDirectoriesFirst, 4311 4321 bool fShowDeleteConfirmation, -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h
r78680 r79434 676 676 void setSoftKeyboardDialogGeometry(const QRect &geometry, bool fMaximized); 677 677 bool softKeyboardDialogShouldBeMaximized(); 678 void setSoftKeyboardColorTheme(const QStringList &colorStringList); 679 QStringList softKeyboardColorTheme(); 678 680 /** @} */ 679 681 -
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
r79412 r79434 62 62 63 63 /* Forward declarations: */ 64 class UISoftKeyboardWidget;65 64 class UISoftKeyboardLayout; 66 65 class UISoftKeyboardRow; 66 class UISoftKeyboardWidget; 67 67 68 68 const int iMessageTimeout = 3000; … … 94 94 QString m_strAltGr; 95 95 QString m_strShiftAltGr; 96 }; 97 98 enum KeyboardColorType 99 { 100 KeyboardColorType_Background = 0, 101 KeyboardColorType_Font, 102 KeyboardColorType_Hover, 103 KeyboardColorType_Edit, 104 KeyboardColorType_Pressed, 105 KeyboardColorType_Max 96 106 }; 97 107 … … 452 462 453 463 /********************************************************************************************************************************* 464 * UISoftKeyboardColorTheme definition. * 465 *********************************************************************************************************************************/ 466 467 class UISoftKeyboardColorTheme 468 { 469 public: 470 471 UISoftKeyboardColorTheme(); 472 void setColor(KeyboardColorType enmColorType, const QColor &color); 473 QColor color(KeyboardColorType enmColorType) const; 474 QStringList colorsToStringList() const; 475 void colorsFromStringList(const QStringList &colorStringList); 476 477 private: 478 QVector<QColor> m_colors; 479 }; 480 481 /********************************************************************************************************************************* 454 482 * UISoftKeyboardWidget definition. * 455 483 *********************************************************************************************************************************/ … … 505 533 void setShowNumPad(bool fShow); 506 534 507 const QColor &color(int iColorType) const; 508 void setColor(int iColorType, const QColor &color); 535 const QColor color(KeyboardColorType enmColorType) const; 536 void setColor(KeyboardColorType ennmColorType, const QColor &color); 537 538 QStringList colorsToStringList() const; 539 void colorsFromStringList(const QStringList &colorStringList); 509 540 510 541 protected: … … 548 579 549 580 UISoftKeyboardKey *m_pKeyPressed; 550 QColor m_keyBackgroundColor; 551 QColor m_keyHoverColor; 552 QColor m_fontDefaultColor; 553 QColor m_fontPressedColor; 554 QColor m_keyEditColor; 581 UISoftKeyboardColorTheme m_colorTheme; 555 582 QVector<UISoftKeyboardKey*> m_pressedModifiers; 556 583 QVector<UISoftKeyboardPhysicalLayout> m_physicalLayouts; … … 672 699 Q_OBJECT; 673 700 674 public:675 676 enum ColorTableRow677 {678 ColorTableRow_Background = 0,679 ColorTableRow_Font,680 ColorTableRow_Hover,681 ColorTableRow_Edit,682 ColorTableRow_Pressed,683 ColorTableRow_Max684 };685 686 701 signals: 687 702 … … 696 711 void setShowOSMenuKeys(bool fShow); 697 712 void setShowNumPad(bool fShow); 698 void setTableItemColor( ColorTableRowtableRow, const QColor &color);713 void setTableItemColor(KeyboardColorType tableRow, const QColor &color); 699 714 700 715 protected: … … 717 732 QToolButton *m_pCloseButton; 718 733 }; 734 719 735 720 736 /********************************************************************************************************************************* … … 1729 1745 1730 1746 /********************************************************************************************************************************* 1747 * UISoftKeyboardColorTheme implementation. * 1748 *********************************************************************************************************************************/ 1749 1750 UISoftKeyboardColorTheme::UISoftKeyboardColorTheme() 1751 : m_colors(QVector<QColor>(KeyboardColorType_Max)) 1752 { 1753 m_colors[KeyboardColorType_Background] = QColor(103, 128, 159); 1754 m_colors[KeyboardColorType_Hover] = QColor(108, 122, 137); 1755 m_colors[KeyboardColorType_Font] = QColor(46, 49, 49); 1756 m_colors[KeyboardColorType_Pressed] = QColor(149, 165, 166); 1757 m_colors[KeyboardColorType_Edit] = QColor(249, 165, 166); 1758 } 1759 1760 void UISoftKeyboardColorTheme::setColor(KeyboardColorType enmColorType, const QColor &color) 1761 { 1762 if ((int) enmColorType >= m_colors.size()) 1763 return; 1764 m_colors[(int)enmColorType] = color; 1765 } 1766 1767 QColor UISoftKeyboardColorTheme::color(KeyboardColorType enmColorType) const 1768 { 1769 if ((int) enmColorType >= m_colors.size()) 1770 return QColor(); 1771 return m_colors[(int)enmColorType]; 1772 } 1773 1774 QStringList UISoftKeyboardColorTheme::colorsToStringList() const 1775 { 1776 QStringList colorStringList; 1777 foreach (const QColor &color, m_colors) 1778 colorStringList << color.name(QColor::HexArgb); 1779 return colorStringList; 1780 } 1781 1782 void UISoftKeyboardColorTheme::colorsFromStringList(const QStringList &colorStringList) 1783 { 1784 for (int i = 0; i < colorStringList.size() && i < m_colors.size(); ++i) 1785 { 1786 if (!QColor::isValidColor(colorStringList[i])) 1787 continue; 1788 m_colors[i].setNamedColor(colorStringList[i]); 1789 } 1790 } 1791 1792 1793 /********************************************************************************************************************************* 1731 1794 * UISoftKeyboardWidget implementation. * 1732 1795 *********************************************************************************************************************************/ … … 1737 1800 , m_pKeyBeingEdited(0) 1738 1801 , m_pKeyPressed(0) 1739 , m_keyBackgroundColor(QColor(103, 128, 159))1740 , m_keyHoverColor(QColor(108, 122, 137))1741 , m_fontDefaultColor(QColor(46, 49, 49))1742 , m_fontPressedColor(QColor(149, 165, 166))1743 , m_keyEditColor(QColor(249, 165, 166))1744 1802 , m_pCurrentKeyboardLayout(0) 1745 1803 , m_iInitialHeight(0) … … 1816 1874 1817 1875 if(&key == m_pKeyBeingEdited) 1818 painter.setBrush(QBrush( m_keyEditColor));1876 painter.setBrush(QBrush(color(KeyboardColorType_Edit))); 1819 1877 else if (&key == m_pKeyUnderMouse) 1820 painter.setBrush(QBrush( m_keyHoverColor));1878 painter.setBrush(QBrush(color(KeyboardColorType_Hover))); 1821 1879 else 1822 painter.setBrush(QBrush( m_keyBackgroundColor));1880 painter.setBrush(QBrush(color(KeyboardColorType_Background))); 1823 1881 1824 1882 if (&key == m_pKeyPressed) 1825 painter.setPen(QPen( QColor(m_fontPressedColor), 2));1883 painter.setPen(QPen(color(KeyboardColorType_Pressed), 2)); 1826 1884 else 1827 painter.setPen(QPen( QColor(m_fontDefaultColor), 2));1885 painter.setPen(QPen(color(KeyboardColorType_Font), 2)); 1828 1886 1829 1887 painter.drawPolygon(key.polygon()); … … 1835 1893 QColor ledColor; 1836 1894 if (key.state() == UIKeyState_NotPressed) 1837 ledColor = m_fontDefaultColor;1895 ledColor = color(KeyboardColorType_Font); 1838 1896 else if (key.state() == UIKeyState_Pressed) 1839 1897 ledColor = QColor(0, 255, 0); … … 2032 2090 } 2033 2091 2034 const QColor &UISoftKeyboardWidget::color(int iColorType) const 2035 { 2036 UISoftKeyboardSettingsWidget::ColorTableRow enmColorType = static_cast<UISoftKeyboardSettingsWidget::ColorTableRow>(iColorType); 2037 switch (enmColorType) 2038 { 2039 case UISoftKeyboardSettingsWidget::ColorTableRow_Background: 2040 return m_keyBackgroundColor; 2041 case UISoftKeyboardSettingsWidget::ColorTableRow_Edit: 2042 return m_keyEditColor; 2043 case UISoftKeyboardSettingsWidget::ColorTableRow_Font: 2044 return m_fontDefaultColor; 2045 case UISoftKeyboardSettingsWidget::ColorTableRow_Hover: 2046 return m_keyHoverColor; 2047 case UISoftKeyboardSettingsWidget::ColorTableRow_Pressed: 2048 return m_fontPressedColor; 2049 case UISoftKeyboardSettingsWidget::ColorTableRow_Max: 2050 default: 2051 return m_keyBackgroundColor; 2052 } 2053 } 2054 2055 void UISoftKeyboardWidget::setColor(int iColorType, const QColor &color) 2056 { 2057 UISoftKeyboardSettingsWidget::ColorTableRow enmColorType = static_cast<UISoftKeyboardSettingsWidget::ColorTableRow>(iColorType); 2058 switch (enmColorType) 2059 { 2060 case UISoftKeyboardSettingsWidget::ColorTableRow_Background: 2061 m_keyBackgroundColor = color; 2062 break; 2063 case UISoftKeyboardSettingsWidget::ColorTableRow_Edit: 2064 m_keyEditColor = color; 2065 break; 2066 case UISoftKeyboardSettingsWidget::ColorTableRow_Font: 2067 m_fontDefaultColor = color; 2068 break; 2069 case UISoftKeyboardSettingsWidget::ColorTableRow_Hover: 2070 m_keyHoverColor = color; 2071 break; 2072 case UISoftKeyboardSettingsWidget::ColorTableRow_Pressed: 2073 m_fontPressedColor = color; 2074 break; 2075 case UISoftKeyboardSettingsWidget::ColorTableRow_Max: 2076 default: 2077 break; 2078 } 2092 const QColor UISoftKeyboardWidget::color(KeyboardColorType enmColorType) const 2093 { 2094 return m_colorTheme.color(enmColorType); 2095 } 2096 2097 void UISoftKeyboardWidget::setColor(KeyboardColorType enmColorType, const QColor &color) 2098 { 2099 m_colorTheme.setColor(enmColorType, color); 2100 } 2101 2102 QStringList UISoftKeyboardWidget::colorsToStringList() const 2103 { 2104 return m_colorTheme.colorsToStringList(); 2105 } 2106 2107 void UISoftKeyboardWidget::colorsFromStringList(const QStringList &colorStringList) 2108 { 2109 m_colorTheme.colorsFromStringList(colorStringList); 2079 2110 } 2080 2111 … … 2131 2162 update(); 2132 2163 } 2133 2134 // void UISoftKeyboardWidget::updateKeyCaptionsInLayout(UISoftKeyboardKey *pKey)2135 // {2136 // if (!m_pCurrentKeyboardLayout || !pKey)2137 // return;2138 2139 // /* Assuming the key captions are changed for the current layout: */2140 // KeyCaptions newCaptions;2141 // // newCaptions.m_strBase = pKey->baseCaption();2142 // // newCaptions.m_strShift = pKey->shiftCaption();2143 // // newCaptions.m_strAltGr = pKey->altGrCaption();2144 // // newCaptions.m_strShiftAltGr = pKey->shiftAltGrCaption();2145 // m_pCurrentKeyboardLayout->updateKeyCaptions(pKey->position(), newCaptions);2146 // }2147 2164 2148 2165 void UISoftKeyboardWidget::addLayout(const UISoftKeyboardLayout &newLayout) … … 2981 2998 } 2982 2999 2983 void UISoftKeyboardSettingsWidget::setTableItemColor( ColorTableRowtableRow, const QColor &color)3000 void UISoftKeyboardSettingsWidget::setTableItemColor(KeyboardColorType tableRow, const QColor &color) 2984 3001 { 2985 3002 if (!m_pColorSelectionTable) … … 3009 3026 if (m_pColorSelectionTable) 3010 3027 { 3011 QTableWidgetItem *pItem = m_pColorSelectionTable->itemAt( ColorTableRow_Background, 0);3028 QTableWidgetItem *pItem = m_pColorSelectionTable->itemAt(KeyboardColorType_Background, 0); 3012 3029 if (pItem) 3013 3030 pItem->setText(UISoftKeyboard::tr("Button Background Color")); 3014 pItem = m_pColorSelectionTable->item( ColorTableRow_Font, 0);3031 pItem = m_pColorSelectionTable->item(KeyboardColorType_Font, 0); 3015 3032 if (pItem) 3016 3033 pItem->setText(UISoftKeyboard::tr("Button Font Color")); 3017 pItem = m_pColorSelectionTable->item( ColorTableRow_Hover, 0);3034 pItem = m_pColorSelectionTable->item(KeyboardColorType_Hover, 0); 3018 3035 if (pItem) 3019 3036 pItem->setText(UISoftKeyboard::tr("Button Hover Color")); 3020 pItem = m_pColorSelectionTable->item( ColorTableRow_Edit, 0);3037 pItem = m_pColorSelectionTable->item(KeyboardColorType_Edit, 0); 3021 3038 if (pItem) 3022 3039 pItem->setText(UISoftKeyboard::tr("Button Edit Color")); 3023 pItem = m_pColorSelectionTable->item( ColorTableRow_Pressed, 0);3040 pItem = m_pColorSelectionTable->item(KeyboardColorType_Pressed, 0); 3024 3041 if (pItem) 3025 3042 pItem->setText(UISoftKeyboard::tr("Pressed Button Color")); … … 3061 3078 m_pColorSelectionTable = new QTableWidget; 3062 3079 pTableGroupBoxLayout->addWidget(m_pColorSelectionTable); 3063 m_pColorSelectionTable->setRowCount( ColorTableRow_Max);3080 m_pColorSelectionTable->setRowCount(KeyboardColorType_Max); 3064 3081 m_pColorSelectionTable->setColumnCount(2); 3065 3082 m_pColorSelectionTable->horizontalHeader()->hide(); … … 3072 3089 3073 3090 /* Create column 0 items: */ 3074 m_pColorSelectionTable->setItem( ColorTableRow_Background, 0, new QTableWidgetItem());3075 m_pColorSelectionTable->setItem( ColorTableRow_Font, 0, new QTableWidgetItem());3076 m_pColorSelectionTable->setItem( ColorTableRow_Hover, 0, new QTableWidgetItem());3077 m_pColorSelectionTable->setItem( ColorTableRow_Edit, 0, new QTableWidgetItem());3078 m_pColorSelectionTable->setItem( ColorTableRow_Pressed, 0, new QTableWidgetItem());3091 m_pColorSelectionTable->setItem(KeyboardColorType_Background, 0, new QTableWidgetItem()); 3092 m_pColorSelectionTable->setItem(KeyboardColorType_Font, 0, new QTableWidgetItem()); 3093 m_pColorSelectionTable->setItem(KeyboardColorType_Hover, 0, new QTableWidgetItem()); 3094 m_pColorSelectionTable->setItem(KeyboardColorType_Edit, 0, new QTableWidgetItem()); 3095 m_pColorSelectionTable->setItem(KeyboardColorType_Pressed, 0, new QTableWidgetItem()); 3079 3096 3080 3097 /* Create column 1 items: */ 3081 for (int i = ColorTableRow_Background; i < ColorTableRow_Max; ++i)3098 for (int i = KeyboardColorType_Background; i < KeyboardColorType_Max; ++i) 3082 3099 { 3083 3100 QTableWidgetItem *pItem = new QTableWidgetItem(); 3084 m_pColorSelectionTable->setItem(static_cast< ColorTableRow>(i), 1, pItem);3101 m_pColorSelectionTable->setItem(static_cast<KeyboardColorType>(i), 1, pItem); 3085 3102 pItem->setIcon(UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowBack)); 3086 3103 } … … 3096 3113 void UISoftKeyboardSettingsWidget::sltColorCellClicked(int row, int column) 3097 3114 { 3098 if (column != 1 || row >= static_cast<int>( ColorTableRow_Max))3115 if (column != 1 || row >= static_cast<int>(KeyboardColorType_Max)) 3099 3116 return; 3100 3117 emit sigColorCellClicked(row); 3101 3118 } 3119 3102 3120 3103 3121 /********************************************************************************************************************************* … … 3127 3145 { 3128 3146 m_pKeyboardWidget->loadLayouts(); 3129 updateLayoutSelector();3130 3147 if (m_pLayoutEditor) 3131 3148 m_pLayoutEditor->setPhysicalLayoutList(m_pKeyboardWidget->physicalLayouts()); … … 3291 3308 void UISoftKeyboard::sltHandleColorCellClick(int iColorRow) 3292 3309 { 3293 if (!m_pKeyboardWidget || iColorRow >= static_cast<int>( UISoftKeyboardSettingsWidget::ColorTableRow_Max))3294 return; 3295 const QColor ¤tColor = m_pKeyboardWidget->color( iColorRow);3310 if (!m_pKeyboardWidget || iColorRow >= static_cast<int>(KeyboardColorType_Max)) 3311 return; 3312 const QColor ¤tColor = m_pKeyboardWidget->color(static_cast<KeyboardColorType>(iColorRow)); 3296 3313 QColorDialog colorDialog(currentColor, this); 3297 3314 … … 3301 3318 if (currentColor == newColor) 3302 3319 return; 3303 m_pKeyboardWidget->setColor( iColorRow, newColor);3304 m_pSettingsWidget->setTableItemColor(static_cast< UISoftKeyboardSettingsWidget::ColorTableRow>(iColorRow), newColor);3320 m_pKeyboardWidget->setColor(static_cast<KeyboardColorType>(iColorRow), newColor); 3321 m_pSettingsWidget->setTableItemColor(static_cast<KeyboardColorType>(iColorRow), newColor); 3305 3322 } 3306 3323 … … 3392 3409 LogRel2(("GUI: Soft Keyboard: Geometry saved as: Origin=%dx%d, Size=%dx%d\n", 3393 3410 saveGeometry.x(), saveGeometry.y(), saveGeometry.width(), saveGeometry.height())); 3411 if (m_pKeyboardWidget) 3412 gEDataManager->setSoftKeyboardColorTheme(m_pKeyboardWidget->colorsToStringList()); 3394 3413 } 3395 3414 … … 3416 3435 geometry.x(), geometry.y(), geometry.width(), geometry.height())); 3417 3436 setDialogGeometry(geometry); 3437 if (m_pKeyboardWidget) 3438 m_pKeyboardWidget->colorsFromStringList(gEDataManager->softKeyboardColorTheme()); 3418 3439 } 3419 3440 … … 3426 3447 m_pSettingsWidget->setShowNumPad(m_pKeyboardWidget->showNumPad()); 3427 3448 3428 for (int i = static_cast<int>(UISoftKeyboardSettingsWidget::ColorTableRow_Background); 3429 i < static_cast<int>(UISoftKeyboardSettingsWidget::ColorTableRow_Max); ++i) 3430 m_pSettingsWidget->setTableItemColor(static_cast<UISoftKeyboardSettingsWidget::ColorTableRow>(i), 3431 m_pKeyboardWidget->color(i)); 3449 for (int i = (int)KeyboardColorType_Background; 3450 i < (int)KeyboardColorType_Max; ++i) 3451 { 3452 KeyboardColorType enmType = (KeyboardColorType)i; 3453 m_pSettingsWidget->setTableItemColor(enmType, m_pKeyboardWidget->color(enmType)); 3454 } 3432 3455 } 3433 3456 }
Note:
See TracChangeset
for help on using the changeset viewer.