VirtualBox

Changeset 67046 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 23, 2017 3:07:57 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: Selector UI: Virtual Media Manager: Moving onto QIManagerDialog rails.

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

Legend:

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

    r66936 r67046  
    167167    virtual QString defaultText() const /* override */
    168168    {
    169         return tr("%1, %2: %3, %4: %5", "col.1 text, col.2 name: col.2 text, col.3 name: col.3 text")
    170                  .arg(text(0))
    171                  .arg(parentTree()->headerItem()->text(1)).arg(text(1))
    172                  .arg(parentTree()->headerItem()->text(2)).arg(text(2));
     169        return UIMediumManager::tr("%1, %2: %3, %4: %5", "col.1 text, col.2 name: col.2 text, col.3 name: col.3 text")
     170                                   .arg(text(0))
     171                                   .arg(parentTree()->headerItem()->text(1)).arg(text(1))
     172                                   .arg(parentTree()->headerItem()->text(2)).arg(text(2));
    173173    }
    174174
     
    654654
    655655
    656 /* static */
    657 UIMediumManager* UIMediumManager::s_pInstance = 0;
    658 UIMediumManager* UIMediumManager::instance() { return s_pInstance; }
    659 
    660 UIMediumManager::UIMediumManager(QWidget *pCenterWidget, bool fRefresh /* = true */)
    661     : QIWithRetranslateUI<QMainWindow>(0)
    662     , m_pPseudoParentWidget(pCenterWidget)
    663     , m_fRefresh(fRefresh)
     656/*********************************************************************************************************************************
     657*   Class UIMediumManagerWidget implementation.                                                                                  *
     658*********************************************************************************************************************************/
     659
     660UIMediumManagerWidget::UIMediumManagerWidget(QWidget *pParent /* = 0 */)
     661    : QIWithRetranslateUI<QWidget>(pParent)
    664662    , m_fPreventChangeCurrentItem(false)
    665663    , m_pTabWidget(0)
     
    677675    , m_pActionRemove(0), m_pActionRelease(0)
    678676    , m_pActionRefresh(0)
    679     , m_pButtonBox(0)
    680677    , m_pProgressBar(0)
    681678{
     
    684681}
    685682
    686 UIMediumManager::~UIMediumManager()
    687 {
    688     /* Cleanup: */
    689     cleanup();
    690 
    691     /* Cleanup instance: */
    692     s_pInstance = 0;
    693 }
    694 
    695 /* static */
    696 void UIMediumManager::showModeless(QWidget *pCenterWidget /* = 0 */, bool fRefresh /* = true */)
    697 {
    698     /* Create instance if not yet created: */
    699     if (!s_pInstance)
    700         s_pInstance = new UIMediumManager(pCenterWidget, fRefresh);
    701 
    702     /* Show instance: */
    703     s_pInstance->show();
    704     s_pInstance->setWindowState(s_pInstance->windowState() & ~Qt::WindowMinimized);
    705     s_pInstance->activateWindow();
    706 }
    707 
    708 void UIMediumManager::sltHandleMediumCreated(const QString &strMediumID)
     683void UIMediumManagerWidget::retranslateUi()
     684{
     685    /* Translate menu: */
     686    if (m_pMenu)
     687        m_pMenu->setTitle(UIMediumManager::tr("&Medium"));
     688
     689    /* Translate actions: */
     690    if (m_pActionCopy)
     691    {
     692        m_pActionCopy->setText(UIMediumManager::tr("&Copy..."));
     693        m_pActionCopy->setToolTip(m_pActionCopy->text().remove('&') + QString(" (%1)").arg(m_pActionCopy->shortcut().toString()));
     694        m_pActionCopy->setStatusTip(UIMediumManager::tr("Copy an existing disk image file"));
     695    }
     696    if (m_pActionModify)
     697    {
     698        m_pActionModify->setText(UIMediumManager::tr("&Modify..."));
     699        m_pActionModify->setToolTip(m_pActionModify->text().remove('&') + QString(" (%1)").arg(m_pActionModify->shortcut().toString()));
     700        m_pActionModify->setStatusTip(UIMediumManager::tr("Modify the attributes of the selected disk image file"));
     701    }
     702    if (m_pActionRemove)
     703    {
     704        m_pActionRemove->setText(UIMediumManager::tr("R&emove"));
     705        m_pActionRemove->setToolTip(m_pActionRemove->text().remove('&') + QString(" (%1)").arg(m_pActionRemove->shortcut().toString()));
     706        m_pActionRemove->setStatusTip(UIMediumManager::tr("Remove the selected disk image file"));
     707    }
     708    if (m_pActionRelease)
     709    {
     710        m_pActionRelease->setText(UIMediumManager::tr("Re&lease"));
     711        m_pActionRelease->setToolTip(m_pActionRelease->text().remove('&') + QString(" (%1)").arg(m_pActionRelease->shortcut().toString()));
     712        m_pActionRelease->setStatusTip(UIMediumManager::tr("Release the selected disk image file by detaching it from the machines"));
     713    }
     714    if (m_pActionRefresh)
     715    {
     716        m_pActionRefresh->setText(UIMediumManager::tr("Re&fresh"));
     717        m_pActionRefresh->setToolTip(m_pActionRefresh->text().remove('&') + QString(" (%1)").arg(m_pActionRefresh->shortcut().toString()));
     718        m_pActionRefresh->setStatusTip(UIMediumManager::tr("Refresh the list of disk image files"));
     719    }
     720
     721    /* Translate toolbar: */
     722#ifdef VBOX_WS_MAC
     723    // WORKAROUND:
     724    // There is a bug in Qt Cocoa which result in showing a "more arrow" when
     725    // the necessary size of the toolbar is increased. Also for some languages
     726    // the with doesn't match if the text increase. So manually adjust the size
     727    // after changing the text. */
     728    if (m_pToolBar)
     729        m_pToolBar->updateLayout();
     730#endif
     731
     732    /* Translate tab-widget: */
     733    if (m_pTabWidget)
     734    {
     735        m_pTabWidget->setTabText(tabIndex(UIMediumType_HardDisk), UIMediumManager::tr("&Hard disks"));
     736        m_pTabWidget->setTabText(tabIndex(UIMediumType_DVD), UIMediumManager::tr("&Optical disks"));
     737        m_pTabWidget->setTabText(tabIndex(UIMediumType_Floppy), UIMediumManager::tr("&Floppy disks"));
     738    }
     739
     740    /* Translate HD tree-widget: */
     741    QITreeWidget *pTreeWidgetHD = treeWidget(UIMediumType_HardDisk);
     742    if (pTreeWidgetHD)
     743    {
     744        pTreeWidgetHD->headerItem()->setText(0, UIMediumManager::tr("Name"));
     745        pTreeWidgetHD->headerItem()->setText(1, UIMediumManager::tr("Virtual Size"));
     746        pTreeWidgetHD->headerItem()->setText(2, UIMediumManager::tr("Actual Size"));
     747    }
     748
     749    /* Translate HD information-labels: */
     750    if (infoLabel(UIMediumType_HardDisk, 0))
     751        infoLabel(UIMediumType_HardDisk, 0)->setText(UIMediumManager::tr("Type:"));
     752    if (infoLabel(UIMediumType_HardDisk, 1))
     753        infoLabel(UIMediumType_HardDisk, 1)->setText(UIMediumManager::tr("Location:"));
     754    if (infoLabel(UIMediumType_HardDisk, 2))
     755        infoLabel(UIMediumType_HardDisk, 2)->setText(UIMediumManager::tr("Format:"));
     756    if (infoLabel(UIMediumType_HardDisk, 3))
     757        infoLabel(UIMediumType_HardDisk, 3)->setText(UIMediumManager::tr("Storage details:"));
     758    if (infoLabel(UIMediumType_HardDisk, 4))
     759        infoLabel(UIMediumType_HardDisk, 4)->setText(UIMediumManager::tr("Attached to:"));
     760    if (infoLabel(UIMediumType_HardDisk, 5))
     761        infoLabel(UIMediumType_HardDisk, 5)->setText(UIMediumManager::tr("Encrypted with key:"));
     762    if (infoLabel(UIMediumType_HardDisk, 6))
     763        infoLabel(UIMediumType_HardDisk, 6)->setText(UIMediumManager::tr("UUID:"));
     764
     765    /* Translate CD tree-widget: */
     766    QITreeWidget *pTreeWidgetCD = treeWidget(UIMediumType_DVD);
     767    if (pTreeWidgetCD)
     768    {
     769        pTreeWidgetCD->headerItem()->setText(0, UIMediumManager::tr("Name"));
     770        pTreeWidgetCD->headerItem()->setText(1, UIMediumManager::tr("Size"));
     771    }
     772
     773    /* Translate CD information-labels: */
     774    if (infoLabel(UIMediumType_DVD, 0))
     775        infoLabel(UIMediumType_DVD, 0)->setText(UIMediumManager::tr("Location:"));
     776    if (infoLabel(UIMediumType_DVD, 1))
     777        infoLabel(UIMediumType_DVD, 1)->setText(UIMediumManager::tr("Attached to:"));
     778    if (infoLabel(UIMediumType_DVD, 2))
     779        infoLabel(UIMediumType_DVD, 2)->setText(UIMediumManager::tr("UUID:"));
     780
     781    /* Translate FD tree-widget: */
     782    QITreeWidget *pTreeWidgetFD = treeWidget(UIMediumType_Floppy);
     783    if (pTreeWidgetFD)
     784    {
     785        pTreeWidgetFD->headerItem()->setText(0, UIMediumManager::tr("Name"));
     786        pTreeWidgetFD->headerItem()->setText(1, UIMediumManager::tr("Size"));
     787    }
     788
     789    /* Translate FD information-labels: */
     790    if (infoLabel(UIMediumType_Floppy, 0))
     791        infoLabel(UIMediumType_Floppy, 0)->setText(UIMediumManager::tr("Location:"));
     792    if (infoLabel(UIMediumType_Floppy, 1))
     793        infoLabel(UIMediumType_Floppy, 1)->setText(UIMediumManager::tr("Attached to:"));
     794    if (infoLabel(UIMediumType_Floppy, 2))
     795        infoLabel(UIMediumType_Floppy, 2)->setText(UIMediumManager::tr("UUID:"));
     796
     797    /* Translate progress-bar: */
     798    if (m_pProgressBar)
     799    {
     800        m_pProgressBar->setText(UIMediumManager::tr("Checking accessibility"));
     801#ifdef VBOX_WS_MAC
     802        /* Make sure that the widgets aren't jumping around
     803         * while the progress-bar get visible. */
     804        m_pProgressBar->adjustSize();
     805        //int h = m_pProgressBar->height();
     806        //if (m_pButtonBox)
     807        //    m_pButtonBox->setMinimumHeight(h + 12);
     808#endif
     809    }
     810
     811    /* Full refresh if there is at least one item present: */
     812    if (   (pTreeWidgetHD && pTreeWidgetHD->topLevelItemCount())
     813        || (pTreeWidgetCD && pTreeWidgetCD->topLevelItemCount())
     814        || (pTreeWidgetFD && pTreeWidgetFD->topLevelItemCount()))
     815        sltRefreshAll();
     816}
     817
     818void UIMediumManagerWidget::sltHandleMediumCreated(const QString &strMediumID)
    709819{
    710820    /* Search for corresponding medium: */
     
    737847}
    738848
    739 void UIMediumManager::sltHandleMediumDeleted(const QString &strMediumID)
     849void UIMediumManagerWidget::sltHandleMediumDeleted(const QString &strMediumID)
    740850{
    741851    /* Make sure corresponding medium-item deleted: */
     
    743853}
    744854
    745 void UIMediumManager::sltHandleMediumEnumerationStart()
     855void UIMediumManagerWidget::sltHandleMediumEnumerationStart()
    746856{
    747857    /* Disable 'refresh' action: */
     
    777887}
    778888
    779 void UIMediumManager::sltHandleMediumEnumerated(const QString &strMediumID)
     889void UIMediumManagerWidget::sltHandleMediumEnumerated(const QString &strMediumID)
    780890{
    781891    /* Search for corresponding medium: */
     
    799909}
    800910
    801 void UIMediumManager::sltHandleMediumEnumerationFinish()
     911void UIMediumManagerWidget::sltHandleMediumEnumerationFinish()
    802912{
    803913    /* Hide progress-bar: */
     
    813923}
    814924
    815 void UIMediumManager::sltCopyMedium()
     925void UIMediumManagerWidget::sltCopyMedium()
    816926{
    817927    /* Get current medium-item: */
     
    824934}
    825935
    826 void UIMediumManager::sltModifyMedium()
     936void UIMediumManagerWidget::sltModifyMedium()
    827937{
    828938    /* Get current medium-item: */
     
    839949}
    840950
    841 void UIMediumManager::sltRemoveMedium()
     951void UIMediumManagerWidget::sltRemoveMedium()
    842952{
    843953    /* Get current medium-item: */
     
    850960}
    851961
    852 void UIMediumManager::sltReleaseMedium()
     962void UIMediumManagerWidget::sltReleaseMedium()
    853963{
    854964    /* Get current medium-item: */
     
    865975}
    866976
    867 void UIMediumManager::sltRefreshAll()
     977void UIMediumManagerWidget::sltRefreshAll()
    868978{
    869979    /* Start medium-enumeration: */
     
    871981}
    872982
    873 void UIMediumManager::sltHandleCurrentTabChanged()
     983void UIMediumManagerWidget::sltHandleCurrentTabChanged()
    874984{
    875985    /* Get current tree-widget: */
     
    8901000}
    8911001
    892 void UIMediumManager::sltHandleCurrentItemChanged()
     1002void UIMediumManagerWidget::sltHandleCurrentItemChanged()
    8931003{
    8941004    /* Get sender() tree-widget: */
     
    9001010}
    9011011
    902 void UIMediumManager::sltHandleDoubleClick()
     1012void UIMediumManagerWidget::sltHandleDoubleClick()
    9031013{
    9041014    /* Skip for non-hard-drives: */
     
    9101020}
    9111021
    912 void UIMediumManager::sltHandleContextMenuCall(const QPoint &position)
     1022void UIMediumManagerWidget::sltHandleContextMenuCall(const QPoint &position)
    9131023{
    9141024    /* Get current tree-widget: */
     
    9291039}
    9301040
    931 void UIMediumManager::sltPerformTablesAdjustment()
     1041void UIMediumManagerWidget::sltPerformTablesAdjustment()
    9321042{
    9331043    /* Get all the tree-widgets: */
     
    9541064}
    9551065
    956 void UIMediumManager::prepare()
     1066void UIMediumManagerWidget::prepare()
    9571067{
    9581068    /* Prepare this: */
    9591069    prepareThis();
    9601070
    961     /* Translate dialog: */
     1071    /* Apply language settings: */
    9621072    retranslateUi();
    963 
    964     /* Center according pseudo-parent widget: */
    965     VBoxGlobal::centerWidget(this, m_pPseudoParentWidget, false);
    9661073
    9671074    /* Initialize information-panes: */
     
    9691076
    9701077    /* Start medium-enumeration (if necessary): */
    971     if (m_fRefresh && !vboxGlobal().isMediumEnumerationInProgress())
     1078    if (!vboxGlobal().isMediumEnumerationInProgress())
    9721079        vboxGlobal().startMediumEnumeration();
    9731080    /* Emulate medium-enumeration otherwise: */
     
    9831090}
    9841091
    985 void UIMediumManager::prepareThis()
    986 {
    987     /* Initial size: */
    988     resize(620, 460);
    989 
    990     /* Dialog should delete itself on 'close': */
    991     setAttribute(Qt::WA_DeleteOnClose);
    992     /* And no need to count it as important for application.
    993      * This way it will NOT be taken into account
    994      * when other top-level windows will be closed: */
    995     setAttribute(Qt::WA_QuitOnClose, false);
    996 
    997     /* Apply window icons: */
    998     setWindowIcon(UIIconPool::iconSetFull(":/diskimage_32px.png", ":/diskimage_16px.png"));
    999 
     1092void UIMediumManagerWidget::prepareThis()
     1093{
    10001094    /* Prepare connections: */
    10011095    prepareConnections();
     
    10031097    prepareActions();
    10041098    /* Prepare central-widget: */
    1005     prepareCentralWidget();
    1006 }
    1007 
    1008 void UIMediumManager::prepareConnections()
     1099    prepareWidgets();
     1100}
     1101
     1102void UIMediumManagerWidget::prepareConnections()
    10091103{
    10101104    /* Configure medium-processing connections: */
     
    10231117}
    10241118
    1025 void UIMediumManager::prepareActions()
    1026 {
    1027     /* Create copy-action: */
     1119void UIMediumManagerWidget::prepareActions()
     1120{
     1121    /* Create 'Copy' action: */
    10281122    m_pActionCopy = new QAction(this);
    10291123    AssertPtrReturnVoid(m_pActionCopy);
     
    10341128    }
    10351129
    1036     /* Create modify-action: */
     1130    /* Create 'Modify' action: */
    10371131    m_pActionModify = new QAction(this);
    10381132    AssertPtrReturnVoid(m_pActionModify);
     
    10431137    }
    10441138
    1045     /* Create remove-action: */
     1139    /* Create 'Remove' action: */
    10461140    m_pActionRemove  = new QAction(this);
    10471141    AssertPtrReturnVoid(m_pActionRemove);
     
    10521146    }
    10531147
    1054     /* Create release-action: */
     1148    /* Create 'Release' action: */
    10551149    m_pActionRelease = new QAction(this);
    10561150    AssertPtrReturnVoid(m_pActionRelease);
     
    10611155    }
    10621156
    1063     /* Create refresh-action: */
     1157    /* Create 'Refresh' action: */
    10641158    m_pActionRefresh = new QAction(this);
    10651159    AssertPtrReturnVoid(m_pActionRefresh);
     
    10731167    updateActionIcons();
    10741168
    1075     /* Prepare menu-bar: */
    1076     prepareMenuBar();
     1169    /* Prepare menu: */
     1170    prepareMenu();
    10771171    /* Prepare context-menu: */
    10781172    prepareContextMenu();
    10791173}
    10801174
    1081 void UIMediumManager::prepareMenuBar()
    1082 {
    1083     /* Create 'Actions' menu: */
    1084     m_pMenu = menuBar()->addMenu(QString());
     1175void UIMediumManagerWidget::prepareMenu()
     1176{
     1177    /* Create 'Medium' menu: */
     1178    m_pMenu = new QMenu(this);
    10851179    AssertPtrReturnVoid(m_pMenu);
    10861180    {
     
    10921186        m_pMenu->addAction(m_pActionRefresh);
    10931187    }
    1094 
    1095 #ifdef VBOX_WS_MAC
    1096     /* Prepare 'Window' menu: */
    1097     AssertPtrReturnVoid(gpWindowMenuManager);
    1098     menuBar()->addMenu(gpWindowMenuManager->createMenu(this));
    1099     gpWindowMenuManager->addWindow(this);
    1100 #endif /* VBOX_WS_MAC */
    1101 }
    1102 
    1103 void UIMediumManager::prepareContextMenu()
     1188}
     1189
     1190void UIMediumManagerWidget::prepareContextMenu()
    11041191{
    11051192    /* Create context-menu: */
     
    11151202}
    11161203
    1117 void UIMediumManager::prepareCentralWidget()
    1118 {
    1119     /* Create central-widget: */
    1120     setCentralWidget(new QWidget);
    1121     AssertPtrReturnVoid(centralWidget());
    1122     {
    1123         /* Create main-layout: */
    1124         new QVBoxLayout(centralWidget());
    1125         AssertPtrReturnVoid(centralWidget()->layout());
    1126         {
    1127             /* Prepare toolbar: */
    1128             prepareToolBar();
    1129             /* Prepare tab-widget: */
    1130             prepareTabWidget();
    1131             /* Prepare button-box: */
    1132             prepareButtonBox();
    1133         }
    1134     }
    1135 }
    1136 
    1137 void UIMediumManager::prepareToolBar()
     1204void UIMediumManagerWidget::prepareWidgets()
     1205{
     1206    /* Create main-layout: */
     1207    new QVBoxLayout(this);
     1208    AssertPtrReturnVoid(layout());
     1209    {
     1210        /* Configure layout: */
     1211        layout()->setContentsMargins(0, 0, 0, 0);
     1212#ifdef VBOX_WS_MAC
     1213        layout()->setSpacing(10);
     1214#else
     1215        layout()->setSpacing(4);
     1216#endif
     1217
     1218        /* Prepare toolbar: */
     1219        prepareToolBar();
     1220        /* Prepare tab-widget: */
     1221        prepareTabWidget();
     1222    }
     1223}
     1224
     1225void UIMediumManagerWidget::prepareToolBar()
    11381226{
    11391227    /* Create toolbar: */
     
    11461234        m_pToolBar->setIconSize(QSize(iIconMetric, iIconMetric));
    11471235        m_pToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    1148         m_pToolBar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
    11491236        /* Add toolbar actions: */
    11501237        if (m_pActionCopy)
     
    11581245        if (m_pActionRefresh)
    11591246            m_pToolBar->addAction(m_pActionRefresh);
    1160         /* Integrate toolbar into dialog: */
    1161         QVBoxLayout *pMainLayout = qobject_cast<QVBoxLayout*>(centralWidget()->layout());
    1162 #ifdef VBOX_WS_MAC
    1163         /* Enable unified toolbars on Mac OS X. Available on Qt >= 4.3: */
    1164         addToolBar(m_pToolBar);
    1165         m_pToolBar->enableMacToolbar();
    1166         /* No spacing/margin on the Mac: */
    1167         pMainLayout->setContentsMargins(0, 0, 0, 0);
    1168         pMainLayout->insertSpacing(0, 10);
    1169 #else /* !VBOX_WS_MAC */
    1170         /* Add the toolbar: */
    1171         pMainLayout->insertWidget(0, m_pToolBar);
    1172         /* Set spacing/margin like in the selector window: */
    1173         pMainLayout->setSpacing(5);
    1174         pMainLayout->setContentsMargins(5, 5, 5, 5);
    1175 #endif /* !VBOX_WS_MAC */
    1176     }
    1177 }
    1178 
    1179 void UIMediumManager::prepareTabWidget()
     1247#ifndef VBOX_WS_MAC
     1248        /* Add into layout: */
     1249        layout()->addWidget(m_pToolBar);
     1250#endif
     1251    }
     1252}
     1253
     1254void UIMediumManagerWidget::prepareTabWidget()
    11801255{
    11811256    /* Create tab-widget: */
     
    11931268        connect(m_pTabWidget, SIGNAL(currentChanged(int)), this, SLOT(sltHandleCurrentTabChanged()));
    11941269        /* Add tab-widget into central layout: */
    1195         centralWidget()->layout()->addWidget(m_pTabWidget);
     1270        layout()->addWidget(m_pTabWidget);
    11961271        /* Focus current tree-widget: */
    11971272        if (currentTreeWidget())
     
    12021277}
    12031278
    1204 void UIMediumManager::prepareTab(UIMediumType type)
     1279void UIMediumManagerWidget::prepareTab(UIMediumType type)
    12051280{
    12061281    /* Create tab: */
     
    12211296}
    12221297
    1223 void UIMediumManager::prepareTreeWidget(UIMediumType type, int iColumns)
     1298void UIMediumManagerWidget::prepareTreeWidget(UIMediumType type, int iColumns)
    12241299{
    12251300    /* Create tree-widget: */
     
    12711346}
    12721347
    1273 void UIMediumManager::prepareInformationContainer(UIMediumType type, int iFields)
     1348void UIMediumManagerWidget::prepareInformationContainer(UIMediumType type, int iFields)
    12741349{
    12751350    /* Create information-container: */
     
    13171392}
    13181393
    1319 void UIMediumManager::prepareButtonBox()
    1320 {
    1321     /* Create button-box: */
    1322     m_pButtonBox = new QIDialogButtonBox;
    1323     AssertPtrReturnVoid(m_pButtonBox);
    1324     {
    1325         /* Configure button-box: */
    1326         m_pButtonBox->setStandardButtons(QDialogButtonBox::Help | QDialogButtonBox::Close);
    1327         m_pButtonBox->button(QDialogButtonBox::Close)->setShortcut(Qt::Key_Escape);
    1328         connect(m_pButtonBox, SIGNAL(helpRequested()), &msgCenter(), SLOT(sltShowHelpHelpDialog()));
    1329         connect(m_pButtonBox, SIGNAL(rejected()), this, SLOT(close()));
    1330         /* Add button-box into central layout: */
    1331         centralWidget()->layout()->addWidget(m_pButtonBox);
    1332         /* Prepare progress-bar: */
    1333         prepareProgressBar();
    1334     }
    1335 }
    1336 
    1337 void UIMediumManager::prepareProgressBar()
    1338 {
    1339     /* Create progress-bar: */
    1340     m_pProgressBar = new UIEnumerationProgressBar;
    1341     AssertPtrReturnVoid(m_pProgressBar);
    1342     {
    1343         /* Configure progress-bar: */
    1344         m_pProgressBar->hide();
    1345         /* Add progress-bar into button-box layout: */
    1346         m_pButtonBox->addExtraWidget(m_pProgressBar);
    1347     }
    1348 }
    1349 
    1350 void UIMediumManager::repopulateTreeWidgets()
     1394//void UIMediumManagerWidget::prepareProgressBar()
     1395//{
     1396//    /* Create progress-bar: */
     1397//    m_pProgressBar = new UIEnumerationProgressBar;
     1398//    AssertPtrReturnVoid(m_pProgressBar);
     1399//    {
     1400//        /* Configure progress-bar: */
     1401//        m_pProgressBar->hide();
     1402//        /* Add progress-bar into button-box layout: */
     1403//        m_pButtonBox->addExtraWidget(m_pProgressBar);
     1404//    }
     1405//}
     1406
     1407void UIMediumManagerWidget::repopulateTreeWidgets()
    13511408{
    13521409    /* Remember current medium-items: */
     
    13961453}
    13971454
    1398 void UIMediumManager::refetchCurrentMediumItem(UIMediumType type)
     1455void UIMediumManagerWidget::refetchCurrentMediumItem(UIMediumType type)
    13991456{
    14001457    /* Get corresponding medium-item: */
     
    14181475}
    14191476
    1420 void UIMediumManager::refetchCurrentChosenMediumItem()
     1477void UIMediumManagerWidget::refetchCurrentChosenMediumItem()
    14211478{
    14221479    refetchCurrentMediumItem(currentMediumType());
    14231480}
    14241481
    1425 void UIMediumManager::refetchCurrentMediumItems()
     1482void UIMediumManagerWidget::refetchCurrentMediumItems()
    14261483{
    14271484    refetchCurrentMediumItem(UIMediumType_HardDisk);
     
    14301487}
    14311488
    1432 void UIMediumManager::updateActions()
     1489void UIMediumManagerWidget::updateActions()
    14331490{
    14341491    /* Get current medium-item: */
     
    14631520}
    14641521
    1465 void UIMediumManager::updateActionIcons()
     1522void UIMediumManagerWidget::updateActionIcons()
    14661523{
    14671524    QString strPrefix = "hd";
     
    15011558}
    15021559
    1503 void UIMediumManager::updateTabIcons(UIMediumItem *pMediumItem, Action action)
     1560void UIMediumManagerWidget::updateTabIcons(UIMediumItem *pMediumItem, Action action)
    15041561{
    15051562    /* Make sure medium-item is valid: */
     
    15891646}
    15901647
    1591 void UIMediumManager::updateInformationFields(UIMediumType type /* = UIMediumType_Invalid */)
     1648void UIMediumManagerWidget::updateInformationFields(UIMediumType type /* = UIMediumType_Invalid */)
    15921649{
    15931650    /* Make sure type is valid: */
     
    16101667}
    16111668
    1612 void UIMediumManager::updateInformationFieldsHD()
     1669void UIMediumManagerWidget::updateInformationFieldsHD()
    16131670{
    16141671    /* Get current hard-drive medium-item: */
     
    16281685        const QString strDetails = pCurrentItem->details();
    16291686        const QString strUsage = pCurrentItem->usage().isNull() ?
    1630                                  formatFieldText(tr("<i>Not&nbsp;Attached</i>"), false) :
     1687                                 formatFieldText(UIMediumManager::tr("<i>Not&nbsp;Attached</i>"), false) :
    16311688                                 formatFieldText(pCurrentItem->usage());
    16321689        const QString strEncryptionPasswordID = pCurrentItem->encryptionPasswordID().isNull() ?
    1633                                                 formatFieldText(tr("<i>Not&nbsp;Encrypted</i>"), false) :
     1690                                                formatFieldText(UIMediumManager::tr("<i>Not&nbsp;Encrypted</i>"), false) :
    16341691                                                formatFieldText(pCurrentItem->encryptionPasswordID());
    16351692        const QString strID = pCurrentItem->id();
     
    16551712}
    16561713
    1657 void UIMediumManager::updateInformationFieldsCD()
     1714void UIMediumManagerWidget::updateInformationFieldsCD()
    16581715{
    16591716    /* Get current optical medium-item: */
     
    16721729        /* Update required details: */
    16731730        QString strUsage = pCurrentItem->usage().isNull() ?
    1674                            formatFieldText(tr("<i>Not&nbsp;Attached</i>"), false) :
     1731                           formatFieldText(UIMediumManager::tr("<i>Not&nbsp;Attached</i>"), false) :
    16751732                           formatFieldText(pCurrentItem->usage());
    16761733        const QString strID = pCurrentItem->id();
     
    16881745}
    16891746
    1690 void UIMediumManager::updateInformationFieldsFD()
     1747void UIMediumManagerWidget::updateInformationFieldsFD()
    16911748{
    16921749    /* Get current floppy medium-item: */
     
    17051762        /* Update required details: */
    17061763        QString strUsage = pCurrentItem->usage().isNull() ?
    1707                            formatFieldText(tr("<i>Not&nbsp;Attached</i>"), false) :
     1764                           formatFieldText(UIMediumManager::tr("<i>Not&nbsp;Attached</i>"), false) :
    17081765                           formatFieldText(pCurrentItem->usage());
    17091766        const QString strID = pCurrentItem->id();
     
    17211778}
    17221779
    1723 void UIMediumManager::cleanupMenuBar()
    1724 {
    1725 #ifdef VBOX_WS_MAC
    1726     /* Cleanup 'Window' menu: */
    1727     AssertPtrReturnVoid(gpWindowMenuManager);
    1728     gpWindowMenuManager->removeWindow(this);
    1729     gpWindowMenuManager->destroyMenu(this);
    1730 #endif /* VBOX_WS_MAC */
    1731 }
    1732 
    1733 void UIMediumManager::cleanup()
    1734 {
    1735     /* Cleanup menu-bar: */
    1736     cleanupMenuBar();
    1737 }
    1738 
    1739 void UIMediumManager::retranslateUi()
    1740 {
    1741     /* Translate window title: */
    1742     setWindowTitle(tr("Virtual Media Manager"));
    1743 
    1744     /* Translate menu: */
    1745     if (m_pMenu)
    1746         m_pMenu->setTitle(tr("&Medium"));
    1747 
    1748     /* Translate actions: */
    1749     if (m_pActionCopy)
    1750     {
    1751         m_pActionCopy->setText(tr("&Copy..."));
    1752         m_pActionCopy->setToolTip(m_pActionCopy->text().remove('&') + QString(" (%1)").arg(m_pActionCopy->shortcut().toString()));
    1753         m_pActionCopy->setStatusTip(tr("Copy an existing disk image file"));
    1754     }
    1755     if (m_pActionModify)
    1756     {
    1757         m_pActionModify->setText(tr("&Modify..."));
    1758         m_pActionModify->setToolTip(m_pActionModify->text().remove('&') + QString(" (%1)").arg(m_pActionModify->shortcut().toString()));
    1759         m_pActionModify->setStatusTip(tr("Modify the attributes of the selected disk image file"));
    1760     }
    1761     if (m_pActionRemove)
    1762     {
    1763         m_pActionRemove->setText(tr("R&emove"));
    1764         m_pActionRemove->setToolTip(m_pActionRemove->text().remove('&') + QString(" (%1)").arg(m_pActionRemove->shortcut().toString()));
    1765         m_pActionRemove->setStatusTip(tr("Remove the selected disk image file"));
    1766     }
    1767     if (m_pActionRelease)
    1768     {
    1769         m_pActionRelease->setText(tr("Re&lease"));
    1770         m_pActionRelease->setToolTip(m_pActionRelease->text().remove('&') + QString(" (%1)").arg(m_pActionRelease->shortcut().toString()));
    1771         m_pActionRelease->setStatusTip(tr("Release the selected disk image file by detaching it from the machines"));
    1772     }
    1773     if (m_pActionRefresh)
    1774     {
    1775         m_pActionRefresh->setText(tr("Re&fresh"));
    1776         m_pActionRefresh->setToolTip(m_pActionRefresh->text().remove('&') + QString(" (%1)").arg(m_pActionRefresh->shortcut().toString()));
    1777         m_pActionRefresh->setStatusTip(tr("Refresh the list of disk image files"));
    1778     }
    1779 
    1780     /* Translate toolbar: */
    1781 #ifdef VBOX_WS_MAC
    1782     /* There is a bug in Qt Cocoa which result in showing a "more arrow" when
    1783        the necessary size of the toolbar is increased. Also for some languages
    1784        the with doesn't match if the text increase. So manually adjust the size
    1785        after changing the text. */
    1786     if (m_pToolBar)
    1787         m_pToolBar->updateLayout();
    1788 #endif /* VBOX_WS_MAC */
    1789 
    1790     /* Translate tab-widget: */
    1791     if (m_pTabWidget)
    1792     {
    1793         m_pTabWidget->setTabText(tabIndex(UIMediumType_HardDisk), tr("&Hard disks"));
    1794         m_pTabWidget->setTabText(tabIndex(UIMediumType_DVD), tr("&Optical disks"));
    1795         m_pTabWidget->setTabText(tabIndex(UIMediumType_Floppy), tr("&Floppy disks"));
    1796     }
    1797 
    1798     /* Translate HD tree-widget: */
    1799     QITreeWidget *pTreeWidgetHD = treeWidget(UIMediumType_HardDisk);
    1800     if (pTreeWidgetHD)
    1801     {
    1802         pTreeWidgetHD->headerItem()->setText(0, tr("Name"));
    1803         pTreeWidgetHD->headerItem()->setText(1, tr("Virtual Size"));
    1804         pTreeWidgetHD->headerItem()->setText(2, tr("Actual Size"));
    1805     }
    1806 
    1807     /* Translate HD information-labels: */
    1808     if (infoLabel(UIMediumType_HardDisk, 0))
    1809         infoLabel(UIMediumType_HardDisk, 0)->setText(tr("Type:"));
    1810     if (infoLabel(UIMediumType_HardDisk, 1))
    1811         infoLabel(UIMediumType_HardDisk, 1)->setText(tr("Location:"));
    1812     if (infoLabel(UIMediumType_HardDisk, 2))
    1813         infoLabel(UIMediumType_HardDisk, 2)->setText(tr("Format:"));
    1814     if (infoLabel(UIMediumType_HardDisk, 3))
    1815         infoLabel(UIMediumType_HardDisk, 3)->setText(tr("Storage details:"));
    1816     if (infoLabel(UIMediumType_HardDisk, 4))
    1817         infoLabel(UIMediumType_HardDisk, 4)->setText(tr("Attached to:"));
    1818     if (infoLabel(UIMediumType_HardDisk, 5))
    1819         infoLabel(UIMediumType_HardDisk, 5)->setText(tr("Encrypted with key:"));
    1820     if (infoLabel(UIMediumType_HardDisk, 6))
    1821         infoLabel(UIMediumType_HardDisk, 6)->setText(tr("UUID:"));
    1822 
    1823     /* Translate CD tree-widget: */
    1824     QITreeWidget *pTreeWidgetCD = treeWidget(UIMediumType_DVD);
    1825     if (pTreeWidgetCD)
    1826     {
    1827         pTreeWidgetCD->headerItem()->setText(0, tr("Name"));
    1828         pTreeWidgetCD->headerItem()->setText(1, tr("Size"));
    1829     }
    1830 
    1831     /* Translate CD information-labels: */
    1832     if (infoLabel(UIMediumType_DVD, 0))
    1833         infoLabel(UIMediumType_DVD, 0)->setText(tr("Location:"));
    1834     if (infoLabel(UIMediumType_DVD, 1))
    1835         infoLabel(UIMediumType_DVD, 1)->setText(tr("Attached to:"));
    1836     if (infoLabel(UIMediumType_DVD, 2))
    1837         infoLabel(UIMediumType_DVD, 2)->setText(tr("UUID:"));
    1838 
    1839     /* Translate FD tree-widget: */
    1840     QITreeWidget *pTreeWidgetFD = treeWidget(UIMediumType_Floppy);
    1841     if (pTreeWidgetFD)
    1842     {
    1843         pTreeWidgetFD->headerItem()->setText(0, tr("Name"));
    1844         pTreeWidgetFD->headerItem()->setText(1, tr("Size"));
    1845     }
    1846 
    1847     /* Translate FD information-labels: */
    1848     if (infoLabel(UIMediumType_Floppy, 0))
    1849         infoLabel(UIMediumType_Floppy, 0)->setText(tr("Location:"));
    1850     if (infoLabel(UIMediumType_Floppy, 1))
    1851         infoLabel(UIMediumType_Floppy, 1)->setText(tr("Attached to:"));
    1852     if (infoLabel(UIMediumType_Floppy, 2))
    1853         infoLabel(UIMediumType_Floppy, 2)->setText(tr("UUID:"));
    1854 
    1855     /* Translate progress-bar: */
    1856     if (m_pProgressBar)
    1857     {
    1858         m_pProgressBar->setText(tr("Checking accessibility"));
    1859 #ifdef VBOX_WS_MAC
    1860         /* Make sure that the widgets aren't jumping around
    1861          * while the progress-bar get visible. */
    1862         m_pProgressBar->adjustSize();
    1863         int h = m_pProgressBar->height();
    1864         if (m_pButtonBox)
    1865             m_pButtonBox->setMinimumHeight(h + 12);
    1866 #endif /* VBOX_WS_MAC */
    1867     }
    1868 
    1869     /* Full refresh if there is at least one item present: */
    1870     if (   (pTreeWidgetHD && pTreeWidgetHD->topLevelItemCount())
    1871         || (pTreeWidgetCD && pTreeWidgetCD->topLevelItemCount())
    1872         || (pTreeWidgetFD && pTreeWidgetFD->topLevelItemCount()))
    1873         sltRefreshAll();
    1874 }
    1875 
    1876 UIMediumItem* UIMediumManager::createMediumItem(const UIMedium &medium)
     1780UIMediumItem* UIMediumManagerWidget::createMediumItem(const UIMedium &medium)
    18771781{
    18781782    /* Get medium type: */
     
    19631867}
    19641868
    1965 UIMediumItem* UIMediumManager::createHardDiskItem(const UIMedium &medium)
     1869UIMediumItem* UIMediumManagerWidget::createHardDiskItem(const UIMedium &medium)
    19661870{
    19671871    /* Make sure passed medium is valid: */
     
    20171921}
    20181922
    2019 void UIMediumManager::updateMediumItem(const UIMedium &medium)
     1923void UIMediumManagerWidget::updateMediumItem(const UIMedium &medium)
    20201924{
    20211925    /* Get medium type: */
     
    20451949}
    20461950
    2047 void UIMediumManager::deleteMediumItem(const QString &strMediumID)
     1951void UIMediumManagerWidget::deleteMediumItem(const QString &strMediumID)
    20481952{
    20491953    /* Search for corresponding tree-widget: */
     
    20791983}
    20801984
    2081 QWidget* UIMediumManager::tab(UIMediumType type) const
     1985QWidget* UIMediumManagerWidget::tab(UIMediumType type) const
    20821986{
    20831987    /* Determine tab index for passed medium type: */
     
    20921996}
    20931997
    2094 QITreeWidget* UIMediumManager::treeWidget(UIMediumType type) const
     1998QITreeWidget* UIMediumManagerWidget::treeWidget(UIMediumType type) const
    20951999{
    20962000    /* Determine tab index for passed medium type: */
     
    21052009}
    21062010
    2107 UIMediumItem* UIMediumManager::mediumItem(UIMediumType type) const
     2011UIMediumItem* UIMediumManagerWidget::mediumItem(UIMediumType type) const
    21082012{
    21092013    /* Get corresponding tree-widget: */
     
    21132017}
    21142018
    2115 QFrame* UIMediumManager::infoContainer(UIMediumType type) const
     2019QFrame* UIMediumManagerWidget::infoContainer(UIMediumType type) const
    21162020{
    21172021    /* Determine tab index for passed medium type: */
     
    21262030}
    21272031
    2128 QLabel* UIMediumManager::infoLabel(UIMediumType type, int iLabelIndex) const
     2032QLabel* UIMediumManagerWidget::infoLabel(UIMediumType type, int iLabelIndex) const
    21292033{
    21302034    /* Determine tab index for passed medium type: */
     
    21442048}
    21452049
    2146 QILabel* UIMediumManager::infoField(UIMediumType type, int iFieldIndex) const
     2050QILabel* UIMediumManagerWidget::infoField(UIMediumType type, int iFieldIndex) const
    21472051{
    21482052    /* Determine tab index for passed medium type: */
     
    21622066}
    21632067
    2164 UIMediumType UIMediumManager::mediumType(QITreeWidget *pTreeWidget) const
     2068UIMediumType UIMediumManagerWidget::mediumType(QITreeWidget *pTreeWidget) const
    21652069{
    21662070    /* Determine tab index of passed tree-widget: */
     
    21752079}
    21762080
    2177 UIMediumType UIMediumManager::currentMediumType() const
     2081UIMediumType UIMediumManagerWidget::currentMediumType() const
    21782082{
    21792083    /* Invalid if tab-widget doesn't exists: */
     
    21852089}
    21862090
    2187 QITreeWidget* UIMediumManager::currentTreeWidget() const
     2091QITreeWidget* UIMediumManagerWidget::currentTreeWidget() const
    21882092{
    21892093    /* Return current tree-widget: */
     
    21912095}
    21922096
    2193 UIMediumItem* UIMediumManager::currentMediumItem() const
     2097UIMediumItem* UIMediumManagerWidget::currentMediumItem() const
    21942098{
    21952099    /* Return current medium-item: */
     
    21972101}
    21982102
    2199 void UIMediumManager::setCurrentItem(QITreeWidget *pTreeWidget, QTreeWidgetItem *pItem)
     2103void UIMediumManagerWidget::setCurrentItem(QITreeWidget *pTreeWidget, QTreeWidgetItem *pItem)
    22002104{
    22012105    /* Make sure passed tree-widget is valid: */
     
    22182122
    22192123/* static */
    2220 int UIMediumManager::tabIndex(UIMediumType type)
     2124int UIMediumManagerWidget::tabIndex(UIMediumType type)
    22212125{
    22222126    /* Return tab index corresponding to known medium type: */
     
    22342138
    22352139/* static */
    2236 UIMediumType UIMediumManager::mediumType(int iIndex)
     2140UIMediumType UIMediumManagerWidget::mediumType(int iIndex)
    22372141{
    22382142    /* Return medium type corresponding to known tab index: */
     
    22502154
    22512155/* static */
    2252 UIMediumItem* UIMediumManager::searchItem(QITreeWidget *pTreeWidget, const CheckIfSuitableBy &condition, CheckIfSuitableBy *pException)
     2156UIMediumItem* UIMediumManagerWidget::searchItem(QITreeWidget *pTreeWidget, const CheckIfSuitableBy &condition, CheckIfSuitableBy *pException)
    22532157{
    22542158    /* Make sure argument is valid: */
     
    22612165
    22622166/* static */
    2263 UIMediumItem* UIMediumManager::searchItem(QTreeWidgetItem *pParentItem, const CheckIfSuitableBy &condition, CheckIfSuitableBy *pException)
     2167UIMediumItem* UIMediumManagerWidget::searchItem(QTreeWidgetItem *pParentItem, const CheckIfSuitableBy &condition, CheckIfSuitableBy *pException)
    22642168{
    22652169    /* Make sure argument is valid: */
     
    22842188
    22852189/* static */
    2286 bool UIMediumManager::checkMediumFor(UIMediumItem *pItem, Action action)
     2190bool UIMediumManagerWidget::checkMediumFor(UIMediumItem *pItem, Action action)
    22872191{
    22882192    /* Make sure passed ID is valid: */
     
    23352239
    23362240/* static */
    2337 UIMediumItem* UIMediumManager::toMediumItem(QTreeWidgetItem *pItem)
     2241UIMediumItem* UIMediumManagerWidget::toMediumItem(QTreeWidgetItem *pItem)
    23382242{
    23392243    /* Cast passed QTreeWidgetItem to UIMediumItem if possible: */
     
    23422246
    23432247/* static */
    2344 QString UIMediumManager::formatFieldText(const QString &strText, bool fCompact /* = true */,
     2248QString UIMediumManagerWidget::formatFieldText(const QString &strText, bool fCompact /* = true */,
    23452249                                         const QString &strElipsis /* = "middle" */)
    23462250{
     
    23492253                              .arg(fCompact ? compactString : "")
    23502254                              .arg(strText.isEmpty() ?
    2351                                    tr("--", "no info") :
     2255                                   UIMediumManager::tr("--", "no info") :
    23522256                                   strText)
    23532257                              .arg(fCompact ? "</compact>" : "");
     
    23552259}
    23562260
     2261
     2262/*********************************************************************************************************************************
     2263*   Class UIMediumManagerFactory implementation.                                                                                 *
     2264*********************************************************************************************************************************/
     2265
     2266void UIMediumManagerFactory::create(QIManagerDialog *&pDialog, QWidget *pCenterWidget)
     2267{
     2268    pDialog = new UIMediumManager(pCenterWidget);
     2269}
     2270
     2271
     2272/*********************************************************************************************************************************
     2273*   Class UIMediumManagerFactory implementation.                                                                                 *
     2274*********************************************************************************************************************************/
     2275
     2276UIMediumManager::UIMediumManager(QWidget *pCenterWidget)
     2277    : QIWithRetranslateUI<QIManagerDialog>(pCenterWidget)
     2278{
     2279}
     2280
     2281void UIMediumManager::retranslateUi()
     2282{
     2283    /* Translate window title: */
     2284    setWindowTitle(tr("Virtual Media Manager"));
     2285}
     2286
     2287void UIMediumManager::prepareDialog()
     2288{
     2289    /* Apply window icons: */
     2290    setWindowIcon(UIIconPool::iconSetFull(":/diskimage_32px.png", ":/diskimage_16px.png"));
     2291
     2292    /* Apply language settings: */
     2293    retranslateUi();
     2294}
     2295
     2296void UIMediumManager::prepareWidget()
     2297{
     2298    /* Create widget: */
     2299    UIMediumManagerWidget *pWidget = new UIMediumManagerWidget(this);
     2300    AssertPtrReturnVoid(pWidget);
     2301    {
     2302        /* Configure widget: */
     2303        setWidget(pWidget);
     2304        setWidgetMenu(pWidget->menu());
     2305#ifdef VBOX_WS_MAC
     2306        setWidgetToolbar(pWidget->toolbar());
     2307#endif
     2308        /* Add to layout: */
     2309        centralWidget()->layout()->addWidget(pWidget);
     2310    }
     2311}
     2312
    23572313#include "UIMediumManager.moc"
    23582314
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.h

    r66916 r67046  
    1919#define ___UIMediumManager_h___
    2020
    21 /* Qt includes: */
    22 #include <QMainWindow>
    23 
    2421/* GUI includes: */
     22#include "QIManagerDialog.h"
    2523#include "QIWithRetranslateUI.h"
    2624#include "UIMediumDefs.h"
     
    5351
    5452
    55 /** Medium Manager dialog. */
    56 class UIMediumManager : public QIWithRetranslateUI<QMainWindow>
     53/** Medium Manager widget. */
     54class UIMediumManagerWidget : public QIWithRetranslateUI<QWidget>
    5755{
    5856    Q_OBJECT;
     
    6159    enum Action { Action_Add, Action_Edit, Action_Copy, Action_Modify, Action_Remove, Action_Release };
    6260
    63     /** Constructs Virtual Medium Manager dialog.
    64       * @param  pCenterWidget  Brings the pseudo-parent widget to center according to.
    65       * @param  fRefresh       Brings whether we should restart medium enumeration. */
    66     UIMediumManager(QWidget *pCenterWidget, bool fRefresh = true);
    67     /** Destructs Virtual Medium Manager dialog. */
    68     ~UIMediumManager();
    69 
    7061public:
    7162
    72     /** Returns Virtual Medium Manager singleton instance. */
    73     static UIMediumManager *instance();
    74     /** Shows Virtual Medium Manager singleton instance, creates new if necessary. */
    75     static void showModeless(QWidget *pCenterWidget, bool fRefresh = true);
     63    /** Constructs Virtual Medium Manager widget. */
     64    UIMediumManagerWidget(QWidget *pParent = 0);
     65
     66    /** Returns the menu. */
     67    QMenu *menu() const { return m_pMenu; }
     68
     69#ifdef VBOX_WS_MAC
     70    /** Returns the toolbar. */
     71    UIToolBar *toolbar() const { return m_pToolBar; }
     72#endif
     73
     74protected:
     75
     76    /** @name Event-handling stuff.
     77      * @{ */
     78        /** Handles translation event. */
     79        virtual void retranslateUi() /* override */;
     80    /** @} */
    7681
    7782private slots:
     
    139144        /** Prepares actions. */
    140145        void prepareActions();
    141         /** Prepares menu-bar. */
    142         void prepareMenuBar();
     146        /** Prepares menu. */
     147        void prepareMenu();
    143148        /** Prepares context-menu. */
    144149        void prepareContextMenu();
    145         /** Prepares central-widget. */
    146         void prepareCentralWidget();
     150        /** Prepares widgets. */
     151        void prepareWidgets();
    147152        /** Prepares toolbar. */
    148153        void prepareToolBar();
     
    155160        /** Prepares tab-widget's information-container. */
    156161        void prepareInformationContainer(UIMediumType type, int iFields);
    157         /** Prepares button-box. */
    158         void prepareButtonBox();
    159         /** Prepares progress-bar. */
    160         void prepareProgressBar();
     162//        /** Prepares progress-bar. */
     163//        void prepareProgressBar();
    161164
    162165        /** Repopulates tree-widgets content. */
     
    184187        /** Updates information fields for floppy-disk tab. */
    185188        void updateInformationFieldsFD();
    186 
    187         /** Cleanups menu-bar. */
    188         void cleanupMenuBar();
    189         /** Cleanups all. */
    190         void cleanup();
    191     /** @} */
    192 
    193     /** @name Event-handling stuff.
    194       * @{ */
    195         /** Handles translation event. */
    196         void retranslateUi();
    197189    /** @} */
    198190
     
    259251    /** @name General variables.
    260252      * @{ */
    261         /** Holds the Virtual Medium Manager singleton instance. */
    262         static UIMediumManager *s_pInstance;
    263 
    264         /** Holds the widget reference to center Virtual Medium Manager according. */
    265         QWidget *m_pPseudoParentWidget;
    266         /** Holds whether Virtual Medium Manager should be refreshed on invoke. */
    267         bool     m_fRefresh;
    268253        /** Holds whether Virtual Medium Manager should preserve current item change. */
    269         bool     m_fPreventChangeCurrentItem;
     254        bool m_fPreventChangeCurrentItem;
    270255    /** @} */
    271256
     
    324309    /** @} */
    325310
    326     /** @name Button-box variables.
    327       * @{ */
    328         /** Holds the dialog button-box instance. */
    329         QIDialogButtonBox        *m_pButtonBox;
     311    /** @name Progress-bar variables.
     312      * @{ */
    330313        /** Holds the progress-bar widget instance. */
    331314        UIEnumerationProgressBar *m_pProgressBar;
     
    333316};
    334317
     318
     319/** Medium Manager dialog factory. */
     320class UIMediumManagerFactory : public QIManagerDialogFactory
     321{
     322protected:
     323
     324    /** Creates derived @a pDialog instance.
     325      * @param  pCenterWidget  Brings the widget reference to center according to. */
     326    virtual void create(QIManagerDialog *&pDialog, QWidget *pCenterWidget) /* override */;
     327};
     328
     329
     330/** QIManagerDialog sub-class used as Host Network Manager dialog. */
     331class UIMediumManager : public QIWithRetranslateUI<QIManagerDialog>
     332{
     333    Q_OBJECT;
     334
     335protected:
     336
     337    /** Constructs Host Network Manager dialog.
     338      * @param  pCenterWidget  Brings the widget reference to center according to. */
     339    UIMediumManager(QWidget *pCenterWidget);
     340
     341    /** @name Event-handling stuff.
     342      * @{ */
     343        /** Handles translation event. */
     344        virtual void retranslateUi() /* override */;
     345    /** @} */
     346
     347    /** @name Prepare/cleanup cascade.
     348      * @{ */
     349        /** Prepares dialog. */
     350        void prepareDialog();
     351        /** Prepares widget. */
     352        void prepareWidget();
     353    /** @} */
     354
     355    /** Allow factory access to private/protected members: */
     356    friend class UIMediumManagerFactory;
     357};
     358
    335359#endif /* !___UIMediumManager_h___ */
    336360
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r67021 r67046  
    133133    , m_pGroupMenuAction(0)
    134134    , m_pMachineMenuAction(0)
     135    , m_pManagerVirtualMedia(0)
    135136    , m_pManagerHostNetwork(0)
    136137{
     
    305306
    306307    /* Make sure MM window is not opened: */
    307     if (UIMediumManager::instance())
     308    if (m_pManagerVirtualMedia)
    308309        return;
    309310
     
    322323    if (fIsThereAnyInaccessibleMedium && !msgCenter().warnAboutInaccessibleMedia())
    323324    {
    324         /* Open the MM window (without refresh): */
    325         UIMediumManager::showModeless(this, false /* refresh? */);
     325        /* Open the MM window: */
     326        sltOpenVirtualMediumManagerWindow();
    326327    }
    327328}
     
    424425void UISelectorWindow::sltOpenVirtualMediumManagerWindow()
    425426{
    426     /* Show modeless Virtual Medium Manager: */
    427     UIMediumManager::showModeless(this);
     427    /* Create instance if not yet created: */
     428    if (!m_pManagerVirtualMedia)
     429    {
     430        UIMediumManagerFactory().prepare(m_pManagerVirtualMedia, this);
     431        connect(m_pManagerVirtualMedia, &QIManagerDialog::sigClose,
     432                this, &UISelectorWindow::sltCloseVirtualMediumManagerWindow);
     433    }
     434
     435    /* Show instance: */
     436    m_pManagerVirtualMedia->show();
     437    m_pManagerVirtualMedia->setWindowState(m_pManagerVirtualMedia->windowState() & ~Qt::WindowMinimized);
     438    m_pManagerVirtualMedia->activateWindow();
     439}
     440
     441void UISelectorWindow::sltCloseVirtualMediumManagerWindow()
     442{
     443    /* Destroy instance if still exists: */
     444    if (m_pManagerVirtualMedia)
     445    {
     446        m_pManagerVirtualMedia->close();
     447        UIMediumManagerFactory().cleanup(m_pManagerVirtualMedia);
     448    }
    428449}
    429450
     
    20322053{
    20332054    /* Close the sub-dialogs first: */
     2055    sltCloseVirtualMediumManagerWindow();
    20342056    sltCloseHostNetworkManagerWindow();
    20352057
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h

    r67021 r67046  
    125125        /** Handles call to open Virtual Medium Manager window. */
    126126        void sltOpenVirtualMediumManagerWindow();
     127        /** Handles call to close Virtual Medium Manager window. */
     128        void sltCloseVirtualMediumManagerWindow();
    127129        /** Handles call to open Host Network Manager window. */
    128130        void sltOpenHostNetworkManagerWindow();
     
    359361    QAction *m_pMachineMenuAction;
    360362
     363    /** Holds the Virtual Media Manager window instance. */
     364    QIManagerDialog *m_pManagerVirtualMedia;
    361365    /** Holds the Host Network Manager window instance. */
    362366    QIManagerDialog *m_pManagerHostNetwork;
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