VirtualBox

Ignore:
Timestamp:
Jun 17, 2019 9:09:03 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
131343
Message:

FE/Qt: bugref:6143. Adding a spliter to the dialog.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/VirtualBox_xml.qrc

    r79121 r79172  
    44        <file alias="102_iso.xml">xml/102_iso.xml</file>
    55        <file alias="us_international.xml">xml/us_international.xml</file>
     6        <file alias="german.xml">xml/german.xml</file>
    67    </qresource>
    78</RCC>
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp

    r79130 r79172  
    2323#include <QLabel>
    2424#include <QLineEdit>
     25#include <QListWidget>
    2526#include <QMenu>
    2627#include <QPainter>
    2728#include <QPushButton>
     29#include <QSplitter>
    2830#include <QStatusBar>
    2931#include <QStyle>
     32#include <QStackedWidget>
    3033#include <QToolButton>
    3134#include <QXmlStreamReader>
     
    4952/* Forward declarations: */
    5053class UISoftKeyboardWidget;
     54class UISoftKeyboardLayout;
     55class UISoftKeyboardRow;
    5156
    5257enum UIKeyState
     
    7681};
    7782
     83
     84/*********************************************************************************************************************************
     85*   UISoftKeyboardPhysicalLayout definition.                                                                                     *
     86*********************************************************************************************************************************/
     87
     88class UISoftKeyboardPhysicalLayout
     89{
     90
     91public:
     92
     93    void setName(const QString &strName)
     94    {
     95        m_strName = strName;
     96    }
     97
     98    const QString &name() const
     99    {
     100        return m_strName;
     101    }
     102
     103    QString  m_strFileName;
     104    QUuid    m_uId;
     105
     106    QVector<UISoftKeyboardRow>  m_rows;
     107
     108private:
     109
     110    QString  m_strName;
     111};
     112
    78113/*********************************************************************************************************************************
    79114*   UILayoutEditor definition.                                                                                  *
     
    86121signals:
    87122
    88     void sigKeyCaptionEdited();
    89     void sigPhysicalLayoutChanged(int iIndex);
    90     void sigLayoutNameChanged(const QString &strName);
     123    void sigLayoutEdited();
     124    void sigGoBackButton();
    91125
    92126public:
     
    94128    UILayoutEditor(QWidget *pParent = 0);
    95129    void setKey(UISoftKeyboardKey *pKey);
    96     void setLayoutName(const QString &strName);
    97     void setPhysicalLayoutNames(const QStringList &strPhysicalLayoutNames);
     130
     131    void setLayoutToEdit(UISoftKeyboardLayout *pLayout);
     132    void setPhysicalLayoutList(const QVector<UISoftKeyboardPhysicalLayout> &physicalLayouts);
    98133
    99134protected:
     
    107142    void sltKeyAltGrCaptionChange();
    108143    void sltLayoutNameChange();
     144    void sltHandlePhysicalLayoutChanged();
    109145
    110146private:
     
    115151
    116152    QGridLayout *m_pEditorLayout;
     153    QToolButton *m_pGoBackButton;
    117154    QGroupBox *m_pSelectedKeyGroupBox;
    118155    QGroupBox *m_pCaptionEditGroupBox;
     
    136173    /** The key which is being currently edited. Might be Null. */
    137174    UISoftKeyboardKey  *m_pKey;
     175    /** The layout which is being currently edited. */
     176    UISoftKeyboardLayout *m_pLayout;
     177    QVector<UISoftKeyboardPhysicalLayout> m_physicalLayouts;
     178};
     179
     180/*********************************************************************************************************************************
     181*   UILayoutSelector definition.                                                                                  *
     182*********************************************************************************************************************************/
     183
     184class UILayoutSelector : public QIWithRetranslateUI<QWidget>
     185{
     186    Q_OBJECT;
     187
     188signals:
     189
     190    void sigApplySelectedLayout(const QString &strSelectedLayoutName);
     191    void sigEditSelectedLayout();
     192
     193public:
     194
     195    UILayoutSelector(QWidget *pParent = 0);
     196    void setLayoutList(const QStringList &layoutNames);
     197    QString selectedLayoutName() const;
     198    void selectLayoutByName(const QString &strLayoutName);
     199
     200protected:
     201
     202    virtual void retranslateUi() /* override */;
     203
     204private slots:
     205
     206
     207private:
     208    void prepareObjects();
     209
     210    QListWidget *m_pLayoutListWidget;
     211    QToolButton *m_pApplyLayoutButton;
     212    QToolButton *m_pEditLayoutButton;
    138213};
    139214
     
    269344
    270345/*********************************************************************************************************************************
    271 *   UISoftKeyboardPhysicalLayout definition.                                                                                     *
    272 *********************************************************************************************************************************/
    273 
    274 class UISoftKeyboardPhysicalLayout
    275 {
    276 
    277 public:
    278 
    279     QString  m_strName;
    280     QString  m_strFileName;
    281     QUuid    m_uId;
    282 
    283     QVector<UISoftKeyboardRow>  m_rows;
    284 };
    285 
    286 /*********************************************************************************************************************************
    287346*   UISoftKeyboardLayout definition.                                                                                  *
    288347*********************************************************************************************************************************/
     
    295354    UISoftKeyboardLayout()
    296355        :m_pPhysicalLayout(0){}
     356
     357    void setName(const QString &strName)
     358    {
     359        m_strName = strName;
     360    }
     361
     362    const QString &name() const
     363    {
     364        return m_strName;
     365    }
     366
    297367    /** The physical layout used by this layout. */
    298368    UISoftKeyboardPhysicalLayout *m_pPhysicalLayout;
    299     QString m_strName;
     369
    300370    /** We cache the key caps here instead of reading the layout files each time layout changes.
    301371      * Map key is the key position and the value is the captions of the key. */
    302372    QMap<int, KeyCaptions> m_keyCapMap;
     373
     374private:
     375
     376    QString m_strName;
    303377};
    304378
     
    322396    void sigPutKeyboardSequence(QVector<LONG> sequence);
    323397    void sigLayoutChange(const QString &strLayoutName);
    324     void sigKeyCapChange(const QString &strKepCapFileName);
     398    void sigLayoutListChanged(QStringList layoutNames);
    325399
    326400public:
     
    328402    UISoftKeyboardWidget(QWidget *pParent = 0);
    329403
    330     virtual QSize minimumSizeHint() const;
    331     virtual QSize sizeHint() const;
     404    virtual QSize minimumSizeHint() const /* override */;
     405    virtual QSize sizeHint() const  /* override */;
    332406    void keyStateChange(UISoftKeyboardKey* pKey);
    333     void loadDefaultLayout();
     407    void loadLayouts();
    334408    void showContextMenu(const QPoint &globalPoint);
     409    void applyLayoutByName(const QString &strLayoutName);
     410    QStringList layoutNameList() const;
     411    const QVector<UISoftKeyboardPhysicalLayout> &physicalLayouts() const;
    335412
    336413protected:
    337414
    338     void paintEvent(QPaintEvent *pEvent) /* override */;
    339     void mousePressEvent(QMouseEvent *pEvent) /* override */;
    340     void mouseReleaseEvent(QMouseEvent *pEvent) /* override */;
    341     void mouseMoveEvent(QMouseEvent *pEvent) /* override */;
    342     bool eventFilter(QObject *pWatched, QEvent *pEvent)/* override */;
    343 
     415    virtual void paintEvent(QPaintEvent *pEvent) /* override */;
     416    virtual void mousePressEvent(QMouseEvent *pEvent) /* override */;
     417    virtual void mouseReleaseEvent(QMouseEvent *pEvent) /* override */;
     418    virtual void mouseMoveEvent(QMouseEvent *pEvent) /* override */;
    344419    virtual void retranslateUi() /* override */;
    345420
     
    350425    void sltHandleLayoutEditModeToggle(bool fToggle);
    351426    void sltHandleNewLayout();
    352     void sltHandleKeyCaptionEdited();
    353427    void sltPhysicalLayoutForLayoutChanged(int iIndex);
    354     void sltLayoutNameChange(const QString &strName);
    355428
    356429private:
     
    366439    bool               loadKeyboardLayout(const QString &strLayoutName);
    367440    void               reset();
    368     void               configure();
    369441    void               prepareObjects();
    370442    /** Sets m_pKeyBeingEdited. */
    371443    void               setKeyBeingEdited(UISoftKeyboardKey *pKey);
    372444    void               setCurrentLayout(UISoftKeyboardLayout *pLayout);
     445    void               emitLayoutNames();
     446    UISoftKeyboardLayout *findLayoutByName(const QString &strName);
     447
    373448    UISoftKeyboardKey *m_pKeyUnderMouse;
    374449    UISoftKeyboardKey *m_pKeyBeingEdited;
     
    401476    QAction *m_pShowPositionsAction;
    402477    QAction *m_pLayoutEditModeToggleAction;
    403     UILayoutEditor *m_pLayoutEditor;
    404478    Mode       m_enmMode;
    405479};
     
    460534    :QIWithRetranslateUI<QWidget>(pParent)
    461535    , m_pEditorLayout(0)
     536    , m_pGoBackButton(0)
    462537    , m_pSelectedKeyGroupBox(0)
    463538    , m_pCaptionEditGroupBox(0)
     
    503578}
    504579
    505 void UILayoutEditor::setLayoutName(const QString &strName)
    506 {
     580void UILayoutEditor::setLayoutToEdit(UISoftKeyboardLayout *pLayout)
     581{
     582    if (m_pLayout != pLayout)
     583        return;
    507584    if (m_pLayoutNameEdit)
    508         m_pLayoutNameEdit->setText(strName);
    509 }
    510 
    511 void UILayoutEditor::setPhysicalLayoutNames(const QStringList &strPhysicalLayoutNames)
    512 {
     585        m_pLayoutNameEdit->setText(m_pLayout->name());
     586    update();
     587}
     588
     589void UILayoutEditor::setPhysicalLayoutList(const QVector<UISoftKeyboardPhysicalLayout> &physicalLayouts)
     590{
     591    m_physicalLayouts = physicalLayouts;
     592
    513593    if (!m_pPhysicalLayoutCombo)
    514594        return;
    515     foreach (const QString &strName, strPhysicalLayoutNames)
    516         m_pPhysicalLayoutCombo->addItem(strName);
     595    m_pPhysicalLayoutCombo->clear();
     596    foreach (const UISoftKeyboardPhysicalLayout &physicalLayout, physicalLayouts)
     597        m_pPhysicalLayoutCombo->addItem(physicalLayout.name(), physicalLayout.m_uId);
    517598}
    518599
    519600void UILayoutEditor::retranslateUi()
    520601{
     602    if (m_pGoBackButton)
     603        m_pGoBackButton->setToolTip(UISoftKeyboard::tr("Return Back to Layout List"));
    521604    if (m_pPhysicalLayoutLabel)
    522605        m_pPhysicalLayoutLabel->setText(UISoftKeyboard::tr("Physical Layout"));
     
    544627        return;
    545628    m_pKey->setBaseCaption(m_pBaseCaptionEdit->text());
    546     emit sigKeyCaptionEdited();
     629    emit sigLayoutEdited();
    547630}
    548631
     
    552635        return;
    553636    m_pKey->setShiftCaption(m_pShiftCaptionEdit->text());
    554     emit sigKeyCaptionEdited();
     637    emit sigLayoutEdited();
    555638}
    556639
     
    560643        return;
    561644    m_pKey->setAltGrCaption(m_pAltGrCaptionEdit->text());
    562     emit sigKeyCaptionEdited();
     645    emit sigLayoutEdited();
    563646}
    564647
     
    567650    if (!m_pLayoutNameEdit)
    568651        return;
    569     emit sigLayoutNameChanged(m_pLayoutNameEdit->text());
     652    emit sigLayoutEdited();
     653}
     654
     655void UILayoutEditor::sltHandlePhysicalLayoutChanged()
     656{
     657    if (!m_pPhysicalLayoutCombo)
     658        return;
     659
     660
    570661}
    571662
     
    576667        return;
    577668    setLayout(m_pEditorLayout);
     669
     670    m_pGoBackButton = new QToolButton;
     671    m_pGoBackButton->setIcon(UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowBack));
     672    m_pEditorLayout->addWidget(m_pGoBackButton, 0, 0, 1, 1);
     673    connect(m_pGoBackButton, &QToolButton::pressed, this, &UILayoutEditor::sigGoBackButton);
    578674
    579675    m_pLayoutNameLabel = new QLabel;
    580676    m_pLayoutNameEdit = new QLineEdit;
    581677    m_pLayoutNameLabel->setBuddy(m_pLayoutNameEdit);
    582     m_pEditorLayout->addWidget(m_pLayoutNameLabel, 0, 0, 1, 1);
    583     m_pEditorLayout->addWidget(m_pLayoutNameEdit, 0, 1, 1, 1);
     678    m_pEditorLayout->addWidget(m_pLayoutNameLabel, 1, 0, 1, 1);
     679    m_pEditorLayout->addWidget(m_pLayoutNameEdit, 1, 1, 1, 1);
    584680    connect(m_pLayoutNameEdit, &QLineEdit::editingFinished, this, &UILayoutEditor::sltLayoutNameChange);
    585681
     
    588684    m_pPhysicalLayoutCombo = new QComboBox;
    589685    m_pPhysicalLayoutLabel->setBuddy(m_pPhysicalLayoutCombo);
    590     m_pEditorLayout->addWidget(m_pPhysicalLayoutLabel, 1, 0, 1, 1);
    591     m_pEditorLayout->addWidget(m_pPhysicalLayoutCombo, 1, 1, 1, 1);
     686    m_pEditorLayout->addWidget(m_pPhysicalLayoutLabel, 2, 0, 1, 1);
     687    m_pEditorLayout->addWidget(m_pPhysicalLayoutCombo, 2, 1, 1, 1);
    592688    connect(m_pPhysicalLayoutCombo, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
    593             this, &UILayoutEditor::sigPhysicalLayoutChanged);
     689            this, &UILayoutEditor::sltHandlePhysicalLayoutChanged);
    594690
    595691    m_pSelectedKeyGroupBox = new QGroupBox;
    596692    m_pSelectedKeyGroupBox->setEnabled(false);
    597693
    598     m_pEditorLayout->addWidget(m_pSelectedKeyGroupBox, 2, 0, 1, 2);
     694    m_pEditorLayout->addWidget(m_pSelectedKeyGroupBox, 3, 0, 1, 2);
    599695    QGridLayout *pSelectedKeyLayout = new QGridLayout(m_pSelectedKeyGroupBox);
    600696    pSelectedKeyLayout->setSpacing(0);
     
    665761        pCaptionEditorLayout->addItem(pSpacer, 4, 1);
    666762    return m_pCaptionEditGroupBox;
     763}
     764
     765/*********************************************************************************************************************************
     766*   UILayoutSelector implementation.                                                                                  *
     767*********************************************************************************************************************************/
     768
     769UILayoutSelector::UILayoutSelector(QWidget *pParent /* = 0 */)
     770    :QIWithRetranslateUI<QWidget>(pParent)
     771    , m_pLayoutListWidget(0)
     772    , m_pApplyLayoutButton(0)
     773    , m_pEditLayoutButton(0)
     774{
     775    prepareObjects();
     776}
     777
     778QString UILayoutSelector::selectedLayoutName() const
     779{
     780    if (!m_pLayoutListWidget || !m_pLayoutListWidget->currentItem())
     781        return QString();
     782    return m_pLayoutListWidget->currentItem()->text();
     783}
     784
     785void UILayoutSelector::selectLayoutByName(const QString &strLayoutName)
     786{
     787    if (!m_pLayoutListWidget)
     788        return;
     789    QList<QListWidgetItem *> items = m_pLayoutListWidget->findItems(strLayoutName, Qt::MatchFixedString |Qt::MatchCaseSensitive);
     790    if (items.isEmpty())
     791        return;
     792    QListWidgetItem *pItem = items[0];
     793    if (!pItem || pItem == m_pLayoutListWidget->currentItem())
     794        return;
     795    m_pLayoutListWidget->setCurrentItem(pItem);
     796}
     797
     798void UILayoutSelector::setLayoutList(const QStringList &layoutNames)
     799{
     800    if (!m_pLayoutListWidget)
     801        return;
     802    m_pLayoutListWidget->clear();
     803    foreach (const QString &strLayoutName, layoutNames)
     804        m_pLayoutListWidget->addItem(strLayoutName);
     805}
     806
     807void UILayoutSelector::retranslateUi()
     808{
     809    if (m_pApplyLayoutButton)
     810        m_pApplyLayoutButton->setToolTip(UISoftKeyboard::tr("Use the selected layout"));
     811    if (m_pEditLayoutButton)
     812        m_pEditLayoutButton->setToolTip(UISoftKeyboard::tr("Edit the selected layout"));
     813}
     814
     815void UILayoutSelector::prepareObjects()
     816{
     817    QVBoxLayout *pLayout = new QVBoxLayout;
     818    if (!pLayout)
     819        return;
     820    pLayout->setSpacing(0);
     821    setLayout(pLayout);
     822
     823    m_pLayoutListWidget = new QListWidget;
     824    pLayout->addWidget(m_pLayoutListWidget);
     825    connect(m_pLayoutListWidget, &QListWidget::currentTextChanged, this, &UILayoutSelector::sigApplySelectedLayout);
     826
     827    QHBoxLayout *pButtonsLayout = new QHBoxLayout;
     828    pLayout->addLayout(pButtonsLayout);
     829
     830    // m_pApplyLayoutButton = new QToolButton;
     831    // m_pApplyLayoutButton->setIcon(UIIconPool::iconSet(":/keyboard_16px.png"));
     832    // pButtonsLayout->addWidget(m_pApplyLayoutButton);
     833
     834
     835    m_pEditLayoutButton = new QToolButton;
     836    m_pEditLayoutButton->setIcon(UIIconPool::iconSet(":/keyboard_settings_16px.png"));
     837    pButtonsLayout->addWidget(m_pEditLayoutButton);
     838    connect(m_pEditLayoutButton, &QToolButton::pressed, this, &UILayoutSelector::sigEditSelectedLayout);
     839
     840    pButtonsLayout->addStretch(2);
     841
     842    retranslateUi();
    667843}
    668844
     
    9951171    , m_enmMode(Mode_Keyboard)
    9961172{
    997 
    998     configure();
    9991173    prepareObjects();
    10001174}
     
    10021176QSize UISoftKeyboardWidget::minimumSizeHint() const
    10031177{
    1004     return m_minimumSize;
     1178    return QSize(0.5 * m_minimumSize.width(), 0.5 * m_minimumSize.height());
    10051179}
    10061180
    10071181QSize UISoftKeyboardWidget::sizeHint() const
    10081182{
    1009     return m_minimumSize;
     1183    return QSize(0.5 * m_minimumSize.width(), 0.5 * m_minimumSize.height());
     1184    //return m_minimumSize;
    10101185}
    10111186
     
    10301205    float fLedRadius =  0.8 * unitSize;
    10311206    float fLedMargin =  0.6 * unitSize;
    1032 
    1033     if (m_enmMode == Mode_LayoutEdit)
    1034     {
    1035         m_pLayoutEditor->setGeometry(width() - iEditDialogWidth, 0,
    1036                                      iEditDialogWidth, height());
    1037         m_pLayoutEditor->show();
    1038         m_pLayoutEditor->setFocus();
    1039     }
    1040     else
    1041         m_pLayoutEditor->hide();
    10421207
    10431208    if (!m_pCurrentKeyboardLayout || m_iInitialWidth == 0 || m_iInitialHeight == 0)
     
    11411306}
    11421307
    1143 bool UISoftKeyboardWidget::eventFilter(QObject *pWatched, QEvent *pEvent)
    1144 {
    1145     if (pWatched != m_pLayoutEditor)
    1146         return QIWithRetranslateUI<QWidget>::eventFilter(pWatched, pEvent);
    1147 
    1148     switch (pEvent->type())
    1149     {
    1150         case QEvent::KeyPress:
    1151         {
    1152             QKeyEvent *pKeyEvent = dynamic_cast<QKeyEvent*>(pEvent);
    1153             if (pKeyEvent && pKeyEvent->key() == Qt::Key_Escape)
    1154             {
    1155                 setKeyBeingEdited(0);
    1156                 update();
    1157                 return true;
    1158             }
    1159             else if (pKeyEvent && (pKeyEvent->key() == Qt::Key_Enter || pKeyEvent->key() == Qt::Key_Return))
    1160             {
    1161                 // if (m_pKeyBeingEdited)
    1162                 //     m_pKeyBeingEdited->setStaticKeyCap(m_pLayoutEditor->text());
    1163                 setKeyBeingEdited(0);
    1164                 update();
    1165                 return true;
    1166             }
    1167             break;
    1168         }
    1169         default:
    1170             break;
    1171     }
    1172 
    1173     return QIWithRetranslateUI<QWidget>::eventFilter(pWatched, pEvent);
    1174 }
     1308// bool UISoftKeyboardWidget::eventFilter(QObject *pWatched, QEvent *pEvent)
     1309// {
     1310//     if (pWatched != m_pLayoutEditor)
     1311//         return QIWithRetranslateUI<QWidget>::eventFilter(pWatched, pEvent);
     1312
     1313//     switch (pEvent->type())
     1314//     {
     1315//         case QEvent::KeyPress:
     1316//         {
     1317//             QKeyEvent *pKeyEvent = dynamic_cast<QKeyEvent*>(pEvent);
     1318//             if (pKeyEvent && pKeyEvent->key() == Qt::Key_Escape)
     1319//             {
     1320//                 setKeyBeingEdited(0);
     1321//                 update();
     1322//                 return true;
     1323//             }
     1324//             else if (pKeyEvent && (pKeyEvent->key() == Qt::Key_Enter || pKeyEvent->key() == Qt::Key_Return))
     1325//             {
     1326//                 // if (m_pKeyBeingEdited)
     1327//                 //     m_pKeyBeingEdited->setStaticKeyCap(m_pLayoutEditor->text());
     1328//                 setKeyBeingEdited(0);
     1329//                 update();
     1330//                 return true;
     1331//             }
     1332//             break;
     1333//         }
     1334//         default:
     1335//             break;
     1336//     }
     1337
     1338//     return QIWithRetranslateUI<QWidget>::eventFilter(pWatched, pEvent);
     1339// }
    11751340
    11761341
     
    12421407    xmlWriter.writeStartDocument("1.0");
    12431408    xmlWriter.writeStartElement("layout");
    1244     xmlWriter.writeTextElement("name", m_pCurrentKeyboardLayout->m_strName);
     1409    xmlWriter.writeTextElement("name", m_pCurrentKeyboardLayout->name());
    12451410    xmlWriter.writeTextElement("physicallayoutid", m_pCurrentKeyboardLayout->m_pPhysicalLayout->m_uId.toString());
    12461411
     
    13141479    UISoftKeyboardLayout &newLayout = m_layouts.back();
    13151480    newLayout.m_pPhysicalLayout = &(m_physicalLayouts[0]);
    1316     newLayout.m_strName = QString(UISoftKeyboard::tr("Unnamed"));
     1481    newLayout.setName(QString(UISoftKeyboard::tr("Unnamed")));
    13171482    setCurrentLayout(&newLayout);
    1318 }
    1319 
    1320 void UISoftKeyboardWidget::sltHandleKeyCaptionEdited()
    1321 {
    1322     update();
    13231483}
    13241484
     
    13341494    m_pCurrentKeyboardLayout->m_pPhysicalLayout = &(m_physicalLayouts[iIndex]);
    13351495    update();
    1336 }
    1337 
    1338 void UISoftKeyboardWidget::sltLayoutNameChange(const QString &strName)
    1339 {
    1340     if (!m_pCurrentKeyboardLayout)
    1341         return;
    1342     m_pCurrentKeyboardLayout->m_strName = strName;
    1343     emit sigLayoutChange(m_pCurrentKeyboardLayout->m_strName);
    13441496}
    13451497
     
    14281580}
    14291581
    1430 void UISoftKeyboardWidget::loadDefaultLayout()
    1431 {
    1432     if (m_layouts.isEmpty())
    1433         return;
    1434     setCurrentLayout(&(m_layouts[0]));
    1435 }
    1436 
    14371582void UISoftKeyboardWidget::showContextMenu(const QPoint &globalPoint)
    14381583{
    14391584    m_pContextMenu->exec(globalPoint);
    14401585    update();
     1586}
     1587
     1588void UISoftKeyboardWidget::applyLayoutByName(const QString &strLayoutName)
     1589{
     1590    UISoftKeyboardLayout *pLayout = findLayoutByName(strLayoutName);
     1591    if (!pLayout)
     1592        return;
     1593    setCurrentLayout(pLayout);
    14411594}
    14421595
     
    15121665    int iInitialWidth = iMaxWidth + m_iRightMargin;
    15131666    int iInitialHeight = iY + m_iBottomMargin;
    1514     float fScale = 1.0f;
    1515     setNewMinimumSize(QSize(fScale * iInitialWidth, fScale * iInitialHeight));
    1516     setInitialSize(fScale * iInitialWidth, fScale * iInitialHeight);
     1667
     1668    setNewMinimumSize(QSize(iInitialWidth, iInitialHeight));
     1669    setInitialSize(iInitialWidth, iInitialHeight);
    15171670    return true;
    15181671}
     
    15441697    UISoftKeyboardLayout &newLayout = m_layouts.back();
    15451698    newLayout.m_pPhysicalLayout = pPhysicalLayout;
    1546     newLayout.m_strName = keyboardLayoutReader.name();
     1699    newLayout.setName(keyboardLayoutReader.name());
    15471700    newLayout.m_keyCapMap = keyboardLayoutReader.keyCapMap();
    15481701    return true;
     
    15551708}
    15561709
    1557 void UISoftKeyboardWidget::configure()
     1710void UISoftKeyboardWidget::loadLayouts()
    15581711{
    15591712    /* Load physical layouts from resources: */
     
    15651718    /* Load keyboard layouts from resources: */
    15661719    QStringList keyboardLayoutNames;
    1567     keyboardLayoutNames << ":/us_international.xml";
     1720    keyboardLayoutNames << ":/us_international.xml"
     1721                        <<":/german.xml";
    15681722    foreach (const QString &strName, keyboardLayoutNames)
    1569     {
    15701723        loadKeyboardLayout(strName);
    1571     }
    1572 
    1573     setMouseTracking(true);
    1574     setContextMenuPolicy(Qt::CustomContextMenu);
    1575     connect(this, &UISoftKeyboardWidget::customContextMenuRequested,
    1576             this, &UISoftKeyboardWidget::sltHandleContextMenuRequest);
     1724    emitLayoutNames();
     1725    if (m_layouts.isEmpty())
     1726        return;
     1727    setCurrentLayout(&(m_layouts[0]));
    15771728}
    15781729
    15791730void UISoftKeyboardWidget::prepareObjects()
    15801731{
    1581     m_pLayoutEditor = new UILayoutEditor(this);
    1582     if (m_pLayoutEditor)
    1583     {
    1584         m_pLayoutEditor->hide();
    1585         m_pLayoutEditor->installEventFilter(this);
    1586 
    1587         QStringList physicalLayoutNames;
    1588         for (int i = 0; i < m_physicalLayouts.size(); ++i)
    1589             physicalLayoutNames << m_physicalLayouts[i].m_strName;
    1590         m_pLayoutEditor->setPhysicalLayoutNames(physicalLayoutNames);
    1591 
    1592         connect(m_pLayoutEditor, &UILayoutEditor::sigKeyCaptionEdited, this, &UISoftKeyboardWidget::sltHandleKeyCaptionEdited);
    1593         connect(m_pLayoutEditor, &UILayoutEditor::sigPhysicalLayoutChanged, this, &UISoftKeyboardWidget::sltPhysicalLayoutForLayoutChanged);
    1594         connect(m_pLayoutEditor, &UILayoutEditor::sigLayoutNameChanged, this, &UISoftKeyboardWidget::sltLayoutNameChange);
    1595     }
    15961732    m_pContextMenu = new QMenu(this);
    15971733
     
    16121748    m_pShowPositionsAction->setChecked(false);
    16131749#endif
     1750
     1751    setMouseTracking(true);
     1752    setContextMenuPolicy(Qt::CustomContextMenu);
     1753    connect(this, &UISoftKeyboardWidget::customContextMenuRequested,
     1754            this, &UISoftKeyboardWidget::sltHandleContextMenuRequest);
    16141755}
    16151756
     
    16191760        return;
    16201761    m_pKeyBeingEdited = pKey;
    1621     if (m_pLayoutEditor)
    1622         m_pLayoutEditor->setKey(pKey);
     1762    // if (m_pLayoutEditor)
     1763    //     m_pLayoutEditor->setKey(pKey);
    16231764}
    16241765
     
    16331774        return;
    16341775    }
    1635     emit sigLayoutChange(m_pCurrentKeyboardLayout->m_strName);
    1636 
    1637     if (m_pLayoutEditor)
    1638         m_pLayoutEditor->setLayoutName(m_pCurrentKeyboardLayout->m_strName);
     1776    emit sigLayoutChange(m_pCurrentKeyboardLayout->name());
     1777
    16391778    const QMap<int, KeyCaptions> &keyCapMap = m_pCurrentKeyboardLayout->m_keyCapMap;
    16401779
     
    16571796}
    16581797
     1798void UISoftKeyboardWidget::emitLayoutNames()
     1799{
     1800    emit sigLayoutListChanged(layoutNameList());
     1801}
     1802
     1803UISoftKeyboardLayout *UISoftKeyboardWidget::findLayoutByName(const QString &strName)
     1804{
     1805    for (int i = 0; i < m_layouts.size(); ++i)
     1806    {
     1807        if (m_layouts[i].name() == strName)
     1808            return &(m_layouts[i]);
     1809    }
     1810    return 0;
     1811}
     1812
     1813QStringList UISoftKeyboardWidget::layoutNameList() const
     1814{
     1815    QStringList layoutNames;
     1816    foreach (const UISoftKeyboardLayout &layout, m_layouts)
     1817        layoutNames << layout.name();
     1818    return layoutNames;
     1819}
     1820
     1821const QVector<UISoftKeyboardPhysicalLayout> &UISoftKeyboardWidget::physicalLayouts() const
     1822{
     1823    return m_physicalLayouts;
     1824}
     1825
    16591826/*********************************************************************************************************************************
    16601827*   UIPhysicalLayoutReader implementation.                                                                                  *
     
    16871854            parseRowSpace(rows);
    16881855        else if (m_xmlReader.name() == "name")
    1689             physicalLayout.m_strName = m_xmlReader.readElementText();
     1856            physicalLayout.setName(m_xmlReader.readElementText());
    16901857        else if (m_xmlReader.name() == "id")
    16911858            physicalLayout.m_uId = m_xmlReader.readElementText();
     
    19522119    , m_pContainerWidget(0)
    19532120    , m_strMachineName(strMachineName)
     2121    , m_pSplitter(0)
    19542122    , m_pSettingsButton(0)
     2123    , m_pSidePanelContainerWidget(0)
     2124    , m_pLayoutEditor(0)
    19552125{
    19562126    setWindowTitle(QString("%1 - %2").arg(m_strMachineName).arg(tr("Soft Keyboard")));
     
    19602130
    19612131    if (m_pContainerWidget)
    1962         m_pContainerWidget->loadDefaultLayout();
     2132        m_pContainerWidget->loadLayouts();
    19632133
    19642134    loadSettings();
     
    20092179}
    20102180
    2011 void UISoftKeyboard::sltHandleLayoutChange(const QString &strLayoutName)
    2012 {
    2013     if (m_strLayoutName == strLayoutName)
    2014         return;
    2015     m_strLayoutName = strLayoutName;
    2016     updateStatusBarMessage();
    2017 }
    2018 
    2019 void UISoftKeyboard::sltHandleKeyCapFileChange(const QString &strKeyCapFileName)
    2020 {
    2021     if (strKeyCapFileName == m_strKeyCapFileName)
    2022         return;
    2023     m_strKeyCapFileName = strKeyCapFileName;
    2024     updateStatusBarMessage();
    2025 }
    2026 
    20272181void UISoftKeyboard::sltHandleStatusBarContextMenuRequest(const QPoint &point)
    20282182{
     
    20332187void UISoftKeyboard::prepareObjects()
    20342188{
     2189    m_pSplitter = new QSplitter;
     2190    if (!m_pSplitter)
     2191        return;
     2192    setCentralWidget(m_pSplitter);
     2193
     2194    m_pSidePanelContainerWidget = new QStackedWidget;
     2195    m_pSplitter->addWidget(m_pSidePanelContainerWidget);
     2196
     2197    m_pLayoutSelector = new UILayoutSelector;
     2198    if (m_pLayoutSelector)
     2199        m_pSidePanelContainerWidget->addWidget(m_pLayoutSelector);
     2200
     2201    m_pLayoutEditor = new UILayoutEditor;
     2202    if (m_pLayoutEditor)
     2203        m_pSidePanelContainerWidget->addWidget(m_pLayoutEditor);
     2204
    20352205    m_pContainerWidget = new UISoftKeyboardWidget;
    20362206    if (!m_pContainerWidget)
    20372207        return;
    20382208    m_pContainerWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
    2039     setCentralWidget(m_pContainerWidget);
    20402209    m_pContainerWidget->updateGeometry();
    2041 
     2210    m_pSplitter->addWidget(m_pContainerWidget);
    20422211
    20432212    statusBar()->setContextMenuPolicy(Qt::CustomContextMenu);
     
    20622231    connect(m_pSession, &UISession::sigKeyboardLedsChange, this, &UISoftKeyboard::sltHandleKeyboardLedsChange);
    20632232    connect(m_pContainerWidget, &UISoftKeyboardWidget::sigPutKeyboardSequence, this, &UISoftKeyboard::sltHandlePutKeyboardSequence);
    2064     connect(m_pContainerWidget, &UISoftKeyboardWidget::sigLayoutChange, this, &UISoftKeyboard::sltHandleLayoutChange);
    2065     connect(m_pContainerWidget, &UISoftKeyboardWidget::sigKeyCapChange, this, &UISoftKeyboard::sltHandleKeyCapFileChange);
    20662233}
    20672234
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h

    r79089 r79172  
    3737class QHBoxLayout;
    3838class QVBoxLayout;
    39 class UISoftKeyboardWidget;
    4039class QToolButton;
     40class UILayoutEditor;
     41class UILayoutSelector;
    4142class UISession;
    4243class UISoftKeyboardKey;
     44class UISoftKeyboardLayout;
     45class UISoftKeyboardWidget;
     46class QSplitter;
     47class QStackedWidget;
    4348
    4449class UISoftKeyboard : public QIWithRetranslateUI<QMainWindow>
     
    6166    void sltHandleKeyboardLedsChange();
    6267    void sltHandlePutKeyboardSequence(QVector<LONG> sequence);
    63     void sltHandleLayoutChange(const QString &strLayoutName);
    64     void sltHandleKeyCapFileChange(const QString &strKeyCapFileName);
    6568    void sltHandleStatusBarContextMenuRequest(const QPoint &point);
    6669
     
    8083    QString       m_strLayoutName;
    8184    QString       m_strKeyCapFileName;
    82     QToolButton   *m_pSettingsButton;
     85    QSplitter      *m_pSplitter;
     86    QToolButton    *m_pSettingsButton;
     87    QStackedWidget *m_pSidePanelContainerWidget;
     88    UILayoutEditor *m_pLayoutEditor;
     89    UILayoutSelector *m_pLayoutSelector;
    8390};
    8491
  • trunk/src/VBox/Frontends/VirtualBox/xml/german.xml

    r79130 r79172  
    11<?xml version="1.0" encoding="UTF-8"?>
    22<layout>
    3     <name>US International</name>
     3    <name>German</name>
    44    <physicallayoutid>{368efa94-3744-48c5-9d5a-59c2f15fe5ec}</physicallayoutid>
    55    <key>
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