VirtualBox

vbox的更動 69131 路徑 trunk/src/VBox


忽略:
時間撮記:
2017-10-18 上午10:09:36 (7 年 以前)
作者:
vboxsync
訊息:

FE/Qt: bugref:8400: Media Manager: Reworking medium location widget to be more simple (s.a. r118414 & r118416).

位置:
trunk/src/VBox/Frontends/VirtualBox/src/medium
檔案:
修改 2 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDetailsWidget.cpp

    r69115 r69131  
    2626# include <QSlider>
    2727# include <QStackedLayout>
     28# include <QStyle>
    2829# include <QTextEdit>
    2930# include <QVBoxLayout>
     
    3132/* GUI includes: */
    3233# include "QIDialogButtonBox.h"
     34# include "QIFileDialog.h"
    3335# include "QILabel.h"
    3436# include "QILineEdit.h"
    3537# include "QITabWidget.h"
     38# include "QIToolButton.h"
    3639# include "UIConverter.h"
    37 # include "UIFilePathSelector.h"
    3840# include "UIIconPool.h"
    3941# include "UIMediumDetailsWidget.h"
     
    5456    , m_pTabWidget(0)
    5557    , m_pLabelType(0), m_pComboBoxType(0), m_pErrorPaneType(0)
    56     , m_pLabelLocation(0), m_pSelectorLocation(0), m_pErrorPaneLocation(0)
     58    , m_pLabelLocation(0), m_pEditorLocation(0), m_pButtonLocation(0), m_pErrorPaneLocation(0)
    5759    , m_pLabelDescription(0), m_pEditorDescription(0), m_pErrorPaneDescription(0)
    5860    , m_pLabelSize(0), m_pEditorSize(0), m_pErrorPaneSize(0)
     
    102104    for (int i = 0; i < m_pComboBoxType->count(); ++i)
    103105        m_pComboBoxType->setItemText(i, gpConverter->toString(m_pComboBoxType->itemData(i).value<KMediumType>()));
    104     m_pSelectorLocation->setToolTip(tr("Holds the location of this medium."));
     106    m_pEditorLocation->setToolTip(tr("Holds the location of this medium."));
     107    m_pButtonLocation->setToolTip(tr("Choose Medium Location"));
    105108    m_pEditorDescription->setToolTip(tr("Holds the description of this medium."));
    106109    m_pEditorSize->setToolTip(tr("Holds the size of this medium."));
     
    139142    revalidate(m_pErrorPaneLocation);
    140143    updateButtonStates();
     144}
     145
     146void UIMediumDetailsWidget::sltChooseLocationPath()
     147{
     148    /* Open file-save dialog to choose location for current medium: */
     149    const QString strFileName = QIFileDialog::getSaveFileName(m_pEditorLocation->text(),
     150                                                              QApplication::translate("UIMediumManager", "Current extension (*.%1)")
     151                                                                 .arg(QFileInfo(m_oldData.m_options.m_strLocation).suffix()),
     152                                                              this,
     153                                                              QApplication::translate("UIMediumManager", "Choose the location of this medium"),
     154                                                              0, true, true);
     155    if (!strFileName.isNull())
     156        m_pEditorLocation->setText(QDir::toNativeSeparators(strFileName));
    141157}
    142158
     
    308324
    309325                /* Create location editor: */
    310                 m_pSelectorLocation = new UIFilePathSelector;
    311                 AssertPtrReturnVoid(m_pSelectorLocation);
     326                m_pEditorLocation = new QLineEdit;
     327                AssertPtrReturnVoid(m_pEditorLocation);
    312328                {
    313329                    /* Configure editor: */
    314                     m_pLabelLocation->setBuddy(m_pSelectorLocation);
    315                     m_pSelectorLocation->setResetEnabled(false);
    316                     m_pSelectorLocation->setMode(UIFilePathSelector::Mode_File_Save);
    317                     m_pSelectorLocation->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    318                     connect(m_pSelectorLocation, &UIFilePathSelector::pathChanged,
     330                    m_pLabelLocation->setBuddy(m_pEditorLocation);
     331                    m_pEditorLocation->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     332                    connect(m_pEditorLocation, &QLineEdit::textChanged,
    319333                            this, &UIMediumDetailsWidget::sltLocationPathChanged);
    320334
    321335                    /* Add into layout: */
    322                     pLayoutLocation->addWidget(m_pSelectorLocation);
     336                    pLayoutLocation->addWidget(m_pEditorLocation);
     337                }
     338
     339                /* Create location button: */
     340                m_pButtonLocation = new QIToolButton;
     341                AssertPtrReturnVoid(m_pButtonLocation);
     342                {
     343                    /* Configure editor: */
     344                    const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
     345                    m_pButtonLocation->setIconSize(QSize(iIconMetric, iIconMetric));
     346                    m_pButtonLocation->setIcon(UIIconPool::iconSet(":/select_file_16px.png"));
     347                    m_pButtonLocation->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
     348                    connect(m_pButtonLocation, &QIToolButton::clicked,
     349                            this, &UIMediumDetailsWidget::sltChooseLocationPath);
     350
     351                    /* Add into layout: */
     352                    pLayoutLocation->addWidget(m_pButtonLocation);
    323353                }
    324354
     
    601631    /* Load location: */
    602632    m_pLabelLocation->setEnabled(m_newData.m_fValid);
    603     m_pSelectorLocation->setEnabled(m_newData.m_fValid);
    604     m_pSelectorLocation->setPath(m_newData.m_options.m_strLocation);
    605     sltLocationPathChanged(m_pSelectorLocation->path());
     633    m_pEditorLocation->setEnabled(m_newData.m_fValid);
     634    m_pEditorLocation->setText(m_newData.m_options.m_strLocation);
    606635
    607636    /* Load description: */
     
    654683    {
    655684        /* Always valid for now: */
    656         const bool fError = false;
     685        const bool fError = m_newData.m_options.m_strLocation.isEmpty();
    657686        m_pErrorPaneLocation->setVisible(fError);
    658687        if (fError)
     
    686715//        m_pErrorPaneType->setToolTip(tr("Cannot change from type <b>%1</b> to <b>%2</b>.")
    687716//                                     .arg(m_oldData.m_options.m_enmType).arg(m_newData.m_options.m_enmType));
    688 //    if (!pWidget || pWidget == m_pErrorPaneLocation)
    689 //        m_pErrorPaneLocation->setToolTip(tr("Cannot change medium location from <b>%1</b> to <b>%2</b>.")
    690 //                                         .arg(m_oldData.m_options.m_strLocation).arg(m_newData.m_options.m_strLocation));
     717    if (!pWidget || pWidget == m_pErrorPaneLocation)
     718        m_pErrorPaneLocation->setToolTip(tr("Location can not be empty."));
    691719//    if (!pWidget || pWidget == m_pErrorPaneDescription)
    692720//        m_pErrorPaneDescription->setToolTip(tr("Cannot change medium description from <b>%1</b> to <b>%2</b>.")
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDetailsWidget.h

    r69115 r69131  
    3434class QComboBox;
    3535class QLabel;
     36class QLineEdit;
    3637class QStackedLayout;
    3738class QTextEdit;
     
    3940class QILabel;
    4041class QITabWidget;
    41 class UIFilePathSelector;
     42class QIToolButton;
    4243class UIMediumSizeEditor;
    4344
     
    207208        /** Handles location change. */
    208209        void sltLocationPathChanged(const QString &strPath);
     210        /** Handles request to choose location. */
     211        void sltChooseLocationPath();
    209212        /** Handles description text change. */
    210213        void sltDescriptionTextChanged();
     
    286289
    287290        /** Holds the location label. */
    288         QLabel             *m_pLabelLocation;
    289         /** Holds the location selector. */
    290         UIFilePathSelector *m_pSelectorLocation;
     291        QLabel       *m_pLabelLocation;
     292        /** Holds the location editor. */
     293        QLineEdit    *m_pEditorLocation;
     294        /** Holds the location button. */
     295        QIToolButton *m_pButtonLocation;
    291296        /** Holds the location error pane. */
    292         QLabel             *m_pErrorPaneLocation;
     297        QLabel       *m_pErrorPaneLocation;
    293298
    294299        /** Holds the description label. */
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette