Changeset 72410 in vbox for trunk/src/VBox
- Timestamp:
- Jun 1, 2018 12:48:18 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/medium
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.cpp
r72409 r72410 30 30 # include "QITabWidget.h" 31 31 # include "VBoxGlobal.h" 32 # include "UIDesktopWidgetWatchdog.h" 32 33 # include "UIExtraDataManager.h" 33 34 # include "UIMediumSelector.h" … … 63 64 , m_pAttachedSubTreeRoot(0) 64 65 , m_pNotAttachedSubTreeRoot(0) 66 , m_pParent(pParent) 65 67 { 66 68 configure(); … … 89 91 if (m_pActionAdd) 90 92 { 91 m_pActionAdd->setText(QApplication::translate("UIMediumManager", "&Add ..."));93 m_pActionAdd->setText(QApplication::translate("UIMediumManager", "&Add from file...")); 92 94 m_pActionAdd->setToolTip(QApplication::translate("UIMediumManager", "Add Disk Image File")); 93 95 m_pActionAdd->setStatusTip(QApplication::translate("UIMediumManager", "Add disk image file")); … … 102 104 if (m_pButtonBox) 103 105 m_pButtonBox->button(QDialogButtonBox::Ok)->setText("Add Selected"); 106 107 if (m_pTreeWidget) 108 { 109 m_pTreeWidget->headerItem()->setText(0, QApplication::translate("UIMediumManager","Name")); 110 } 104 111 } 105 112 … … 108 115 /* Apply window icons: */ 109 116 setWindowIcon(UIIconPool::iconSetFull(":/diskimage_32px.png", ":/diskimage_16px.png")); 117 118 110 119 prepareActions(); 111 120 prepareWidgets(); 112 121 prepareConnections(); 122 113 123 } 114 124 … … 166 176 if (m_pActionRefresh) 167 177 connect(m_pActionRefresh, &QAction::triggered, this, &UIMediumSelector::sltHandleRefresh); 178 179 if (m_pTreeWidget) 180 connect(m_pTreeWidget, &QITreeWidget::itemSelectionChanged, this, &UIMediumSelector::sltHandleItemSelectionChanged); 181 182 if (m_pButtonBox) 183 { 184 connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UIMediumSelector::close); 185 connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UIMediumSelector::accept); 186 } 168 187 } 169 188 … … 244 263 { 245 264 m_pTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection); 246 //connect(m_pTreeWidget, &QITreeWidget::currentItemChanged, this, &UIMediumSelector::sltHandleCurrentItemChanged);247 connect(m_pTreeWidget, &QITreeWidget::itemSelectionChanged, this, &UIMediumSelector::sltHandleItemSelectionChanged);248 265 m_pMainLayout->addWidget(m_pTreeWidget); 249 } 250 251 m_pButtonBox = new QIDialogButtonBox; 266 267 } 268 269 m_pButtonBox = new QIDialogButtonBox; 252 270 if (m_pButtonBox) 253 271 { … … 255 273 m_pButtonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok); 256 274 m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape); 257 // connect(m_pButtonBox, &QIDialogButtonBox::helpRequested, &msgCenter(), &UIMessageCenter::sltShowHelpHelpDialog);258 connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UIMediumSelector::close);259 connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UIMediumSelector::accept);260 275 261 276 /* Add button-box into main layout: */ … … 338 353 /* Apply language settings: */ 339 354 retranslateUi(); 355 } 356 357 void UIMediumSelector::showEvent(QShowEvent *pEvent) 358 { 359 360 /* Try to determine the initial size: */ 361 QSize proposedSize; 362 int iHostScreen = 0; 363 if (m_pParent) 364 iHostScreen = gpDesktop->screenNumber(m_pParent); 365 else 366 iHostScreen = gpDesktop->screenNumber(this); 367 if (iHostScreen >= 0 && iHostScreen < gpDesktop->screenCount()) 368 { 369 /* On the basis of current host-screen geometry if possible: */ 370 const QRect screenGeometry = gpDesktop->screenGeometry(iHostScreen); 371 if (screenGeometry.isValid()) 372 proposedSize = screenGeometry.size() * 7 / 15; 373 } 374 /* Fallback to default size if we failed: */ 375 if (proposedSize.isNull()) 376 proposedSize = QSize(800, 600); 377 /* Resize to initial size: */ 378 resize(proposedSize); 379 380 if (m_pParent) 381 VBoxGlobal::centerWidget(this, m_pParent, false); 382 340 383 } 341 384 … … 396 439 m_pTreeWidget->expandItem(m_pNotAttachedSubTreeRoot); 397 440 398 // QItemSelectionModel *selectionModel = m_pTreeWidget->selectionModel(); 399 // selectionModel->clearSelection(); 400 401 // /* Remember current medium-items: */ 402 // if (UIMediumItem *pMediumItem = mediumItem(UIMediumType_HardDisk)) 403 // m_strCurrentIdHD = pMediumItem->id(); 404 // if (UIMediumItem *pMediumItem = mediumItem(UIMediumType_DVD)) 405 // m_strCurrentIdCD = pMediumItem->id(); 406 // if (UIMediumItem *pMediumItem = mediumItem(UIMediumType_Floppy)) 407 // m_strCurrentIdFD = pMediumItem->id(); 408 409 // /* Clear tree-widgets: */ 410 // QITreeWidget *pTreeWidgetHD = treeWidget(UIMediumType_HardDisk); 411 // if (pTreeWidgetHD) 412 // { 413 // setCurrentItem(pTreeWidgetHD, 0); 414 // pTreeWidgetHD->clear(); 415 // } 416 // QITreeWidget *pTreeWidgetCD = treeWidget(UIMediumType_DVD); 417 // if (pTreeWidgetCD) 418 // { 419 // setCurrentItem(pTreeWidgetCD, 0); 420 // pTreeWidgetCD->clear(); 421 // } 422 // QITreeWidget *pTreeWidgetFD = treeWidget(UIMediumType_Floppy); 423 // if (pTreeWidgetFD) 424 // { 425 // setCurrentItem(pTreeWidgetFD, 0); 426 // pTreeWidgetFD->clear(); 427 // } 428 429 // /* Create medium-items (do not change current one): */ 430 // m_fPreventChangeCurrentItem = true; 431 432 // m_fPreventChangeCurrentItem = false; 433 434 // /* Select first item as current one if nothing selected: */ 435 // if (pTreeWidgetHD && !mediumItem(UIMediumType_HardDisk)) 436 // if (QTreeWidgetItem *pItem = pTreeWidgetHD->topLevelItem(0)) 437 // setCurrentItem(pTreeWidgetHD, pItem); 438 // if (pTreeWidgetCD && !mediumItem(UIMediumType_DVD)) 439 // if (QTreeWidgetItem *pItem = pTreeWidgetCD->topLevelItem(0)) 440 // setCurrentItem(pTreeWidgetCD, pItem); 441 // if (pTreeWidgetFD && !mediumItem(UIMediumType_Floppy)) 442 // if (QTreeWidgetItem *pItem = pTreeWidgetFD->topLevelItem(0)) 443 // setCurrentItem(pTreeWidgetFD, pItem); 444 445 446 } 441 } -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.h
r72406 r72410 37 37 38 38 39 /** QIDialog extension providing GUI with the dialog to select an existing media. */39 /** QIDialog extension providing GUI with a dialog to select an existing medium. */ 40 40 class SHARED_LIBRARY_STUFF UIMediumSelector : public QIWithRetranslateUI<QIDialog> 41 41 { … … 50 50 QStringList selectedMediumIds() const; 51 51 52 protected: 53 54 void showEvent(QShowEvent *pEvent); 55 52 56 private slots: 53 57 54 58 void sltAddMedium(); 55 //void sltHandleCurrentItemChanged();56 59 void sltHandleItemSelectionChanged(); 57 60 void sltHandleMediumEnumerationStart(); … … 97 100 /** All the known media that are not attached to any vm are added under the following top level tree item */ 98 101 QITreeWidgetItem *m_pNotAttachedSubTreeRoot; 102 QWidget *m_pParent; 99 103 }; 100 104
Note:
See TracChangeset
for help on using the changeset viewer.