VirtualBox

Changeset 67517 in vbox


Ignore:
Timestamp:
Jun 20, 2017 5:52:13 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8901: Selector UI: Tools pane: Snapshot pane: Details widget: Replace 'Apply' action with 'Apply' button in proper place; add 'Discard' button as well.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotDetailsWidget.cpp

    r67409 r67517  
    3737
    3838/* GUI includes: */
     39# include "QIDialogButtonBox.h"
    3940# include "QIFlowLayout.h"
    4041# include "UIConverter.h"
     
    524525    , m_pLabelName(0), m_pEditorName(0), m_pErrorPaneName(0)
    525526    , m_pLabelDescription(0), m_pBrowserDescription(0), m_pErrorPaneDescription(0)
     527    , m_pButtonBox(0)
    526528    , m_pLayoutDetails(0)
    527529    , m_pScrollAreaDetails(0)
     
    563565                                 "Press <b>Take</b> button if you wish to take a new snapshot.</p>");
    564566    m_pTabWidget->setTabText(0, tr("&Attributes"));
    565     m_pTabWidget->setTabText(1, tr("D&etails"));
     567    m_pTabWidget->setTabText(1, tr("&Information"));
    566568    m_pLabelName->setText(tr("&Name:"));
    567569    m_pLabelDescription->setText(tr("&Description:"));
     570    m_pEditorName->setToolTip(tr("Holds the snapshot name."));
     571    m_pBrowserDescription->setToolTip(tr("Holds the snapshot description."));
     572    m_pButtonBox->button(QDialogButtonBox::Ok)->setText(tr("Apply"));
     573    m_pButtonBox->button(QDialogButtonBox::Cancel)->setText(tr("Discard"));
     574    m_pButtonBox->button(QDialogButtonBox::Ok)->setShortcut(QString("Ctrl+Return"));
     575    m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape);
     576    m_pButtonBox->button(QDialogButtonBox::Ok)->setStatusTip(tr("Apply changes in current snapshot details"));
     577    m_pButtonBox->button(QDialogButtonBox::Cancel)->setStatusTip(tr("Discard changes in current snapshot details"));
     578    m_pButtonBox->button(QDialogButtonBox::Ok)->
     579        setToolTip(tr("Apply Changes (%1)").arg(m_pButtonBox->button(QDialogButtonBox::Ok)->shortcut().toString()));
     580    m_pButtonBox->button(QDialogButtonBox::Cancel)->
     581        setToolTip(tr("Discard Changes (%1)").arg(m_pButtonBox->button(QDialogButtonBox::Cancel)->shortcut().toString()));
    568582
    569583    /* And if snapshot is valid: */
     
    609623    m_newData.m_strName = m_pEditorName->text();
    610624    revalidate(m_pErrorPaneName);
    611     notify();
     625    updateButtonStates();
    612626}
    613627
     
    616630    m_newData.m_strDescription = m_pBrowserDescription->toPlainText();
    617631    revalidate(m_pErrorPaneDescription);
    618     notify();
     632    updateButtonStates();
    619633}
    620634
     
    633647        pViewer->activateWindow();
    634648    }
     649}
     650
     651void UISnapshotDetailsWidget::sltHandleChangeAccepted()
     652{
     653    /* Disable buttons first of all: */
     654    m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
     655    m_pButtonBox->button(QDialogButtonBox::Cancel)->setEnabled(false);
     656
     657    /* Notify listeners: */
     658    emit sigDataChangeAccepted();
     659}
     660
     661void UISnapshotDetailsWidget::sltHandleChangeRejected()
     662{
     663    /* Reset new data to old: */
     664    m_newData = m_oldData;
     665
     666    /* Load snapshot data: */
     667    loadSnapshotData();
    635668}
    636669
     
    799832                m_pLayoutOptions->addLayout(pLayoutDescription, 1, 1);
    800833            }
     834
     835            /* Create button-box: */
     836            m_pButtonBox = new QIDialogButtonBox;
     837            AssertPtrReturnVoid(m_pButtonBox);
     838            {
     839                /* Configure button-box: */
     840                m_pButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
     841                connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UISnapshotDetailsWidget::sltHandleChangeAccepted);
     842                connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UISnapshotDetailsWidget::sltHandleChangeRejected);
     843
     844                /* Add into layout: */
     845                m_pLayoutOptions->addWidget(m_pButtonBox, 2, 0, 1, 2);
     846            }
    801847        }
    802848
     
    10161062    /* Retranslate: */
    10171063    retranslateUi();
     1064
     1065    /* Update button states finally: */
     1066    updateButtonStates();
    10181067}
    10191068
     
    10411090}
    10421091
    1043 void UISnapshotDetailsWidget::notify()
     1092void UISnapshotDetailsWidget::updateButtonStates()
    10441093{
    10451094//    if (m_oldData != m_newData)
     
    10481097//               m_newData.m_strDescription.toUtf8().constData());
    10491098
    1050     emit sigDataChanged(m_oldData != m_newData);
     1099    /* Update 'Apply' / 'Discard' button states: */
     1100    m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(m_oldData != m_newData);
     1101    m_pButtonBox->button(QDialogButtonBox::Cancel)->setEnabled(m_oldData != m_newData);
    10511102}
    10521103
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotDetailsWidget.h

    r67409 r67517  
    3939class QVBoxLayout;
    4040class QWidget;
     41class QIDialogButtonBox;
    4142class UISnapshotDetailsElement;
    4243
     
    7980signals:
    8081
    81     /** Notifies listeners about data changed and whether it @a fDiffers. */
    82     void sigDataChanged(bool fDiffers);
     82    /** Notifies listeners about data change accepted and should be applied. */
     83    void sigDataChangeAccepted();
    8384
    8485public:
     
    109110    void sltHandleAnchorClicked(const QUrl &link);
    110111
     112    /** Handles snapshot details change accepting. */
     113    void sltHandleChangeAccepted();
     114    /** Handles snapshot details change rejecting. */
     115    void sltHandleChangeRejected();
     116
    111117private:
    112118
     
    132138    /** Retranslates validation for passed @a pWidget. */
    133139    void retranslateValidation(QWidget *pWidget = 0);
    134     /** Notifies listeners about data changed or not. */
    135     void notify();
     140    /** Updates button states. */
     141    void updateButtonStates();
    136142
    137143    /** Returns a details report on a given @a comMachine. */
     
    177183    QLabel    *m_pErrorPaneDescription;
    178184
     185    /** Holds the button-box instance. */
     186    QIDialogButtonBox *m_pButtonBox;
     187
    179188    /** Holds the 'Details' layout instance. */
    180189    QVBoxLayout *m_pLayoutDetails;
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp

    r67509 r67517  
    467467    , m_pActionRestoreSnapshot(0)
    468468    , m_pActionShowSnapshotDetails(0)
    469     , m_pActionCommitSnapshotDetails(0)
    470469    , m_pActionCloneSnapshot(0)
    471470    , m_pSnapshotTree(0)
     
    522521    m_pActionRestoreSnapshot->setText(tr("&Restore"));
    523522    m_pActionShowSnapshotDetails->setText(tr("D&etails..."));
    524     m_pActionCommitSnapshotDetails->setText(tr("&Apply..."));
    525523    m_pActionCloneSnapshot->setText(tr("&Clone..."));
    526524    /* Translate actions tool-tips: */
     
    533531    m_pActionShowSnapshotDetails->setToolTip(tr("Open Snapshot Details (%1)")
    534532                                             .arg(m_pActionShowSnapshotDetails->shortcut().toString()));
    535     m_pActionCommitSnapshotDetails->setToolTip(tr("Apply Changes in Snapshot Details (%1)")
    536                                                .arg(m_pActionCommitSnapshotDetails->shortcut().toString()));
    537533    m_pActionCloneSnapshot->setToolTip(tr("Clone Virtual Machine (%1)")
    538534                                       .arg(m_pActionCloneSnapshot->shortcut().toString()));
     
    542538    m_pActionRestoreSnapshot->setStatusTip(tr("Restore selected snapshot of the virtual machine"));
    543539    m_pActionShowSnapshotDetails->setStatusTip(tr("Open pane with the selected snapshot details"));
    544     m_pActionCommitSnapshotDetails->setStatusTip(tr("Apply changes in snapshot details pane"));
    545540    m_pActionCloneSnapshot->setStatusTip(tr("Clone selected virtual machine"));
    546541
     
    914909{
    915910    /* Show/hide commit action and details-widget: */
    916     m_pActionCommitSnapshotDetails->setVisible(fVisible);
    917911    m_pDetailsWidget->setVisible(fVisible);
    918912    /* If details-widget is visible: */
     
    926920}
    927921
    928 void UISnapshotPane::sltCommitSnapshotDetailsChanges()
     922void UISnapshotPane::sltApplySnapshotDetailsChanges()
    929923{
    930924    /* Make sure nothing being edited in the meantime: */
    931925    if (!m_pLockReadWrite->tryLockForWrite())
    932926        return;
    933 
    934     /* Disable button first of all: */
    935     m_pActionCommitSnapshotDetails->setEnabled(false);
    936927
    937928    /* Acquire "current snapshot" item: */
     
    10191010        menu.addAction(m_pActionRestoreSnapshot);
    10201011        menu.addAction(m_pActionShowSnapshotDetails);
    1021         menu.addAction(m_pActionCommitSnapshotDetails);
    10221012        menu.addSeparator();
    10231013        menu.addAction(m_pActionCloneSnapshot);
     
    12211211        }
    12221212
    1223         /* Add Commit Snapshot Details action: */
    1224         m_pActionCommitSnapshotDetails = m_pToolBar->addAction(UIIconPool::iconSetFull(":/snapshot_commit_details_22px.png",
    1225                                                                                        ":/snapshot_commit_details_16px.png",
    1226                                                                                        ":/snapshot_commit_details_disabled_22px.png",
    1227                                                                                        ":/snapshot_commit_details_disabled_16px.png"),
    1228                                                                QString(), this, &UISnapshotPane::sltCommitSnapshotDetailsChanges);
    1229         {
    1230             connect(m_pActionShowSnapshotDetails, &QAction::toggled,
    1231                     m_pActionCommitSnapshotDetails, &QAction::setVisible);
    1232             m_pActionCommitSnapshotDetails->setShortcut(QString("Ctrl+Return"));
    1233             m_pActionCommitSnapshotDetails->setVisible(false);
    1234         }
    1235 
    12361213        m_pToolBar->addSeparator();
    12371214
     
    12801257        /* Configure details-widget: */
    12811258        m_pDetailsWidget->setVisible(false);
    1282         connect(m_pDetailsWidget, &UISnapshotDetailsWidget::sigDataChanged,
    1283                 m_pActionCommitSnapshotDetails, &QAction::setEnabled);
     1259        connect(m_pDetailsWidget, &UISnapshotDetailsWidget::sigDataChangeAccepted,
     1260                this, &UISnapshotPane::sltApplySnapshotDetailsChanges);
    12841261
    12851262        /* Add into layout: */
     
    14601437    m_pActionShowSnapshotDetails->setEnabled(
    14611438        pSnapshotItem
    1462     );
    1463 
    1464     /* Update 'Commit Details' action: */
    1465     m_pActionCommitSnapshotDetails->setEnabled(
    1466         false
    14671439    );
    14681440
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.h

    r67509 r67517  
    119119        /** Handles command to make snapshot details @a fVisible. */
    120120        void sltToggleSnapshotDetailsVisibility(bool fVisible);
    121         /** Handles command to commit snapshot details changes. */
    122         void sltCommitSnapshotDetailsChanges();
     121        /** Handles command to apply snapshot details changes. */
     122        void sltApplySnapshotDetailsChanges();
    123123        /** Proposes to clone the snapshot. */
    124124        void sltCloneSnapshot() { cloneSnapshot(); }
     
    227227        /** Holds the Show Snapshot Details action instance. */
    228228        QAction   *m_pActionShowSnapshotDetails;
    229         /** Holds the Commit Snapshot Details action instance. */
    230         QAction   *m_pActionCommitSnapshotDetails;
    231229        /** Holds the Clone Snapshot action instance. */
    232230        QAction   *m_pActionCloneSnapshot;
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