Changeset 81293 in vbox
- Timestamp:
- Oct 16, 2019 6:46:56 AM (5 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
r81285 r81293 141 141 bool fRelease; 142 142 }; 143 144 143 /* Name, background color, normal font color, hover color, edited button background color, pressed button font color. */ 144 const char* predefinedColorThemes[][6] = {{"Solarized-Dark","#073642", "#586e75", "#dc322f", "#6c71c4", "#859900"}, 145 {"Solarized-Light","#b58900", "#586e75", "#dc322f", "#6c71c4", "#859900"}, 146 {0, 0, 0, 0, 0, 0}}; 145 147 /********************************************************************************************************************************* 146 148 * UISoftKeyboardPhysicalLayout definition. * … … 534 536 535 537 UISoftKeyboardColorTheme(); 538 UISoftKeyboardColorTheme(const QString &strName, 539 const QString &strBackgroundColor, 540 const QString &strNormalFontColor, 541 const QString &strHoverColor, 542 const QString &strEditedButtonBackgroundColor, 543 const QString &strPressedButtonFontColor); 544 536 545 void setColor(KeyboardColorType enmColorType, const QColor &color); 537 546 QColor color(KeyboardColorType enmColorType) const; … … 539 548 void colorsFromStringList(const QStringList &colorStringList); 540 549 550 const QString &name() const; 551 void setName(const QString &strName); 552 541 553 private: 542 554 543 555 QVector<QColor> m_colors; 556 QString m_strName; 544 557 }; 545 558 … … 565 578 void sigStatusBarMessage(const QString &strMessage); 566 579 void sigPutKeyboardSequence(QVector<LONG> sequence); 567 568 580 void sigPutUsageCodesPress(QVector<QPair<LONG, LONG> > sequence); 569 581 void sigPutUsageCodesRelease(QVector<QPair<LONG, LONG> > sequence); 570 571 572 582 void sigCurrentLayoutChange(); 573 583 void sigKeyToEdit(UISoftKeyboardKey* pKey); 584 void sigCurrentColorThemeChanged(); 574 585 575 586 public: … … 605 616 void setHideMultimediaKeys(bool fHide); 606 617 607 constQColor color(KeyboardColorType enmColorType) const;618 QColor color(KeyboardColorType enmColorType) const; 608 619 void setColor(KeyboardColorType ennmColorType, const QColor &color); 609 620 … … 615 626 void updateLockKeyStates(bool fCapsLockState, bool fNumLockState, bool fScrollLockState); 616 627 void reset(); 628 629 QStringList colorThemeNames() const; 630 QString currentColorThemeName() const; 631 void setColorTheme(const QString &strColorThemeName); 617 632 618 633 protected: … … 657 672 658 673 UISoftKeyboardKey *m_pKeyPressed; 659 UISoftKeyboardColorTheme m_colorTheme; 674 UISoftKeyboardColorTheme *m_currentColorTheme; 675 QVector<UISoftKeyboardColorTheme> m_colorThemes; 660 676 QVector<UISoftKeyboardKey*> m_pressedModifiers; 661 677 QVector<UISoftKeyboardPhysicalLayout> m_physicalLayouts; … … 773 789 void sigColorCellClicked(int iColorRow); 774 790 void sigCloseSettingsWidget(); 791 void sigColorThemeSelectionChanged(const QString &strColorThemeName); 775 792 776 793 public: … … 781 798 void setHideMultimediaKeys(bool fHide); 782 799 void setTableItemColor(KeyboardColorType tableRow, const QColor &color); 800 void setColorThemeNames(const QStringList &colorThemeNames); 801 void setCurrentColorThemeName(const QString &strColorThemeName); 783 802 784 803 protected: … … 798 817 QCheckBox *m_pHideMultimediaKeysCheckBox; 799 818 QGroupBox *m_pColorTableGroupBox; 819 QListWidget *m_pColorThemeList; 800 820 QTableWidget *m_pColorSelectionTable; 801 821 QLabel *m_pTitleLabel; … … 1994 2014 } 1995 2015 2016 UISoftKeyboardColorTheme::UISoftKeyboardColorTheme(const QString &strName, 2017 const QString &strBackgroundColor, 2018 const QString &strNormalFontColor, 2019 const QString &strHoverColor, 2020 const QString &strEditedButtonBackgroundColor, 2021 const QString &strPressedButtonFontColor) 2022 :m_colors(QVector<QColor>(KeyboardColorType_Max)) 2023 ,m_strName(strName) 2024 { 2025 m_colors[KeyboardColorType_Background].setNamedColor(strBackgroundColor); 2026 m_colors[KeyboardColorType_Font].setNamedColor(strNormalFontColor); 2027 m_colors[KeyboardColorType_Hover].setNamedColor(strHoverColor); 2028 m_colors[KeyboardColorType_Edit].setNamedColor(strEditedButtonBackgroundColor); 2029 m_colors[KeyboardColorType_Pressed].setNamedColor(strPressedButtonFontColor); 2030 } 2031 2032 1996 2033 void UISoftKeyboardColorTheme::setColor(KeyboardColorType enmColorType, const QColor &color) 1997 2034 { … … 2025 2062 } 2026 2063 } 2064 2065 const QString &UISoftKeyboardColorTheme::name() const 2066 { 2067 return m_strName; 2068 } 2069 2070 void UISoftKeyboardColorTheme::setName(const QString &strName) 2071 { 2072 m_strName = strName; 2073 } 2074 2027 2075 2028 2076 /********************************************************************************************************************************* … … 2035 2083 , m_pKeyBeingEdited(0) 2036 2084 , m_pKeyPressed(0) 2085 , m_currentColorTheme(0) 2037 2086 , m_pCurrentKeyboardLayout(0) 2038 2087 , m_iInitialHeight(0) … … 2051 2100 { 2052 2101 prepareObjects(); 2102 2103 int iIndex = 0; 2104 while (predefinedColorThemes[iIndex][0]) 2105 { 2106 m_colorThemes << UISoftKeyboardColorTheme(predefinedColorThemes[iIndex][0], 2107 predefinedColorThemes[iIndex][1], 2108 predefinedColorThemes[iIndex][2], 2109 predefinedColorThemes[iIndex][3], 2110 predefinedColorThemes[iIndex][4], 2111 predefinedColorThemes[iIndex][5]); 2112 ++iIndex; 2113 } 2114 2115 UISoftKeyboardColorTheme customTheme; 2116 customTheme.setName("Custom"); 2117 m_colorThemes.append(customTheme); 2118 m_currentColorTheme = &(m_colorThemes.back()); 2053 2119 } 2054 2120 … … 2365 2431 } 2366 2432 2367 const QColor UISoftKeyboardWidget::color(KeyboardColorType enmColorType) const 2368 { 2369 return m_colorTheme.color(enmColorType); 2433 QColor UISoftKeyboardWidget::color(KeyboardColorType enmColorType) const 2434 { 2435 if (!m_currentColorTheme) 2436 return QColor(); 2437 return m_currentColorTheme->color(enmColorType); 2370 2438 } 2371 2439 2372 2440 void UISoftKeyboardWidget::setColor(KeyboardColorType enmColorType, const QColor &color) 2373 2441 { 2374 m_colorTheme.setColor(enmColorType, color); 2442 if (m_currentColorTheme) 2443 m_currentColorTheme->setColor(enmColorType, color); 2444 update(); 2375 2445 } 2376 2446 2377 2447 QStringList UISoftKeyboardWidget::colorsToStringList() const 2378 2448 { 2379 return m_colorTheme.colorsToStringList(); 2449 if (!m_currentColorTheme) 2450 QStringList(); 2451 return m_currentColorTheme->colorsToStringList(); 2380 2452 } 2381 2453 2382 2454 void UISoftKeyboardWidget::colorsFromStringList(const QStringList &colorStringList) 2383 2455 { 2384 m_colorTheme.colorsFromStringList(colorStringList); 2456 if (m_currentColorTheme) 2457 m_currentColorTheme->colorsFromStringList(colorStringList); 2385 2458 } 2386 2459 … … 2390 2463 m_physicalLayouts[i].updateLockKeyStates(fCapsLockState, fNumLockState, fScrollLockState); 2391 2464 update(); 2465 } 2466 2467 QStringList UISoftKeyboardWidget::colorThemeNames() const 2468 { 2469 QStringList nameList; 2470 foreach (const UISoftKeyboardColorTheme &theme, m_colorThemes) 2471 { 2472 nameList << theme.name(); 2473 } 2474 return nameList; 2475 } 2476 2477 QString UISoftKeyboardWidget::currentColorThemeName() const 2478 { 2479 if (!m_currentColorTheme) 2480 return QString(); 2481 return m_currentColorTheme->name(); 2482 } 2483 2484 void UISoftKeyboardWidget::setColorTheme(const QString &strColorThemeName) 2485 { 2486 if (m_currentColorTheme && m_currentColorTheme->name() == strColorThemeName) 2487 return; 2488 for (int i = 0; i < m_colorThemes.size(); ++i) 2489 { 2490 if (m_colorThemes[i].name() == strColorThemeName) 2491 { 2492 m_currentColorTheme = &(m_colorThemes[i]); 2493 break; 2494 } 2495 } 2496 update(); 2497 emit sigCurrentColorThemeChanged(); 2392 2498 } 2393 2499 … … 3362 3468 , m_pHideMultimediaKeysCheckBox(0) 3363 3469 , m_pColorTableGroupBox(0) 3470 , m_pColorThemeList(0) 3364 3471 , m_pColorSelectionTable(0) 3365 3472 , m_pTitleLabel(0) … … 3397 3504 pItem->setBackground(color); 3398 3505 m_pColorSelectionTable->update(); 3506 } 3507 3508 void UISoftKeyboardSettingsWidget::setColorThemeNames(const QStringList &colorThemeNames) 3509 { 3510 if (!m_pColorThemeList) 3511 return; 3512 foreach (const QString &strName, colorThemeNames) 3513 m_pColorThemeList->addItem(strName); 3514 } 3515 3516 void UISoftKeyboardSettingsWidget::setCurrentColorThemeName(const QString &strColorThemeName) 3517 { 3518 if (!m_pColorThemeList) 3519 return; 3520 QList<QListWidgetItem*> items = m_pColorThemeList->findItems(strColorThemeName, Qt::MatchFixedString); 3521 if (items.isEmpty()) 3522 return; 3523 m_pColorThemeList->blockSignals(true); 3524 m_pColorThemeList->setCurrentItem(items[0]); 3525 m_pColorThemeList->blockSignals(false); 3399 3526 } 3400 3527 … … 3432 3559 pItem = m_pColorSelectionTable->item(KeyboardColorType_Pressed, 0); 3433 3560 if (pItem) 3434 pItem->setText(UISoftKeyboard::tr("Pressed Button Color"));3561 pItem->setText(UISoftKeyboard::tr("Pressed Button Font Color")); 3435 3562 m_pColorSelectionTable->setToolTip(UISoftKeyboard::tr("Click on the corresponding table cells to modify colors")); 3436 3563 } … … 3469 3596 QVBoxLayout *pTableGroupBoxLayout = new QVBoxLayout(m_pColorTableGroupBox); 3470 3597 pSettingsLayout->addWidget(m_pColorTableGroupBox, 4, 0, 2, 1); 3598 3599 m_pColorThemeList = new QListWidget; 3600 pTableGroupBoxLayout->addWidget(m_pColorThemeList); 3601 connect(m_pColorThemeList, &QListWidget::currentTextChanged, this, &UISoftKeyboardSettingsWidget::sigColorThemeSelectionChanged); 3471 3602 3472 3603 /* Creating and configuring the color table widget: */ … … 3678 3809 } 3679 3810 3811 void UISoftKeyboard::sltHandleColorThemeListSelection(const QString &strColorThemeName) 3812 { 3813 if (m_pKeyboardWidget) 3814 m_pKeyboardWidget->setColorTheme(strColorThemeName); 3815 } 3816 3817 void UISoftKeyboard::sltHandleKeyboardWidgetColorThemeChange() 3818 { 3819 for (int i = (int)KeyboardColorType_Background; 3820 i < (int)KeyboardColorType_Max; ++i) 3821 { 3822 KeyboardColorType enmType = (KeyboardColorType)i; 3823 m_pSettingsWidget->setTableItemColor(enmType, m_pKeyboardWidget->color(enmType)); 3824 } 3825 } 3680 3826 3681 3827 void UISoftKeyboard::sltCopyLayout() … … 3808 3954 connect(m_pKeyboardWidget, &UISoftKeyboardWidget::sigKeyToEdit, this, &UISoftKeyboard::sltKeyToEditChanged); 3809 3955 connect(m_pKeyboardWidget, &UISoftKeyboardWidget::sigStatusBarMessage, this, &UISoftKeyboard::sltStatusBarMessage); 3956 connect(m_pKeyboardWidget, &UISoftKeyboardWidget::sigStatusBarMessage, this, &UISoftKeyboard::sltStatusBarMessage); 3957 connect(m_pKeyboardWidget, &UISoftKeyboardWidget::sigCurrentColorThemeChanged, this, &UISoftKeyboard::sltHandleKeyboardWidgetColorThemeChange); 3810 3958 3811 3959 connect(m_pLayoutSelector, &UILayoutSelector::sigLayoutSelectionChanged, this, &UISoftKeyboard::sltLayoutSelectionChanged); … … 3828 3976 connect(m_pSettingsWidget, &UISoftKeyboardSettingsWidget::sigColorCellClicked, this, &UISoftKeyboard::sltHandleColorCellClick); 3829 3977 connect(m_pSettingsWidget, &UISoftKeyboardSettingsWidget::sigCloseSettingsWidget, this, &UISoftKeyboard::sltShowHideSettingsWidget); 3978 connect(m_pSettingsWidget, &UISoftKeyboardSettingsWidget::sigColorThemeSelectionChanged, this, &UISoftKeyboard::sltHandleColorThemeListSelection); 3979 3830 3980 } 3831 3981 … … 3897 4047 m_pSettingsWidget->setHideMultimediaKeys(m_pKeyboardWidget->hideMultimediaKeys()); 3898 4048 4049 m_pSettingsWidget->setColorThemeNames(m_pKeyboardWidget->colorThemeNames()); 4050 m_pSettingsWidget->setCurrentColorThemeName(m_pKeyboardWidget->currentColorThemeName()); 4051 3899 4052 for (int i = (int)KeyboardColorType_Background; 3900 4053 i < (int)KeyboardColorType_Max; ++i) -
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h
r81285 r81293 86 86 void sltShowHideSidePanel(); 87 87 void sltShowHideSettingsWidget(); 88 void sltHandleColorThemeListSelection(const QString &strColorThemeName); 89 void sltHandleKeyboardWidgetColorThemeChange(); 88 90 void sltCopyLayout(); 89 91 void sltSaveLayout();
Note:
See TracChangeset
for help on using the changeset viewer.