Changeset 81399 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Oct 21, 2019 11:24:19 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 134113
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
r81358 r81399 70 70 const QString strSubDirectorName("keyboardLayouts"); 71 71 72 /** Name, background color, normal font color, hover color, edited button background color, pressed button font color. */ 73 const char* predefinedColorThemes[][6] = {{"Clear Night","#000000", "#ffffff", "#859900", "#9b6767", "#000000"}, 74 {"Gobi Dark","#002b36", "#fdf6e3", "#859900", "#cb4b16", "#002b36"}, 75 {"Gobi Light","#fdf6e3", "#002b36", "#2aa198", "#cb4b16", "#bf4040"}, 76 {0, 0, 0, 0, 0, 0}}; 77 72 78 typedef QPair<QLabel*, UISoftKeyboardColorButton*> ColorSelectLabelButton; 73 79 … … 144 150 bool fRelease; 145 151 }; 146 /* Name, background color, normal font color, hover color, edited button background color, pressed button font color. */147 const char* predefinedColorThemes[][6] = {{"Clear Night","#000000", "#ffffff", "#859900", "#9b6767", "#000000"},148 {"Gobi Dark","#002b36", "#fdf6e3", "#859900", "#cb4b16", "#002b36"},149 {"Gobi Light","#fdf6e3", "#002b36", "#2aa198", "#cb4b16", "#bf4040"},150 {0, 0, 0, 0, 0, 0}};151 152 152 153 … … 575 576 const QString &name() const; 576 577 void setName(const QString &strName); 577 void print(); 578 579 bool isEditable() const; 580 void setIsEditable(bool fIsEditable); 578 581 579 582 private: … … 581 584 QVector<QColor> m_colors; 582 585 QString m_strName; 586 bool m_fIsEditable; 583 587 }; 584 588 … … 657 661 void setColorThemeByName(const QString &strColorThemeName); 658 662 void parentDialogDeactivated(); 663 bool isColorThemeEditable() const; 659 664 660 665 protected: … … 829 834 void setHideNumPad(bool fHide); 830 835 void setHideMultimediaKeys(bool fHide); 831 void setColorSelectionButtonBackground (KeyboardColorType enmColorType, const QColor &color);836 void setColorSelectionButtonBackgroundAndTooltip(KeyboardColorType enmColorType, const QColor &color, bool fIsColorEditable); 832 837 void setColorThemeNames(const QStringList &colorThemeNames); 833 838 void setCurrentColorThemeName(const QString &strColorThemeName); … … 2053 2058 UISoftKeyboardColorTheme::UISoftKeyboardColorTheme() 2054 2059 : m_colors(QVector<QColor>(KeyboardColorType_Max)) 2060 , m_fIsEditable(false) 2055 2061 { 2056 2062 m_colors[KeyboardColorType_Background].setNamedColor("#ff878787"); … … 2069 2075 :m_colors(QVector<QColor>(KeyboardColorType_Max)) 2070 2076 ,m_strName(strName) 2077 , m_fIsEditable(false) 2071 2078 { 2072 2079 m_colors[KeyboardColorType_Background].setNamedColor(strBackgroundColor); … … 2120 2127 } 2121 2128 2122 void UISoftKeyboardColorTheme::print() 2123 { 2124 printf("=====================\n"); 2125 printf("name: %s\n backround %s\n font %s\n hover %s\n edit %s\n pressed %s\n", 2126 qPrintable(m_strName), 2127 qPrintable(m_colors[KeyboardColorType_Background].name(QColor::HexRgb)), 2128 qPrintable(m_colors[KeyboardColorType_Font].name(QColor::HexRgb)), 2129 qPrintable(m_colors[KeyboardColorType_Hover].name(QColor::HexRgb)), 2130 qPrintable(m_colors[KeyboardColorType_Edit].name(QColor::HexRgb)), 2131 qPrintable(m_colors[KeyboardColorType_Pressed].name(QColor::HexRgb))); 2132 } 2133 2129 bool UISoftKeyboardColorTheme::isEditable() const 2130 { 2131 return m_fIsEditable; 2132 } 2133 2134 void UISoftKeyboardColorTheme::setIsEditable(bool fIsEditable) 2135 { 2136 m_fIsEditable = fIsEditable; 2137 } 2134 2138 2135 2139 /********************************************************************************************************************************* … … 2575 2579 } 2576 2580 2581 bool UISoftKeyboardWidget::isColorThemeEditable() const 2582 { 2583 if (!m_currentColorTheme) 2584 return false; 2585 return m_currentColorTheme->isEditable(); 2586 } 2587 2577 2588 void UISoftKeyboardWidget::deleteCurrentLayout() 2578 2589 { … … 3070 3081 UISoftKeyboardColorTheme customTheme; 3071 3082 customTheme.setName("Custom"); 3083 customTheme.setIsEditable(true); 3072 3084 m_colorThemes.append(customTheme); 3073 3085 m_currentColorTheme = &(m_colorThemes.back()); … … 3610 3622 } 3611 3623 3612 void UISoftKeyboardSettingsWidget::setColorSelectionButtonBackground(KeyboardColorType enmColorType, const QColor &color) 3624 void UISoftKeyboardSettingsWidget::setColorSelectionButtonBackgroundAndTooltip(KeyboardColorType enmColorType, 3625 const QColor &color, bool fIsColorEditable) 3613 3626 { 3614 3627 if (m_colorSelectLabelsButtons.size() > enmColorType && m_colorSelectLabelsButtons[enmColorType].second) … … 3619 3632 pButton->setAutoFillBackground(true); 3620 3633 pButton->setPalette(pal); 3634 pButton->setToolTip(fIsColorEditable ? UISoftKeyboard::tr("Click to change the color.") : UISoftKeyboard::tr("This color theme is not editable.")); 3621 3635 pButton->update(); 3622 3636 } … … 3628 3642 return; 3629 3643 m_pColorThemeComboBox->blockSignals(true); 3644 m_pColorThemeComboBox->clear(); 3630 3645 foreach (const QString &strName, colorThemeNames) 3631 3646 m_pColorThemeComboBox->addItem(strName); … … 3723 3738 QLabel *pLabel = new QLabel; 3724 3739 UISoftKeyboardColorButton *pButton = new UISoftKeyboardColorButton((KeyboardColorType)i); 3740 pButton->setFlat(true); 3741 pButton->setMaximumWidth(3 * qApp->style()->pixelMetric(QStyle::PM_LargeIconSize)); 3725 3742 pColorSelectionLayout->addWidget(pLabel, i, 0, 1, 1); 3726 3743 pColorSelectionLayout->addWidget(pButton, i, 1, 1, 1); … … 3938 3955 { 3939 3956 KeyboardColorType enmType = (KeyboardColorType)i; 3940 m_pSettingsWidget->setColorSelectionButtonBackground(enmType, m_pKeyboardWidget->color(enmType)); 3957 m_pSettingsWidget->setColorSelectionButtonBackgroundAndTooltip(enmType, 3958 m_pKeyboardWidget->color(enmType), 3959 m_pKeyboardWidget->isColorThemeEditable()); 3941 3960 } 3942 3961 } … … 3992 4011 if (!m_pKeyboardWidget || iColorRow >= static_cast<int>(KeyboardColorType_Max)) 3993 4012 return; 4013 4014 if (!m_pKeyboardWidget->isColorThemeEditable()) 4015 return; 3994 4016 const QColor ¤tColor = m_pKeyboardWidget->color(static_cast<KeyboardColorType>(iColorRow)); 3995 4017 QColorDialog colorDialog(currentColor, this); … … 4001 4023 return; 4002 4024 m_pKeyboardWidget->setColor(static_cast<KeyboardColorType>(iColorRow), newColor); 4003 m_pSettingsWidget->setColorSelectionButtonBackground(static_cast<KeyboardColorType>(iColorRow), newColor); 4025 m_pSettingsWidget->setColorSelectionButtonBackgroundAndTooltip(static_cast<KeyboardColorType>(iColorRow), 4026 newColor, m_pKeyboardWidget->isColorThemeEditable()); 4004 4027 } 4005 4028 … … 4173 4196 { 4174 4197 KeyboardColorType enmType = (KeyboardColorType)i; 4175 m_pSettingsWidget->setColorSelectionButtonBackground(enmType, m_pKeyboardWidget->color(enmType)); 4198 m_pSettingsWidget->setColorSelectionButtonBackgroundAndTooltip(enmType, 4199 m_pKeyboardWidget->color(enmType), 4200 m_pKeyboardWidget->isColorThemeEditable()); 4176 4201 } 4177 4202 }
Note:
See TracChangeset
for help on using the changeset viewer.