VirtualBox

Ignore:
Timestamp:
Jun 17, 2019 1:23:13 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6143. Connecting the editor widget to selector widget

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

Legend:

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

    r79172 r79184  
    3535#include <QVBoxLayout>
    3636
    37 
    3837/* GUI includes: */
    3938#include "QIDialogButtonBox.h"
     
    122121
    123122    void sigLayoutEdited();
     123    void sigKeyCaptionsEdited(UISoftKeyboardKey* pKey);
    124124    void sigGoBackButton();
    125125
     
    141141    void sltKeyShiftCaptionChange();
    142142    void sltKeyAltGrCaptionChange();
    143     void sltLayoutNameChange();
    144143    void sltHandlePhysicalLayoutChanged();
    145144
     
    149148    void prepareConnections();
    150149    QWidget *prepareKeyCaptionEditWidgets();
     150    void reset();
    151151
    152152    QGridLayout *m_pEditorLayout;
     
    175175    /** The layout which is being currently edited. */
    176176    UISoftKeyboardLayout *m_pLayout;
    177     QVector<UISoftKeyboardPhysicalLayout> m_physicalLayouts;
    178177};
    179178
     
    188187signals:
    189188
    190     void sigApplySelectedLayout(const QString &strSelectedLayoutName);
    191     void sigEditSelectedLayout();
     189    void sigLayoutSelectionChanged(const QString &strSelectedLayoutName);
     190    void sigShowLayoutEditor();
    192191
    193192public:
     
    195194    UILayoutSelector(QWidget *pParent = 0);
    196195    void setLayoutList(const QStringList &layoutNames);
    197     QString selectedLayoutName() const;
    198     void selectLayoutByName(const QString &strLayoutName);
     196    void setCurrentLayout(const QString &strLayoutName);
    199197
    200198protected:
     
    352350public:
    353351
    354     UISoftKeyboardLayout()
    355         :m_pPhysicalLayout(0){}
     352    UISoftKeyboardLayout(){}
    356353
    357354    void setName(const QString &strName)
     
    360357    }
    361358
     359    void updateKeyCaptions(int iKeyPosition, KeyCaptions &newCaptions)
     360    {
     361        if (!m_keyCapMap.contains(iKeyPosition))
     362            return;
     363        m_keyCapMap[iKeyPosition] = newCaptions;
     364    }
     365
    362366    const QString &name() const
    363367    {
     
    365369    }
    366370
    367     /** The physical layout used by this layout. */
    368     UISoftKeyboardPhysicalLayout *m_pPhysicalLayout;
     371    /** The UUID of the physical layout used by this layout. */
     372    QUuid m_physicalLayoutUuid;
    369373
    370374    /** We cache the key caps here instead of reading the layout files each time layout changes.
     
    395399
    396400    void sigPutKeyboardSequence(QVector<LONG> sequence);
    397     void sigLayoutChange(const QString &strLayoutName);
    398     void sigLayoutListChanged(QStringList layoutNames);
     401    void sigCurrentLayoutChange();
     402    void sigKeyToEdit(UISoftKeyboardKey* pKey);
    399403
    400404public:
     
    407411    void loadLayouts();
    408412    void showContextMenu(const QPoint &globalPoint);
    409     void applyLayoutByName(const QString &strLayoutName);
     413
     414    void setCurrentLayout(const QString &strLayoutName);
     415    UISoftKeyboardLayout *currentLayout();
     416
    410417    QStringList layoutNameList() const;
    411418    const QVector<UISoftKeyboardPhysicalLayout> &physicalLayouts() const;
     419
     420    void toggleEditMode(bool fIsEditMode);
     421    /** Is called when the captions in UISoftKeyboardKey is changed and forward this changes to
     422      * corresponding UISoftKeyboardLayout */
     423    void updateKeyCaptionsInLayout(UISoftKeyboardKey *pKey);
    412424
    413425protected:
     
    423435    void sltHandleContextMenuRequest(const QPoint &point);
    424436    void sltHandleSaveLayout();
    425     void sltHandleLayoutEditModeToggle(bool fToggle);
    426437    void sltHandleNewLayout();
    427438    void sltPhysicalLayoutForLayoutChanged(int iIndex);
     
    440451    void               reset();
    441452    void               prepareObjects();
     453    UISoftKeyboardPhysicalLayout *findPhysicalLayout(const QUuid &uuid);
    442454    /** Sets m_pKeyBeingEdited. */
    443455    void               setKeyBeingEdited(UISoftKeyboardKey *pKey);
    444456    void               setCurrentLayout(UISoftKeyboardLayout *pLayout);
    445     void               emitLayoutNames();
    446457    UISoftKeyboardLayout *findLayoutByName(const QString &strName);
    447458
     
    552563    , m_pAltGrCaptionEdit(0)
    553564    , m_pKey(0)
     565    , m_pLayout(0)
    554566{
    555567    setAutoFillBackground(true);
     
    580592void UILayoutEditor::setLayoutToEdit(UISoftKeyboardLayout *pLayout)
    581593{
    582     if (m_pLayout != pLayout)
    583         return;
     594    if (m_pLayout == pLayout)
     595        return;
     596
     597    m_pLayout = pLayout;
     598    if (!m_pLayout)
     599        reset();
     600
    584601    if (m_pLayoutNameEdit)
    585         m_pLayoutNameEdit->setText(m_pLayout->name());
     602        m_pLayoutNameEdit->setText(m_pLayout ? m_pLayout->name() : QString());
     603
     604    if (m_pPhysicalLayoutCombo && m_pLayout)
     605    {
     606        int iIndex = m_pPhysicalLayoutCombo->findData(m_pLayout->m_physicalLayoutUuid);
     607        if (iIndex != -1)
     608            m_pPhysicalLayoutCombo->setCurrentIndex(iIndex);
     609    }
    586610    update();
    587611}
     
    589613void UILayoutEditor::setPhysicalLayoutList(const QVector<UISoftKeyboardPhysicalLayout> &physicalLayouts)
    590614{
    591     m_physicalLayouts = physicalLayouts;
    592 
    593615    if (!m_pPhysicalLayoutCombo)
    594616        return;
     
    627649        return;
    628650    m_pKey->setBaseCaption(m_pBaseCaptionEdit->text());
     651    emit sigKeyCaptionsEdited(m_pKey);
     652}
     653
     654void UILayoutEditor::sltKeyShiftCaptionChange()
     655{
     656    if (!m_pKey || !m_pShiftCaptionEdit)
     657        return;
     658    m_pKey->setShiftCaption(m_pShiftCaptionEdit->text());
     659    emit sigKeyCaptionsEdited(m_pKey);
     660}
     661
     662void UILayoutEditor::sltKeyAltGrCaptionChange()
     663{
     664    if (!m_pKey || !m_pAltGrCaptionEdit)
     665        return;
     666    m_pKey->setAltGrCaption(m_pAltGrCaptionEdit->text());
     667    emit sigKeyCaptionsEdited(m_pKey);
     668}
     669
     670void UILayoutEditor::sltHandlePhysicalLayoutChanged()
     671{
     672    if (!m_pPhysicalLayoutCombo || !m_pLayout)
     673        return;
     674    QUuid currentData = m_pPhysicalLayoutCombo->currentData().toUuid();
     675    if (!currentData.isNull())
     676        m_pLayout->m_physicalLayoutUuid = currentData;
    629677    emit sigLayoutEdited();
    630 }
    631 
    632 void UILayoutEditor::sltKeyShiftCaptionChange()
    633 {
    634     if (!m_pKey || !m_pShiftCaptionEdit)
    635         return;
    636     m_pKey->setShiftCaption(m_pShiftCaptionEdit->text());
    637     emit sigLayoutEdited();
    638 }
    639 
    640 void UILayoutEditor::sltKeyAltGrCaptionChange()
    641 {
    642     if (!m_pKey || !m_pAltGrCaptionEdit)
    643         return;
    644     m_pKey->setAltGrCaption(m_pAltGrCaptionEdit->text());
    645     emit sigLayoutEdited();
    646 }
    647 
    648 void UILayoutEditor::sltLayoutNameChange()
    649 {
    650     if (!m_pLayoutNameEdit)
    651         return;
    652     emit sigLayoutEdited();
    653 }
    654 
    655 void UILayoutEditor::sltHandlePhysicalLayoutChanged()
    656 {
    657     if (!m_pPhysicalLayoutCombo)
    658         return;
    659 
    660 
    661678}
    662679
     
    678695    m_pEditorLayout->addWidget(m_pLayoutNameLabel, 1, 0, 1, 1);
    679696    m_pEditorLayout->addWidget(m_pLayoutNameEdit, 1, 1, 1, 1);
    680     connect(m_pLayoutNameEdit, &QLineEdit::editingFinished, this, &UILayoutEditor::sltLayoutNameChange);
     697    connect(m_pLayoutNameEdit, &QLineEdit::editingFinished, this, &UILayoutEditor::sigLayoutEdited);
    681698
    682699
     
    756773    connect(m_pAltGrCaptionEdit, &QLineEdit::editingFinished, this, &UILayoutEditor::sltKeyAltGrCaptionChange);
    757774
    758 
    759775    QSpacerItem *pSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding);
    760776    if (pSpacer)
    761777        pCaptionEditorLayout->addItem(pSpacer, 4, 1);
    762778    return m_pCaptionEditGroupBox;
     779}
     780
     781void UILayoutEditor::reset()
     782{
     783    if (m_pLayoutNameEdit)
     784        m_pLayoutNameEdit->clear();
     785    if (m_pScanCodeEdit)
     786        m_pScanCodeEdit->clear();
     787    if (m_pPositionEdit)
     788        m_pPositionEdit->clear();
     789    if (m_pBaseCaptionEdit)
     790        m_pBaseCaptionEdit->clear();
     791    if (m_pShiftCaptionEdit)
     792        m_pShiftCaptionEdit->clear();
     793    if (m_pAltGrCaptionEdit)
     794        m_pAltGrCaptionEdit->clear();
    763795}
    764796
     
    776808}
    777809
    778 QString UILayoutSelector::selectedLayoutName() const
    779 {
    780     if (!m_pLayoutListWidget || !m_pLayoutListWidget->currentItem())
    781         return QString();
    782     return m_pLayoutListWidget->currentItem()->text();
    783 }
    784 
    785 void UILayoutSelector::selectLayoutByName(const QString &strLayoutName)
     810void UILayoutSelector::setCurrentLayout(const QString &strLayoutName)
    786811{
    787812    if (!m_pLayoutListWidget)
    788813        return;
     814    if (strLayoutName.isEmpty())
     815    {
     816        m_pLayoutListWidget->selectionModel()->clear();
     817        return;
     818    }
    789819    QList<QListWidgetItem *> items = m_pLayoutListWidget->findItems(strLayoutName, Qt::MatchFixedString |Qt::MatchCaseSensitive);
    790820    if (items.isEmpty())
     
    823853    m_pLayoutListWidget = new QListWidget;
    824854    pLayout->addWidget(m_pLayoutListWidget);
    825     connect(m_pLayoutListWidget, &QListWidget::currentTextChanged, this, &UILayoutSelector::sigApplySelectedLayout);
     855    connect(m_pLayoutListWidget, &QListWidget::currentTextChanged, this, &UILayoutSelector::sigLayoutSelectionChanged);
    826856
    827857    QHBoxLayout *pButtonsLayout = new QHBoxLayout;
    828858    pLayout->addLayout(pButtonsLayout);
    829 
    830     // m_pApplyLayoutButton = new QToolButton;
    831     // m_pApplyLayoutButton->setIcon(UIIconPool::iconSet(":/keyboard_16px.png"));
    832     // pButtonsLayout->addWidget(m_pApplyLayoutButton);
    833 
    834859
    835860    m_pEditLayoutButton = new QToolButton;
    836861    m_pEditLayoutButton->setIcon(UIIconPool::iconSet(":/keyboard_settings_16px.png"));
    837862    pButtonsLayout->addWidget(m_pEditLayoutButton);
    838     connect(m_pEditLayoutButton, &QToolButton::pressed, this, &UILayoutSelector::sigEditSelectedLayout);
     863    connect(m_pEditLayoutButton, &QToolButton::pressed, this, &UILayoutSelector::sigShowLayoutEditor);
    839864
    840865    pButtonsLayout->addStretch(2);
     
    11891214    Q_UNUSED(pEvent);
    11901215
    1191     int iEditDialogWidth = 0;
    1192     if (m_enmMode == Mode_LayoutEdit)
    1193         iEditDialogWidth = 34 * QApplication::fontMetrics().width('x');
    1194     m_fScaleFactorX = (width() - iEditDialogWidth) / (float) m_iInitialWidth;
     1216    m_fScaleFactorX = width() / (float) m_iInitialWidth;
    11951217    m_fScaleFactorY = height() / (float) m_iInitialHeight;
    11961218
     
    12081230    if (!m_pCurrentKeyboardLayout || m_iInitialWidth == 0 || m_iInitialHeight == 0)
    12091231        return;
    1210     if (!m_pCurrentKeyboardLayout->m_pPhysicalLayout)
    1211         return;
    1212 
    1213     QVector<UISoftKeyboardRow> &rows = m_pCurrentKeyboardLayout->m_pPhysicalLayout->m_rows;
     1232
     1233    UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->m_physicalLayoutUuid);
     1234    if (!pPhysicalLayout)
     1235        return;
     1236
     1237    QVector<UISoftKeyboardRow> &rows = pPhysicalLayout->m_rows;
    12141238    for (int i = 0; i < rows.size(); ++i)
    12151239    {
     
    13711395//         {
    13721396//             m_pLastSelectedLayout = pSenderAction;
    1373 //             emit sigLayoutChange(strLayout);
     1397//             emit sigCurrentLayoutChange(strLayout);
    13741398//             return;
    13751399//         }
     
    13801404//         QString strLayout = m_pLastSelectedLayout->data().toString();
    13811405//         loadPhysicalLayout(strLayout);
    1382 //         emit sigLayoutChange(strLayout);
     1406//         emit sigCurrentLayoutChange(strLayout);
    13831407//         m_pLastSelectedLayout->setChecked(true);
    13841408//     }
     
    13911415    if (strFileName.isEmpty())
    13921416        return;
    1393     if (!m_pCurrentKeyboardLayout || !m_pCurrentKeyboardLayout->m_pPhysicalLayout)
     1417    if (!m_pCurrentKeyboardLayout)
     1418        return;
     1419
     1420    UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->m_physicalLayoutUuid);
     1421    if (!pPhysicalLayout)
    13941422        return;
    13951423
     
    14081436    xmlWriter.writeStartElement("layout");
    14091437    xmlWriter.writeTextElement("name", m_pCurrentKeyboardLayout->name());
    1410     xmlWriter.writeTextElement("physicallayoutid", m_pCurrentKeyboardLayout->m_pPhysicalLayout->m_uId.toString());
    1411 
    1412     QVector<UISoftKeyboardRow> &rows = m_pCurrentKeyboardLayout->m_pPhysicalLayout->m_rows;
     1438    xmlWriter.writeTextElement("physicallayoutid", pPhysicalLayout->m_uId.toString());
     1439
     1440    QVector<UISoftKeyboardRow> &rows = pPhysicalLayout->m_rows;
    14131441    for (int i = 0; i < rows.size(); ++i)
    14141442    {
     
    14601488// }
    14611489
    1462 void UISoftKeyboardWidget::sltHandleLayoutEditModeToggle(bool fToggle)
    1463 {
    1464     if (fToggle)
     1490void UISoftKeyboardWidget::toggleEditMode(bool fIsEditMode)
     1491{
     1492    if (fIsEditMode)
    14651493        m_enmMode = Mode_LayoutEdit;
    14661494    else
     
    14711499}
    14721500
     1501void UISoftKeyboardWidget::updateKeyCaptionsInLayout(UISoftKeyboardKey *pKey)
     1502{
     1503    if (!m_pCurrentKeyboardLayout || !pKey)
     1504        return;
     1505
     1506    /* Assuming the key captions are changed for the current layout: */
     1507    KeyCaptions newCaptions;
     1508    newCaptions.m_strBase = pKey->baseCaption();
     1509    newCaptions.m_strShift = pKey->shiftCaption();
     1510    newCaptions.m_strAltGr = pKey->altGrCaption();
     1511    m_pCurrentKeyboardLayout->updateKeyCaptions(pKey->position(), newCaptions);
     1512}
     1513
    14731514void UISoftKeyboardWidget::sltHandleNewLayout()
    14741515{
     
    14781519    m_layouts.append(UISoftKeyboardLayout());
    14791520    UISoftKeyboardLayout &newLayout = m_layouts.back();
    1480     newLayout.m_pPhysicalLayout = &(m_physicalLayouts[0]);
     1521    newLayout.m_physicalLayoutUuid = m_physicalLayouts[0].m_uId;
    14811522    newLayout.setName(QString(UISoftKeyboard::tr("Unnamed")));
    14821523    setCurrentLayout(&newLayout);
     
    14901531        return;
    14911532
    1492     if (m_pCurrentKeyboardLayout->m_pPhysicalLayout == &(m_physicalLayouts[iIndex]))
    1493         return;
    1494     m_pCurrentKeyboardLayout->m_pPhysicalLayout = &(m_physicalLayouts[iIndex]);
     1533    if (m_pCurrentKeyboardLayout->m_physicalLayoutUuid == m_physicalLayouts[iIndex].m_uId)
     1534        return;
     1535    m_pCurrentKeyboardLayout->m_physicalLayoutUuid = m_physicalLayouts[iIndex].m_uId;
    14951536    update();
    14961537}
     
    15161557UISoftKeyboardKey *UISoftKeyboardWidget::keyUnderMouse(const QPoint &eventPosition)
    15171558{
    1518     if (!m_pCurrentKeyboardLayout || !m_pCurrentKeyboardLayout->m_pPhysicalLayout)
     1559    if (!m_pCurrentKeyboardLayout)
    15191560        return 0;
     1561    UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->m_physicalLayoutUuid);
     1562    if (!pPhysicalLayout)
     1563        return 0;
     1564
    15201565    UISoftKeyboardKey *pKey = 0;
    1521     QVector<UISoftKeyboardRow> &rows = m_pCurrentKeyboardLayout->m_pPhysicalLayout->m_rows;
     1566    QVector<UISoftKeyboardRow> &rows = pPhysicalLayout->m_rows;
    15221567    for (int i = 0; i < rows.size(); ++i)
    15231568    {
     
    15861631}
    15871632
    1588 void UISoftKeyboardWidget::applyLayoutByName(const QString &strLayoutName)
     1633void UISoftKeyboardWidget::setCurrentLayout(const QString &strLayoutName)
    15891634{
    15901635    UISoftKeyboardLayout *pLayout = findLayoutByName(strLayoutName);
     
    15921637        return;
    15931638    setCurrentLayout(pLayout);
     1639}
     1640
     1641UISoftKeyboardLayout *UISoftKeyboardWidget::currentLayout()
     1642{
     1643    return m_pCurrentKeyboardLayout;
    15941644}
    15951645
     
    16961746    m_layouts.append(UISoftKeyboardLayout());
    16971747    UISoftKeyboardLayout &newLayout = m_layouts.back();
    1698     newLayout.m_pPhysicalLayout = pPhysicalLayout;
     1748    newLayout.m_physicalLayoutUuid = pPhysicalLayout->m_uId;
    16991749    newLayout.setName(keyboardLayoutReader.name());
    17001750    newLayout.m_keyCapMap = keyboardLayoutReader.keyCapMap();
    17011751    return true;
     1752}
     1753
     1754UISoftKeyboardPhysicalLayout *UISoftKeyboardWidget::findPhysicalLayout(const QUuid &uuid)
     1755{
     1756    for (int i = 0; i < m_physicalLayouts.size(); ++i)
     1757    {
     1758        if (m_physicalLayouts[i].m_uId == uuid)
     1759            return &(m_physicalLayouts[i]);
     1760    }
     1761    return 0;
    17021762}
    17031763
     
    17221782    foreach (const QString &strName, keyboardLayoutNames)
    17231783        loadKeyboardLayout(strName);
    1724     emitLayoutNames();
     1784
    17251785    if (m_layouts.isEmpty())
    17261786        return;
     
    17361796
    17371797    m_pLayoutEditModeToggleAction = m_pContextMenu->addAction(UISoftKeyboard::tr("Edit the layout"));
    1738     connect(m_pLayoutEditModeToggleAction, &QAction::toggled, this, &UISoftKeyboardWidget::sltHandleLayoutEditModeToggle);
    17391798    m_pLayoutEditModeToggleAction->setCheckable(true);
    17401799    m_pLayoutEditModeToggleAction->setChecked(false);
     
    17601819        return;
    17611820    m_pKeyBeingEdited = pKey;
    1762     // if (m_pLayoutEditor)
    1763     //     m_pLayoutEditor->setKey(pKey);
     1821    emit sigKeyToEdit(pKey);
    17641822}
    17651823
     
    17711829    if (!m_pCurrentKeyboardLayout)
    17721830    {
    1773         emit sigLayoutChange(QString());
    1774         return;
    1775     }
    1776     emit sigLayoutChange(m_pCurrentKeyboardLayout->name());
     1831        emit sigCurrentLayoutChange();
     1832        return;
     1833    }
     1834    emit sigCurrentLayoutChange();
    17771835
    17781836    const QMap<int, KeyCaptions> &keyCapMap = m_pCurrentKeyboardLayout->m_keyCapMap;
    17791837
     1838   UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->m_physicalLayoutUuid);
     1839    if (!pPhysicalLayout)
     1840        return;
     1841
    17801842    /* Update the key captions: */
    1781     QVector<UISoftKeyboardRow> &rows = m_pCurrentKeyboardLayout->m_pPhysicalLayout->m_rows;
     1843    QVector<UISoftKeyboardRow> &rows = pPhysicalLayout->m_rows;
    17821844    for (int i = 0; i < rows.size(); ++i)
    17831845    {
     
    17941856        }
    17951857    }
    1796 }
    1797 
    1798 void UISoftKeyboardWidget::emitLayoutNames()
    1799 {
    1800     emit sigLayoutListChanged(layoutNameList());
     1858    update();
    18011859}
    18021860
     
    21172175    , m_pSession(pSession)
    21182176    , m_pMainLayout(0)
    2119     , m_pContainerWidget(0)
     2177    , m_pKeyboardWidget(0)
    21202178    , m_strMachineName(strMachineName)
    21212179    , m_pSplitter(0)
     
    21292187    prepareConnections();
    21302188
    2131     if (m_pContainerWidget)
    2132         m_pContainerWidget->loadLayouts();
     2189    if (m_pKeyboardWidget)
     2190    {
     2191        m_pKeyboardWidget->loadLayouts();
     2192        /* Update the selector widget: */
     2193        if (m_pLayoutSelector)
     2194            m_pLayoutSelector->setLayoutList(m_pKeyboardWidget->layoutNameList());
     2195        if (m_pLayoutEditor)
     2196            m_pLayoutEditor->setPhysicalLayoutList(m_pKeyboardWidget->physicalLayouts());
     2197    }
    21332198
    21342199    loadSettings();
    21352200    retranslateUi();
    2136     updateStatusBarMessage();
    21372201}
    21382202
     
    21582222        if (pMouseEvent && pMouseEvent->button() == Qt::LeftButton)
    21592223        {
    2160             if (m_pContainerWidget)
    2161                 m_pContainerWidget->showContextMenu(m_pSettingsButton->mapToGlobal(pMouseEvent->pos()));
     2224            if (m_pKeyboardWidget)
     2225                m_pKeyboardWidget->showContextMenu(m_pSettingsButton->mapToGlobal(pMouseEvent->pos()));
    21622226            return true;
    21632227        }
     
    21812245void UISoftKeyboard::sltHandleStatusBarContextMenuRequest(const QPoint &point)
    21822246{
    2183     if (m_pContainerWidget)
    2184         m_pContainerWidget->showContextMenu(statusBar()->mapToGlobal(point));
     2247    if (m_pKeyboardWidget)
     2248        m_pKeyboardWidget->showContextMenu(statusBar()->mapToGlobal(point));
     2249}
     2250
     2251void UISoftKeyboard::sltLayoutSelectionChanged(const QString &strLayoutName)
     2252{
     2253    if (m_pKeyboardWidget)
     2254        m_pKeyboardWidget->setCurrentLayout(strLayoutName);
     2255}
     2256
     2257void UISoftKeyboard::sltCurentLayoutChanged()
     2258{
     2259    if (!m_pKeyboardWidget)
     2260        return;
     2261    UISoftKeyboardLayout *pCurrentLayout = m_pKeyboardWidget->currentLayout();
     2262
     2263    /* Update the status bar string: */
     2264    QString strLayoutName = pCurrentLayout ? pCurrentLayout->name() : QString();
     2265    updateStatusBarMessage(strLayoutName);
     2266}
     2267
     2268void UISoftKeyboard::sltShowLayoutSelector()
     2269{
     2270    if (m_pSidePanelContainerWidget && m_pLayoutSelector)
     2271        m_pSidePanelContainerWidget->setCurrentWidget(m_pLayoutSelector);
     2272    if (m_pKeyboardWidget)
     2273        m_pKeyboardWidget->toggleEditMode(false);
     2274}
     2275
     2276void UISoftKeyboard::sltShowLayoutEditor()
     2277{
     2278    if (m_pSidePanelContainerWidget && m_pLayoutEditor)
     2279    {
     2280        m_pLayoutEditor->setLayoutToEdit(m_pKeyboardWidget->currentLayout());
     2281        m_pSidePanelContainerWidget->setCurrentWidget(m_pLayoutEditor);
     2282    }
     2283    if (m_pKeyboardWidget)
     2284        m_pKeyboardWidget->toggleEditMode(true);
     2285}
     2286
     2287void UISoftKeyboard::sltKeyToEditChanged(UISoftKeyboardKey* pKey)
     2288{
     2289    if (m_pLayoutEditor)
     2290        m_pLayoutEditor->setKey(pKey);
     2291}
     2292
     2293void UISoftKeyboard::sltLayoutEdited()
     2294{
     2295    if (!m_pKeyboardWidget)
     2296        return;
     2297    m_pKeyboardWidget->update();
     2298    if (m_pLayoutSelector)
     2299    {
     2300        m_pLayoutSelector->setLayoutList(m_pKeyboardWidget->layoutNameList());
     2301        m_pLayoutSelector->setCurrentLayout(m_pKeyboardWidget->currentLayout() ? m_pKeyboardWidget->currentLayout()->name() : QString());
     2302    }
     2303}
     2304
     2305void UISoftKeyboard::sltKeyCaptionsEdited(UISoftKeyboardKey* pKey)
     2306{
     2307    if (m_pKeyboardWidget)
     2308    {
     2309        m_pKeyboardWidget->updateKeyCaptionsInLayout(pKey);
     2310        m_pKeyboardWidget->update();
     2311    }
    21852312}
    21862313
     
    22032330        m_pSidePanelContainerWidget->addWidget(m_pLayoutEditor);
    22042331
    2205     m_pContainerWidget = new UISoftKeyboardWidget;
    2206     if (!m_pContainerWidget)
    2207         return;
    2208     m_pContainerWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
    2209     m_pContainerWidget->updateGeometry();
    2210     m_pSplitter->addWidget(m_pContainerWidget);
     2332    m_pKeyboardWidget = new UISoftKeyboardWidget;
     2333    if (!m_pKeyboardWidget)
     2334        return;
     2335    m_pKeyboardWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
     2336    m_pKeyboardWidget->updateGeometry();
     2337    m_pSplitter->addWidget(m_pKeyboardWidget);
    22112338
    22122339    statusBar()->setContextMenuPolicy(Qt::CustomContextMenu);
     
    22302357{
    22312358    connect(m_pSession, &UISession::sigKeyboardLedsChange, this, &UISoftKeyboard::sltHandleKeyboardLedsChange);
    2232     connect(m_pContainerWidget, &UISoftKeyboardWidget::sigPutKeyboardSequence, this, &UISoftKeyboard::sltHandlePutKeyboardSequence);
     2359    connect(m_pKeyboardWidget, &UISoftKeyboardWidget::sigPutKeyboardSequence, this, &UISoftKeyboard::sltHandlePutKeyboardSequence);
     2360    connect(m_pKeyboardWidget, &UISoftKeyboardWidget::sigCurrentLayoutChange, this, &UISoftKeyboard::sltCurentLayoutChanged);
     2361    connect(m_pKeyboardWidget, &UISoftKeyboardWidget::sigKeyToEdit, this, &UISoftKeyboard::sltKeyToEditChanged);
     2362
     2363    connect(m_pLayoutSelector, &UILayoutSelector::sigLayoutSelectionChanged, this, &UISoftKeyboard::sltLayoutSelectionChanged);
     2364    connect(m_pLayoutSelector, &UILayoutSelector::sigShowLayoutEditor, this, &UISoftKeyboard::sltShowLayoutEditor);
     2365    connect(m_pLayoutEditor, &UILayoutEditor::sigGoBackButton, this, &UISoftKeyboard::sltShowLayoutSelector);
     2366    connect(m_pLayoutEditor, &UILayoutEditor::sigLayoutEdited, this, &UISoftKeyboard::sltLayoutEdited);
     2367    connect(m_pLayoutEditor, &UILayoutEditor::sigKeyCaptionsEdited, this, &UISoftKeyboard::sltKeyCaptionsEdited);
    22332368}
    22342369
     
    22412376}
    22422377
    2243 void UISoftKeyboard::updateStatusBarMessage()
     2378void UISoftKeyboard::updateStatusBarMessage(const QString &strName)
    22442379{
    22452380    QString strMessage;
    2246     if (!m_strLayoutName.isEmpty())
    2247         strMessage += QString("%1: %2").arg(tr("Layout")).arg(m_strLayoutName);
    2248     if (!m_strKeyCapFileName.isEmpty())
    2249         strMessage += QString("\t/\t %1: %2").arg(tr("Key Captions File")).arg(m_strKeyCapFileName);
    2250     statusBar()->showMessage(strMessage);
     2381    if (!strName.isEmpty())
     2382    {
     2383        strMessage += QString("%1: %2").arg(tr("Layout")).arg(strName);
     2384        statusBar()->showMessage(strMessage);
     2385    }
     2386    else
     2387        statusBar()->showMessage(QString());
    22512388}
    22522389
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h

    r79172 r79184  
    6868    void sltHandleStatusBarContextMenuRequest(const QPoint &point);
    6969
     70    /** Handles the signal we get from the layout selector widget.
     71      * Selection changed is forwarded to the keyboard widget. */
     72    void sltLayoutSelectionChanged(const QString &strLayoutName);
     73
     74    /** Handles the signal we get from the keyboard widget. */
     75    void sltCurentLayoutChanged();
     76
     77    void sltShowLayoutSelector();
     78    void sltShowLayoutEditor();
     79    void sltKeyToEditChanged(UISoftKeyboardKey* pKey);
     80    void sltLayoutEdited();
     81    /** Make th necessary changes to data structures when th key captions updated. */
     82    void sltKeyCaptionsEdited(UISoftKeyboardKey* pKey);
     83
    7084private:
    7185
     
    7488    void saveSettings();
    7589    void loadSettings();
    76     void updateStatusBarMessage();
     90    void updateStatusBarMessage(const QString &strLayoutName);
    7791    CKeyboard& keyboard() const;
    7892
    7993    UISession     *m_pSession;
    8094    QHBoxLayout   *m_pMainLayout;
    81     UISoftKeyboardWidget       *m_pContainerWidget;
     95    UISoftKeyboardWidget       *m_pKeyboardWidget;
    8296    QString       m_strMachineName;
    83     QString       m_strLayoutName;
    84     QString       m_strKeyCapFileName;
    8597    QSplitter      *m_pSplitter;
    8698    QToolButton    *m_pSettingsButton;
  • trunk/src/VBox/Frontends/VirtualBox/xml/german.xml

    r79172 r79184  
    55    <key>
    66        <position>110</position>
    7         <basecaption>Esc</basecaption>
     7        <basecaption>Escxx</basecaption>
    88        <shiftcaption></shiftcaption>
    99        <altgrcaption></altgrcaption>
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