VirtualBox

Ignore:
Timestamp:
Oct 17, 2019 11:40:23 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
134014
Message:

FE/Qt: bugref:6143. Remembering the last selected color theme

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.cpp

    r81263 r81309  
    205205const char *UIExtraDataDefs::GUI_SoftKeyboard_DialogGeometry = "GUI/SoftKeyboardDialogGeometry";
    206206const char *UIExtraDataDefs::GUI_SoftKeyboard_ColorTheme  = "GUI/SoftKeyboardColorTheme";
     207const char *UIExtraDataDefs::GUI_SoftKeyboard_SelectedColorTheme  = "GUI/SoftKeyboardSelectedColorTheme";
    207208const char *UIExtraDataDefs::GUI_SoftKeyboard_SelectedLayout  = "GUI/SoftKeyboardSelectedLayout";
    208209const char *UIExtraDataDefs::GUI_SoftKeyboard_Options  = "GUI/SoftKeyboardOptions";
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r81263 r81309  
    382382        extern const char *GUI_SoftKeyboard_DialogGeometry;
    383383        extern const char *GUI_SoftKeyboard_ColorTheme;
     384        extern const char *GUI_SoftKeyboard_SelectedColorTheme;
    384385        extern const char *GUI_SoftKeyboard_SelectedLayout;
    385386        extern const char *GUI_SoftKeyboard_Options;
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r81272 r81309  
    42774277}
    42784278
     4279void UIExtraDataManager::setSoftKeyboardSelectedColorTheme(const QString &strColorThemeName)
     4280{
     4281    setExtraDataString(GUI_SoftKeyboard_SelectedColorTheme, strColorThemeName);
     4282}
     4283
     4284QString UIExtraDataManager::softKeyboardSelectedColorTheme()
     4285{
     4286    return extraDataString(GUI_SoftKeyboard_SelectedColorTheme);
     4287}
     4288
    42794289void UIExtraDataManager::setSoftKeyboardSelectedLayout(const QUuid &uLayoutUid)
    42804290{
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r81263 r81309  
    669669        void setSoftKeyboardColorTheme(const QStringList &colorStringList);
    670670        QStringList softKeyboardColorTheme();
     671        void setSoftKeyboardSelectedColorTheme(const QString &strColorThemeName);
     672        QString softKeyboardSelectedColorTheme();
    671673        void setSoftKeyboardSelectedLayout(const QUuid &uLayoutUid);
    672674        QUuid softKeyboardSelectedLayout();
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp

    r81303 r81309  
    645645    void setColor(KeyboardColorType ennmColorType, const QColor &color);
    646646
    647     QStringList colorsToStringList() const;
    648     void colorsFromStringList(const QStringList &colorStringList);
     647    QStringList colorsToStringList(const QString &strColorThemeName);
     648    void colorsFromStringList(const QString &strColorThemeName, const QStringList &colorStringList);
    649649
    650650    /** Unlike modifier and ordinary keys we update the state of the Lock keys thru event singals we receieve
     
    655655    QStringList colorThemeNames() const;
    656656    QString currentColorThemeName() const;
    657     void setColorTheme(const QString &strColorThemeName);
     657    void setColorThemeByName(const QString &strColorThemeName);
    658658    void parentDialogDeactivated();
    659659
     
    694694    /** Looks under the default keyboard layout folder and add the file names to the fileList. */
    695695    void               lookAtDefaultLayoutFolder(QStringList &fileList);
    696 
     696    UISoftKeyboardColorTheme *colorTheme(const QString &strColorThemeName);
    697697    UISoftKeyboardKey *m_pKeyUnderMouse;
    698698    UISoftKeyboardKey *m_pKeyBeingEdited;
     
    24992499}
    25002500
    2501 QStringList UISoftKeyboardWidget::colorsToStringList() const
    2502 {
    2503     if (!m_currentColorTheme)
    2504         QStringList();
    2505     return m_currentColorTheme->colorsToStringList();
    2506 }
    2507 
    2508 void UISoftKeyboardWidget::colorsFromStringList(const QStringList &colorStringList)
    2509 {
    2510     if (m_currentColorTheme)
    2511         m_currentColorTheme->colorsFromStringList(colorStringList);
     2501QStringList UISoftKeyboardWidget::colorsToStringList(const QString &strColorThemeName)
     2502{
     2503    UISoftKeyboardColorTheme *pTheme = colorTheme(strColorThemeName);
     2504    if (!pTheme)
     2505        return QStringList();
     2506    return pTheme->colorsToStringList();
     2507}
     2508
     2509void UISoftKeyboardWidget::colorsFromStringList(const QString &strColorThemeName, const QStringList &colorStringList)
     2510{
     2511    UISoftKeyboardColorTheme *pTheme = colorTheme(strColorThemeName);
     2512    if (!pTheme)
     2513        return;
     2514    pTheme->colorsFromStringList(colorStringList);
    25122515}
    25132516
     
    25362539}
    25372540
    2538 void UISoftKeyboardWidget::setColorTheme(const QString &strColorThemeName)
     2541void UISoftKeyboardWidget::setColorThemeByName(const QString &strColorThemeName)
    25392542{
    25402543    if (m_currentColorTheme && m_currentColorTheme->name() == strColorThemeName)
     
    31043107    foreach (const QFileInfo &fileInfo, fileInfoList)
    31053108        fileList << fileInfo.absoluteFilePath();
     3109}
     3110
     3111UISoftKeyboardColorTheme *UISoftKeyboardWidget::colorTheme(const QString &strColorThemeName)
     3112{
     3113    for (int i = 0; i < m_colorThemes.size(); ++i)
     3114    {
     3115        if (m_colorThemes[i].name() == strColorThemeName)
     3116            return &(m_colorThemes[i]);
     3117    }
     3118    return 0;
    31063119}
    31073120
     
    38793892{
    38803893    if (m_pKeyboardWidget)
    3881         m_pKeyboardWidget->setColorTheme(strColorThemeName);
     3894        m_pKeyboardWidget->setColorThemeByName(strColorThemeName);
    38823895}
    38833896
     
    40584071    if (m_pKeyboardWidget)
    40594072    {
    4060         gEDataManager->setSoftKeyboardColorTheme(m_pKeyboardWidget->colorsToStringList());
    4061 
     4073        /* Save the changes to the 'Custom' color theme to extra data: */
     4074        QStringList colors = m_pKeyboardWidget->colorsToStringList("Custom");
     4075        colors.prepend("Custom");
     4076        gEDataManager->setSoftKeyboardColorTheme(colors);
     4077        gEDataManager->setSoftKeyboardSelectedColorTheme(m_pKeyboardWidget->currentColorThemeName());
    40624078        gEDataManager->setSoftKeyboardOptions(m_pKeyboardWidget->hideNumPad(),
    40634079                                              m_pKeyboardWidget->hideOSMenuKeys(),
     
    40924108    if (m_pKeyboardWidget)
    40934109    {
    4094         m_pKeyboardWidget->colorsFromStringList(gEDataManager->softKeyboardColorTheme());
     4110        QStringList colorTheme = gEDataManager->softKeyboardColorTheme();
     4111        /* The fist item is the theme name and the rest are color codes: */
     4112        QString strThemeName = colorTheme[0];
     4113        colorTheme.removeFirst();
     4114        m_pKeyboardWidget->colorsFromStringList(strThemeName, colorTheme);
     4115        m_pKeyboardWidget->setColorThemeByName(gEDataManager->softKeyboardSelectedColorTheme());
    40954116        m_pKeyboardWidget->setCurrentLayout(gEDataManager->softKeyboardSelectedLayout());
    40964117        /* Load other options from exra data: */
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