Changeset 70029 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Dec 8, 2017 1:52:37 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIManagerDialog.cpp
r69726 r70029 175 175 void QIManagerDialog::prepareMenuBar() 176 176 { 177 if (!m_pWidgetMenu) 178 return; 177 179 /* Add widget menu: */ 178 180 menuBar()->addMenu(m_pWidgetMenu); -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerDialog.cpp
r70027 r70029 33 33 34 34 /* GUI includes: */ 35 # include "UIIconPool.h" 35 36 # include "UIVMLogViewerDialog.h" 36 37 # include "UIVMLogViewerWidget.h" 37 38 38 /* COM includes: */39 # include "COMEnums.h"40 41 39 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 42 40 43 /** Holds the VM Log-Viewer array. */ 44 VMLogViewerMap UIVMLogViewerDialog::m_viewers = VMLogViewerMap(); 45 46 47 UIVMLogViewerDialog::UIVMLogViewerDialog(QWidget *pParent, const CMachine &machine) 48 : QIWithRetranslateUI<QIDialog>(pParent) 49 , m_strMachineUUID(machine.GetHardwareUUID()) 41 UIVMLogViewerDialogFactory::UIVMLogViewerDialogFactory(const CMachine &machine) 42 :m_comMachine(machine) 50 43 { 51 prepare(machine);52 44 } 53 45 54 UIVMLogViewerDialog::~UIVMLogViewerDialog()46 void UIVMLogViewerDialogFactory::create(QIManagerDialog *&pDialog, QWidget *pCenterWidget) 55 47 { 56 cleanup();48 pDialog = new UIVMLogViewerDialog(pCenterWidget, m_comMachine); 57 49 } 58 50 59 void UIVMLogViewerDialog::showLogViewerFor(QWidget* parent, const CMachine &machine) 51 UIVMLogViewerDialog::UIVMLogViewerDialog(QWidget *pCenterWidget, const CMachine &machine) 52 : QIWithRetranslateUI<QIManagerDialog>(pCenterWidget) 53 , m_comMachine(machine) 60 54 { 61 if (m_viewers.contains(machine.GetHardwareUUID()))62 {63 showLogViewerDialog(m_viewers[machine.GetHardwareUUID()]);64 return;65 }66 UIVMLogViewerDialog dialog(parent, machine);67 dialog.exec();68 55 } 69 56 70 57 void UIVMLogViewerDialog::retranslateUi() 71 58 { 72 m_pCloseButton->setText(UIVMLogViewerWidget::tr("Close"));59 button(ButtonType_Close)->setText(UIVMLogViewerWidget::tr("Close")); 73 60 } 74 61 75 void UIVMLogViewerDialog:: prepare(const CMachine& machine)62 void UIVMLogViewerDialog::configureCentralWidget() 76 63 { 77 setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); 78 /* According to QDoc passing widget to layout's ctor also handles setLayout(..) call: */ 79 m_pMainLayout = new QVBoxLayout(this); 80 81 UIVMLogViewerWidget *viewerWidget = new UIVMLogViewerWidget(this, machine); 82 m_pMainLayout->addWidget(viewerWidget); 83 84 m_pButtonBox = new QDialogButtonBox(this); 85 m_pCloseButton = m_pButtonBox->addButton("Close", QDialogButtonBox::RejectRole); 86 m_pMainLayout->addWidget(m_pButtonBox); 87 connect(m_pCloseButton, &QPushButton::clicked, this, &UIVMLogViewerDialog::close); 88 89 m_viewers[m_strMachineUUID] = this; 90 91 /* Load settings: */ 92 loadSettings(); 93 94 showLogViewerDialog(this); 64 /* Create widget: */ 65 UIVMLogViewerWidget *pWidget = new UIVMLogViewerWidget(this, m_comMachine); 66 AssertPtrReturnVoid(pWidget); 67 { 68 /* Configure widget: */ 69 setWidget(pWidget); 70 //setWidgetMenu(pWidget->menu()); 71 #ifdef VBOX_WS_MAC 72 //setWidgetToolbar(pWidget->toolbar()); 73 #endif 74 /* Add into layout: */ 75 centralWidget()->layout()->addWidget(pWidget); 76 } 95 77 } 96 78 97 void UIVMLogViewerDialog:: showLogViewerDialog(UIVMLogViewerDialog *logViewerDialog)79 void UIVMLogViewerDialog::configure() 98 80 { 99 logViewerDialog->show(); 100 logViewerDialog->raise(); 101 logViewerDialog->setWindowState(logViewerDialog->windowState() & ~Qt::WindowMinimized); 102 logViewerDialog->activateWindow(); 81 /* Apply window icons: */ 82 setWindowIcon(UIIconPool::iconSetFull(":/diskimage_32px.png", ":/diskimage_16px.png")); 103 83 } 104 105 void UIVMLogViewerDialog::cleanup()106 {107 saveSettings();108 /* Remove log-viewer: */109 if (!m_strMachineUUID.isNull())110 m_viewers.remove(m_strMachineUUID);111 }112 113 void UIVMLogViewerDialog::loadSettings()114 {115 }116 117 void UIVMLogViewerDialog::saveSettings()118 {119 } -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerDialog.h
r70027 r70029 24 24 25 25 /* GUI includes: */ 26 #include "QI Dialog.h"26 #include "QIManagerDialog.h" 27 27 #include "QIWithRetranslateUI.h" 28 29 /* COM includes: */ 30 # include "COMEnums.h" 31 #include "CMachine.h" 28 32 29 33 /* Forward declarations: */ … … 33 37 class UIVMLogViewerDialog; 34 38 35 /* Type definitions: */ 36 typedef QMap<QString, UIVMLogViewerDialog*> VMLogViewerMap; 39 40 /** QIManagerDialogFactory used as a factory for Virtual Media Manager dialog. */ 41 class UIVMLogViewerDialogFactory : public QIManagerDialogFactory 42 { 43 public: 44 UIVMLogViewerDialogFactory(const CMachine &machine); 45 46 protected: 47 /** Creates derived @a pDialog instance. 48 * @param pCenterWidget Brings the widget to center wrt. pCenterWidget. */ 49 virtual void create(QIManagerDialog *&pDialog, QWidget *pCenterWidget) /* override */; 50 51 CMachine m_comMachine; 52 }; 37 53 38 54 /** A QIDialog to display machine logs. */ 39 class UIVMLogViewerDialog : public QIWithRetranslateUI<QI Dialog>55 class UIVMLogViewerDialog : public QIWithRetranslateUI<QIManagerDialog> 40 56 { 41 57 Q_OBJECT; 42 58 43 59 public: 44 UIVMLogViewerDialog(QWidget *pParent, const CMachine &machine); 45 ~UIVMLogViewerDialog(); 60 UIVMLogViewerDialog(QWidget *pCenterWidget, const CMachine &machine); 46 61 47 /** Static method to create/show VM Log Viewer by passing @a pParent to QWidget base-class constructor. 48 * @param machine Specifies the machine for which VM Log-Viewer is requested. */49 static void showLogViewerFor(QWidget* parent, const CMachine &machine);62 protected: 63 virtual void configure() /* override */; 64 virtual void configureCentralWidget() /* override */; 50 65 51 66 private: 67 void retranslateUi(); 52 68 53 static void showLogViewerDialog(UIVMLogViewerDialog *logViewerDialog); 54 void retranslateUi(); 55 void prepare(const CMachine& machine); 56 void cleanup(); 57 58 /** Load settings helper. */ 59 void loadSettings(); 60 /** Save settings helper. */ 61 void saveSettings(); 62 63 QPushButton *m_pCloseButton; 64 QDialogButtonBox *m_pButtonBox; 65 QVBoxLayout *m_pMainLayout; 66 67 /** Holds the UUID of the machine instance. */ 68 QString m_strMachineUUID; 69 70 /** Holds the list of all VM Log Viewers. */ 71 static VMLogViewerMap m_viewers; 69 CMachine m_comMachine; 72 70 }; 73 71 74 72 #endif /* !___UIVMLogViewerDialog_h___ */ 73 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r70027 r70029 51 51 : QIWithRetranslateUI<QWidget>(pParent) 52 52 , m_fIsPolished(false) 53 , m_ machine(machine)53 , m_comMachine(machine) 54 54 , m_pButtonBox(0) 55 55 , m_pMainLayout(0) … … 119 119 { 120 120 /* Query the log file name for index i: */ 121 QString strFileName = m_ machine.QueryLogFilename(i);121 QString strFileName = m_comMachine.QueryLogFilename(i); 122 122 if (!strFileName.isEmpty()) 123 123 { … … 127 127 while (true) 128 128 { 129 QVector<BYTE> data = m_ machine.ReadLog(i, uOffset, _1M);129 QVector<BYTE> data = m_comMachine.ReadLog(i, uOffset, _1M); 130 130 if (data.size() == 0) 131 131 break; … … 160 160 "<b>Refresh</b> button to rescan the log folder " 161 161 "<nobr><b>%1</b></nobr>.</p>") 162 .arg(m_ machine.GetLogFolder()));162 .arg(m_comMachine.GetLogFolder())); 163 163 /* We don't want it to remain white: */ 164 164 QPalette pal = pDummyLog->palette(); … … 190 190 const QDateTime dtInfo = fileInfo.lastModified(); 191 191 const QString strDtString = dtInfo.toString("yyyy-MM-dd-hh-mm-ss"); 192 const QString strDefaultFileName = QString("%1-%2.log").arg(m_ machine.GetName()).arg(strDtString);192 const QString strDefaultFileName = QString("%1-%2.log").arg(m_comMachine.GetName()).arg(strDtString); 193 193 const QString strDefaultFullName = QDir::toNativeSeparators(QDir::home().absolutePath() + "/" + strDefaultFileName); 194 194 /* Show "save as" dialog: */ … … 207 207 QFile::remove(strNewFileName); 208 208 /* Copy log into the file: */ 209 QFile::copy(m_ machine.QueryLogFilename(m_pViewerContainer->currentIndex()), strNewFileName);209 QFile::copy(m_comMachine.QueryLogFilename(m_pViewerContainer->currentIndex()), strNewFileName); 210 210 } 211 211 } … … 243 243 { 244 244 /* Create VM Log-Viewer container: */ 245 //m_pViewerContainer = new QITabWidget(centralWidget());246 245 m_pViewerContainer = new QITabWidget(this); 247 246 AssertPtrReturnVoid(m_pViewerContainer); … … 256 255 { 257 256 /* Configure VM Log-Viewer search-panel: */ 258 //centralWidget()->installEventFilter(m_pSearchPanel);257 installEventFilter(m_pSearchPanel); 259 258 m_pSearchPanel->hide(); 260 259 /* Add VM Log-Viewer search-panel to main-layout: */ … … 267 266 { 268 267 /* Configure VM Log-Viewer filter-panel: */ 269 //centralWidget()->installEventFilter(m_pFilterPanel);268 installEventFilter(m_pFilterPanel); 270 269 m_pFilterPanel->hide(); 271 270 /* Add VM Log-Viewer filter-panel to main-layout: */ … … 305 304 { 306 305 /* Setup a dialog caption: */ 307 if (!m_ machine.isNull())308 setWindowTitle(tr("%1 - VirtualBox Log Viewer").arg(m_ machine.GetName()));306 if (!m_comMachine.isNull()) 307 setWindowTitle(tr("%1 - VirtualBox Log Viewer").arg(m_comMachine.GetName())); 309 308 310 309 /* Translate other tags: */ -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h
r70027 r70029 115 115 116 116 /** Holds the machine instance. */ 117 CMachine m_ machine;117 CMachine m_comMachine; 118 118 119 119 /** Holds container for log-pages. */ … … 149 149 150 150 #endif /* !___UIVMLogViewerWidget_h___ */ 151 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r69958 r70029 844 844 , m_pHostLedsState(NULL) 845 845 , m_fIsHidLedsSyncEnabled(false) 846 , m_pLogViewerDialog(0) 846 847 { 847 848 } … … 2382 2383 void UIMachineLogic::sltShowLogDialog() 2383 2384 { 2384 /* Show VM Log Viewer: */ 2385 UIVMLogViewerDialog::showLogViewerFor(activeMachineWindow(), machine()); 2385 if (machine().isNull() || !activeMachineWindow()) 2386 return; 2387 2388 /* Create a logviewer only if we don't have one already */ 2389 if (m_pLogViewerDialog) 2390 return; 2391 2392 QIManagerDialog *pLogViewerDialog; 2393 UIVMLogViewerDialogFactory dialogFactory(machine()); 2394 dialogFactory.prepare(pLogViewerDialog, activeMachineWindow()); 2395 if (pLogViewerDialog) 2396 { 2397 m_pLogViewerDialog = pLogViewerDialog; 2398 2399 /* Show instance: */ 2400 pLogViewerDialog->show(); 2401 pLogViewerDialog->setWindowState(pLogViewerDialog->windowState() & ~Qt::WindowMinimized); 2402 pLogViewerDialog->activateWindow(); 2403 connect(pLogViewerDialog, &QIManagerDialog::sigClose, 2404 this, &UIMachineLogic::sltCloseLogViewerWindow); 2405 } 2406 } 2407 2408 void UIMachineLogic::sltCloseLogViewerWindow() 2409 { 2410 QIManagerDialog* pDialog = qobject_cast<QIManagerDialog*>(sender()); 2411 if (m_pLogViewerDialog != pDialog || !pDialog) 2412 return; 2413 2414 /* Set the m_pLogViewerDialog to NULL before closing the dialog. or we will have redundant deletes*/ 2415 m_pLogViewerDialog = 0; 2416 pDialog->close(); 2417 UIVMLogViewerDialogFactory(CMachine()).cleanup(pDialog); 2386 2418 } 2387 2419 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
r69958 r70029 29 29 class QAction; 30 30 class QActionGroup; 31 class QIManagerDialog; 31 32 class UISession; 32 33 class UIActionPool; … … 194 195 /** Handles host-screen available-area change. */ 195 196 virtual void sltHostScreenAvailableAreaChange(); 197 198 /** Handles close signal from the log viewer dialog. */ 199 void sltCloseLogViewerWindow(); 196 200 197 201 protected: … … 419 423 bool m_fIsHidLedsSyncEnabled; 420 424 425 /** Holds the log viewer dialog instance. */ 426 QIManagerDialog *m_pLogViewerDialog; 427 421 428 /* Friend classes: */ 422 429 friend class UIMachineWindow; -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp
r70024 r70029 1025 1025 1026 1026 /* Show VM Log Viewer: */ 1027 UIVMLogViewerDialog::showLogViewerFor(this, pItem->machine()); 1028 } 1027 if (!m_logViewers[pItem->machine().GetHardwareUUID()]) 1028 { 1029 QIManagerDialog *pLogViewerDialog; 1030 UIVMLogViewerDialogFactory dialogFactory(pItem->machine()); 1031 dialogFactory.prepare(pLogViewerDialog, this); 1032 if (pLogViewerDialog) 1033 { 1034 m_logViewers[pItem->machine().GetHardwareUUID()] = pLogViewerDialog; 1035 1036 /* Show instance: */ 1037 pLogViewerDialog->show(); 1038 pLogViewerDialog->setWindowState(pLogViewerDialog->windowState() & ~Qt::WindowMinimized); 1039 pLogViewerDialog->activateWindow(); 1040 connect(pLogViewerDialog, &QIManagerDialog::sigClose, 1041 this, &UISelectorWindow::sltCloseLogViewerWindow); 1042 } 1043 } 1044 } 1045 } 1046 1047 void UISelectorWindow::sltCloseLogViewerWindow() 1048 { 1049 QMap<QString, QIManagerDialog*>::iterator sendersIterator = m_logViewers.begin(); 1050 1051 /* Search for the sender of the signal within the m_logViewers map: */ 1052 while (sendersIterator != m_logViewers.end() && sendersIterator.value() != sender()) 1053 ++sendersIterator; 1054 /* Do nothing if we cannot find it with the map: */ 1055 if (sendersIterator == m_logViewers.end()) 1056 return; 1057 1058 QIManagerDialog* pDialog = qobject_cast<QIManagerDialog*>(sendersIterator.value()); 1059 if (!pDialog) 1060 return; 1061 1062 /* First remove this log viewer dialog from the map. This should be 1063 done before closing the dialog which will incur a second call to 1064 this function and result in double delete!!!: */ 1065 m_logViewers.erase(sendersIterator); 1066 pDialog->close(); 1067 UIVMLogViewerDialogFactory(CMachine()).cleanup(pDialog); 1029 1068 } 1030 1069 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h
r68392 r70029 42 42 class UIVMItem; 43 43 44 /* Type definitions: */ 45 typedef QMap<QString, QIManagerDialog*> VMLogViewerMap; 44 46 45 47 /** Singleton QIMainWindow extension … … 123 125 /** Handles call to close Host Network Manager window. */ 124 126 void sltCloseHostNetworkManagerWindow(); 127 /** Handles call to close a Machine LogViewer window. */ 128 void sltCloseLogViewerWindow(); 125 129 /** Handles call to open Import Appliance wizard. 126 130 * @param strFileName can bring the name of file to import appliance from. */ … … 375 379 /** Holds the Host Network Manager window instance. */ 376 380 QIManagerDialog *m_pManagerHostNetwork; 381 /** Holds a map of (machineUUID, UIVMLogViewerDialog). */ 382 VMLogViewerMap m_logViewers; 377 383 }; 378 384
Note:
See TracChangeset
for help on using the changeset viewer.