VirtualBox

Changeset 37874 in vbox


Ignore:
Timestamp:
Jul 11, 2011 2:34:40 PM (13 years ago)
Author:
vboxsync
Message:

FE/Qt: 4397: Virtual Media Manager UI: Reworking medium-type-change UI according latest requirements: Replacing medium-type-change combo-box with tool-button opening sub-dialog for this operation.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r37551 r37874  
    267267        src/VBoxGlobalSettings.h \
    268268        src/VBoxMediaManagerDlg.h \
     269        src/UIMediumTypeChangeDialog.h \
    269270        src/VBoxSnapshotDetailsDlg.h \
    270271        src/VBoxTakeSnapshotDlg.h \
     
    431432        src/VBoxHelpActions.cpp \
    432433        src/VBoxMediaManagerDlg.cpp \
     434        src/UIMediumTypeChangeDialog.cpp \
    433435        src/VBoxMedium.cpp \
    434436        src/VBoxSnapshotDetailsDlg.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.cpp

    r37655 r37874  
    4444#include "UIIconPool.h"
    4545#include "UIVirtualBoxEventHandler.h"
     46#include "UIMediumTypeChangeDialog.h"
    4647#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    4748
     
    205206    , mShowDiffs (true)
    206207    , mSetupMode (false)
    207     , m_previousMediumType(KMediumType_Normal)
    208     , m_fParentMediumType(true)
    209208{
    210209    /* Apply UI decorations */
     
    287286
    288287    /* Setup information pane: */
    289     qRegisterMetaType<KMediumType>();
    290     connect(m_pTypeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(sltCurrentMediumTypeChanged()));
     288    m_pChangeMediumTypeButton->setIcon(UIIconPool::iconSet(":/arrow_down_10px.png"));
     289    connect(m_pChangeMediumTypeButton, SIGNAL(clicked()), this, SLOT(sltOpenMediumTypeChangeDialog()));
     290    m_pChangeMediumTypeButton->setIconSize(QSize(10, 10));
    291291
    292292    /* Context menu composing */
     
    653653#endif /* QT_MAC_USE_COCOA */
    654654
    655     if (mDoSelect)
    656         mButtonBox->button (QDialogButtonBox::Ok)->setText (tr ("&Select"));
     655    mButtonBox->button(QDialogButtonBox::Ok)->setText(mDoSelect ? tr("&Select") : tr("C&lose"));
    657656
    658657    if (mTwHD->model()->rowCount() || mTwCD->model()->rowCount() || mTwFD->model()->rowCount())
    659658        refreshAll();
    660 
    661     /* Translate medium type combo: */
    662     repopulateMediumTypeCombo();
    663 }
    664 
    665 void VBoxMediaManagerDlg::repopulateMediumTypeCombo()
    666 {
    667     /* Block signals: */
    668     m_pTypeCombo->blockSignals(true);
    669 
    670     /* Remember current index: */
    671     int iCurrentIndex = m_pTypeCombo->currentIndex();
    672 
    673     /* Repopulate medium types: */
    674     m_pTypeCombo->clear();
    675 
    676     /* Check parent mode: */
    677     if (m_fParentMediumType)
    678     {
    679         /* Populate possible types for parent disks: */
    680         m_pTypeCombo->insertItem(0, vboxGlobal().toString(KMediumType_Normal), QVariant::fromValue(KMediumType_Normal));
    681         m_pTypeCombo->insertItem(1, vboxGlobal().toString(KMediumType_Immutable), QVariant::fromValue(KMediumType_Immutable));
    682         m_pTypeCombo->insertItem(2, vboxGlobal().toString(KMediumType_Writethrough), QVariant::fromValue(KMediumType_Writethrough));
    683         m_pTypeCombo->insertItem(3, vboxGlobal().toString(KMediumType_Shareable), QVariant::fromValue(KMediumType_Shareable));
    684         m_pTypeCombo->insertItem(4, vboxGlobal().toString(KMediumType_MultiAttach), QVariant::fromValue(KMediumType_MultiAttach));
    685     }
    686     else
    687     {
    688         /* Just one 'differencing' type for children disks: */
    689         m_pTypeCombo->insertItem(0, vboxGlobal().differencingMediumTypeName());
    690     }
    691 
    692     /* Choose current index again if still possible: */
    693     if (iCurrentIndex >= 0 && iCurrentIndex < m_pTypeCombo->count())
    694         m_pTypeCombo->setCurrentIndex(iCurrentIndex);
    695     else
    696         m_pTypeCombo->setCurrentIndex(0);
    697 
    698     /* Unblock signals: */
    699     m_pTypeCombo->blockSignals(false);
    700659}
    701660
     
    14831442        if (item->treeWidget() == mTwHD)
    14841443        {
    1485             /* Update parent mode: */
    1486             m_fParentMediumType = !item->medium().parent();
    1487             /* Repopulate combo: */
    1488             repopulateMediumTypeCombo();
    1489 
    1490             /* Block signals: */
    1491             m_pTypeCombo->blockSignals(true);
    1492             /* Choose the correct one medium type: */
    1493             int iIndexOfType = m_pTypeCombo->findText(item->hardDiskType());
    1494             AssertMsg(iIndexOfType != -1, ("Incorrect medium type: %s\n", item->hardDiskType().toLatin1().constData()));
    1495             m_pTypeCombo->setCurrentIndex(iIndexOfType);
    1496             /* Remember new medium type: */
    1497             m_previousMediumType = m_pTypeCombo->itemData(m_pTypeCombo->currentIndex()).value<KMediumType>();
    1498             /* Unblock signals: */
    1499             m_pTypeCombo->blockSignals(false);
     1444            /* Check if thats parent medium: */
     1445            bool fIsThatParentMedium = !item->medium().parent();
     1446            m_pChangeMediumTypeButton->setEnabled(fIsThatParentMedium);
    15001447
    15011448            /* Other panes: */
     1449            m_pTypePane->setText(item->hardDiskType());
    15021450            m_pLocationPane->setText(formatPaneText(item->location(), true, "end"));
    15031451            m_pFormatPane->setText(item->hardDiskFormat());
     
    15981546}
    15991547
    1600 void VBoxMediaManagerDlg::sltCurrentMediumTypeChanged()
    1601 {
    1602     /* Get new medium type: */
    1603     KMediumType newMediumType = m_pTypeCombo->itemData(m_pTypeCombo->currentIndex()).value<KMediumType>();
    1604 
    1605     /* Check that new type exists and differs from the old one: */
    1606     if (newMediumType == m_previousMediumType)
    1607         return;
    1608 
     1548void VBoxMediaManagerDlg::sltOpenMediumTypeChangeDialog()
     1549{
    16091550    MediaItem *pMediumItem = toMediaItem(currentTreeWidget()->currentItem());
    1610     CMedium medium = pMediumItem->medium().medium();
    1611     medium.SetType(newMediumType);
    1612     if (!medium.isOk())
    1613     {
    1614         /* Revert medium type: */
    1615         m_pTypeCombo->blockSignals(true);
    1616         int iPreviousIndex = m_pTypeCombo->findText(vboxGlobal().toString(m_previousMediumType));
    1617         m_pTypeCombo->setCurrentIndex(iPreviousIndex);
    1618         m_pTypeCombo->blockSignals(false);
    1619         /* Show warning: */
    1620         vboxProblem().cannotChangeMediumType(this, medium, m_previousMediumType, newMediumType);
    1621     }
    1622     else
    1623     {
    1624         /* Remember new medium type: */
    1625         m_previousMediumType = m_pTypeCombo->itemData(m_pTypeCombo->currentIndex()).value<KMediumType>();
    1626         /* Refresh related VMM item: */
     1551    UIMediumTypeChangeDialog dlg(this, pMediumItem->id());
     1552    if (dlg.exec() == QDialog::Accepted)
     1553    {
    16271554        pMediumItem->refreshAll();
     1555        m_pTypePane->setText(pMediumItem->hardDiskType());
    16281556    }
    16291557}
     
    19071835void VBoxMediaManagerDlg::clearInfoPanes()
    19081836{
    1909     m_pTypeCombo->setCurrentIndex(-1); m_pLocationPane->clear(); m_pFormatPane->clear(); m_pDetailsPane->clear(); m_pUsagePane->clear();
     1837    m_pTypePane->clear(); m_pLocationPane->clear(); m_pFormatPane->clear(); m_pDetailsPane->clear(); m_pUsagePane->clear();
    19101838    mIpCD1->clear(); mIpCD2->clear();
    19111839    mIpFD1->clear(); mIpFD2->clear();
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.h

    r37470 r37874  
    7070
    7171    void retranslateUi();
    72     void repopulateMediumTypeCombo();
    7372    virtual void closeEvent (QCloseEvent *aEvent);
    7473    virtual bool eventFilter (QObject *aObject, QEvent *aEvent);
     
    102101    void performTablesAdjustment();
    103102
    104     void sltCurrentMediumTypeChanged();
     103    void sltOpenMediumTypeChangeDialog();
    105104
    106105private:
     
    148147    bool mSetupMode : 1;
    149148
    150     /* Medium type related variables: */
    151     KMediumType m_previousMediumType;
    152     bool m_fParentMediumType;
    153 
    154149    /* Icon definitions */
    155150    QIcon mHardDiskIcon;
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.ui

    r37470 r37874  
    104104           </item>
    105105           <item row="0" column="1" >
    106             <widget class="QComboBox" name="m_pTypeCombo" >
    107              <property name="sizePolicy" >
    108               <sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" >
    109                <horstretch>0</horstretch>
    110                <verstretch>0</verstretch>
    111               </sizepolicy>
    112              </property>
    113             </widget>
     106            <layout class="QHBoxLayout">
     107             <item>
     108              <widget class="QILabel" name="m_pTypePane">
     109               <property name="sizePolicy">
     110                <sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding">
     111                 <horstretch>0</horstretch>
     112                 <verstretch>0</verstretch>
     113                </sizepolicy>
     114               </property>
     115              </widget>
     116             </item>
     117             <item>
     118              <widget class="QIToolButton" name="m_pChangeMediumTypeButton">
     119               <property name="autoRaise">
     120                <bool>true</bool>
     121               </property>
     122               <property name="toolTip">
     123                <string>Change medium type...</string>
     124               </property>
     125              </widget>
     126             </item>
     127            </layout>
    114128           </item>
    115129           <item row="1" column="0" >
     
    399413   <header>QITabWidget.h</header>
    400414  </customwidget>
     415  <customwidget>
     416   <class>QIToolButton</class>
     417   <extends>QToolButton</extends>
     418   <header>QIToolButton.h</header>
     419  </customwidget>
    401420 </customwidgets>
    402421 <resources/>
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