VirtualBox

Changeset 79206 in vbox


Ignore:
Timestamp:
Jun 18, 2019 10:18:26 AM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6143. Adding layout copy thingy

Location:
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard
Files:
2 edited

Legend:

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

    r79201 r79206  
    141141    void sltKeyShiftCaptionChange();
    142142    void sltKeyAltGrCaptionChange();
    143     void sltHandlePhysicalLayoutChanged();
     143    void sltPhysicalLayoutChanged();
    144144
    145145private:
     
    156156
    157157    QComboBox *m_pPhysicalLayoutCombo;
     158    QLabel *m_pTitleLabel;
    158159    QLabel *m_pPhysicalLayoutLabel;
    159160    QLabel *m_pLayoutNameLabel;
     
    187188signals:
    188189
     190    void sigSaveLayout();
     191    void sigCopyLayout();
    189192    void sigLayoutSelectionChanged(const QString &strSelectedLayoutName);
    190193    void sigShowLayoutEditor();
     
    211214    QToolButton *m_pApplyLayoutButton;
    212215    QToolButton *m_pEditLayoutButton;
     216    QToolButton *m_pCopyLayoutButton;
     217    QToolButton *m_pSaveLayoutButton;
    213218    QLabel      *m_pTitleLabel;
    214219    QToolButton *m_pCloseButton;
     
    426431      * corresponding UISoftKeyboardLayout */
    427432    void updateKeyCaptionsInLayout(UISoftKeyboardKey *pKey);
     433    void addLayout(const UISoftKeyboardLayout &newLayout);
    428434
    429435protected:
     
    437443private slots:
    438444
    439     void sltHandleContextMenuRequest(const QPoint &point);
    440     void sltHandleSaveLayout();
     445    void sltContextMenuRequest(const QPoint &point);
     446    void sltSaveLayout();
    441447    void sltPhysicalLayoutForLayoutChanged(int iIndex);
    442448
     
    583589    , m_pCaptionEditGroupBox(0)
    584590    , m_pPhysicalLayoutCombo(0)
     591    , m_pTitleLabel(0)
    585592    , m_pPhysicalLayoutLabel(0)
    586593    , m_pLayoutNameLabel(0)
     
    656663void UILayoutEditor::retranslateUi()
    657664{
     665    if (m_pTitleLabel)
     666        m_pTitleLabel->setText(UISoftKeyboard::tr("Layout Editor"));
    658667    if (m_pGoBackButton)
    659668        m_pGoBackButton->setToolTip(UISoftKeyboard::tr("Return Back to Layout List"));
     
    702711}
    703712
    704 void UILayoutEditor::sltHandlePhysicalLayoutChanged()
     713void UILayoutEditor::sltPhysicalLayoutChanged()
    705714{
    706715    if (!m_pPhysicalLayoutCombo || !m_pLayout)
     
    719728    setLayout(m_pEditorLayout);
    720729
     730    QHBoxLayout *pTitleLayout = new QHBoxLayout;
    721731    m_pGoBackButton = new QToolButton;
    722732    m_pGoBackButton->setIcon(UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowBack));
     
    724734    m_pEditorLayout->addWidget(m_pGoBackButton, 0, 0, 1, 1);
    725735    connect(m_pGoBackButton, &QToolButton::pressed, this, &UILayoutEditor::sigGoBackButton);
     736    pTitleLayout->addWidget(m_pGoBackButton);
     737    pTitleLayout->addStretch(2);
     738    m_pTitleLabel = new QLabel;
     739    pTitleLayout->addWidget(m_pTitleLabel);
     740    m_pEditorLayout->addLayout(pTitleLayout, 0, 0, 1, 2);
     741
    726742
    727743    m_pLayoutNameLabel = new QLabel;
    728744    m_pLayoutNameEdit = new QLineEdit;
    729745    m_pLayoutNameLabel->setBuddy(m_pLayoutNameEdit);
    730     m_pEditorLayout->addWidget(m_pLayoutNameLabel, 1, 0, 1, 1);
    731     m_pEditorLayout->addWidget(m_pLayoutNameEdit, 1, 1, 1, 1);
     746    m_pEditorLayout->addWidget(m_pLayoutNameLabel, 2, 0, 1, 1);
     747    m_pEditorLayout->addWidget(m_pLayoutNameEdit, 2, 1, 1, 1);
    732748    connect(m_pLayoutNameEdit, &QLineEdit::editingFinished, this, &UILayoutEditor::sigLayoutEdited);
    733749
     
    736752    m_pPhysicalLayoutCombo = new QComboBox;
    737753    m_pPhysicalLayoutLabel->setBuddy(m_pPhysicalLayoutCombo);
    738     m_pEditorLayout->addWidget(m_pPhysicalLayoutLabel, 2, 0, 1, 1);
    739     m_pEditorLayout->addWidget(m_pPhysicalLayoutCombo, 2, 1, 1, 1);
     754    m_pEditorLayout->addWidget(m_pPhysicalLayoutLabel, 3, 0, 1, 1);
     755    m_pEditorLayout->addWidget(m_pPhysicalLayoutCombo, 3, 1, 1, 1);
    740756    connect(m_pPhysicalLayoutCombo, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
    741             this, &UILayoutEditor::sltHandlePhysicalLayoutChanged);
     757            this, &UILayoutEditor::sltPhysicalLayoutChanged);
    742758
    743759    m_pSelectedKeyGroupBox = new QGroupBox;
    744760    m_pSelectedKeyGroupBox->setEnabled(false);
    745761
    746     m_pEditorLayout->addWidget(m_pSelectedKeyGroupBox, 3, 0, 1, 2);
     762    m_pEditorLayout->addWidget(m_pSelectedKeyGroupBox, 4, 0, 1, 2);
    747763    QGridLayout *pSelectedKeyLayout = new QGridLayout(m_pSelectedKeyGroupBox);
    748764    pSelectedKeyLayout->setSpacing(0);
     
    839855    , m_pApplyLayoutButton(0)
    840856    , m_pEditLayoutButton(0)
     857    , m_pCopyLayoutButton(0)
     858    , m_pSaveLayoutButton(0)
    841859    , m_pTitleLabel(0)
    842860    , m_pCloseButton(0)
     
    878896    if (m_pEditLayoutButton)
    879897        m_pEditLayoutButton->setToolTip(UISoftKeyboard::tr("Edit the selected layout"));
     898    if (m_pCopyLayoutButton)
     899        m_pCopyLayoutButton->setToolTip(UISoftKeyboard::tr("Copy the selected layout"));
     900    if (m_pSaveLayoutButton)
     901        m_pSaveLayoutButton->setToolTip(UISoftKeyboard::tr("Save the selected layout into File"));
    880902    if (m_pTitleLabel)
    881903        m_pTitleLabel->setText(UISoftKeyboard::tr("Layout List"));
     
    914936    pButtonsLayout->addWidget(m_pEditLayoutButton);
    915937    connect(m_pEditLayoutButton, &QToolButton::pressed, this, &UILayoutSelector::sigShowLayoutEditor);
     938
     939    m_pCopyLayoutButton = new QToolButton;
     940    m_pCopyLayoutButton->setIcon(UIIconPool::iconSet(":/vm_clone_16px.png"));
     941    pButtonsLayout->addWidget(m_pCopyLayoutButton);
     942    connect(m_pCopyLayoutButton, &QToolButton::pressed, this, &UILayoutSelector::sigCopyLayout);
     943
     944    m_pSaveLayoutButton = new QToolButton;
     945    m_pSaveLayoutButton->setIcon(UIIconPool::iconSet(":/vm_save_state_16px.png"));
     946    pButtonsLayout->addWidget(m_pSaveLayoutButton);
     947    connect(m_pSaveLayoutButton, &QToolButton::pressed, this, &UILayoutSelector::sigSaveLayout);
     948
    916949
    917950    pButtonsLayout->addStretch(2);
     
    14191452}
    14201453
    1421 void UISoftKeyboardWidget::sltHandleContextMenuRequest(const QPoint &point)
     1454void UISoftKeyboardWidget::sltContextMenuRequest(const QPoint &point)
    14221455{
    14231456    showContextMenu(mapToGlobal(point));
    14241457}
    14251458
    1426 // void UISoftKeyboardWidget::sltHandleLoadLayout(QAction *pSenderAction)
     1459// void UISoftKeyboardWidget::sltLoadLayout(QAction *pSenderAction)
    14271460// {
    14281461//     if (!pSenderAction)
     
    14601493// }
    14611494
    1462 void UISoftKeyboardWidget::sltHandleSaveLayout()
     1495void UISoftKeyboardWidget::sltSaveLayout()
    14631496{
    14641497    QString strFileName = QIFileDialog::getSaveFileName(vboxGlobal().documentsPath(), UISoftKeyboard::tr("XML files (*.xml)"),
     
    15171550}
    15181551
    1519 // void UISoftKeyboardWidget::sltHandleLoadKeyCapFile()
     1552// void UISoftKeyboardWidget::sltLoadKeyCapFile()
    15201553// {
    15211554//     const QString strFileName = QIFileDialog::getOpenFileName(QString(), UISoftKeyboard::tr("XML files (*.xml)"), this,
     
    15611594    newCaptions.m_strAltGr = pKey->altGrCaption();
    15621595    m_pCurrentKeyboardLayout->updateKeyCaptions(pKey->position(), newCaptions);
     1596}
     1597
     1598void UISoftKeyboardWidget::addLayout(const UISoftKeyboardLayout &newLayout)
     1599{
     1600    m_layouts.append(newLayout);
    15631601}
    15641602
     
    17701808        return false;
    17711809
    1772 
    1773     UISoftKeyboardPhysicalLayout *pPhysicalLayout = 0;
    1774     /* Search for the physical layout among the one stored in m_pPhysicalLayout: */
    1775     for (int i = 0; i < m_physicalLayouts.size(); ++i)
    1776     {
    1777         if (keyboardLayoutReader.physicalLayoutUUID() == m_physicalLayouts[i].m_uId)
    1778             pPhysicalLayout = &(m_physicalLayouts[i]);
    1779     }
    1780 
     1810    UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(keyboardLayoutReader.physicalLayoutUUID());
    17811811    /* If no pyhsical layout with the UUID the keyboard layout refers is found then cancel loading the keyboard layout: */
    17821812    if (!pPhysicalLayout)
     
    18401870    setContextMenuPolicy(Qt::CustomContextMenu);
    18411871    connect(this, &UISoftKeyboardWidget::customContextMenuRequested,
    1842             this, &UISoftKeyboardWidget::sltHandleContextMenuRequest);
     1872            this, &UISoftKeyboardWidget::sltContextMenuRequest);
    18431873}
    18441874
     
    22712301    {
    22722302        m_pKeyboardWidget->loadLayouts();
    2273         /* Update the selector widget: */
    2274         if (m_pLayoutSelector)
    2275         {
    2276             m_pLayoutSelector->setLayoutList(m_pKeyboardWidget->layoutNameList());
    2277                         m_pLayoutSelector->setCurrentLayout(m_pKeyboardWidget->currentLayout() ? m_pKeyboardWidget->currentLayout()->name() : QString());
    2278         }
     2303        updateLayoutSelector();
    22792304        if (m_pLayoutEditor)
    22802305            m_pLayoutEditor->setPhysicalLayoutList(m_pKeyboardWidget->physicalLayouts());
     
    23152340}
    23162341
    2317 void UISoftKeyboard::sltHandleKeyboardLedsChange()
     2342void UISoftKeyboard::sltKeyboardLedsChange()
    23182343{
    23192344    // bool fNumLockLed = m_pSession->isNumLock();
     
    23222347}
    23232348
    2324 void UISoftKeyboard::sltHandlePutKeyboardSequence(QVector<LONG> sequence)
     2349void UISoftKeyboard::sltPutKeyboardSequence(QVector<LONG> sequence)
    23252350{
    23262351    keyboard().PutScancodes(sequence);
    23272352}
    23282353
    2329 void UISoftKeyboard::sltHandleStatusBarContextMenuRequest(const QPoint &point)
     2354void UISoftKeyboard::sltStatusBarContextMenuRequest(const QPoint &point)
    23302355{
    23312356    if (m_pKeyboardWidget)
     
    23802405        return;
    23812406    m_pKeyboardWidget->update();
    2382     if (m_pLayoutSelector)
    2383     {
    2384         m_pLayoutSelector->setLayoutList(m_pKeyboardWidget->layoutNameList());
    2385         m_pLayoutSelector->setCurrentLayout(m_pKeyboardWidget->currentLayout() ? m_pKeyboardWidget->currentLayout()->name() : QString());
    2386     }
     2407    updateLayoutSelector();
    23872408}
    23882409
     
    24012422        return;
    24022423    m_pSidePanelWidget->setVisible(!m_pSidePanelWidget->isVisible());
     2424}
     2425
     2426void UISoftKeyboard::sltCopyLayout()
     2427{
     2428    if (!m_pKeyboardWidget || !m_pKeyboardWidget->currentLayout())
     2429        return;
     2430    UISoftKeyboardLayout newLayout(*(m_pKeyboardWidget->currentLayout()));
     2431    QString strNewName = QString("%1-%2").arg(newLayout.name()).arg(tr("Copy"));
     2432    newLayout.setName(strNewName);
     2433    m_pKeyboardWidget->addLayout(newLayout);
     2434    updateLayoutSelector();
     2435}
     2436
     2437void UISoftKeyboard::sltSaveLayout()
     2438{
    24032439}
    24042440
     
    24432479void UISoftKeyboard::prepareConnections()
    24442480{
    2445     connect(m_pSession, &UISession::sigKeyboardLedsChange, this, &UISoftKeyboard::sltHandleKeyboardLedsChange);
    2446     connect(m_pKeyboardWidget, &UISoftKeyboardWidget::sigPutKeyboardSequence, this, &UISoftKeyboard::sltHandlePutKeyboardSequence);
     2481    connect(m_pSession, &UISession::sigKeyboardLedsChange, this, &UISoftKeyboard::sltKeyboardLedsChange);
     2482    connect(m_pKeyboardWidget, &UISoftKeyboardWidget::sigPutKeyboardSequence, this, &UISoftKeyboard::sltPutKeyboardSequence);
    24472483    connect(m_pKeyboardWidget, &UISoftKeyboardWidget::sigCurrentLayoutChange, this, &UISoftKeyboard::sltCurentLayoutChanged);
    24482484    connect(m_pKeyboardWidget, &UISoftKeyboardWidget::sigKeyToEdit, this, &UISoftKeyboard::sltKeyToEditChanged);
     
    24512487    connect(m_pLayoutSelector, &UILayoutSelector::sigShowLayoutEditor, this, &UISoftKeyboard::sltShowLayoutEditor);
    24522488    connect(m_pLayoutSelector, &UILayoutSelector::sigCloseLayoutList, this, &UISoftKeyboard::sltShowHideSidePanel);
     2489    connect(m_pLayoutSelector, &UILayoutSelector::sigSaveLayout, this, &UISoftKeyboard::sltSaveLayout);
     2490    connect(m_pLayoutSelector, &UILayoutSelector::sigCopyLayout, this, &UISoftKeyboard::sltCopyLayout);
    24532491    connect(m_pLayoutEditor, &UILayoutEditor::sigGoBackButton, this, &UISoftKeyboard::sltShowLayoutSelector);
    24542492    connect(m_pLayoutEditor, &UILayoutEditor::sigLayoutEdited, this, &UISoftKeyboard::sltLayoutEdited);
     
    24802518}
    24812519
     2520void UISoftKeyboard::updateLayoutSelector()
     2521{
     2522    if (!m_pKeyboardWidget || !m_pLayoutSelector)
     2523        return;
     2524    m_pLayoutSelector->setLayoutList(m_pKeyboardWidget->layoutNameList());
     2525    m_pLayoutSelector->setCurrentLayout(m_pKeyboardWidget->currentLayout() ? m_pKeyboardWidget->currentLayout()->name() : QString());
     2526}
     2527
    24822528CKeyboard& UISoftKeyboard::keyboard() const
    24832529{
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h

    r79201 r79206  
    6565private slots:
    6666
    67     void sltHandleKeyboardLedsChange();
    68     void sltHandlePutKeyboardSequence(QVector<LONG> sequence);
    69     void sltHandleStatusBarContextMenuRequest(const QPoint &point);
     67    void sltKeyboardLedsChange();
     68    void sltPutKeyboardSequence(QVector<LONG> sequence);
     69    void sltStatusBarContextMenuRequest(const QPoint &point);
    7070    /** Handles the signal we get from the layout selector widget.
    7171      * Selection changed is forwarded to the keyboard widget. */
     
    8080    void sltKeyCaptionsEdited(UISoftKeyboardKey* pKey);
    8181    void sltShowHideSidePanel();
     82    void sltCopyLayout();
     83    void sltSaveLayout();
    8284
    8385private:
     
    8890    void loadSettings();
    8991    void updateStatusBarMessage(const QString &strLayoutName);
     92    void updateLayoutSelector();
    9093    CKeyboard& keyboard() const;
    9194
Note: See TracChangeset for help on using the changeset viewer.

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