Changeset 70139 in vbox for trunk/src/VBox
- Timestamp:
- Dec 15, 2017 10:59:25 AM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIManagerDialog.cpp
r70074 r70139 108 108 /* Center according requested widget: */ 109 109 VBoxGlobal::centerWidget(this, pCenterWidget, false); 110 111 /* Load the dialog's settings from extradata */ 112 loadSettings(); 110 113 } 111 114 … … 211 214 void QIManagerDialog::cleanup() 212 215 { 216 saveSettings(); 213 217 /* Cleanup menu-bar: */ 214 218 cleanupMenuBar(); … … 223 227 } 224 228 229 void QIManagerDialog::setDialogGeometry(const QRect &geometry) 230 { 231 #ifdef VBOX_WS_MAC 232 /* Use the old approach for OSX: */ 233 move(geometry.topLeft()); 234 resize(geometry.size()); 235 #else /* VBOX_WS_MAC */ 236 /* Use the new approach for Windows/X11: */ 237 VBoxGlobal::setTopLevelGeometry(this, geometry); 238 #endif /* !VBOX_WS_MAC */ 239 240 /* Maximize (if necessary): */ 241 if (shouldBeMaximized()) 242 showMaximized(); 243 } 244 -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIManagerDialog.h
r69877 r70139 124 124 * @note Injected into prepare(), reimplement to postprocess all there. */ 125 125 virtual void finalize() {} 126 /** Loads dialog setting such as geometry from extradata. */ 127 virtual void loadSettings() {} 126 128 127 129 /** Cleanup menu-bar. … … 131 133 * @note Normally you don't need to reimplement it. */ 132 134 void cleanup(); 135 /** Saves dialog setting such as geometry into extradata. */ 136 virtual void saveSettings() const {} 137 133 138 /** @} */ 134 139 … … 150 155 /** Returns button of passed @a enmType. */ 151 156 QPushButton *button(ButtonType enmType) { return m_buttons.value(enmType); } 157 /** Returns center widget. */ 158 QWidget* centerWidget() const { return pCenterWidget; } 152 159 /** @} */ 153 160 … … 158 165 /** @} */ 159 166 167 /** @name Functions related to geometry restoration. 168 * @{ */ 169 /* Sets the position and size of the dialog. */ 170 void setDialogGeometry(const QRect &geometry); 171 /** Returns whether the window should be maximized when geometry being restored. */ 172 virtual bool shouldBeMaximized() const { return false; } 173 /** @} */ 174 160 175 private: 161 176 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerDialog.cpp
r70098 r70139 33 33 34 34 /* GUI includes: */ 35 # include "UIDesktopWidgetWatchdog.h" 36 # include "UIExtraDataManager.h" 35 37 # include "UIIconPool.h" 36 38 # include "UIVMLogViewerDialog.h" 37 39 # include "UIVMLogViewerWidget.h" 40 # include "VBoxGlobal.h" 38 41 39 42 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ … … 94 97 } 95 98 99 void UIVMLogViewerDialog::loadSettings() 100 { 101 const UIVMLogViewerWidget *pWidget = qobject_cast<const UIVMLogViewerWidget *>(widget()); 102 103 /* Restore window geometry: */ 104 /* Getting available geometry to calculate default geometry: */ 105 const QRect desktopRect = gpDesktop->availableGeometry(this); 106 int iDefaultWidth = desktopRect.width() / 2; 107 int iDefaultHeight = desktopRect.height() * 3 / 4; 108 109 /* Try obtain the default width of the current logviewer */ 110 if (pWidget) 111 { 112 int width = pWidget->defaultLogPageWidth(); 113 if (width != 0) 114 iDefaultWidth = width; 115 } 116 117 QRect defaultGeometry(0, 0, iDefaultWidth, iDefaultHeight); 118 if (centerWidget()) 119 defaultGeometry.moveCenter(centerWidget()->geometry().center()); 120 121 /* Load geometry from extradata: */ 122 QRect geometry = gEDataManager->logWindowGeometry(this, defaultGeometry); 123 124 /* Restore geometry: */ 125 LogRel2(("GUI: UIVMLogViewer: Restoring geometry to: Origin=%dx%d, Size=%dx%d\n", 126 geometry.x(), geometry.y(), geometry.width(), geometry.height())); 127 setDialogGeometry(geometry); 128 } 129 130 void UIVMLogViewerDialog::saveSettings() const 131 { 132 /* Save window geometry to extradata: */ 133 const QRect saveGeometry = geometry(); 134 #ifdef VBOX_WS_MAC 135 gEDataManager->setLogWindowGeometry(saveGeometry, ::darwinIsWindowMaximized(this)); 136 #else /* !VBOX_WS_MAC */ 137 gEDataManager->setLogWindowGeometry(saveGeometry, isMaximized()); 138 #endif /* !VBOX_WS_MAC */ 139 LogRel2(("GUI: UIVMLogViewer: Geometry saved as: Origin=%dx%d, Size=%dx%d\n", 140 saveGeometry.x(), saveGeometry.y(), saveGeometry.width(), saveGeometry.height())); 141 } 142 143 bool UIVMLogViewerDialog::shouldBeMaximized() const 144 { 145 return gEDataManager->logWindowShouldBeMaximized(); 146 } 147 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerDialog.h
r70074 r70139 58 58 59 59 public: 60 60 61 UIVMLogViewerDialog(QWidget *pCenterWidget, const CMachine &machine); 61 62 62 63 protected: 63 virtual void configure() /* override */; 64 virtual void configureCentralWidget() /* override */; 65 virtual void finalize() /* override */; 64 65 /** @name Prepare/cleanup cascade. 66 * @{ */ 67 virtual void configure() /* override */; 68 virtual void configureCentralWidget() /* override */; 69 virtual void finalize() /* override */; 70 virtual void saveSettings() const /* override */; 71 virtual void loadSettings() /* override */; 72 /** @} */ 73 /* Reads the related extradata to determine if the dialog should be maximized. */ 74 virtual bool shouldBeMaximized() const /* override */; 66 75 67 76 private: 77 68 78 void retranslateUi(); 69 79 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r70098 r70139 28 28 # endif 29 29 # include <QPlainTextEdit> 30 # include <QScrollBar> 30 31 31 32 /* GUI includes: */ … … 70 71 } 71 72 72 int UIVMLogViewerWidget:: currentLogPagewidth() const73 { 74 if(! currentLogPage())73 int UIVMLogViewerWidget::defaultLogPageWidth() const 74 { 75 if(!m_pViewerContainer) 75 76 return 0; 76 77 77 Q TextDocument *pTextDocument = currentLogPage()->document();78 if(!p TextDocument)78 QWidget *pContainer = m_pViewerContainer->currentWidget(); 79 if(!pContainer) 79 80 return 0; 80 /* Adjust text-edit size: */ 81 pTextDocument->adjustSize(); 82 /* Get corresponding QTextDocument size: */ 83 QSize textSize = pTextDocument->size().toSize(); 84 return textSize.width(); 81 82 QPlainTextEdit *pBrowser = pContainer->findChild<QPlainTextEdit*>(); 83 if (!pBrowser) 84 return 0; 85 /* Compute a width for 132 characters plus scrollbar and frame width: */ 86 int iDefaultWidth = pBrowser->fontMetrics().width(QChar('x')) * 132 + 87 pBrowser->verticalScrollBar()->width() + 88 pBrowser->frameWidth() * 2; 89 90 return iDefaultWidth; 85 91 } 86 92 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h
r70098 r70139 58 58 ~UIVMLogViewerWidget(); 59 59 /* Returns the width of the current log page. return 0 if there is no current log page: */ 60 int currentLogPagewidth() const;60 int defaultLogPageWidth() const; 61 61 62 62 /** Returns the menu. */
Note:
See TracChangeset
for help on using the changeset viewer.