VirtualBox

Ignore:
Timestamp:
Jul 7, 2017 5:40:58 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
116819
Message:

FE/Qt: bugref:8400: Virtual Media Manager: Implementing possibility to change medium name/location.

File:
1 edited

Legend:

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

    r67810 r67863  
    3232# include "QITabWidget.h"
    3333# include "UIConverter.h"
     34# include "UIFilePathSelector.h"
    3435# include "UIIconPool.h"
    3536# include "UIMediumDetailsWidget.h"
     
    4445    , m_newData(UIDataMedium())
    4546    , m_pTabWidget(0)
    46     , m_pLabelType(0)
    47     , m_pComboBoxType(0)
    48     , m_pErrorPaneType(0)
     47    , m_pLabelType(0), m_pComboBoxType(0), m_pErrorPaneType(0)
     48    , m_pLabelLocation(0), m_pSelectorLocation(0), m_pErrorPaneLocation(0)
    4949    , m_pButtonBox(0)
    5050    , m_pLayoutDetails(0)
     
    8181    /* Translate 'Options' tab content. */
    8282
    83     /* Translate type label: */
    84     m_pLabelType->setText(tr("&Type"));
    85 
    86     /* Translate type field: */
     83    /* Translate labels: */
     84    m_pLabelType->setText(tr("&Type:"));
     85    m_pLabelLocation->setText(tr("&Location:"));
     86
     87    /* Translate fields: */
    8788    m_pComboBoxType->setToolTip(tr("Holds the type of this medium."));
    8889    for (int i = 0; i < m_pComboBoxType->count(); ++i)
    8990        m_pComboBoxType->setItemText(i, gpConverter->toString(m_pComboBoxType->itemData(i).value<KMediumType>()));
     91    m_pSelectorLocation->setToolTip(tr("Holds the location of this medium."));
    9092
    9193    /* Translate button-box: */
     
    114116    m_newData.m_options.m_enmType = m_pComboBoxType->itemData(iIndex).value<KMediumType>();
    115117    revalidate(m_pErrorPaneType);
     118    updateButtonStates();
     119}
     120
     121void UIMediumDetailsWidget::sltLocationPathChanged(const QString &strPath)
     122{
     123    m_newData.m_options.m_strLocation = strPath;
     124    revalidate(m_pErrorPaneLocation);
    116125    updateButtonStates();
    117126}
     
    238247            }
    239248
     249            /* Create location label: */
     250            m_pLabelLocation = new QLabel;
     251            AssertPtrReturnVoid(m_pLabelLocation);
     252            {
     253                /* Configure label: */
     254                m_pLabelLocation->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
     255                /* Add into layout: */
     256                pLayoutOptions->addWidget(m_pLabelLocation, 1, 0);
     257            }
     258            /* Create location layout: */
     259            QHBoxLayout *pLayoutLocation = new QHBoxLayout;
     260            AssertPtrReturnVoid(pLayoutLocation);
     261            {
     262                /* Configure layout: */
     263                pLayoutLocation->setContentsMargins(0, 0, 0, 0);
     264                /* Create location editor: */
     265                m_pSelectorLocation = new UIFilePathSelector;
     266                AssertPtrReturnVoid(m_pSelectorLocation);
     267                {
     268                    /* Configure editor: */
     269                    m_pLabelLocation->setBuddy(m_pSelectorLocation);
     270                    m_pSelectorLocation->setResetEnabled(false);
     271                    m_pSelectorLocation->setMode(UIFilePathSelector::Mode_File_Save);
     272                    m_pSelectorLocation->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     273                    connect(m_pSelectorLocation, &UIFilePathSelector::pathChanged,
     274                            this, &UIMediumDetailsWidget::sltLocationPathChanged);
     275
     276                    /* Add into layout: */
     277                    pLayoutLocation->addWidget(m_pSelectorLocation);
     278                }
     279                /* Create location error pane: */
     280                m_pErrorPaneLocation = new QLabel;
     281                AssertPtrReturnVoid(m_pErrorPaneLocation);
     282                {
     283                    /* Configure label: */
     284                    m_pErrorPaneLocation->setAlignment(Qt::AlignCenter);
     285                    m_pErrorPaneLocation->setPixmap(UIIconPool::iconSet(":/status_error_16px.png")
     286                                                    .pixmap(QSize(iIconMetric, iIconMetric)));
     287                    /* Add into layout: */
     288                    pLayoutLocation->addWidget(m_pErrorPaneLocation);
     289                }
     290                /* Add into layout: */
     291                pLayoutOptions->addLayout(pLayoutLocation, 1, 1);
     292            }
     293
    240294            /* Create stretch: */
    241295            QSpacerItem *pSpacer2 = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
     
    243297            {
    244298                /* Add into layout: */
    245                 pLayoutOptions->addItem(pSpacer2, 1, 0, 1, 2);
     299                pLayoutOptions->addItem(pSpacer2, 2, 0, 1, 2);
    246300            }
    247301
     
    380434            m_pComboBoxType->setCurrentIndex(i);
    381435    sltTypeIndexChanged(m_pComboBoxType->currentIndex());
     436
     437    /* Load location: */
     438    m_pSelectorLocation->setPath(m_newData.m_options.m_strLocation);
     439    sltLocationPathChanged(m_pSelectorLocation->path());
    382440}
    383441
     
    408466        m_pErrorPaneType->setVisible(fError);
    409467    }
     468    if (!pWidget || pWidget == m_pErrorPaneLocation)
     469    {
     470        /* Always valid for now: */
     471        const bool fError = false;
     472        m_pErrorPaneLocation->setVisible(fError);
     473    }
    410474
    411475    /* Retranslate validation: */
     
    417481    /* Translate 'Interface' tab content: */
    418482//    if (!pWidget || pWidget == m_pErrorPaneType)
    419 //        m_pErrorPaneType->setToolTip(tr("Cannot directly change from type <b>%1</b> to type <b>%2</b>.")
    420 //                                     .arg(m_oldData.m_enmType).arg(m_newData.m_enmType));
     483//        m_pErrorPaneType->setToolTip(tr("Cannot change from type <b>%1</b> to <b>%2</b>.")
     484//                                     .arg(m_oldData.m_options.m_enmType).arg(m_newData.m_options.m_enmType));
     485//    if (!pWidget || pWidget == m_pErrorPaneLocation)
     486//        m_pErrorPaneLocation->setToolTip(tr("Cannot change medium location from <b>%1</b> to <b>%2</b>.")
     487//                                         .arg(m_oldData.m_options.m_strLocation).arg(m_newData.m_options.m_strLocation));
    421488}
    422489
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