VirtualBox

Ignore:
Timestamp:
Jun 19, 2019 4:05:53 PM (6 years ago)
Author:
vboxsync
Message:

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

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

Legend:

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

    r79172 r79248  
    55        <file alias="us_international.xml">xml/us_international.xml</file>
    66        <file alias="german.xml">xml/german.xml</file>
     7        <file alias="us.xml">xml/us.xml</file>
    78    </qresource>
    89</RCC>
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp

    r79212 r79248  
    4141#include "UIExtraDataManager.h"
    4242#include "UIIconPool.h"
     43#include "UIMessageCenter.h"
    4344#include "UIModalWindowManager.h"
    4445#include "UISession.h"
     
    143144private slots:
    144145
    145     void sltKeyBaseCaptionChange();
    146     void sltKeyShiftCaptionChange();
    147     void sltKeyAltGrCaptionChange();
     146    void sltKeyBaseCaptionChange(const QString &strCaption);
     147    void sltKeyShiftCaptionChange(const QString &strCaption);
     148    void sltKeyAltGrCaptionChange(const QString &strCaption);
    148149    void sltPhysicalLayoutChanged();
     150    void sltLayoutNameChanged(const QString &strCaption);
    149151
    150152private:
     
    195197    void sigSaveLayout();
    196198    void sigCopyLayout();
     199    void sigDeleteLayout();
    197200    void sigLayoutSelectionChanged(const QString &strSelectedLayoutName);
    198201    void sigShowLayoutEditor();
     
    204207    void setLayoutList(const QStringList &layoutNames);
    205208    void setCurrentLayout(const QString &strLayoutName);
     209    void setCurrentLayoutIsEditable(bool fEditable);
    206210
    207211protected:
     
    221225    QToolButton *m_pCopyLayoutButton;
    222226    QToolButton *m_pSaveLayoutButton;
     227    QToolButton *m_pDeleteLayoutButton;
    223228    QLabel      *m_pTitleLabel;
    224229    QToolButton *m_pCloseButton;
     
    364369public:
    365370
    366     UISoftKeyboardLayout(){}
    367 
    368     void setName(const QString &strName)
    369     {
    370         m_strName = strName;
    371     }
    372 
    373     void updateKeyCaptions(int iKeyPosition, KeyCaptions &newCaptions)
    374     {
    375         if (!m_keyCapMap.contains(iKeyPosition))
    376             return;
    377         m_keyCapMap[iKeyPosition] = newCaptions;
    378     }
    379 
    380     const QString &name() const
    381     {
    382         return m_strName;
    383     }
     371    UISoftKeyboardLayout();
     372
     373    void setName(const QString &strName);
     374    const QString &name() const;
     375
     376    void setSourceFilePath(const QString& strSourceFilePath);
     377    const QString& sourceFilePath() const;
     378
     379    void setIsFromResources(bool fIsFromResources);
     380    bool isFromResources() const;
     381
     382    void updateKeyCaptions(int iKeyPosition, KeyCaptions &newCaptions);
     383
     384    void setEditable(bool fEditable);
     385    bool editable() const;
     386
     387    void setPhysicalLayoutUuid(const QUuid &uuid);
     388    const QUuid &physicalLayoutUuid() const;
     389
     390    void setKeyCapMap(const QMap<int, KeyCaptions> &keyCapMap);
     391    QMap<int, KeyCaptions> &keyCapMap();
     392    const QMap<int, KeyCaptions> &keyCapMap() const;
     393    bool operator==(const UISoftKeyboardLayout &otherLayout);
     394
     395private:
    384396
    385397    /** The UUID of the physical layout used by this layout. */
     
    390402    QMap<int, KeyCaptions> m_keyCapMap;
    391403
    392 private:
    393 
    394404    QString m_strName;
     405    QString m_strSourceFilePath;
     406    bool    m_fEditable;
     407    bool    m_fIsFromResources;
    395408};
    396409
     
    432445    QStringList layoutNameList() const;
    433446    const QVector<UISoftKeyboardPhysicalLayout> &physicalLayouts() const;
    434 
     447    void deleteCurrentLayout();
    435448    void toggleEditMode(bool fIsEditMode);
    436449    /** Is called when the captions in UISoftKeyboardKey is changed and forward this changes to
    437450      * corresponding UISoftKeyboardLayout */
    438451    void updateKeyCaptionsInLayout(UISoftKeyboardKey *pKey);
    439     void addLayout(const UISoftKeyboardLayout &newLayout);
    440452    void saveCurentLayoutToFile();
     453    void copyCurentLayout();
    441454
    442455protected:
     
    455468private:
    456469
    457     void               setNewMinimumSize(const QSize &size);
    458     void               setInitialSize(int iWidth, int iHeight);
     470    void    addLayout(const UISoftKeyboardLayout &newLayout);
     471    void    setNewMinimumSize(const QSize &size);
     472    void    setInitialSize(int iWidth, int iHeight);
    459473    /** Searches for the key which contains the position of the @p pEvent and returns it if found. */
    460474    UISoftKeyboardKey *keyUnderMouse(QMouseEvent *pEvent);
     
    620634    if (m_pKey == pKey)
    621635        return;
     636    /* First apply the pending changes to the key that has been edited: */
     637    if (m_pKey)
     638    {
     639        if (m_pKey->shiftCaption() != m_pShiftCaptionEdit->text())
     640            m_pKey->setShiftCaption(m_pShiftCaptionEdit->text());
     641        if (m_pKey->baseCaption() != m_pBaseCaptionEdit->text())
     642            m_pKey->setBaseCaption(m_pBaseCaptionEdit->text());
     643        if (m_pKey->altGrCaption() != m_pAltGrCaptionEdit->text())
     644            m_pKey->setAltGrCaption(m_pAltGrCaptionEdit->text());
     645    }
     646
    622647    m_pKey = pKey;
    623648    if (m_pSelectedKeyGroupBox)
     
    651676    if (m_pPhysicalLayoutCombo && m_pLayout)
    652677    {
    653         int iIndex = m_pPhysicalLayoutCombo->findData(m_pLayout->m_physicalLayoutUuid);
     678        int iIndex = m_pPhysicalLayoutCombo->findData(m_pLayout->physicalLayoutUuid());
    654679        if (iIndex != -1)
    655680            m_pPhysicalLayoutCombo->setCurrentIndex(iIndex);
     
    693718}
    694719
    695 void UILayoutEditor::sltKeyBaseCaptionChange()
    696 {
    697     if (!m_pKey || !m_pBaseCaptionEdit)
    698         return;
    699     m_pKey->setBaseCaption(m_pBaseCaptionEdit->text());
     720void UILayoutEditor::sltKeyBaseCaptionChange(const QString &strCaption)
     721{
     722    if (!m_pKey || m_pKey->baseCaption() == strCaption)
     723        return;
     724    m_pKey->setBaseCaption(strCaption);
    700725    emit sigKeyCaptionsEdited(m_pKey);
    701726}
    702727
    703 void UILayoutEditor::sltKeyShiftCaptionChange()
    704 {
    705     if (!m_pKey || !m_pShiftCaptionEdit)
    706         return;
    707     m_pKey->setShiftCaption(m_pShiftCaptionEdit->text());
     728void UILayoutEditor::sltKeyShiftCaptionChange(const QString &strCaption)
     729{
     730    if (!m_pKey || m_pKey->shiftCaption() == strCaption)
     731        return;
     732    m_pKey->setShiftCaption(strCaption);
    708733    emit sigKeyCaptionsEdited(m_pKey);
    709734}
    710735
    711 void UILayoutEditor::sltKeyAltGrCaptionChange()
    712 {
    713     if (!m_pKey || !m_pAltGrCaptionEdit)
    714         return;
    715     m_pKey->setAltGrCaption(m_pAltGrCaptionEdit->text());
     736void UILayoutEditor::sltKeyAltGrCaptionChange(const QString &strCaption)
     737{
     738    if (!m_pKey  || m_pKey->altGrCaption() == strCaption)
     739        return;
     740    m_pKey->setAltGrCaption(strCaption);
    716741    emit sigKeyCaptionsEdited(m_pKey);
    717742}
     
    723748    QUuid currentData = m_pPhysicalLayoutCombo->currentData().toUuid();
    724749    if (!currentData.isNull())
    725         m_pLayout->m_physicalLayoutUuid = currentData;
     750        m_pLayout->setPhysicalLayoutUuid(currentData);
     751    emit sigLayoutEdited();
     752}
     753
     754void UILayoutEditor::sltLayoutNameChanged(const QString &strName)
     755{
     756    if (!m_pLayout || m_pLayout->name() == strName)
     757        return;
     758    m_pLayout->setName(strName);
    726759    emit sigLayoutEdited();
    727760}
     
    739772    m_pGoBackButton->setStyleSheet("QToolButton { border: 0px none black; margin: 0px 0px 0px 0px; } QToolButton::menu-indicator {image: none;}");
    740773    m_pEditorLayout->addWidget(m_pGoBackButton, 0, 0, 1, 1);
    741     connect(m_pGoBackButton, &QToolButton::pressed, this, &UILayoutEditor::sigGoBackButton);
     774    connect(m_pGoBackButton, &QToolButton::clicked, this, &UILayoutEditor::sigGoBackButton);
    742775    pTitleLayout->addWidget(m_pGoBackButton);
    743776    pTitleLayout->addStretch(2);
     
    752785    m_pEditorLayout->addWidget(m_pLayoutNameLabel, 2, 0, 1, 1);
    753786    m_pEditorLayout->addWidget(m_pLayoutNameEdit, 2, 1, 1, 1);
    754     connect(m_pLayoutNameEdit, &QLineEdit::editingFinished, this, &UILayoutEditor::sigLayoutEdited);
     787    connect(m_pLayoutNameEdit, &QLineEdit::textChanged, this, &UILayoutEditor::sltLayoutNameChanged);
    755788
    756789
     
    814847    pCaptionEditorLayout->addWidget(m_pBaseCaptionLabel, 0, 0);
    815848    pCaptionEditorLayout->addWidget(m_pBaseCaptionEdit, 0, 1);
    816     connect(m_pBaseCaptionEdit, &QLineEdit::editingFinished, this, &UILayoutEditor::sltKeyBaseCaptionChange);
     849    connect(m_pBaseCaptionEdit, &QLineEdit::textChanged, this, &UILayoutEditor::sltKeyBaseCaptionChange);
    817850
    818851    m_pShiftCaptionLabel = new QLabel;
     
    821854    pCaptionEditorLayout->addWidget(m_pShiftCaptionLabel, 1, 0);
    822855    pCaptionEditorLayout->addWidget(m_pShiftCaptionEdit, 1, 1);
    823     connect(m_pShiftCaptionEdit, &QLineEdit::editingFinished, this, &UILayoutEditor::sltKeyShiftCaptionChange);
     856    connect(m_pShiftCaptionEdit, &QLineEdit::textChanged, this, &UILayoutEditor::sltKeyShiftCaptionChange);
    824857
    825858    m_pAltGrCaptionLabel = new QLabel;
     
    828861    pCaptionEditorLayout->addWidget(m_pAltGrCaptionLabel, 2, 0);
    829862    pCaptionEditorLayout->addWidget(m_pAltGrCaptionEdit, 2, 1);
    830     connect(m_pAltGrCaptionEdit, &QLineEdit::editingFinished, this, &UILayoutEditor::sltKeyAltGrCaptionChange);
     863    connect(m_pAltGrCaptionEdit, &QLineEdit::textChanged, this, &UILayoutEditor::sltKeyAltGrCaptionChange);
    831864
    832865    QSpacerItem *pSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding);
     
    863896    , m_pCopyLayoutButton(0)
    864897    , m_pSaveLayoutButton(0)
     898    , m_pDeleteLayoutButton(0)
    865899    , m_pTitleLabel(0)
    866900    , m_pCloseButton(0)
     
    885919        return;
    886920    m_pLayoutListWidget->setCurrentItem(pItem);
     921}
     922
     923void UILayoutSelector::setCurrentLayoutIsEditable(bool fEditable)
     924{
     925    if (m_pEditLayoutButton)
     926        m_pEditLayoutButton->setEnabled(fEditable);
     927    if (m_pSaveLayoutButton)
     928        m_pSaveLayoutButton->setEnabled(fEditable);
     929    if (m_pDeleteLayoutButton)
     930        m_pDeleteLayoutButton->setEnabled(fEditable);
    887931}
    888932
     
    902946    if (m_pEditLayoutButton)
    903947        m_pEditLayoutButton->setToolTip(UISoftKeyboard::tr("Edit the selected layout"));
     948    if (m_pDeleteLayoutButton)
     949        m_pDeleteLayoutButton->setToolTip(UISoftKeyboard::tr("Delete the selected layout"));
    904950    if (m_pCopyLayoutButton)
    905951        m_pCopyLayoutButton->setToolTip(UISoftKeyboard::tr("Copy the selected layout"));
     
    924970    m_pCloseButton->setIcon(UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_DialogCancel));
    925971    m_pCloseButton->setStyleSheet("QToolButton { border: 0px none black; margin: 0px 0px 0px 0px; } QToolButton::menu-indicator {image: none;}");
    926     connect(m_pCloseButton, &QToolButton::pressed, this, &UILayoutSelector::sigCloseLayoutList);
     972    connect(m_pCloseButton, &QToolButton::clicked, this, &UILayoutSelector::sigCloseLayoutList);
    927973    pTitleLayout->addWidget(m_pCloseButton);
    928974    pTitleLayout->addStretch(2);
     
    941987    m_pEditLayoutButton->setIcon(UIIconPool::iconSet(":/keyboard_settings_16px.png"));
    942988    pButtonsLayout->addWidget(m_pEditLayoutButton);
    943     connect(m_pEditLayoutButton, &QToolButton::pressed, this, &UILayoutSelector::sigShowLayoutEditor);
     989    connect(m_pEditLayoutButton, &QToolButton::clicked, this, &UILayoutSelector::sigShowLayoutEditor);
    944990
    945991    m_pCopyLayoutButton = new QToolButton;
    946992    m_pCopyLayoutButton->setIcon(UIIconPool::iconSet(":/vm_clone_16px.png"));
    947993    pButtonsLayout->addWidget(m_pCopyLayoutButton);
    948     connect(m_pCopyLayoutButton, &QToolButton::pressed, this, &UILayoutSelector::sigCopyLayout);
     994    connect(m_pCopyLayoutButton, &QToolButton::clicked, this, &UILayoutSelector::sigCopyLayout);
    949995
    950996    m_pSaveLayoutButton = new QToolButton;
    951997    m_pSaveLayoutButton->setIcon(UIIconPool::iconSet(":/vm_save_state_16px.png"));
    952998    pButtonsLayout->addWidget(m_pSaveLayoutButton);
    953     connect(m_pSaveLayoutButton, &QToolButton::pressed, this, &UILayoutSelector::sigSaveLayout);
    954 
     999    connect(m_pSaveLayoutButton, &QToolButton::clicked, this, &UILayoutSelector::sigSaveLayout);
     1000
     1001    m_pDeleteLayoutButton = new QToolButton;
     1002    m_pDeleteLayoutButton->setIcon(UIIconPool::iconSet(":/file_manager_delete_16px.png"));
     1003    pButtonsLayout->addWidget(m_pDeleteLayoutButton);
     1004    connect(m_pDeleteLayoutButton, &QToolButton::clicked, this, &UILayoutSelector::sigDeleteLayout);
    9551005
    9561006    pButtonsLayout->addStretch(2);
     
    12581308        m_strText += QString("%1\n").arg(m_strAltGrCaption);
    12591309}
     1310
     1311/*********************************************************************************************************************************
     1312*   UISoftKeyboardLayout implementation.                                                                                  *
     1313*********************************************************************************************************************************/
     1314
     1315UISoftKeyboardLayout::UISoftKeyboardLayout()
     1316    : m_fEditable(true)
     1317    , m_fIsFromResources(false)
     1318{
     1319}
     1320
     1321void UISoftKeyboardLayout::updateKeyCaptions(int iKeyPosition, KeyCaptions &newCaptions)
     1322{
     1323    if (!m_keyCapMap.contains(iKeyPosition))
     1324        return;
     1325    m_keyCapMap[iKeyPosition] = newCaptions;
     1326}
     1327
     1328void UISoftKeyboardLayout::setSourceFilePath(const QString& strSourceFilePath)
     1329{
     1330    m_strSourceFilePath = strSourceFilePath;
     1331}
     1332
     1333const QString& UISoftKeyboardLayout::sourceFilePath() const
     1334{
     1335    return m_strSourceFilePath;
     1336}
     1337
     1338void UISoftKeyboardLayout::setIsFromResources(bool fIsFromResources)
     1339{
     1340    m_fIsFromResources = fIsFromResources;
     1341}
     1342
     1343bool UISoftKeyboardLayout::isFromResources() const
     1344{
     1345    return m_fIsFromResources;
     1346}
     1347
     1348void UISoftKeyboardLayout::setName(const QString &strName)
     1349{
     1350    m_strName = strName;
     1351}
     1352
     1353const QString &UISoftKeyboardLayout::name() const
     1354{
     1355    return m_strName;
     1356}
     1357
     1358void UISoftKeyboardLayout::setEditable(bool fEditable)
     1359{
     1360    m_fEditable = fEditable;
     1361}
     1362
     1363bool UISoftKeyboardLayout::editable() const
     1364{
     1365    return m_fEditable;
     1366}
     1367
     1368void UISoftKeyboardLayout::setPhysicalLayoutUuid(const QUuid &uuid)
     1369{
     1370    m_physicalLayoutUuid = uuid;
     1371}
     1372
     1373const QUuid &UISoftKeyboardLayout::physicalLayoutUuid() const
     1374{
     1375    return m_physicalLayoutUuid;
     1376}
     1377
     1378void UISoftKeyboardLayout::setKeyCapMap(const QMap<int, KeyCaptions> &keyCapMap)
     1379{
     1380    m_keyCapMap = keyCapMap;
     1381}
     1382
     1383QMap<int, KeyCaptions> &UISoftKeyboardLayout::keyCapMap()
     1384{
     1385    return m_keyCapMap;
     1386}
     1387
     1388const QMap<int, KeyCaptions> &UISoftKeyboardLayout::keyCapMap() const
     1389{
     1390    return m_keyCapMap;
     1391}
     1392
     1393bool UISoftKeyboardLayout::operator==(const UISoftKeyboardLayout &otherLayout)
     1394{
     1395    if (m_strName != otherLayout.m_strName)
     1396        return false;
     1397    if (m_physicalLayoutUuid != otherLayout.m_physicalLayoutUuid)
     1398        return false;
     1399    if (m_fEditable != otherLayout.m_fEditable)
     1400        return false;
     1401    if (m_strSourceFilePath != otherLayout.m_strSourceFilePath)
     1402        return false;
     1403    if (m_fIsFromResources != otherLayout.m_fIsFromResources)
     1404        return false;
     1405    return true;
     1406}
     1407
    12601408
    12611409/*********************************************************************************************************************************
     
    13201468        return;
    13211469
    1322     UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->m_physicalLayoutUuid);
     1470    UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->physicalLayoutUuid());
    13231471    if (!pPhysicalLayout)
    13241472        return;
     
    13851533        handleKeyPress(m_pKeyPressed);
    13861534    else if (m_enmMode == Mode_LayoutEdit)
    1387     {
    1388         /* If the editor is shown already for another key clicking away accepts the entered text: */
    1389         if (m_pKeyBeingEdited && m_pKeyBeingEdited != m_pKeyUnderMouse)
    1390         {
    1391             //printf("farkli %p\n", m_pKeyBeingEdited);
    1392         }
    13931535        setKeyBeingEdited(m_pKeyUnderMouse);
    1394         // if (m_pKeyBeingEdited && m_pLayoutEditor)
    1395         //     m_pLayoutEditor->setText(m_pKeyBeingEdited->keyCap());
    1396     }
    13971536    update();
    13981537}
     
    14301569void UISoftKeyboardWidget::saveCurentLayoutToFile()
    14311570{
     1571    if (!m_pCurrentKeyboardLayout)
     1572        return;
     1573
    14321574    QString strHomeFolder = vboxGlobal().homeFolder();
    14331575    QDir dir(strHomeFolder);
     
    14461588    dialog.setWindowModality(Qt::WindowModal);
    14471589    dialog.setWindowTitle(UISoftKeyboard::tr("Provide a file name"));
    1448     dialog.setLabelText(QString("%1 %2").arg(UISoftKeyboard::tr("The File will be saved under:\n")).arg(strHomeFolder));
     1590    dialog.setTextValue(m_pCurrentKeyboardLayout->name());
     1591    dialog.setLabelText(QString("%1 %2").arg(UISoftKeyboard::tr("The file will be saved under:\n")).arg(strHomeFolder));
    14491592    if (dialog.exec() == QDialog::Rejected)
    14501593        return;
     
    14561599    }
    14571600
    1458     if (!m_pCurrentKeyboardLayout)
    1459         return;
    1460 
    1461     UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->m_physicalLayoutUuid);
     1601    UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->physicalLayoutUuid());
    14621602    if (!pPhysicalLayout)
    14631603    {
     
    14711611    strFileName = strHomeFolder + QString(QDir::separator()) + strFileName;
    14721612    QFile xmlFile(strFileName);
    1473     if (!xmlFile.open(QIODevice::WriteOnly))
     1613    if (!xmlFile.open(QIODevice::WriteOnly | QIODevice::Truncate))
    14741614    {
    14751615        sigStatusBarMessage("The layout file could not be saved");
     
    15071647
    15081648   xmlFile.close();
    1509 
     1649   m_pCurrentKeyboardLayout->setSourceFilePath(strFileName);
    15101650   sigStatusBarMessage(QString("%1 %2").arg(strFileName).arg(UISoftKeyboard::tr(" is saved")));
     1651}
     1652
     1653void UISoftKeyboardWidget::copyCurentLayout()
     1654{
     1655    UISoftKeyboardLayout newLayout(*(m_pCurrentKeyboardLayout));
     1656    QString strNewName = QString("%1-%2").arg(newLayout.name()).arg(tr("Copy"));
     1657    newLayout.setName(strNewName);
     1658    newLayout.setEditable(true);
     1659    newLayout.setIsFromResources(false);
     1660    newLayout.setSourceFilePath(QString());
     1661    addLayout(newLayout);
     1662}
     1663
     1664void UISoftKeyboardWidget::deleteCurrentLayout()
     1665{
     1666    if (!m_pCurrentKeyboardLayout || !m_pCurrentKeyboardLayout->editable() || m_pCurrentKeyboardLayout->isFromResources())
     1667        return;
     1668    /* Make sure we have at least one layout. */
     1669    if (m_layouts.size() <= 1)
     1670        return;
     1671
     1672    int iIndex = m_layouts.indexOf(*(m_pCurrentKeyboardLayout));
     1673    if (iIndex == -1)
     1674        return;
     1675
     1676    QDir fileToDelete;
     1677    QString strFilePath(m_pCurrentKeyboardLayout->sourceFilePath());
     1678    bool fFileExists = fileToDelete.exists(strFilePath);
     1679
     1680    if (fFileExists)
     1681    {
     1682        if (!msgCenter().questionBinary(this, MessageType_Question,
     1683                                        QString(UISoftKeyboard::tr("This will delete the keyboard layout file as well, Proceed?")),
     1684                                        0 /* auto-confirm id */,
     1685                                        QString("Delete") /* ok button text */,
     1686                                        QString() /* cancel button text */,
     1687                                        false /* ok button by default? */))
     1688            return;
     1689    }
     1690
     1691    m_layouts.removeAt(iIndex);
     1692    setCurrentLayout(&(m_layouts[0]));
     1693    /* It might be that the layout copied but not yet saved into a file: */
     1694    if (fFileExists)
     1695    {
     1696        if (fileToDelete.remove(strFilePath))
     1697            sigStatusBarMessage(QString("%1 %2 %3").arg(UISoftKeyboard::tr("The file ")).arg(strFilePath).arg(UISoftKeyboard::tr(" has been deleted")));
     1698        else
     1699            sigStatusBarMessage(QString("%1 %2 %3").arg(UISoftKeyboard::tr("Deleting the file ")).arg(strFilePath).arg(UISoftKeyboard::tr(" has failed")));
     1700    }
    15111701}
    15121702
     
    15471737        return;
    15481738
    1549     if (m_pCurrentKeyboardLayout->m_physicalLayoutUuid == m_physicalLayouts[iIndex].m_uId)
    1550         return;
    1551     m_pCurrentKeyboardLayout->m_physicalLayoutUuid = m_physicalLayouts[iIndex].m_uId;
     1739    if (m_pCurrentKeyboardLayout->physicalLayoutUuid() == m_physicalLayouts[iIndex].m_uId)
     1740        return;
     1741    m_pCurrentKeyboardLayout->setPhysicalLayoutUuid(m_physicalLayouts[iIndex].m_uId);
    15521742    update();
    15531743}
     
    15751765    if (!m_pCurrentKeyboardLayout)
    15761766        return 0;
    1577     UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->m_physicalLayoutUuid);
     1767    UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->physicalLayoutUuid());
    15781768    if (!pPhysicalLayout)
    15791769        return 0;
     
    17371927}
    17381928
    1739 bool UISoftKeyboardWidget::loadKeyboardLayout(const QString &strLayoutName)
    1740 {
    1741     if (strLayoutName.isEmpty())
     1929bool UISoftKeyboardWidget::loadKeyboardLayout(const QString &strLayoutFileName)
     1930{
     1931    if (strLayoutFileName.isEmpty())
    17421932        return false;
    17431933
    17441934    UIKeyboardLayoutReader keyboardLayoutReader;
    17451935
    1746     if (!keyboardLayoutReader.parseFile(strLayoutName))
     1936    if (!keyboardLayoutReader.parseFile(strLayoutFileName))
    17471937        return false;
    17481938
     
    17541944    m_layouts.append(UISoftKeyboardLayout());
    17551945    UISoftKeyboardLayout &newLayout = m_layouts.back();
    1756     newLayout.m_physicalLayoutUuid = pPhysicalLayout->m_uId;
     1946    newLayout.setPhysicalLayoutUuid(pPhysicalLayout->m_uId);
    17571947    newLayout.setName(keyboardLayoutReader.name());
    1758     newLayout.m_keyCapMap = keyboardLayoutReader.keyCapMap();
     1948    newLayout.setSourceFilePath(strLayoutFileName);
     1949    newLayout.setKeyCapMap(keyboardLayoutReader.keyCapMap());
    17591950    return true;
    17601951}
     
    17861977    QStringList keyboardLayoutNames;
    17871978    keyboardLayoutNames << ":/us_international.xml"
    1788                         <<":/german.xml";
     1979                        <<":/german.xml"
     1980                        << ":/us.xml";
     1981
     1982    foreach (const QString &strName, keyboardLayoutNames)
     1983        loadKeyboardLayout(strName);
     1984    /* Mark the layouts we load from the resources as non-editable: */
     1985    for (int i = 0; i < m_layouts.size(); ++i)
     1986    {
     1987        m_layouts[i].setEditable(false);
     1988        m_layouts[i].setIsFromResources(true);
     1989    }
     1990    keyboardLayoutNames.clear();
    17891991    /* Add keyboard layouts from the defalt keyboard layout folder: */
    17901992    lookAtDefaultLayoutFolder(keyboardLayoutNames);
     
    18332035    emit sigCurrentLayoutChange();
    18342036
    1835     const QMap<int, KeyCaptions> &keyCapMap = m_pCurrentKeyboardLayout->m_keyCapMap;
    1836 
    1837    UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->m_physicalLayoutUuid);
     2037    const QMap<int, KeyCaptions> &keyCapMap = m_pCurrentKeyboardLayout->keyCapMap();
     2038
     2039    UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->physicalLayoutUuid());
    18382040    if (!pPhysicalLayout)
    18392041        return;
     
    22142416        m_pLayoutListButton->resize(QSize(iIconMetric, iIconMetric));
    22152417        m_pLayoutListButton->setStyleSheet("QToolButton { border: 0px none black; margin: 0px 0px 0px 0px; } QToolButton::menu-indicator {image: none;}");
    2216         connect(m_pLayoutListButton, &QToolButton::pressed, this, &UISoftKeyboardStatusBarWidget::sigShowHideSidePanel);
     2418        connect(m_pLayoutListButton, &QToolButton::clicked, this, &UISoftKeyboardStatusBarWidget::sigShowHideSidePanel);
    22172419        pLayout->addWidget(m_pLayoutListButton);
    22182420    }
     
    22932495void UISoftKeyboard::sltLayoutSelectionChanged(const QString &strLayoutName)
    22942496{
    2295     if (m_pKeyboardWidget)
    2296         m_pKeyboardWidget->setCurrentLayout(strLayoutName);
     2497    if (!m_pKeyboardWidget)
     2498        return;
     2499    m_pKeyboardWidget->setCurrentLayout(strLayoutName);
     2500    if (m_pLayoutSelector && m_pKeyboardWidget->currentLayout())
     2501        m_pLayoutSelector->setCurrentLayoutIsEditable(m_pKeyboardWidget->currentLayout()->editable());
    22972502}
    22982503
     
    23062511    QString strLayoutName = pCurrentLayout ? pCurrentLayout->name() : QString();
    23072512    updateStatusBarMessage(strLayoutName);
     2513    updateLayoutSelector();
    23082514}
    23092515
     
    23392545    m_pKeyboardWidget->update();
    23402546    updateLayoutSelector();
     2547    UISoftKeyboardLayout *pCurrentLayout = m_pKeyboardWidget->currentLayout();
     2548
     2549    /* Update the status bar string: */
     2550    QString strLayoutName = pCurrentLayout ? pCurrentLayout->name() : QString();
     2551    updateStatusBarMessage(strLayoutName);
    23412552}
    23422553
     
    23592570void UISoftKeyboard::sltCopyLayout()
    23602571{
    2361     if (!m_pKeyboardWidget || !m_pKeyboardWidget->currentLayout())
    2362         return;
    2363     UISoftKeyboardLayout newLayout(*(m_pKeyboardWidget->currentLayout()));
    2364     QString strNewName = QString("%1-%2").arg(newLayout.name()).arg(tr("Copy"));
    2365     newLayout.setName(strNewName);
    2366     m_pKeyboardWidget->addLayout(newLayout);
     2572    if (!m_pKeyboardWidget)
     2573        return;
     2574    m_pKeyboardWidget->copyCurentLayout();
    23672575    updateLayoutSelector();
    23682576}
     
    23722580    if (m_pKeyboardWidget)
    23732581        m_pKeyboardWidget->saveCurentLayoutToFile();
     2582}
     2583
     2584void UISoftKeyboard::sltDeleteLayout()
     2585{
     2586    if (m_pKeyboardWidget)
     2587        m_pKeyboardWidget->deleteCurrentLayout();
    23742588}
    23752589
     
    24292643    connect(m_pLayoutSelector, &UILayoutSelector::sigCloseLayoutList, this, &UISoftKeyboard::sltShowHideSidePanel);
    24302644    connect(m_pLayoutSelector, &UILayoutSelector::sigSaveLayout, this, &UISoftKeyboard::sltSaveLayout);
     2645    connect(m_pLayoutSelector, &UILayoutSelector::sigDeleteLayout, this, &UISoftKeyboard::sltDeleteLayout);
    24312646    connect(m_pLayoutSelector, &UILayoutSelector::sigCopyLayout, this, &UISoftKeyboard::sltCopyLayout);
    24322647    connect(m_pLayoutEditor, &UILayoutEditor::sigGoBackButton, this, &UISoftKeyboard::sltShowLayoutSelector);
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h

    r79212 r79248  
    8181    void sltCopyLayout();
    8282    void sltSaveLayout();
     83    void sltDeleteLayout();
    8384    void sltStatusBarMessage(const QString &strMessage);
    8485
  • trunk/src/VBox/Frontends/VirtualBox/xml/us.xml

    r79184 r79248  
    11<?xml version="1.0" encoding="UTF-8"?>
    22<layout>
    3     <name>German</name>
     3    <name>US</name>
    44    <physicallayoutid>{368efa94-3744-48c5-9d5a-59c2f15fe5ec}</physicallayoutid>
    55    <key>
    66        <position>110</position>
    7         <basecaption>Escxx</basecaption>
     7        <basecaption>Esc</basecaption>
    88        <shiftcaption></shiftcaption>
    99        <altgrcaption></altgrcaption>
     
    8383    <key>
    8484        <position>124</position>
    85         <basecaption></basecaption>
    86         <shiftcaption></shiftcaption>
     85        <basecaption>Prt Scrn</basecaption>
     86        <shiftcaption>Sys Rq</shiftcaption>
    8787        <altgrcaption></altgrcaption>
    8888    </key>
    8989    <key>
    9090        <position>125</position>
    91         <basecaption></basecaption>
     91        <basecaption>Scroll Lock</basecaption>
    9292        <shiftcaption></shiftcaption>
    9393        <altgrcaption></altgrcaption>
     
    9595    <key>
    9696        <position>126</position>
    97         <basecaption></basecaption>
     97        <basecaption>Pause Break</basecaption>
    9898        <shiftcaption></shiftcaption>
    9999        <altgrcaption></altgrcaption>
     
    131131    <key>
    132132        <position>6</position>
    133         <basecaption></basecaption>
    134         <shiftcaption></shiftcaption>
     133        <basecaption>5</basecaption>
     134        <shiftcaption>%</shiftcaption>
    135135        <altgrcaption></altgrcaption>
    136136    </key>
     
    143143    <key>
    144144        <position>8</position>
    145         <basecaption></basecaption>
    146         <shiftcaption></shiftcaption>
     145        <basecaption>6</basecaption>
     146        <shiftcaption>^</shiftcaption>
    147147        <altgrcaption></altgrcaption>
    148148    </key>
    149149    <key>
    150150        <position>9</position>
    151         <basecaption></basecaption>
    152         <shiftcaption></shiftcaption>
     151        <basecaption>7</basecaption>
     152        <shiftcaption>&amp;</shiftcaption>
    153153        <altgrcaption></altgrcaption>
    154154    </key>
    155155    <key>
    156156        <position>10</position>
    157         <basecaption></basecaption>
    158         <shiftcaption></shiftcaption>
     157        <basecaption>8</basecaption>
     158        <shiftcaption>*</shiftcaption>
    159159        <altgrcaption></altgrcaption>
    160160    </key>
    161161    <key>
    162162        <position>11</position>
    163         <basecaption></basecaption>
    164         <shiftcaption></shiftcaption>
     163        <basecaption>9</basecaption>
     164        <shiftcaption>(</shiftcaption>
    165165        <altgrcaption></altgrcaption>
    166166    </key>
    167167    <key>
    168168        <position>12</position>
    169         <basecaption></basecaption>
    170         <shiftcaption></shiftcaption>
     169        <basecaption>0</basecaption>
     170        <shiftcaption>)</shiftcaption>
    171171        <altgrcaption></altgrcaption>
    172172    </key>
    173173    <key>
    174174        <position>13</position>
    175         <basecaption></basecaption>
    176         <shiftcaption></shiftcaption>
     175        <basecaption>-</basecaption>
     176        <shiftcaption>_</shiftcaption>
    177177        <altgrcaption></altgrcaption>
    178178    </key>
    179179    <key>
    180180        <position>15</position>
    181         <basecaption></basecaption>
     181        <basecaption>Backspace</basecaption>
    182182        <shiftcaption></shiftcaption>
    183183        <altgrcaption></altgrcaption>
     
    185185    <key>
    186186        <position>75</position>
    187         <basecaption></basecaption>
     187        <basecaption>Insert</basecaption>
    188188        <shiftcaption></shiftcaption>
    189189        <altgrcaption></altgrcaption>
     
    191191    <key>
    192192        <position>80</position>
    193         <basecaption></basecaption>
     193        <basecaption>Home</basecaption>
    194194        <shiftcaption></shiftcaption>
    195195        <altgrcaption></altgrcaption>
     
    197197    <key>
    198198        <position>85</position>
    199         <basecaption></basecaption>
     199        <basecaption>Page Up</basecaption>
    200200        <shiftcaption></shiftcaption>
    201201        <altgrcaption></altgrcaption>
     
    209209    <key>
    210210        <position>17</position>
    211         <basecaption></basecaption>
     211        <basecaption>Q</basecaption>
    212212        <shiftcaption></shiftcaption>
    213213        <altgrcaption></altgrcaption>
     
    215215    <key>
    216216        <position>18</position>
    217         <basecaption></basecaption>
     217        <basecaption>W</basecaption>
    218218        <shiftcaption></shiftcaption>
    219219        <altgrcaption></altgrcaption>
     
    221221    <key>
    222222        <position>19</position>
    223         <basecaption></basecaption>
     223        <basecaption>E</basecaption>
    224224        <shiftcaption></shiftcaption>
    225225        <altgrcaption></altgrcaption>
     
    227227    <key>
    228228        <position>20</position>
    229         <basecaption></basecaption>
     229        <basecaption>R</basecaption>
    230230        <shiftcaption></shiftcaption>
    231231        <altgrcaption></altgrcaption>
     
    233233    <key>
    234234        <position>21</position>
    235         <basecaption></basecaption>
     235        <basecaption>T</basecaption>
    236236        <shiftcaption></shiftcaption>
    237237        <altgrcaption></altgrcaption>
     
    239239    <key>
    240240        <position>22</position>
    241         <basecaption></basecaption>
     241        <basecaption>Y</basecaption>
    242242        <shiftcaption></shiftcaption>
    243243        <altgrcaption></altgrcaption>
     
    245245    <key>
    246246        <position>23</position>
    247         <basecaption></basecaption>
     247        <basecaption>U</basecaption>
    248248        <shiftcaption></shiftcaption>
    249249        <altgrcaption></altgrcaption>
     
    251251    <key>
    252252        <position>24</position>
    253         <basecaption></basecaption>
     253        <basecaption>I</basecaption>
    254254        <shiftcaption></shiftcaption>
    255255        <altgrcaption></altgrcaption>
     
    257257    <key>
    258258        <position>25</position>
    259         <basecaption></basecaption>
     259        <basecaption>O</basecaption>
    260260        <shiftcaption></shiftcaption>
    261261        <altgrcaption></altgrcaption>
     
    263263    <key>
    264264        <position>26</position>
    265         <basecaption></basecaption>
     265        <basecaption>P</basecaption>
    266266        <shiftcaption></shiftcaption>
    267267        <altgrcaption></altgrcaption>
     
    269269    <key>
    270270        <position>27</position>
    271         <basecaption></basecaption>
    272         <shiftcaption></shiftcaption>
     271        <basecaption>[</basecaption>
     272        <shiftcaption>{</shiftcaption>
    273273        <altgrcaption></altgrcaption>
    274274    </key>
    275275    <key>
    276276        <position>28</position>
    277         <basecaption></basecaption>
    278         <shiftcaption></shiftcaption>
     277        <basecaption>]</basecaption>
     278        <shiftcaption>}</shiftcaption>
    279279        <altgrcaption></altgrcaption>
    280280    </key>
    281281    <key>
    282282        <position>29</position>
    283         <basecaption></basecaption>
    284         <shiftcaption></shiftcaption>
     283        <basecaption>\</basecaption>
     284        <shiftcaption>|</shiftcaption>
    285285        <altgrcaption></altgrcaption>
    286286    </key>
    287287    <key>
    288288        <position>76</position>
    289         <basecaption></basecaption>
     289        <basecaption>Delete</basecaption>
    290290        <shiftcaption></shiftcaption>
    291291        <altgrcaption></altgrcaption>
     
    293293    <key>
    294294        <position>81</position>
    295         <basecaption></basecaption>
     295        <basecaption>End</basecaption>
    296296        <shiftcaption></shiftcaption>
    297297        <altgrcaption></altgrcaption>
     
    299299    <key>
    300300        <position>86</position>
    301         <basecaption></basecaption>
     301        <basecaption>Page Down</basecaption>
    302302        <shiftcaption></shiftcaption>
    303303        <altgrcaption></altgrcaption>
     
    311311    <key>
    312312        <position>31</position>
    313         <basecaption></basecaption>
     313        <basecaption>A</basecaption>
    314314        <shiftcaption></shiftcaption>
    315315        <altgrcaption></altgrcaption>
     
    317317    <key>
    318318        <position>32</position>
    319         <basecaption></basecaption>
     319        <basecaption>S</basecaption>
    320320        <shiftcaption></shiftcaption>
    321321        <altgrcaption></altgrcaption>
     
    323323    <key>
    324324        <position>33</position>
    325         <basecaption></basecaption>
     325        <basecaption>D</basecaption>
    326326        <shiftcaption></shiftcaption>
    327327        <altgrcaption></altgrcaption>
     
    329329    <key>
    330330        <position>34</position>
    331         <basecaption></basecaption>
     331        <basecaption>F</basecaption>
    332332        <shiftcaption></shiftcaption>
    333333        <altgrcaption></altgrcaption>
     
    335335    <key>
    336336        <position>35</position>
    337         <basecaption></basecaption>
     337        <basecaption>G</basecaption>
    338338        <shiftcaption></shiftcaption>
    339339        <altgrcaption></altgrcaption>
     
    341341    <key>
    342342        <position>36</position>
    343         <basecaption></basecaption>
     343        <basecaption>H</basecaption>
    344344        <shiftcaption></shiftcaption>
    345345        <altgrcaption></altgrcaption>
     
    347347    <key>
    348348        <position>37</position>
    349         <basecaption></basecaption>
     349        <basecaption>J</basecaption>
    350350        <shiftcaption></shiftcaption>
    351351        <altgrcaption></altgrcaption>
     
    353353    <key>
    354354        <position>38</position>
    355         <basecaption></basecaption>
     355        <basecaption>K</basecaption>
    356356        <shiftcaption></shiftcaption>
    357357        <altgrcaption></altgrcaption>
     
    359359    <key>
    360360        <position>39</position>
    361         <basecaption></basecaption>
     361        <basecaption>L</basecaption>
    362362        <shiftcaption></shiftcaption>
    363363        <altgrcaption></altgrcaption>
     
    365365    <key>
    366366        <position>40</position>
    367         <basecaption></basecaption>
    368         <shiftcaption></shiftcaption>
     367        <basecaption>;</basecaption>
     368        <shiftcaption>:</shiftcaption>
    369369        <altgrcaption></altgrcaption>
    370370    </key>
    371371    <key>
    372372        <position>41</position>
    373         <basecaption></basecaption>
    374         <shiftcaption></shiftcaption>
     373        <basecaption>'</basecaption>
     374        <shiftcaption>&quot;</shiftcaption>
    375375        <altgrcaption></altgrcaption>
    376376    </key>
    377377    <key>
    378378        <position>43</position>
    379         <basecaption></basecaption>
     379        <basecaption>Enter</basecaption>
    380380        <shiftcaption></shiftcaption>
    381381        <altgrcaption></altgrcaption>
     
    449449    <key>
    450450        <position>57</position>
    451         <basecaption></basecaption>
     451        <basecaption>Shift</basecaption>
    452452        <shiftcaption></shiftcaption>
    453453        <altgrcaption></altgrcaption>
     
    455455    <key>
    456456        <position>83</position>
    457         <basecaption></basecaption>
     457        <basecaption></basecaption>
    458458        <shiftcaption></shiftcaption>
    459459        <altgrcaption></altgrcaption>
     
    467467    <key>
    468468        <position>227</position>
    469         <basecaption></basecaption>
     469        <basecaption>OS</basecaption>
    470470        <shiftcaption></shiftcaption>
    471471        <altgrcaption></altgrcaption>
     
    473473    <key>
    474474        <position>60</position>
    475         <basecaption></basecaption>
     475        <basecaption>Alt</basecaption>
    476476        <shiftcaption></shiftcaption>
    477477        <altgrcaption></altgrcaption>
     
    485485    <key>
    486486        <position>62</position>
    487         <basecaption></basecaption>
     487        <basecaption>Alt</basecaption>
    488488        <shiftcaption></shiftcaption>
    489489        <altgrcaption></altgrcaption>
     
    491491    <key>
    492492        <position>231</position>
    493         <basecaption></basecaption>
     493        <basecaption>OS</basecaption>
    494494        <shiftcaption></shiftcaption>
    495495        <altgrcaption></altgrcaption>
     
    497497    <key>
    498498        <position>0</position>
    499         <basecaption></basecaption>
     499        <basecaption>Menu</basecaption>
    500500        <shiftcaption></shiftcaption>
    501501        <altgrcaption></altgrcaption>
     
    503503    <key>
    504504        <position>64</position>
    505         <basecaption></basecaption>
     505        <basecaption>Ctrl</basecaption>
    506506        <shiftcaption></shiftcaption>
    507507        <altgrcaption></altgrcaption>
     
    509509    <key>
    510510        <position>79</position>
    511         <basecaption></basecaption>
     511        <basecaption></basecaption>
    512512        <shiftcaption></shiftcaption>
    513513        <altgrcaption></altgrcaption>
     
    515515    <key>
    516516        <position>84</position>
    517         <basecaption></basecaption>
     517        <basecaption></basecaption>
    518518        <shiftcaption></shiftcaption>
    519519        <altgrcaption></altgrcaption>
     
    521521    <key>
    522522        <position>89</position>
    523         <basecaption></basecaption>
     523        <basecaption></basecaption>
    524524        <shiftcaption></shiftcaption>
    525525        <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