- Timestamp:
- May 20, 2014 4:01:05 PM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/UIVMInfoDialog.cpp
r51308 r51309 76 76 UIVMInfoDialog::UIVMInfoDialog(UIMachineWindow *pMachineWindow) 77 77 : QIWithRetranslateUI<QMainWindow>(0) 78 , m_p PseudoParentWidget(pMachineWindow)78 , m_pMachineWindow(pMachineWindow) 79 79 , m_fIsPolished(false) 80 80 , m_iWidth(0), m_iHeight(0), m_fMax(false) … … 82 82 , m_pTimer(new QTimer(this)) 83 83 { 84 /* Initialize instance early: */84 /* Initialize instance: */ 85 85 m_spInstance = this; 86 86 87 /* Delete dialog on close: */ 88 setAttribute(Qt::WA_DeleteOnClose); 89 90 /* Apply UI decorations */ 91 Ui::UIVMInfoDialog::setupUi(this); 92 93 #ifdef Q_WS_MAC 94 /* No icon for this window on the mac, cause this would act as proxy icon which isn't necessary here. */ 95 setWindowIcon(QIcon()); 96 #else /* !Q_WS_MAC */ 97 /* Apply window icons */ 98 setWindowIcon(UIIconPool::iconSetFull(":/session_info_32px.png", ":/session_info_16px.png")); 99 #endif /* !Q_WS_MAC */ 100 101 /* Setup tab icons: */ 102 mInfoStack->setTabIcon(0, UIIconPool::iconSet(":/session_info_details_16px.png")); 103 mInfoStack->setTabIcon(1, UIIconPool::iconSet(":/session_info_runtime_16px.png")); 104 105 /* Setup focus-proxy for pages: */ 106 mPage1->setFocusProxy(mDetailsText); 107 mPage2->setFocusProxy(mStatisticText); 108 109 /* Setup browsers: */ 110 mDetailsText->viewport()->setAutoFillBackground(false); 111 mStatisticText->viewport()->setAutoFillBackground(false); 112 113 /* Setup margins: */ 114 mDetailsText->setViewportMargins(5, 5, 5, 5); 115 mStatisticText->setViewportMargins(5, 5, 5, 5); 116 117 /* Configure dialog button-box: */ 118 mButtonBox->button(QDialogButtonBox::Close)->setShortcut(Qt::Key_Escape); 119 120 /* Setup handlers: */ 121 connect(pMachineWindow->uisession(), SIGNAL(sigMediumChange(const CMediumAttachment&)), this, SLOT(sltUpdateDetails())); 122 connect(pMachineWindow->uisession(), SIGNAL(sigSharedFolderChange()), this, SLOT(sltUpdateDetails())); 123 /* TODO_NEW_CORE: this is ofc not really right in the mm sense. There are more than one screens. */ 124 connect(pMachineWindow->machineView(), SIGNAL(resizeHintDone()), this, SLOT(sltProcessStatistics())); 125 connect(mInfoStack, SIGNAL(currentChanged(int)), this, SLOT(sltHandlePageChanged(int))); 126 connect(&vboxGlobal(), SIGNAL(sigMediumEnumerationFinished()), this, SLOT(sltUpdateDetails())); 127 connect(m_pTimer, SIGNAL(timeout()), this, SLOT(sltProcessStatistics())); 128 129 /* Loading language constants: */ 130 retranslateUi(); 131 132 /* Details page update: */ 133 sltUpdateDetails(); 134 135 /* Statistics page update: */ 136 sltProcessStatistics(); 137 m_pTimer->start(5000); 138 139 /* Load dialog attributes for this VM: */ 140 QString strSize = m_session.GetMachine().GetExtraData(GUI_InfoDlgState); 141 if (strSize.isEmpty()) 142 { 143 m_iWidth = 400; 144 m_iHeight = 450; 145 m_fMax = false; 146 } 147 else 148 { 149 QStringList list = strSize.split(','); 150 m_iWidth = list[0].toInt(), m_iHeight = list[1].toInt(); 151 m_fMax = list[2] == "max"; 152 } 153 154 /* Make statistics page the default one: */ 155 mInfoStack->setCurrentIndex(1); 87 /* Prepare: */ 88 prepare(); 156 89 } 157 90 158 91 UIVMInfoDialog::~UIVMInfoDialog() 159 92 { 160 /* Save dialog attributes for this VM: */ 161 QString strSize("%1,%2,%3"); 162 m_session.GetMachine().SetExtraData(GUI_InfoDlgState, 163 strSize.arg(m_iWidth).arg(m_iHeight).arg(isMaximized() ? "max" : "normal")); 164 165 /* Deinitialize instance finally: */ 93 /* Cleanup: */ 94 cleanup(); 95 96 /* Deinitialize instance: */ 166 97 m_spInstance = 0; 167 98 } … … 380 311 /* Load window size, adjust position and load window state finally: */ 381 312 resize(m_iWidth, m_iHeight); 382 vboxGlobal().centerWidget(this, m_p PseudoParentWidget, false);313 vboxGlobal().centerWidget(this, m_pMachineWindow, false); 383 314 if (m_fMax) 384 315 QTimer::singleShot(0, this, SLOT(showMaximized())); … … 418 349 /* Focus the browser on shown page: */ 419 350 mInfoStack->widget(iIndex)->setFocus(); 351 } 352 353 void UIVMInfoDialog::prepare() 354 { 355 /* Prepare dialog: */ 356 prepareThis(); 357 /* Load settings: */ 358 loadSettings(); 359 } 360 361 void UIVMInfoDialog::prepareThis() 362 { 363 /* Delete dialog on close: */ 364 setAttribute(Qt::WA_DeleteOnClose); 365 /* Delete dialog on machine-window destruction: */ 366 connect(m_pMachineWindow, SIGNAL(destroyed(QObject*)), this, SLOT(suicide())); 367 368 #ifdef Q_WS_MAC 369 /* No icon for this window on the mac, cause this would act as proxy icon which isn't necessary here. */ 370 setWindowIcon(QIcon()); 371 #else /* !Q_WS_MAC */ 372 /* Apply window icons */ 373 setWindowIcon(UIIconPool::iconSetFull(":/session_info_32px.png", ":/session_info_16px.png")); 374 #endif /* !Q_WS_MAC */ 375 376 /* Apply UI decorations */ 377 Ui::UIVMInfoDialog::setupUi(this); 378 379 /* Setup tab icons: */ 380 mInfoStack->setTabIcon(0, UIIconPool::iconSet(":/session_info_details_16px.png")); 381 mInfoStack->setTabIcon(1, UIIconPool::iconSet(":/session_info_runtime_16px.png")); 382 383 /* Setup focus-proxy for pages: */ 384 mPage1->setFocusProxy(mDetailsText); 385 mPage2->setFocusProxy(mStatisticText); 386 387 /* Setup browsers: */ 388 mDetailsText->viewport()->setAutoFillBackground(false); 389 mStatisticText->viewport()->setAutoFillBackground(false); 390 391 /* Setup margins: */ 392 mDetailsText->setViewportMargins(5, 5, 5, 5); 393 mStatisticText->setViewportMargins(5, 5, 5, 5); 394 395 /* Configure dialog button-box: */ 396 mButtonBox->button(QDialogButtonBox::Close)->setShortcut(Qt::Key_Escape); 397 398 /* Setup handlers: */ 399 connect(m_pMachineWindow->uisession(), SIGNAL(sigMediumChange(const CMediumAttachment&)), this, SLOT(sltUpdateDetails())); 400 connect(m_pMachineWindow->uisession(), SIGNAL(sigSharedFolderChange()), this, SLOT(sltUpdateDetails())); 401 /* TODO_NEW_CORE: this is ofc not really right in the mm sense. There are more than one screens. */ 402 connect(m_pMachineWindow->machineView(), SIGNAL(resizeHintDone()), this, SLOT(sltProcessStatistics())); 403 connect(mInfoStack, SIGNAL(currentChanged(int)), this, SLOT(sltHandlePageChanged(int))); 404 connect(&vboxGlobal(), SIGNAL(sigMediumEnumerationFinished()), this, SLOT(sltUpdateDetails())); 405 connect(m_pTimer, SIGNAL(timeout()), this, SLOT(sltProcessStatistics())); 406 407 /* Loading language constants: */ 408 retranslateUi(); 409 410 /* Details page update: */ 411 sltUpdateDetails(); 412 413 /* Statistics page update: */ 414 sltProcessStatistics(); 415 m_pTimer->start(5000); 416 417 /* Make statistics page the default one: */ 418 mInfoStack->setCurrentIndex(1); 419 } 420 421 void UIVMInfoDialog::loadSettings() 422 { 423 /* Load dialog geometry: */ 424 QString strSize = m_session.GetMachine().GetExtraData(GUI_InfoDlgState); 425 if (strSize.isEmpty()) 426 { 427 m_iWidth = 400; 428 m_iHeight = 450; 429 m_fMax = false; 430 } 431 else 432 { 433 QStringList list = strSize.split(','); 434 m_iWidth = list[0].toInt(), m_iHeight = list[1].toInt(); 435 m_fMax = list[2] == "max"; 436 } 437 } 438 439 void UIVMInfoDialog::saveSettings() 440 { 441 /* Save dialog geometry: */ 442 QString strSize("%1,%2,%3"); 443 m_session.GetMachine().SetExtraData(GUI_InfoDlgState, 444 strSize.arg(m_iWidth).arg(m_iHeight).arg(isMaximized() ? "max" : "normal")); 445 } 446 447 void UIVMInfoDialog::cleanup() 448 { 449 /* Save settings: */ 450 saveSettings(); 420 451 } 421 452 -
trunk/src/VBox/Frontends/VirtualBox/src/UIVMInfoDialog.h
r51308 r51309 70 70 private slots: 71 71 72 /** Slot to destroy dialog immediately. */ 73 void suicide() { delete this; } 72 74 /** Slot to update general VM details. */ 73 75 void sltUpdateDetails(); … … 78 80 79 81 private: 82 83 /** General prepare helper. */ 84 void prepare(); 85 /** Dialog prepare helper. */ 86 void prepareThis(); 87 /** Load settings helper. */ 88 void loadSettings(); 89 90 /** Save settings helper. */ 91 void saveSettings(); 92 // /** Dialog cleanup helper. */ 93 // void cleanupThis() {} 94 /** General cleanup helper. */ 95 void cleanup(); 80 96 81 97 /** Helper to parse passed VM statistics @a aText. */ … … 98 114 /** Dialog instance pointer. */ 99 115 static UIVMInfoDialog *m_spInstance; 100 /** Widgetto center dialog according. */101 QWidget *m_pPseudoParentWidget;116 /** Machine-window to center dialog according. */ 117 UIMachineWindow *m_pMachineWindow; 102 118 /** Whether dialog was polished. */ 103 119 bool m_fIsPolished;
Note:
See TracChangeset
for help on using the changeset viewer.