VirtualBox

Changeset 81442 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Oct 22, 2019 8:39:20 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
134160
Message:

FE/Qt: bugref:6699 Warning the user about not-yet-saved layout (if exists) during soft keyboard close.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r81401 r81442  
    24082408}
    24092409
     2410bool UIMessageCenter::confirmSoftKeyboardClose() const
     2411{
     2412    return questionBinary(0, MessageType_Warning,
     2413                          tr("There are not saved layouts? Closing this dialog will cause loosing the changed. Proceed?"),
     2414                          0 /* auto-confirm id */,
     2415                          "Ok", "Cancel");
     2416
     2417
     2418
     2419    // bool questionBinary(QWidget *pParent, MessageType enmType,
     2420    //                     const QString &strMessage,
     2421    //                     const char *pcszAutoConfirmId = 0,
     2422    //                     const QString &strOkButtonText = QString(),
     2423    //                     const QString &strCancelButtonText = QString(),
     2424    //                     bool fDefaultFocusForOk = true) const;
     2425
     2426}
     2427
    24102428#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    24112429bool UIMessageCenter::confirmCancelingAllNetworkRequests() const
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r80215 r81442  
    446446    void cannotSwitchScreenInSeamless(quint64 uMinVRAM) const;
    447447    void cannotAddDiskEncryptionPassword(const CConsole &console);
     448    bool confirmSoftKeyboardClose() const;
    448449
    449450#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp

    r81405 r81442  
    512512    UIKeyCaptions keyCaptions(int iKeyPosition) const;
    513513
    514     bool operator==(const UISoftKeyboardLayout &otherLayout);
     514    bool operator==(const UISoftKeyboardLayout &otherLayout) const;
    515515
    516516    QString baseCaption(int iKeyPosition) const;
     
    518518    QString altGrCaption(int iKeyPosition) const;
    519519    QString shiftAltGrCaption(int iKeyPosition) const;
     520
     521    void setEditedBuNotSaved(bool fEditedButNotsaved);
     522    bool editedButNotSaved() const;
    520523
    521524    void setUid(const QUuid &uid);
     
    537540    bool    m_fEditable;
    538541    bool    m_fIsFromResources;
     542    bool    m_fEditedButNotSaved;
    539543    QUuid   m_uid;
    540544};
     
    650654    void parentDialogDeactivated();
    651655    bool isColorThemeEditable() const;
     656    bool unsavedLayoutsExist() const;
    652657
    653658protected:
     
    12491254    connect(m_pShiftAltGrCaptionEdit, &QLineEdit::textChanged, this, &UIKeyboardLayoutEditor::sltCaptionsUpdate);
    12501255
    1251 
    12521256    QSpacerItem *pSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding);
    12531257    if (pSpacer)
     
    13141318        if (pItem->data(Qt::UserRole).toUuid() == layoutUid)
    13151319            pFoundItem = pItem;
    1316 
    13171320    }
    13181321    if (!pFoundItem)
     
    17651768    : m_fEditable(true)
    17661769    , m_fIsFromResources(false)
     1770    , m_fEditedButNotSaved(false)
    17671771    , m_uid(QUuid::createUuid())
    17681772{
     
    17841788{
    17851789    m_strSourceFilePath = strSourceFilePath;
     1790    setEditedBuNotSaved(true);
    17861791}
    17871792
     
    17941799{
    17951800    m_fIsFromResources = fIsFromResources;
     1801    setEditedBuNotSaved(true);
    17961802}
    17971803
     
    18041810{
    18051811    m_strName = strName;
     1812    setEditedBuNotSaved(true);
    18061813}
    18071814
     
    18141821{
    18151822    m_strNativeName = strNativeName;
     1823    setEditedBuNotSaved(true);
    18161824}
    18171825
     
    18241832{
    18251833    m_fEditable = fEditable;
     1834    setEditedBuNotSaved(true);
    18261835}
    18271836
     
    18341843{
    18351844    m_physicalLayoutUuid = uuid;
     1845    setEditedBuNotSaved(true);
    18361846}
    18371847
     
    18481858    /* Updating the captions invalidates the cached font size. We set it to 0, thereby forcing its recomputaion: */
    18491859    m_keyCaptionsFontSizeMap[iKeyPosition] = 0;
     1860    setEditedBuNotSaved(true);
    18501861}
    18511862
     
    18551866}
    18561867
    1857 bool UISoftKeyboardLayout::operator==(const UISoftKeyboardLayout &otherLayout)
     1868bool UISoftKeyboardLayout::operator==(const UISoftKeyboardLayout &otherLayout) const
    18581869{
    18591870    if (m_strName != otherLayout.m_strName)
     
    18981909}
    18991910
     1911void UISoftKeyboardLayout::setEditedBuNotSaved(bool fEditedButNotsaved)
     1912{
     1913    m_fEditedButNotSaved = fEditedButNotsaved;
     1914}
     1915
     1916bool UISoftKeyboardLayout::editedButNotSaved() const
     1917{
     1918    return m_fEditedButNotSaved;
     1919}
     1920
    19001921void UISoftKeyboardLayout::setUid(const QUuid &uid)
    19011922{
    19021923    m_uid = uid;
     1924    setEditedBuNotSaved(true);
    19031925}
    19041926
     
    23962418   xmlFile.close();
    23972419   m_pCurrentKeyboardLayout->setSourceFilePath(strFileName);
     2420   m_pCurrentKeyboardLayout->setEditedBuNotSaved(false);
    23982421   sigStatusBarMessage(QString("%1 %2").arg(strFileName).arg(UISoftKeyboard::tr(" is saved")));
    23992422}
     
    24092432        strNewNativeName= QString("%1-%2").arg(newLayout.nativeName()).arg(UISoftKeyboard::tr("Copy"));
    24102433    newLayout.setName(strNewName);
     2434    newLayout.setEditedBuNotSaved(true);
    24112435    newLayout.setNativeName(strNewNativeName);
    24122436    newLayout.setEditable(true);
     
    25452569        return false;
    25462570    return m_currentColorTheme->isEditable();
     2571}
     2572
     2573bool UISoftKeyboardWidget::unsavedLayoutsExist() const
     2574{
     2575    foreach (const UISoftKeyboardLayout &layout, m_layouts)
     2576    {
     2577        if (layout.editedButNotSaved())
     2578            return true;
     2579    }
     2580    return false;
    25472581}
    25482582
     
    30053039    if (m_layouts.isEmpty())
    30063040        return;
     3041    for (int i = 0; i < m_layouts.size(); ++i)
     3042        m_layouts[i].setEditedBuNotSaved(false);
    30073043    setCurrentLayout(&(m_layouts[0]));
    30083044}
     
    37593795}
    37603796
     3797void UISoftKeyboard::closeEvent(QCloseEvent *event)
     3798{
     3799    /* Show a warning dialog when there are not saved layouts: */
     3800    if (m_pKeyboardWidget && m_pKeyboardWidget->unsavedLayoutsExist())
     3801    {
     3802        if (msgCenter().confirmSoftKeyboardClose())
     3803            QMainWindowWithRestorableGeometryAndRetranslateUi::closeEvent(event);
     3804        else
     3805            event->ignore();
     3806        return;
     3807    }
     3808    QMainWindowWithRestorableGeometryAndRetranslateUi::closeEvent(event);
     3809}
     3810
    37613811bool UISoftKeyboard::event(QEvent *pEvent)
    37623812{
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h

    r81303 r81442  
    6464    virtual void retranslateUi() /* override */;
    6565    virtual bool shouldBeMaximized() const /* override */;
     66    virtual void closeEvent(QCloseEvent *event) /* override */;
    6667    bool event(QEvent *pEvent) /* override */;
    6768
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