Changeset 67046 in vbox for trunk/src/VBox
- Timestamp:
- May 23, 2017 3:07:57 PM (8 years ago)
- 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 167 167 virtual QString defaultText() const /* override */ 168 168 { 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)); 173 173 } 174 174 … … 654 654 655 655 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 660 UIMediumManagerWidget::UIMediumManagerWidget(QWidget *pParent /* = 0 */) 661 : QIWithRetranslateUI<QWidget>(pParent) 664 662 , m_fPreventChangeCurrentItem(false) 665 663 , m_pTabWidget(0) … … 677 675 , m_pActionRemove(0), m_pActionRelease(0) 678 676 , m_pActionRefresh(0) 679 , m_pButtonBox(0)680 677 , m_pProgressBar(0) 681 678 { … … 684 681 } 685 682 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) 683 void 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 818 void UIMediumManagerWidget::sltHandleMediumCreated(const QString &strMediumID) 709 819 { 710 820 /* Search for corresponding medium: */ … … 737 847 } 738 848 739 void UIMediumManager ::sltHandleMediumDeleted(const QString &strMediumID)849 void UIMediumManagerWidget::sltHandleMediumDeleted(const QString &strMediumID) 740 850 { 741 851 /* Make sure corresponding medium-item deleted: */ … … 743 853 } 744 854 745 void UIMediumManager ::sltHandleMediumEnumerationStart()855 void UIMediumManagerWidget::sltHandleMediumEnumerationStart() 746 856 { 747 857 /* Disable 'refresh' action: */ … … 777 887 } 778 888 779 void UIMediumManager ::sltHandleMediumEnumerated(const QString &strMediumID)889 void UIMediumManagerWidget::sltHandleMediumEnumerated(const QString &strMediumID) 780 890 { 781 891 /* Search for corresponding medium: */ … … 799 909 } 800 910 801 void UIMediumManager ::sltHandleMediumEnumerationFinish()911 void UIMediumManagerWidget::sltHandleMediumEnumerationFinish() 802 912 { 803 913 /* Hide progress-bar: */ … … 813 923 } 814 924 815 void UIMediumManager ::sltCopyMedium()925 void UIMediumManagerWidget::sltCopyMedium() 816 926 { 817 927 /* Get current medium-item: */ … … 824 934 } 825 935 826 void UIMediumManager ::sltModifyMedium()936 void UIMediumManagerWidget::sltModifyMedium() 827 937 { 828 938 /* Get current medium-item: */ … … 839 949 } 840 950 841 void UIMediumManager ::sltRemoveMedium()951 void UIMediumManagerWidget::sltRemoveMedium() 842 952 { 843 953 /* Get current medium-item: */ … … 850 960 } 851 961 852 void UIMediumManager ::sltReleaseMedium()962 void UIMediumManagerWidget::sltReleaseMedium() 853 963 { 854 964 /* Get current medium-item: */ … … 865 975 } 866 976 867 void UIMediumManager ::sltRefreshAll()977 void UIMediumManagerWidget::sltRefreshAll() 868 978 { 869 979 /* Start medium-enumeration: */ … … 871 981 } 872 982 873 void UIMediumManager ::sltHandleCurrentTabChanged()983 void UIMediumManagerWidget::sltHandleCurrentTabChanged() 874 984 { 875 985 /* Get current tree-widget: */ … … 890 1000 } 891 1001 892 void UIMediumManager ::sltHandleCurrentItemChanged()1002 void UIMediumManagerWidget::sltHandleCurrentItemChanged() 893 1003 { 894 1004 /* Get sender() tree-widget: */ … … 900 1010 } 901 1011 902 void UIMediumManager ::sltHandleDoubleClick()1012 void UIMediumManagerWidget::sltHandleDoubleClick() 903 1013 { 904 1014 /* Skip for non-hard-drives: */ … … 910 1020 } 911 1021 912 void UIMediumManager ::sltHandleContextMenuCall(const QPoint &position)1022 void UIMediumManagerWidget::sltHandleContextMenuCall(const QPoint &position) 913 1023 { 914 1024 /* Get current tree-widget: */ … … 929 1039 } 930 1040 931 void UIMediumManager ::sltPerformTablesAdjustment()1041 void UIMediumManagerWidget::sltPerformTablesAdjustment() 932 1042 { 933 1043 /* Get all the tree-widgets: */ … … 954 1064 } 955 1065 956 void UIMediumManager ::prepare()1066 void UIMediumManagerWidget::prepare() 957 1067 { 958 1068 /* Prepare this: */ 959 1069 prepareThis(); 960 1070 961 /* Translate dialog: */1071 /* Apply language settings: */ 962 1072 retranslateUi(); 963 964 /* Center according pseudo-parent widget: */965 VBoxGlobal::centerWidget(this, m_pPseudoParentWidget, false);966 1073 967 1074 /* Initialize information-panes: */ … … 969 1076 970 1077 /* Start medium-enumeration (if necessary): */ 971 if ( m_fRefresh &&!vboxGlobal().isMediumEnumerationInProgress())1078 if (!vboxGlobal().isMediumEnumerationInProgress()) 972 1079 vboxGlobal().startMediumEnumeration(); 973 1080 /* Emulate medium-enumeration otherwise: */ … … 983 1090 } 984 1091 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 1092 void UIMediumManagerWidget::prepareThis() 1093 { 1000 1094 /* Prepare connections: */ 1001 1095 prepareConnections(); … … 1003 1097 prepareActions(); 1004 1098 /* Prepare central-widget: */ 1005 prepare CentralWidget();1006 } 1007 1008 void UIMediumManager ::prepareConnections()1099 prepareWidgets(); 1100 } 1101 1102 void UIMediumManagerWidget::prepareConnections() 1009 1103 { 1010 1104 /* Configure medium-processing connections: */ … … 1023 1117 } 1024 1118 1025 void UIMediumManager ::prepareActions()1026 { 1027 /* Create copy-action: */1119 void UIMediumManagerWidget::prepareActions() 1120 { 1121 /* Create 'Copy' action: */ 1028 1122 m_pActionCopy = new QAction(this); 1029 1123 AssertPtrReturnVoid(m_pActionCopy); … … 1034 1128 } 1035 1129 1036 /* Create modify-action: */1130 /* Create 'Modify' action: */ 1037 1131 m_pActionModify = new QAction(this); 1038 1132 AssertPtrReturnVoid(m_pActionModify); … … 1043 1137 } 1044 1138 1045 /* Create remove-action: */1139 /* Create 'Remove' action: */ 1046 1140 m_pActionRemove = new QAction(this); 1047 1141 AssertPtrReturnVoid(m_pActionRemove); … … 1052 1146 } 1053 1147 1054 /* Create release-action: */1148 /* Create 'Release' action: */ 1055 1149 m_pActionRelease = new QAction(this); 1056 1150 AssertPtrReturnVoid(m_pActionRelease); … … 1061 1155 } 1062 1156 1063 /* Create refresh-action: */1157 /* Create 'Refresh' action: */ 1064 1158 m_pActionRefresh = new QAction(this); 1065 1159 AssertPtrReturnVoid(m_pActionRefresh); … … 1073 1167 updateActionIcons(); 1074 1168 1075 /* Prepare menu -bar: */1076 prepareMenu Bar();1169 /* Prepare menu: */ 1170 prepareMenu(); 1077 1171 /* Prepare context-menu: */ 1078 1172 prepareContextMenu(); 1079 1173 } 1080 1174 1081 void UIMediumManager ::prepareMenuBar()1082 { 1083 /* Create ' Actions' menu: */1084 m_pMenu = menuBar()->addMenu(QString());1175 void UIMediumManagerWidget::prepareMenu() 1176 { 1177 /* Create 'Medium' menu: */ 1178 m_pMenu = new QMenu(this); 1085 1179 AssertPtrReturnVoid(m_pMenu); 1086 1180 { … … 1092 1186 m_pMenu->addAction(m_pActionRefresh); 1093 1187 } 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 1190 void UIMediumManagerWidget::prepareContextMenu() 1104 1191 { 1105 1192 /* Create context-menu: */ … … 1115 1202 } 1116 1203 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() 1204 void 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 1225 void UIMediumManagerWidget::prepareToolBar() 1138 1226 { 1139 1227 /* Create toolbar: */ … … 1146 1234 m_pToolBar->setIconSize(QSize(iIconMetric, iIconMetric)); 1147 1235 m_pToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); 1148 m_pToolBar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);1149 1236 /* Add toolbar actions: */ 1150 1237 if (m_pActionCopy) … … 1158 1245 if (m_pActionRefresh) 1159 1246 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 1254 void UIMediumManagerWidget::prepareTabWidget() 1180 1255 { 1181 1256 /* Create tab-widget: */ … … 1193 1268 connect(m_pTabWidget, SIGNAL(currentChanged(int)), this, SLOT(sltHandleCurrentTabChanged())); 1194 1269 /* Add tab-widget into central layout: */ 1195 centralWidget()->layout()->addWidget(m_pTabWidget);1270 layout()->addWidget(m_pTabWidget); 1196 1271 /* Focus current tree-widget: */ 1197 1272 if (currentTreeWidget()) … … 1202 1277 } 1203 1278 1204 void UIMediumManager ::prepareTab(UIMediumType type)1279 void UIMediumManagerWidget::prepareTab(UIMediumType type) 1205 1280 { 1206 1281 /* Create tab: */ … … 1221 1296 } 1222 1297 1223 void UIMediumManager ::prepareTreeWidget(UIMediumType type, int iColumns)1298 void UIMediumManagerWidget::prepareTreeWidget(UIMediumType type, int iColumns) 1224 1299 { 1225 1300 /* Create tree-widget: */ … … 1271 1346 } 1272 1347 1273 void UIMediumManager ::prepareInformationContainer(UIMediumType type, int iFields)1348 void UIMediumManagerWidget::prepareInformationContainer(UIMediumType type, int iFields) 1274 1349 { 1275 1350 /* Create information-container: */ … … 1317 1392 } 1318 1393 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 1407 void UIMediumManagerWidget::repopulateTreeWidgets() 1351 1408 { 1352 1409 /* Remember current medium-items: */ … … 1396 1453 } 1397 1454 1398 void UIMediumManager ::refetchCurrentMediumItem(UIMediumType type)1455 void UIMediumManagerWidget::refetchCurrentMediumItem(UIMediumType type) 1399 1456 { 1400 1457 /* Get corresponding medium-item: */ … … 1418 1475 } 1419 1476 1420 void UIMediumManager ::refetchCurrentChosenMediumItem()1477 void UIMediumManagerWidget::refetchCurrentChosenMediumItem() 1421 1478 { 1422 1479 refetchCurrentMediumItem(currentMediumType()); 1423 1480 } 1424 1481 1425 void UIMediumManager ::refetchCurrentMediumItems()1482 void UIMediumManagerWidget::refetchCurrentMediumItems() 1426 1483 { 1427 1484 refetchCurrentMediumItem(UIMediumType_HardDisk); … … 1430 1487 } 1431 1488 1432 void UIMediumManager ::updateActions()1489 void UIMediumManagerWidget::updateActions() 1433 1490 { 1434 1491 /* Get current medium-item: */ … … 1463 1520 } 1464 1521 1465 void UIMediumManager ::updateActionIcons()1522 void UIMediumManagerWidget::updateActionIcons() 1466 1523 { 1467 1524 QString strPrefix = "hd"; … … 1501 1558 } 1502 1559 1503 void UIMediumManager ::updateTabIcons(UIMediumItem *pMediumItem, Action action)1560 void UIMediumManagerWidget::updateTabIcons(UIMediumItem *pMediumItem, Action action) 1504 1561 { 1505 1562 /* Make sure medium-item is valid: */ … … 1589 1646 } 1590 1647 1591 void UIMediumManager ::updateInformationFields(UIMediumType type /* = UIMediumType_Invalid */)1648 void UIMediumManagerWidget::updateInformationFields(UIMediumType type /* = UIMediumType_Invalid */) 1592 1649 { 1593 1650 /* Make sure type is valid: */ … … 1610 1667 } 1611 1668 1612 void UIMediumManager ::updateInformationFieldsHD()1669 void UIMediumManagerWidget::updateInformationFieldsHD() 1613 1670 { 1614 1671 /* Get current hard-drive medium-item: */ … … 1628 1685 const QString strDetails = pCurrentItem->details(); 1629 1686 const QString strUsage = pCurrentItem->usage().isNull() ? 1630 formatFieldText( tr("<i>Not Attached</i>"), false) :1687 formatFieldText(UIMediumManager::tr("<i>Not Attached</i>"), false) : 1631 1688 formatFieldText(pCurrentItem->usage()); 1632 1689 const QString strEncryptionPasswordID = pCurrentItem->encryptionPasswordID().isNull() ? 1633 formatFieldText( tr("<i>Not Encrypted</i>"), false) :1690 formatFieldText(UIMediumManager::tr("<i>Not Encrypted</i>"), false) : 1634 1691 formatFieldText(pCurrentItem->encryptionPasswordID()); 1635 1692 const QString strID = pCurrentItem->id(); … … 1655 1712 } 1656 1713 1657 void UIMediumManager ::updateInformationFieldsCD()1714 void UIMediumManagerWidget::updateInformationFieldsCD() 1658 1715 { 1659 1716 /* Get current optical medium-item: */ … … 1672 1729 /* Update required details: */ 1673 1730 QString strUsage = pCurrentItem->usage().isNull() ? 1674 formatFieldText( tr("<i>Not Attached</i>"), false) :1731 formatFieldText(UIMediumManager::tr("<i>Not Attached</i>"), false) : 1675 1732 formatFieldText(pCurrentItem->usage()); 1676 1733 const QString strID = pCurrentItem->id(); … … 1688 1745 } 1689 1746 1690 void UIMediumManager ::updateInformationFieldsFD()1747 void UIMediumManagerWidget::updateInformationFieldsFD() 1691 1748 { 1692 1749 /* Get current floppy medium-item: */ … … 1705 1762 /* Update required details: */ 1706 1763 QString strUsage = pCurrentItem->usage().isNull() ? 1707 formatFieldText( tr("<i>Not Attached</i>"), false) :1764 formatFieldText(UIMediumManager::tr("<i>Not Attached</i>"), false) : 1708 1765 formatFieldText(pCurrentItem->usage()); 1709 1766 const QString strID = pCurrentItem->id(); … … 1721 1778 } 1722 1779 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) 1780 UIMediumItem* UIMediumManagerWidget::createMediumItem(const UIMedium &medium) 1877 1781 { 1878 1782 /* Get medium type: */ … … 1963 1867 } 1964 1868 1965 UIMediumItem* UIMediumManager ::createHardDiskItem(const UIMedium &medium)1869 UIMediumItem* UIMediumManagerWidget::createHardDiskItem(const UIMedium &medium) 1966 1870 { 1967 1871 /* Make sure passed medium is valid: */ … … 2017 1921 } 2018 1922 2019 void UIMediumManager ::updateMediumItem(const UIMedium &medium)1923 void UIMediumManagerWidget::updateMediumItem(const UIMedium &medium) 2020 1924 { 2021 1925 /* Get medium type: */ … … 2045 1949 } 2046 1950 2047 void UIMediumManager ::deleteMediumItem(const QString &strMediumID)1951 void UIMediumManagerWidget::deleteMediumItem(const QString &strMediumID) 2048 1952 { 2049 1953 /* Search for corresponding tree-widget: */ … … 2079 1983 } 2080 1984 2081 QWidget* UIMediumManager ::tab(UIMediumType type) const1985 QWidget* UIMediumManagerWidget::tab(UIMediumType type) const 2082 1986 { 2083 1987 /* Determine tab index for passed medium type: */ … … 2092 1996 } 2093 1997 2094 QITreeWidget* UIMediumManager ::treeWidget(UIMediumType type) const1998 QITreeWidget* UIMediumManagerWidget::treeWidget(UIMediumType type) const 2095 1999 { 2096 2000 /* Determine tab index for passed medium type: */ … … 2105 2009 } 2106 2010 2107 UIMediumItem* UIMediumManager ::mediumItem(UIMediumType type) const2011 UIMediumItem* UIMediumManagerWidget::mediumItem(UIMediumType type) const 2108 2012 { 2109 2013 /* Get corresponding tree-widget: */ … … 2113 2017 } 2114 2018 2115 QFrame* UIMediumManager ::infoContainer(UIMediumType type) const2019 QFrame* UIMediumManagerWidget::infoContainer(UIMediumType type) const 2116 2020 { 2117 2021 /* Determine tab index for passed medium type: */ … … 2126 2030 } 2127 2031 2128 QLabel* UIMediumManager ::infoLabel(UIMediumType type, int iLabelIndex) const2032 QLabel* UIMediumManagerWidget::infoLabel(UIMediumType type, int iLabelIndex) const 2129 2033 { 2130 2034 /* Determine tab index for passed medium type: */ … … 2144 2048 } 2145 2049 2146 QILabel* UIMediumManager ::infoField(UIMediumType type, int iFieldIndex) const2050 QILabel* UIMediumManagerWidget::infoField(UIMediumType type, int iFieldIndex) const 2147 2051 { 2148 2052 /* Determine tab index for passed medium type: */ … … 2162 2066 } 2163 2067 2164 UIMediumType UIMediumManager ::mediumType(QITreeWidget *pTreeWidget) const2068 UIMediumType UIMediumManagerWidget::mediumType(QITreeWidget *pTreeWidget) const 2165 2069 { 2166 2070 /* Determine tab index of passed tree-widget: */ … … 2175 2079 } 2176 2080 2177 UIMediumType UIMediumManager ::currentMediumType() const2081 UIMediumType UIMediumManagerWidget::currentMediumType() const 2178 2082 { 2179 2083 /* Invalid if tab-widget doesn't exists: */ … … 2185 2089 } 2186 2090 2187 QITreeWidget* UIMediumManager ::currentTreeWidget() const2091 QITreeWidget* UIMediumManagerWidget::currentTreeWidget() const 2188 2092 { 2189 2093 /* Return current tree-widget: */ … … 2191 2095 } 2192 2096 2193 UIMediumItem* UIMediumManager ::currentMediumItem() const2097 UIMediumItem* UIMediumManagerWidget::currentMediumItem() const 2194 2098 { 2195 2099 /* Return current medium-item: */ … … 2197 2101 } 2198 2102 2199 void UIMediumManager ::setCurrentItem(QITreeWidget *pTreeWidget, QTreeWidgetItem *pItem)2103 void UIMediumManagerWidget::setCurrentItem(QITreeWidget *pTreeWidget, QTreeWidgetItem *pItem) 2200 2104 { 2201 2105 /* Make sure passed tree-widget is valid: */ … … 2218 2122 2219 2123 /* static */ 2220 int UIMediumManager ::tabIndex(UIMediumType type)2124 int UIMediumManagerWidget::tabIndex(UIMediumType type) 2221 2125 { 2222 2126 /* Return tab index corresponding to known medium type: */ … … 2234 2138 2235 2139 /* static */ 2236 UIMediumType UIMediumManager ::mediumType(int iIndex)2140 UIMediumType UIMediumManagerWidget::mediumType(int iIndex) 2237 2141 { 2238 2142 /* Return medium type corresponding to known tab index: */ … … 2250 2154 2251 2155 /* static */ 2252 UIMediumItem* UIMediumManager ::searchItem(QITreeWidget *pTreeWidget, const CheckIfSuitableBy &condition, CheckIfSuitableBy *pException)2156 UIMediumItem* UIMediumManagerWidget::searchItem(QITreeWidget *pTreeWidget, const CheckIfSuitableBy &condition, CheckIfSuitableBy *pException) 2253 2157 { 2254 2158 /* Make sure argument is valid: */ … … 2261 2165 2262 2166 /* static */ 2263 UIMediumItem* UIMediumManager ::searchItem(QTreeWidgetItem *pParentItem, const CheckIfSuitableBy &condition, CheckIfSuitableBy *pException)2167 UIMediumItem* UIMediumManagerWidget::searchItem(QTreeWidgetItem *pParentItem, const CheckIfSuitableBy &condition, CheckIfSuitableBy *pException) 2264 2168 { 2265 2169 /* Make sure argument is valid: */ … … 2284 2188 2285 2189 /* static */ 2286 bool UIMediumManager ::checkMediumFor(UIMediumItem *pItem, Action action)2190 bool UIMediumManagerWidget::checkMediumFor(UIMediumItem *pItem, Action action) 2287 2191 { 2288 2192 /* Make sure passed ID is valid: */ … … 2335 2239 2336 2240 /* static */ 2337 UIMediumItem* UIMediumManager ::toMediumItem(QTreeWidgetItem *pItem)2241 UIMediumItem* UIMediumManagerWidget::toMediumItem(QTreeWidgetItem *pItem) 2338 2242 { 2339 2243 /* Cast passed QTreeWidgetItem to UIMediumItem if possible: */ … … 2342 2246 2343 2247 /* static */ 2344 QString UIMediumManager ::formatFieldText(const QString &strText, bool fCompact /* = true */,2248 QString UIMediumManagerWidget::formatFieldText(const QString &strText, bool fCompact /* = true */, 2345 2249 const QString &strElipsis /* = "middle" */) 2346 2250 { … … 2349 2253 .arg(fCompact ? compactString : "") 2350 2254 .arg(strText.isEmpty() ? 2351 tr("--", "no info") :2255 UIMediumManager::tr("--", "no info") : 2352 2256 strText) 2353 2257 .arg(fCompact ? "</compact>" : ""); … … 2355 2259 } 2356 2260 2261 2262 /********************************************************************************************************************************* 2263 * Class UIMediumManagerFactory implementation. * 2264 *********************************************************************************************************************************/ 2265 2266 void UIMediumManagerFactory::create(QIManagerDialog *&pDialog, QWidget *pCenterWidget) 2267 { 2268 pDialog = new UIMediumManager(pCenterWidget); 2269 } 2270 2271 2272 /********************************************************************************************************************************* 2273 * Class UIMediumManagerFactory implementation. * 2274 *********************************************************************************************************************************/ 2275 2276 UIMediumManager::UIMediumManager(QWidget *pCenterWidget) 2277 : QIWithRetranslateUI<QIManagerDialog>(pCenterWidget) 2278 { 2279 } 2280 2281 void UIMediumManager::retranslateUi() 2282 { 2283 /* Translate window title: */ 2284 setWindowTitle(tr("Virtual Media Manager")); 2285 } 2286 2287 void 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 2296 void 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 2357 2313 #include "UIMediumManager.moc" 2358 2314 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.h
r66916 r67046 19 19 #define ___UIMediumManager_h___ 20 20 21 /* Qt includes: */22 #include <QMainWindow>23 24 21 /* GUI includes: */ 22 #include "QIManagerDialog.h" 25 23 #include "QIWithRetranslateUI.h" 26 24 #include "UIMediumDefs.h" … … 53 51 54 52 55 /** Medium Manager dialog. */56 class UIMediumManager : public QIWithRetranslateUI<QMainWindow>53 /** Medium Manager widget. */ 54 class UIMediumManagerWidget : public QIWithRetranslateUI<QWidget> 57 55 { 58 56 Q_OBJECT; … … 61 59 enum Action { Action_Add, Action_Edit, Action_Copy, Action_Modify, Action_Remove, Action_Release }; 62 60 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 70 61 public: 71 62 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 74 protected: 75 76 /** @name Event-handling stuff. 77 * @{ */ 78 /** Handles translation event. */ 79 virtual void retranslateUi() /* override */; 80 /** @} */ 76 81 77 82 private slots: … … 139 144 /** Prepares actions. */ 140 145 void prepareActions(); 141 /** Prepares menu -bar. */142 void prepareMenu Bar();146 /** Prepares menu. */ 147 void prepareMenu(); 143 148 /** Prepares context-menu. */ 144 149 void prepareContextMenu(); 145 /** Prepares central-widget. */146 void prepare CentralWidget();150 /** Prepares widgets. */ 151 void prepareWidgets(); 147 152 /** Prepares toolbar. */ 148 153 void prepareToolBar(); … … 155 160 /** Prepares tab-widget's information-container. */ 156 161 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(); 161 164 162 165 /** Repopulates tree-widgets content. */ … … 184 187 /** Updates information fields for floppy-disk tab. */ 185 188 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();197 189 /** @} */ 198 190 … … 259 251 /** @name General variables. 260 252 * @{ */ 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;268 253 /** Holds whether Virtual Medium Manager should preserve current item change. */ 269 bool 254 bool m_fPreventChangeCurrentItem; 270 255 /** @} */ 271 256 … … 324 309 /** @} */ 325 310 326 /** @name Button-box variables. 327 * @{ */ 328 /** Holds the dialog button-box instance. */ 329 QIDialogButtonBox *m_pButtonBox; 311 /** @name Progress-bar variables. 312 * @{ */ 330 313 /** Holds the progress-bar widget instance. */ 331 314 UIEnumerationProgressBar *m_pProgressBar; … … 333 316 }; 334 317 318 319 /** Medium Manager dialog factory. */ 320 class UIMediumManagerFactory : public QIManagerDialogFactory 321 { 322 protected: 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. */ 331 class UIMediumManager : public QIWithRetranslateUI<QIManagerDialog> 332 { 333 Q_OBJECT; 334 335 protected: 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 335 359 #endif /* !___UIMediumManager_h___ */ 336 360 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp
r67021 r67046 133 133 , m_pGroupMenuAction(0) 134 134 , m_pMachineMenuAction(0) 135 , m_pManagerVirtualMedia(0) 135 136 , m_pManagerHostNetwork(0) 136 137 { … … 305 306 306 307 /* Make sure MM window is not opened: */ 307 if ( UIMediumManager::instance())308 if (m_pManagerVirtualMedia) 308 309 return; 309 310 … … 322 323 if (fIsThereAnyInaccessibleMedium && !msgCenter().warnAboutInaccessibleMedia()) 323 324 { 324 /* Open the MM window (without refresh): */325 UIMediumManager::showModeless(this, false /* refresh? */);325 /* Open the MM window: */ 326 sltOpenVirtualMediumManagerWindow(); 326 327 } 327 328 } … … 424 425 void UISelectorWindow::sltOpenVirtualMediumManagerWindow() 425 426 { 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 441 void UISelectorWindow::sltCloseVirtualMediumManagerWindow() 442 { 443 /* Destroy instance if still exists: */ 444 if (m_pManagerVirtualMedia) 445 { 446 m_pManagerVirtualMedia->close(); 447 UIMediumManagerFactory().cleanup(m_pManagerVirtualMedia); 448 } 428 449 } 429 450 … … 2032 2053 { 2033 2054 /* Close the sub-dialogs first: */ 2055 sltCloseVirtualMediumManagerWindow(); 2034 2056 sltCloseHostNetworkManagerWindow(); 2035 2057 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h
r67021 r67046 125 125 /** Handles call to open Virtual Medium Manager window. */ 126 126 void sltOpenVirtualMediumManagerWindow(); 127 /** Handles call to close Virtual Medium Manager window. */ 128 void sltCloseVirtualMediumManagerWindow(); 127 129 /** Handles call to open Host Network Manager window. */ 128 130 void sltOpenHostNetworkManagerWindow(); … … 359 361 QAction *m_pMachineMenuAction; 360 362 363 /** Holds the Virtual Media Manager window instance. */ 364 QIManagerDialog *m_pManagerVirtualMedia; 361 365 /** Holds the Host Network Manager window instance. */ 362 366 QIManagerDialog *m_pManagerHostNetwork;
Note:
See TracChangeset
for help on using the changeset viewer.