VirtualBox

Changeset 81399 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Oct 21, 2019 11:24:19 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
134113
Message:

FE/Qt: bugref:6699. Marking color themes not-editable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp

    r81358 r81399  
    7070const QString strSubDirectorName("keyboardLayouts");
    7171
     72/** Name, background color, normal font color, hover color, edited button background color, pressed button font color. */
     73const 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
    7278typedef QPair<QLabel*, UISoftKeyboardColorButton*> ColorSelectLabelButton;
    7379
     
    144150    bool fRelease;
    145151};
    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}};
    151152
    152153
     
    575576    const QString &name() const;
    576577    void setName(const QString &strName);
    577     void print();
     578
     579    bool isEditable() const;
     580    void setIsEditable(bool fIsEditable);
    578581
    579582private:
     
    581584    QVector<QColor> m_colors;
    582585    QString m_strName;
     586    bool    m_fIsEditable;
    583587};
    584588
     
    657661    void setColorThemeByName(const QString &strColorThemeName);
    658662    void parentDialogDeactivated();
     663    bool isColorThemeEditable() const;
    659664
    660665protected:
     
    829834    void setHideNumPad(bool fHide);
    830835    void setHideMultimediaKeys(bool fHide);
    831     void setColorSelectionButtonBackground(KeyboardColorType enmColorType, const QColor &color);
     836    void setColorSelectionButtonBackgroundAndTooltip(KeyboardColorType enmColorType, const QColor &color, bool fIsColorEditable);
    832837    void setColorThemeNames(const QStringList &colorThemeNames);
    833838    void setCurrentColorThemeName(const QString &strColorThemeName);
     
    20532058UISoftKeyboardColorTheme::UISoftKeyboardColorTheme()
    20542059    : m_colors(QVector<QColor>(KeyboardColorType_Max))
     2060    , m_fIsEditable(false)
    20552061{
    20562062    m_colors[KeyboardColorType_Background].setNamedColor("#ff878787");
     
    20692075    :m_colors(QVector<QColor>(KeyboardColorType_Max))
    20702076    ,m_strName(strName)
     2077    , m_fIsEditable(false)
    20712078{
    20722079    m_colors[KeyboardColorType_Background].setNamedColor(strBackgroundColor);
     
    21202127}
    21212128
    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 
     2129bool UISoftKeyboardColorTheme::isEditable() const
     2130{
     2131    return m_fIsEditable;
     2132}
     2133
     2134void UISoftKeyboardColorTheme::setIsEditable(bool fIsEditable)
     2135{
     2136    m_fIsEditable = fIsEditable;
     2137}
    21342138
    21352139/*********************************************************************************************************************************
     
    25752579}
    25762580
     2581bool UISoftKeyboardWidget::isColorThemeEditable() const
     2582{
     2583    if (!m_currentColorTheme)
     2584        return false;
     2585    return m_currentColorTheme->isEditable();
     2586}
     2587
    25772588void UISoftKeyboardWidget::deleteCurrentLayout()
    25782589{
     
    30703081    UISoftKeyboardColorTheme customTheme;
    30713082    customTheme.setName("Custom");
     3083    customTheme.setIsEditable(true);
    30723084    m_colorThemes.append(customTheme);
    30733085    m_currentColorTheme = &(m_colorThemes.back());
     
    36103622}
    36113623
    3612 void UISoftKeyboardSettingsWidget::setColorSelectionButtonBackground(KeyboardColorType enmColorType, const QColor &color)
     3624void UISoftKeyboardSettingsWidget::setColorSelectionButtonBackgroundAndTooltip(KeyboardColorType enmColorType,
     3625                                                                               const QColor &color, bool fIsColorEditable)
    36133626{
    36143627    if (m_colorSelectLabelsButtons.size() > enmColorType && m_colorSelectLabelsButtons[enmColorType].second)
     
    36193632        pButton->setAutoFillBackground(true);
    36203633        pButton->setPalette(pal);
     3634        pButton->setToolTip(fIsColorEditable ? UISoftKeyboard::tr("Click to change the color.") : UISoftKeyboard::tr("This color theme is not editable."));
    36213635        pButton->update();
    36223636    }
     
    36283642        return;
    36293643    m_pColorThemeComboBox->blockSignals(true);
     3644    m_pColorThemeComboBox->clear();
    36303645    foreach (const QString &strName, colorThemeNames)
    36313646        m_pColorThemeComboBox->addItem(strName);
     
    37233738        QLabel *pLabel = new QLabel;
    37243739        UISoftKeyboardColorButton *pButton = new UISoftKeyboardColorButton((KeyboardColorType)i);
     3740        pButton->setFlat(true);
     3741        pButton->setMaximumWidth(3 * qApp->style()->pixelMetric(QStyle::PM_LargeIconSize));
    37253742        pColorSelectionLayout->addWidget(pLabel, i, 0, 1, 1);
    37263743        pColorSelectionLayout->addWidget(pButton, i, 1, 1, 1);
     
    39383955    {
    39393956        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());
    39413960    }
    39423961}
     
    39924011    if (!m_pKeyboardWidget || iColorRow >= static_cast<int>(KeyboardColorType_Max))
    39934012        return;
     4013
     4014    if (!m_pKeyboardWidget->isColorThemeEditable())
     4015        return;
    39944016    const QColor &currentColor = m_pKeyboardWidget->color(static_cast<KeyboardColorType>(iColorRow));
    39954017    QColorDialog colorDialog(currentColor, this);
     
    40014023        return;
    40024024    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());
    40044027}
    40054028
     
    41734196        {
    41744197            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());
    41764201        }
    41774202    }
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette