VirtualBox

Changeset 69113 in vbox for trunk


Ignore:
Timestamp:
Oct 17, 2017 4:23:37 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8400: Media Manager: Reworking medium location widget to be more simple.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/medium
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDetailsWidget.cpp

    r68330 r69113  
    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                                                              tr("Current extension (*.%1)")
     151                                                                 .arg(QFileInfo(m_oldData.m_options.m_strLocation).suffix()),
     152                                                              this,
     153                                                              tr("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: */
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDetailsWidget.h

    r68326 r69113  
    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. */
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