VirtualBox

Changeset 91445 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 28, 2021 6:16:17 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: Updating the recent media list of the UIFilePathSelector.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp

    r91414 r91445  
    23422342        default: break;
    23432343    }
     2344    emit sigRecentMediaListUpdated(enmMediumType);
    23442345}
    23452346
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h

    r91414 r91445  
    120120        /** Notifies listeners about medium-enumeration finished. */
    121121        void sigMediumEnumerationFinished();
     122        /** Notifies listeners about update of recently media list. */
     123        void sigRecentMediaListUpdated(UIMediumDeviceType enmMediumType);
    122124    /** @} */
    123125
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.cpp

    r91436 r91445  
    2525#include "QILineEdit.h"
    2626#include "UICommon.h"
    27 #include "UIExtraDataManager.h"
    2827#include "UIIconPool.h"
    2928#include "UIFilePathSelector.h"
     
    514513                m_pImageSelector->setFileDialogFilters("ISO Images(*.iso *.ISO)");
    515514                m_pImageSelector->setInitialPath(uiCommon().defaultFolderPathForType(UIMediumDeviceType_DVD));
    516                 m_pImageSelector->setRecentPathList(gEDataManager->recentListOfOpticalDisks());
     515                m_pImageSelector->setRecentMediaListType(UIMediumDeviceType_DVD);
    517516
    518517                m_pMainLayout->addWidget(m_pImageSelector, iRow, 1, 1, 2);
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFilePathSelector.cpp

    r91436 r91445  
    3434#include "QIToolButton.h"
    3535#include "UICommon.h"
     36#include "UIExtraDataManager.h"
    3637#include "UIIconPool.h"
    3738#include "UIFilePathSelector.h"
     
    6566    , m_fToolTipOverriden(false)
    6667    , m_pCopyAction(new QAction(this))
     68    , m_enmRecentMediaListType(UIMediumDeviceType_Invalid)
    6769{
    6870#ifdef VBOX_WS_WIN
     
    98100    connect(this, static_cast<void(UIFilePathSelector::*)(int)>(&UIFilePathSelector::activated), this, &UIFilePathSelector::onActivated);
    99101    connect(m_pCopyAction, &QAction::triggered, this, &UIFilePathSelector::copyToClipboard);
     102    connect(&uiCommon(), &UICommon::sigRecentMediaListUpdated, this, &UIFilePathSelector::sltRecentMediaListUpdated);
    100103
    101104    /* Editable by default: */
     
    194197}
    195198
    196 void UIFilePathSelector::setRecentPathList(const QStringList &recentPathList)
    197 {
    198     while (count() >= static_cast<int>(RecentListSeparator))
    199     {
    200         removeItem(count() - 1);
    201     }
    202     insertSeparator(RecentListSeparator);
    203 
    204     foreach (const QString strPath, recentPathList)
    205         addItem(strPath);
     199void UIFilePathSelector::setRecentMediaListType(UIMediumDeviceType enmMediumType)
     200{
     201    m_enmRecentMediaListType = enmMediumType;
     202    sltRecentMediaListUpdated(enmMediumType);
     203}
     204
     205UIMediumDeviceType UIFilePathSelector::recentMediaListType() const
     206{
     207    return m_enmRecentMediaListType;
    206208}
    207209
     
    547549         * and text have be corresponding real stored path
    548550         * which can be absolute or relative. */
    549         //if (lineEdit()->text() != m_strPath)
     551        if (lineEdit()->text() != m_strPath)
    550552            setItemText(PathId, m_strPath);
    551553        setItemIcon(PathId, QIcon());
     
    607609    }
    608610}
     611
     612void UIFilePathSelector::sltRecentMediaListUpdated(UIMediumDeviceType enmMediumType)
     613{
     614    /* Remove the recent media list from the end of the combo: */
     615    while (count() >= static_cast<int>(RecentListSeparator))
     616    {
     617        removeItem(count() - 1);
     618    }
     619
     620
     621    if (enmMediumType != m_enmRecentMediaListType)
     622        return;
     623    QStringList recentMedia;
     624
     625    switch (enmMediumType)
     626    {
     627        case UIMediumDeviceType_DVD:
     628            recentMedia = gEDataManager->recentListOfOpticalDisks();
     629            break;
     630        case UIMediumDeviceType_Floppy:
     631            recentMedia = gEDataManager->recentListOfFloppyDisks();
     632            break;
     633        case UIMediumDeviceType_HardDisk:
     634            recentMedia = gEDataManager->recentListOfHardDrives();
     635            break;
     636        default:
     637            break;
     638    }
     639
     640    if (recentMedia.isEmpty())
     641        return;
     642
     643    insertSeparator(RecentListSeparator);
     644    foreach (const QString strPath, recentMedia)
     645        addItem(strPath);
     646
     647}
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFilePathSelector.h

    r91436 r91445  
    2626#include "QIWithRetranslateUI.h"
    2727#include "UILibraryDefs.h"
     28#include "UIMediumDefs.h"
    2829
    2930/* Forward declarations: */
     
    122123    const QString& defaultPath() const;
    123124
    124     void setRecentPathList(const QStringList &recentPathList);
     125    void setRecentMediaListType(UIMediumDeviceType enmMediumType);
     126    UIMediumDeviceType recentMediaListType() const;
    125127
    126128public slots:
     
    161163    /** Refreshes combo-box text according to chosen path. */
    162164    void refreshText();
     165
     166    void sltRecentMediaListUpdated(UIMediumDeviceType enmMediumType);
    163167
    164168private:
     
    219223    /** Path is set to m_strDefaultPath when it is reset. */
    220224    QString m_strDefaultPath;
     225
     226    /** Holds whether medium type for recent media list. If it is UIMediumDeviceType_Invalid the recent list is not shown. */
     227    UIMediumDeviceType  m_enmRecentMediaListType;
    221228};
    222229
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