Changeset 81298 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Oct 16, 2019 5:15:13 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 134003
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
r81294 r81298 31 31 #include <QPainter> 32 32 #include <QPicture> 33 #include <QPushButton> 33 34 #include <QSplitter> 34 35 #include <QStatusBar> … … 54 55 55 56 /* Forward declarations: */ 57 class UISoftKeyboardColorButton; 56 58 class UISoftKeyboardLayout; 57 59 class UISoftKeyboardRow; … … 66 68 /** Set a generous file size limit. */ 67 69 const qint64 iFileSizeLimit = _256K; 68 69 70 const QString strSubDirectorName("keyboardLayouts"); 71 72 typedef QPair<QLabel*, UISoftKeyboardColorButton*> ColorSelectLabelButton; 70 73 71 74 enum KeyState … … 145 148 {"Solarized-Light","#b58900", "#586e75", "#dc322f", "#6c71c4", "#859900"}, 146 149 {0, 0, 0, 0, 0, 0}}; 150 151 152 /********************************************************************************************************************************* 153 * UISoftKeyboardColorButton definition. * 154 *********************************************************************************************************************************/ 155 156 class UISoftKeyboardColorButton : public QPushButton 157 { 158 Q_OBJECT; 159 160 public: 161 162 UISoftKeyboardColorButton(KeyboardColorType enmColorType, QWidget *pParent = 0); 163 KeyboardColorType colorType() const; 164 165 public: 166 167 KeyboardColorType m_enmColorType; 168 }; 147 169 148 170 … … 625 647 626 648 /** Unlike modifier and ordinary keys we update the state of the Lock keys thru event singals we receieve 627 * from the guest OS. Parameter f XXXState is true if the corresponding key is locked. */649 * from the guest OS. Parameter f???State is true if the corresponding key is locked. */ 628 650 void updateLockKeyStates(bool fCapsLockState, bool fNumLockState, bool fScrollLockState); 629 651 void reset(); … … 809 831 private slots: 810 832 811 void sltColor CellClicked(int row, int column);833 void sltColorSelectionButtonClicked(); 812 834 813 835 private: … … 819 841 QCheckBox *m_pHideMultimediaKeysCheckBox; 820 842 QGroupBox *m_pColorTableGroupBox; 821 QListWidget *m_pColorThemeList; 822 QTableWidget *m_pColorSelectionTable; 843 QComboBox *m_pColorThemeComboBox; 823 844 QLabel *m_pTitleLabel; 824 845 QToolButton *m_pCloseButton; 846 QVector<ColorSelectLabelButton> m_colorSelectLabelsButtons; 825 847 }; 848 849 850 /********************************************************************************************************************************* 851 * UISoftKeyboardColorButton implementation. * 852 *********************************************************************************************************************************/ 853 854 855 UISoftKeyboardColorButton::UISoftKeyboardColorButton(KeyboardColorType enmColorType, QWidget *pParent /*= 0 */) 856 :QPushButton(pParent) 857 , m_enmColorType(enmColorType){} 858 859 KeyboardColorType UISoftKeyboardColorButton::colorType() const 860 { 861 return m_enmColorType; 862 } 826 863 827 864 … … 3470 3507 , m_pHideMultimediaKeysCheckBox(0) 3471 3508 , m_pColorTableGroupBox(0) 3472 , m_pColorThemeList(0) 3473 , m_pColorSelectionTable(0) 3509 , m_pColorThemeComboBox(0) 3474 3510 , m_pTitleLabel(0) 3475 3511 , m_pCloseButton(0) … … 3499 3535 void UISoftKeyboardSettingsWidget::setTableItemColor(KeyboardColorType tableRow, const QColor &color) 3500 3536 { 3501 if (!m_pColorSelectionTable) 3502 return; 3503 QTableWidgetItem *pItem = m_pColorSelectionTable->item(tableRow, 1); 3504 if (!pItem) 3505 return; 3506 pItem->setBackground(color); 3507 m_pColorSelectionTable->update(); 3537 if (m_colorSelectLabelsButtons.size() > tableRow && m_colorSelectLabelsButtons[tableRow].second) 3538 { 3539 UISoftKeyboardColorButton *pButton = m_colorSelectLabelsButtons[tableRow].second; 3540 QPalette pal = pButton->palette(); 3541 pal.setColor(QPalette::Button, color); 3542 pButton->setAutoFillBackground(true); 3543 pButton->setPalette(pal); 3544 pButton->update(); 3545 } 3508 3546 } 3509 3547 3510 3548 void UISoftKeyboardSettingsWidget::setColorThemeNames(const QStringList &colorThemeNames) 3511 3549 { 3512 if (!m_pColorThemeList) 3513 return; 3550 if (!m_pColorThemeComboBox) 3551 return; 3552 m_pColorThemeComboBox->blockSignals(true); 3514 3553 foreach (const QString &strName, colorThemeNames) 3515 m_pColorThemeList->addItem(strName); 3554 m_pColorThemeComboBox->addItem(strName); 3555 m_pColorThemeComboBox->blockSignals(false); 3516 3556 } 3517 3557 3518 3558 void UISoftKeyboardSettingsWidget::setCurrentColorThemeName(const QString &strColorThemeName) 3519 3559 { 3520 if (!m_pColorTheme List)3521 return; 3522 QList<QListWidgetItem*> items = m_pColorThemeList->findItems(strColorThemeName, Qt::MatchFixedString);3523 if (i tems.isEmpty())3524 return; 3525 m_pColorTheme List->blockSignals(true);3526 m_pColorTheme List->setCurrentItem(items[0]);3527 m_pColorTheme List->blockSignals(false);3560 if (!m_pColorThemeComboBox) 3561 return; 3562 int iItemIndex = m_pColorThemeComboBox->findText(strColorThemeName, Qt::MatchFixedString); 3563 if (iItemIndex == -1) 3564 return; 3565 m_pColorThemeComboBox->blockSignals(true); 3566 m_pColorThemeComboBox->setCurrentIndex(iItemIndex); 3567 m_pColorThemeComboBox->blockSignals(false); 3528 3568 } 3529 3569 … … 3545 3585 if (m_pColorTableGroupBox) 3546 3586 m_pColorTableGroupBox->setTitle(UISoftKeyboard::tr("Button Colors")); 3547 if (m_pColorSelectionTable) 3548 { 3549 QTableWidgetItem *pItem = m_pColorSelectionTable->itemAt(KeyboardColorType_Background, 0); 3550 if (pItem) 3551 pItem->setText(UISoftKeyboard::tr("Button Background Color")); 3552 pItem = m_pColorSelectionTable->item(KeyboardColorType_Font, 0); 3553 if (pItem) 3554 pItem->setText(UISoftKeyboard::tr("Button Font Color")); 3555 pItem = m_pColorSelectionTable->item(KeyboardColorType_Hover, 0); 3556 if (pItem) 3557 pItem->setText(UISoftKeyboard::tr("Button Hover Color")); 3558 pItem = m_pColorSelectionTable->item(KeyboardColorType_Edit, 0); 3559 if (pItem) 3560 pItem->setText(UISoftKeyboard::tr("Button Edit Color")); 3561 pItem = m_pColorSelectionTable->item(KeyboardColorType_Pressed, 0); 3562 if (pItem) 3563 pItem->setText(UISoftKeyboard::tr("Pressed Button Font Color")); 3564 m_pColorSelectionTable->setToolTip(UISoftKeyboard::tr("Click on the corresponding table cells to modify colors")); 3587 3588 if (m_colorSelectLabelsButtons.size() == KeyboardColorType_Max) 3589 { 3590 if (m_colorSelectLabelsButtons[KeyboardColorType_Background].first) 3591 m_colorSelectLabelsButtons[KeyboardColorType_Background].first->setText(UISoftKeyboard::tr("Button Background Color")); 3592 if (m_colorSelectLabelsButtons[KeyboardColorType_Font].first) 3593 m_colorSelectLabelsButtons[KeyboardColorType_Font].first->setText(UISoftKeyboard::tr("Button Font Color")); 3594 if (m_colorSelectLabelsButtons[KeyboardColorType_Hover].first) 3595 m_colorSelectLabelsButtons[KeyboardColorType_Hover].first->setText(UISoftKeyboard::tr("Button Hover Color")); 3596 if (m_colorSelectLabelsButtons[KeyboardColorType_Edit].first) 3597 m_colorSelectLabelsButtons[KeyboardColorType_Edit].first->setText(UISoftKeyboard::tr("Button Edit Color")); 3598 if (m_colorSelectLabelsButtons[KeyboardColorType_Pressed].first) 3599 m_colorSelectLabelsButtons[KeyboardColorType_Pressed].first->setText(UISoftKeyboard::tr("Pressed Button Font Color")); 3565 3600 } 3566 3601 } … … 3597 3632 m_pColorTableGroupBox = new QGroupBox; 3598 3633 QVBoxLayout *pTableGroupBoxLayout = new QVBoxLayout(m_pColorTableGroupBox); 3599 pSettingsLayout->addWidget(m_pColorTableGroupBox, 4, 0, 2, 1); 3600 3601 m_pColorThemeList = new QListWidget; 3602 pTableGroupBoxLayout->addWidget(m_pColorThemeList); 3603 connect(m_pColorThemeList, &QListWidget::currentTextChanged, this, &UISoftKeyboardSettingsWidget::sigColorThemeSelectionChanged); 3604 3605 /* Creating and configuring the color table widget: */ 3606 m_pColorSelectionTable = new QTableWidget; 3607 pTableGroupBoxLayout->addWidget(m_pColorSelectionTable); 3608 m_pColorSelectionTable->setRowCount(KeyboardColorType_Max); 3609 m_pColorSelectionTable->setColumnCount(2); 3610 m_pColorSelectionTable->horizontalHeader()->hide(); 3611 m_pColorSelectionTable->verticalHeader()->hide(); 3612 m_pColorSelectionTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); 3613 m_pColorSelectionTable->setEditTriggers(QAbstractItemView::NoEditTriggers); 3614 m_pColorSelectionTable->setFocusPolicy(Qt::NoFocus); 3615 m_pColorSelectionTable->setSelectionMode(QAbstractItemView::NoSelection); 3616 connect(m_pColorSelectionTable, &QTableWidget::cellClicked, this, &UISoftKeyboardSettingsWidget::sltColorCellClicked); 3617 3618 /* Create column 0 items: */ 3619 m_pColorSelectionTable->setItem(KeyboardColorType_Background, 0, new QTableWidgetItem()); 3620 m_pColorSelectionTable->setItem(KeyboardColorType_Font, 0, new QTableWidgetItem()); 3621 m_pColorSelectionTable->setItem(KeyboardColorType_Hover, 0, new QTableWidgetItem()); 3622 m_pColorSelectionTable->setItem(KeyboardColorType_Edit, 0, new QTableWidgetItem()); 3623 m_pColorSelectionTable->setItem(KeyboardColorType_Pressed, 0, new QTableWidgetItem()); 3624 3625 /* Create column 1 items: */ 3634 pSettingsLayout->addWidget(m_pColorTableGroupBox, 4, 0, 1, 1); 3635 3636 m_pColorThemeComboBox = new QComboBox; 3637 pTableGroupBoxLayout->addWidget(m_pColorThemeComboBox); 3638 connect(m_pColorThemeComboBox, &QComboBox::currentTextChanged, this, &UISoftKeyboardSettingsWidget::sigColorThemeSelectionChanged); 3639 3640 /* Creating and configuring the color selection buttons: */ 3641 QGridLayout *pColorSelectionLayout = new QGridLayout; 3642 pColorSelectionLayout->setSpacing(1); 3643 pTableGroupBoxLayout->addLayout(pColorSelectionLayout); 3626 3644 for (int i = KeyboardColorType_Background; i < KeyboardColorType_Max; ++i) 3627 3645 { 3628 QTableWidgetItem *pItem = new QTableWidgetItem(); 3629 m_pColorSelectionTable->setItem(static_cast<KeyboardColorType>(i), 1, pItem); 3630 pItem->setIcon(UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowBack)); 3646 QLabel *pLabel = new QLabel; 3647 UISoftKeyboardColorButton *pButton = new UISoftKeyboardColorButton((KeyboardColorType)i); 3648 pColorSelectionLayout->addWidget(pLabel, i, 0, 1, 1); 3649 pColorSelectionLayout->addWidget(pButton, i, 1, 1, 1); 3650 m_colorSelectLabelsButtons.append(ColorSelectLabelButton(pLabel, pButton)); 3651 connect(pButton, &UISoftKeyboardColorButton::clicked, this, &UISoftKeyboardSettingsWidget::sltColorSelectionButtonClicked); 3631 3652 } 3632 3653 … … 3639 3660 } 3640 3661 3641 void UISoftKeyboardSettingsWidget::sltColorCellClicked(int row, int column) 3642 { 3643 if (column != 1 || row >= static_cast<int>(KeyboardColorType_Max)) 3644 return; 3645 emit sigColorCellClicked(row); 3662 void UISoftKeyboardSettingsWidget::sltColorSelectionButtonClicked() 3663 { 3664 UISoftKeyboardColorButton *pButton = qobject_cast<UISoftKeyboardColorButton*>(sender()); 3665 if (!pButton) 3666 return; 3667 emit sigColorCellClicked((int)pButton->colorType()); 3646 3668 } 3647 3669
Note:
See TracChangeset
for help on using the changeset viewer.