Changeset 76944 in vbox
- Timestamp:
- Jan 23, 2019 7:39:42 AM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 4 edited
- 2 copied
- 4 moved
-
Makefile.kmk (modified) (2 diffs)
-
src/medium/viso/UIVisoConfigurationPanel.cpp (moved) (moved from trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoConfigurationDialog.cpp ) (3 diffs)
-
src/medium/viso/UIVisoConfigurationPanel.h (moved) (moved from trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoConfigurationDialog.h ) (5 diffs)
-
src/medium/viso/UIVisoCreator.cpp (modified) (11 diffs)
-
src/medium/viso/UIVisoCreator.h (modified) (4 diffs)
-
src/medium/viso/UIVisoCreatorDefs.h (modified) (1 diff)
-
src/medium/viso/UIVisoCreatorOptionsPanel.cpp (moved) (moved from trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreatorOptionsDialog.cpp ) (3 diffs)
-
src/medium/viso/UIVisoCreatorOptionsPanel.h (moved) (moved from trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreatorOptionsDialog.h ) (4 diffs)
-
src/medium/viso/UIVisoCreatorPanel.cpp (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerPanel.cpp ) (7 diffs)
-
src/medium/viso/UIVisoCreatorPanel.h (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerPanel.h ) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r76820 r76944 832 832 src/medium/viso/UIVisoContentBrowser.h \ 833 833 src/medium/viso/UIVisoCreator.h \ 834 src/medium/viso/UIVisoConfigurationDialog.h \ 835 src/medium/viso/UIVisoCreatorOptionsDialog.h \ 834 src/medium/viso/UIVisoCreatorPanel.h \ 835 src/medium/viso/UIVisoConfigurationPanel.h \ 836 src/medium/viso/UIVisoCreatorOptionsPanel.h \ 836 837 src/medium/viso/UIVisoHostBrowser.h \ 837 838 src/settings/UISettingsDialog.h \ … … 1297 1298 src/medium/viso/UIVisoContentBrowser.cpp \ 1298 1299 src/medium/viso/UIVisoCreator.cpp \ 1299 src/medium/viso/UIVisoConfigurationDialog.cpp \ 1300 src/medium/viso/UIVisoCreatorOptionsDialog.cpp \ 1300 src/medium/viso/UIVisoCreatorPanel.cpp \ 1301 src/medium/viso/UIVisoConfigurationPanel.cpp \ 1302 src/medium/viso/UIVisoCreatorOptionsPanel.cpp \ 1301 1303 src/medium/viso/UIVisoHostBrowser.cpp \ 1302 1304 src/objects/UIRichTextString.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoConfigurationPanel.cpp
r76943 r76944 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIVisoConfiguration Dialogclass implementation.3 * VBox Qt GUI - UIVisoConfigurationPanel class implementation. 4 4 */ 5 5 … … 26 26 27 27 /* GUI includes: */ 28 #include <QComboBox> 28 29 #include "QIDialogButtonBox.h" 30 #include "UIIconPool.h" 29 31 #include "QILabel.h" 30 32 #include "QILineEdit.h" 31 #include " UIVisoConfigurationDialog.h"32 #include "UIVisoC reator.h"33 #include "QIToolButton.h" 34 #include "UIVisoConfigurationPanel.h" 33 35 34 UIVisoConfigurationDialog::UIVisoConfigurationDialog(const VisoOptions &visoOptions, 35 QWidget *pParent /* =0 */) 36 : QIDialog(pParent) 37 , m_pMainLayout(0) 38 , m_pButtonBox(0) 36 UIVisoConfigurationPanel::UIVisoConfigurationPanel(QWidget *pParent /* =0 */) 37 : UIVisoCreatorPanel(pParent) 38 , m_pVisoNameLabel(0) 39 , m_pCustomOptionsLabel(0) 39 40 , m_pVisoNameLineEdit(0) 40 , m_pCustomOptions TextEdit(0)41 , m_ visoOptions(visoOptions)41 , m_pCustomOptionsComboBox(0) 42 , m_pDeleteButton(0) 42 43 { 43 44 prepareObjects(); … … 45 46 } 46 47 47 UIVisoConfiguration Dialog::~UIVisoConfigurationDialog()48 UIVisoConfigurationPanel::~UIVisoConfigurationPanel() 48 49 { 49 50 } 50 51 51 const VisoOptions &UIVisoConfigurationDialog::visoOptions() const52 QString UIVisoConfigurationPanel::panelName() const 52 53 { 53 return m_visoOptions;54 return "ConfigurationPanel"; 54 55 } 55 56 56 void UIVisoConfiguration Dialog::accept()57 void UIVisoConfigurationPanel::setVisoName(const QString& strVisoName) 57 58 { 58 59 if (m_pVisoNameLineEdit) 59 m_visoOptions.m_strVisoName = m_pVisoNameLineEdit->text(); 60 61 if (m_pCustomOptionsTextEdit) 62 { 63 QTextDocument *pDocument = m_pCustomOptionsTextEdit->document(); 64 if (pDocument) 65 { 66 for(QTextBlock block = pDocument->begin(); block != pDocument->end()/*.isValid()*/; block = block.next()) 67 m_visoOptions.m_customOptions << block.text(); 68 } 69 } 70 71 QIDialog::accept(); 60 m_pVisoNameLineEdit->setText(strVisoName); 72 61 } 73 62 74 void UIVisoConfiguration Dialog::prepareObjects()63 void UIVisoConfigurationPanel::setVisoCustomOptions(const QStringList& visoCustomOptions) 75 64 { 76 m_pMainLayout = new QGridLayout; 65 if (!m_pCustomOptionsComboBox) 66 return; 67 m_pCustomOptionsComboBox->clear(); 68 foreach (const QString &strOption, visoCustomOptions) 69 { 70 m_pCustomOptionsComboBox->addItem(strOption); 71 } 72 } 77 73 78 if (!m_pMainLayout) 74 void UIVisoConfigurationPanel::prepareObjects() 75 { 76 if (!mainLayout()) 79 77 return; 80 78 81 79 /* Name edit and and label: */ 82 QILabel *pVisoNameLabel = new QILabel(UIVisoCreator::tr("VISO Name:"));80 m_pVisoNameLabel = new QILabel(QApplication::translate("UIVisoCreator", "VISO Name:")); 83 81 m_pVisoNameLineEdit = new QILineEdit; 84 if ( pVisoNameLabel && m_pVisoNameLineEdit)82 if (m_pVisoNameLabel && m_pVisoNameLineEdit) 85 83 { 86 m_pVisoNameLineEdit->setText(m_visoOptions.m_strVisoName); 87 pVisoNameLabel->setBuddy(m_pVisoNameLineEdit); 88 m_pMainLayout->addWidget(pVisoNameLabel, 0, 0, 1, 1); 89 m_pMainLayout->addWidget(m_pVisoNameLineEdit, 0, 1, 1, 1); 84 m_pVisoNameLabel->setBuddy(m_pVisoNameLineEdit); 85 mainLayout()->addWidget(m_pVisoNameLabel, 0, Qt::AlignLeft); 86 mainLayout()->addWidget(m_pVisoNameLineEdit, 0, Qt::AlignLeft); 90 87 } 91 88 89 addVerticalSeparator(); 90 91 92 92 /* Cutom Viso options stuff: */ 93 QILabel *pCustomOptionsLabel = new QILabel(UIVisoCreator::tr("Custom VISO options:")); 94 m_pCustomOptionsTextEdit = new QTextEdit; 95 if (pCustomOptionsLabel && m_pCustomOptionsTextEdit) 93 m_pCustomOptionsLabel = new QILabel(QApplication::translate("UIVisoCreator", "Custom VISO options:")); 94 m_pCustomOptionsComboBox = new QComboBox; 95 m_pDeleteButton = new QIToolButton; 96 97 if (m_pCustomOptionsLabel && m_pCustomOptionsComboBox && m_pDeleteButton) 96 98 { 97 m_pCustomOptionsTextEdit->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); 98 pCustomOptionsLabel->setBuddy(m_pCustomOptionsTextEdit); 99 m_pMainLayout->addWidget(pCustomOptionsLabel, 1, 0, 1, 1, Qt::AlignTop); 100 m_pMainLayout->addWidget(m_pCustomOptionsTextEdit, 1, 1, 1, 1); 101 foreach (const QString &strLine, m_visoOptions.m_customOptions) 102 m_pCustomOptionsTextEdit->append(strLine); 99 m_pDeleteButton->setIcon(UIIconPool::iconSet(":/log_viewer_delete_current_bookmark_16px.png")); 100 101 m_pCustomOptionsComboBox->setEditable(true); 102 m_pCustomOptionsLabel->setBuddy(m_pCustomOptionsComboBox); 103 104 mainLayout()->addWidget(m_pCustomOptionsLabel, 0, Qt::AlignLeft); 105 mainLayout()->addWidget(m_pCustomOptionsComboBox, Qt::AlignLeft); 106 mainLayout()->addWidget(m_pDeleteButton, 0, Qt::AlignLeft); 103 107 } 104 105 m_pButtonBox = new QIDialogButtonBox; 106 if (m_pButtonBox) 107 { 108 m_pButtonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok); 109 m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape); 110 m_pMainLayout->addWidget(m_pButtonBox, 2, 0, 1, 2); 111 } 112 setLayout(m_pMainLayout); 108 retranslateUi(); 113 109 } 114 110 115 void UIVisoConfiguration Dialog::prepareConnections()111 void UIVisoConfigurationPanel::prepareConnections() 116 112 { 117 if (m_pButtonBox) 113 if (m_pVisoNameLineEdit) 114 connect(m_pVisoNameLineEdit, &QILineEdit::editingFinished, this, &UIVisoConfigurationPanel::sltHandleVisoNameChanged); 115 if (m_pDeleteButton) 116 connect(m_pDeleteButton, &QIToolButton::clicked, this, &UIVisoConfigurationPanel::sltHandleDeleteCurrentCustomOption); 117 } 118 119 bool UIVisoConfigurationPanel::eventFilter(QObject *pObject, QEvent *pEvent) 120 { 121 /* Depending on event-type: */ 122 switch (pEvent->type()) 118 123 { 119 connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UIVisoConfigurationDialog::close); 120 connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UIVisoConfigurationDialog::accept); 124 /* Process key press only: */ 125 case QEvent::KeyPress: 126 { 127 /* Cast to corresponding key press event: */ 128 QKeyEvent *pKeyEvent = static_cast<QKeyEvent*>(pEvent); 129 130 if (pKeyEvent->key() == Qt::Key_Return && m_pCustomOptionsComboBox && m_pCustomOptionsComboBox->hasFocus()) 131 addCustomVisoOption(); 132 return true; 133 break; 134 } 135 default: 136 break; 121 137 } 138 /* Call to base-class: */ 139 return UIVisoCreatorPanel::eventFilter(pObject, pEvent); 122 140 } 141 142 void UIVisoConfigurationPanel::retranslateUi() 143 { 144 if (m_pVisoNameLabel) 145 m_pVisoNameLabel->setText(QApplication::translate("UIVisoCreator", "VISO Name:")); 146 if (m_pCustomOptionsLabel) 147 m_pCustomOptionsLabel->setText(QApplication::translate("UIVisoCreator", "Custom VISO options:")); 148 if (m_pDeleteButton) 149 m_pDeleteButton->setToolTip(QApplication::translate("UIVisoCreator", "Remove current option.")); 150 } 151 152 void UIVisoConfigurationPanel::addCustomVisoOption() 153 { 154 if (!m_pCustomOptionsComboBox) 155 return; 156 if (m_pCustomOptionsComboBox->currentText().isEmpty()) 157 return; 158 159 emitCustomVisoOptions(); 160 m_pCustomOptionsComboBox->clearEditText(); 161 } 162 163 void UIVisoConfigurationPanel::emitCustomVisoOptions() 164 { 165 if (!m_pCustomOptionsComboBox) 166 return; 167 QStringList customVisoOptions; 168 for (int i = 0; i < m_pCustomOptionsComboBox->count(); ++i) 169 customVisoOptions << m_pCustomOptionsComboBox->itemText(i); 170 171 if (!customVisoOptions.isEmpty()) 172 emit sigCustomVisoOptionsChanged(customVisoOptions); 173 } 174 175 void UIVisoConfigurationPanel::sltHandleVisoNameChanged() 176 { 177 if (m_pVisoNameLineEdit) 178 emit sigVisoNameChanged(m_pVisoNameLineEdit->text()); 179 } 180 181 void UIVisoConfigurationPanel::sltHandleDeleteCurrentCustomOption() 182 { 183 if (!m_pCustomOptionsComboBox) 184 return; 185 if (m_pCustomOptionsComboBox->currentText().isEmpty()) 186 return; 187 m_pCustomOptionsComboBox->removeItem(m_pCustomOptionsComboBox->currentIndex()); 188 emitCustomVisoOptions(); 189 } -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoConfigurationPanel.h
r76943 r76944 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIVisoConfiguration Dialogclass declaration.3 * VBox Qt GUI - UIVisoConfigurationPanel class declaration. 4 4 */ 5 5 … … 16 16 */ 17 17 18 #ifndef FEQT_INCLUDED_SRC_medium_viso_UIVisoConfiguration Dialog_h19 #define FEQT_INCLUDED_SRC_medium_viso_UIVisoConfiguration Dialog_h18 #ifndef FEQT_INCLUDED_SRC_medium_viso_UIVisoConfigurationPanel_h 19 #define FEQT_INCLUDED_SRC_medium_viso_UIVisoConfigurationPanel_h 20 20 #ifndef RT_WITHOUT_PRAGMA_ONCE 21 21 # pragma once … … 23 23 24 24 /* GUI includes: */ 25 #include "QIDialog.h" 26 #include "QIWithRetranslateUI.h" 25 #include "UIVisoCreatorPanel.h" 27 26 #include "UIVisoCreatorDefs.h" 28 27 … … 30 29 class QGridLayout; 31 30 class QTextEdit; 32 class QIDialogButtonBox; 31 class QComboBox; 32 class QILabel; 33 33 class QILineEdit; 34 34 class QITabWidget; 35 class QIToolButton; 36 class UIVisoCreator; 35 37 36 class UIVisoConfiguration Dialog : public QIDialog38 class UIVisoConfigurationPanel : public UIVisoCreatorPanel 37 39 { 38 40 Q_OBJECT; 39 41 40 42 public: 41 UIVisoConfigurationDialog(const VisoOptions &visoOptions, 42 QWidget *pParent = 0); 43 ~UIVisoConfigurationDialog(); 44 const VisoOptions &visoOptions() const; 43 UIVisoConfigurationPanel(QWidget *pParent = 0); 44 ~UIVisoConfigurationPanel(); 45 virtual QString panelName() const /* override */; 46 void setVisoName(const QString& strVisoName); 47 void setVisoCustomOptions(const QStringList& visoCustomOptions); 45 48 46 public slots:49 signals: 47 50 48 void accept() /* override */; 51 void sigVisoNameChanged(const QString &strVisoName); 52 void sigCustomVisoOptionsChanged(const QStringList &customVisoOptions); 49 53 54 55 protected: 56 57 bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */; 58 void retranslateUi() /* override */; 59 60 private slots: 61 62 void sltHandleVisoNameChanged(); 63 void sltHandleDeleteCurrentCustomOption(); 50 64 51 65 private: … … 53 67 void prepareObjects(); 54 68 void prepareConnections(); 69 void addCustomVisoOption(); 70 void emitCustomVisoOptions(); 55 71 56 Q GridLayout *m_pMainLayout;57 QI DialogButtonBox *m_pButtonBox;58 QILineEdit *m_pVisoNameLineEdit;59 Q TextEdit *m_pCustomOptionsTextEdit;60 VisoOptions m_visoOptions;72 QILabel *m_pVisoNameLabel; 73 QILabel *m_pCustomOptionsLabel; 74 QILineEdit *m_pVisoNameLineEdit; 75 QComboBox *m_pCustomOptionsComboBox; 76 QIToolButton *m_pDeleteButton; 61 77 62 78 friend class UIVisoCreator; 63 79 }; 64 80 65 #endif /* !FEQT_INCLUDED_SRC_medium_viso_UIVisoConfiguration Dialog_h */81 #endif /* !FEQT_INCLUDED_SRC_medium_viso_UIVisoConfigurationPanel_h */ -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.cpp
r76844 r76944 29 29 #include "UIVisoHostBrowser.h" 30 30 #include "UIVisoCreator.h" 31 #include "UIVisoConfiguration Dialog.h"32 #include "UIVisoCreatorOptions Dialog.h"31 #include "UIVisoConfigurationPanel.h" 32 #include "UIVisoCreatorOptionsPanel.h" 33 33 #include "UIVisoContentBrowser.h" 34 34 … … 49 49 , m_pVisoContentBrowserMenu(0) 50 50 , m_strMachineName(strMachineName) 51 , m_pCreatorOptionsPanel(0) 52 , m_pConfigurationPanel(0) 51 53 { 52 54 prepareActions(); 53 55 prepareObjects(); 54 56 prepareConnections(); 57 manageEscapeShortCut(); 55 58 } 56 59 … … 105 108 } 106 109 107 void UIVisoCreator::sltHandleOptionsAction() 108 { 109 UIVisoCreatorOptionsDialog *pDialog = new UIVisoCreatorOptionsDialog(m_browserOptions, this); 110 111 if(!pDialog) 112 return; 113 if (pDialog->execute(true, false)) 114 { 115 /** Check if any of the options has been modified: */ 116 checkBrowserOptions(pDialog->browserOptions()); 117 } 118 delete pDialog; 119 } 120 121 void UIVisoCreator::sltHandleConfigurationAction() 122 { 123 UIVisoConfigurationDialog *pDialog = new UIVisoConfigurationDialog(m_visoOptions, this); 124 125 if(!pDialog) 126 return; 127 if (pDialog->execute(true, false)) 128 { 129 /** Check if any of the options has been modified: */ 130 checkVisoOptions(pDialog->visoOptions()); 131 } 132 delete pDialog; 110 // void UIVisoCreator::sltHandleOptionsAction() 111 // { 112 // // UIVisoCreatorOptionsDialog *pDialog = new UIVisoCreatorOptionsDialog(this, m_browserOptions, this); 113 114 // // if(!pDialog) 115 // // return; 116 // // if (pDialog->execute(true, false)) 117 // // { 118 // // /** Check if any of the options has been modified: */ 119 // // checkBrowserOptions(pDialog->browserOptions()); 120 // // } 121 // // delete pDialog; 122 // } 123 124 // void UIVisoCreator::sltHandleConfigurationAction() 125 // { 126 // // UIVisoConfigurationDialog *pDialog = new UIVisoConfigurationDialog(m_visoOptions, this); 127 128 // // if(!pDialog) 129 // // return; 130 // // if (pDialog->execute(true, false)) 131 // // { 132 // // /** Check if any of the options has been modified: */ 133 // // checkVisoOptions(pDialog->visoOptions()); 134 // // } 135 // // delete pDialog; 136 // } 137 138 void UIVisoCreator::sltPanelActionToggled(bool fChecked) 139 { 140 QAction *pSenderAction = qobject_cast<QAction*>(sender()); 141 if (!pSenderAction) 142 return; 143 UIVisoCreatorPanel* pPanel = 0; 144 /* Look for the sender() within the m_panelActionMap's values: */ 145 for (QMap<UIVisoCreatorPanel*, QAction*>::const_iterator iterator = m_panelActionMap.begin(); 146 iterator != m_panelActionMap.end(); ++iterator) 147 { 148 if (iterator.value() == pSenderAction) 149 pPanel = iterator.key(); 150 } 151 if (!pPanel) 152 return; 153 if (fChecked) 154 showPanel(pPanel); 155 else 156 hidePanel(pPanel); 157 } 158 159 void UIVisoCreator::sltHandleVisoNameChanged(const QString &strVisoName) 160 { 161 if (m_visoOptions.m_strVisoName == strVisoName) 162 return; 163 m_visoOptions.m_strVisoName = strVisoName; 164 if(m_pVisoBrowser) 165 m_pVisoBrowser->setVisoName(m_visoOptions.m_strVisoName); 166 } 167 168 void UIVisoCreator::sltHandleCustomVisoOptionsChanged(const QStringList &customVisoOptions) 169 { 170 if (m_visoOptions.m_customOptions == customVisoOptions) 171 return; 172 m_visoOptions.m_customOptions = customVisoOptions; 173 } 174 175 void UIVisoCreator::sltHandleShowHiddenObjectsChange(bool fShow) 176 { 177 if (m_browserOptions.m_fShowHiddenObjects == fShow) 178 return; 179 m_browserOptions.m_fShowHiddenObjects = fShow; 180 m_pHostBrowser->showHideHiddenObjects(fShow); 181 } 182 183 void UIVisoCreator::sltHandleHidePanel(UIVisoCreatorPanel *pPanel) 184 { 185 hidePanel(pPanel); 133 186 } 134 187 … … 144 197 if (!m_pMainLayout || !menuBar()) 145 198 return; 199 200 /* Configure layout: */ 201 m_pMainLayout->setContentsMargins(1, 1, 1, 1); 202 #ifdef VBOX_WS_MAC 203 m_pMainLayout->setSpacing(10); 204 #else 205 m_pMainLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing) / 2); 206 #endif 146 207 147 208 m_pMainMenu = menuBar()->addMenu(tr("VISO")); … … 184 245 this, &UIVisoCreator::sltHandleAddObjectsToViso); 185 246 } 247 186 248 m_pVisoBrowser = new UIVisoContentBrowser(0 /* parent */, m_pVisoContentBrowserMenu); 187 249 if (m_pVisoBrowser) … … 190 252 m_pVisoBrowser->setVisoName(m_visoOptions.m_strVisoName); 191 253 } 254 255 m_pConfigurationPanel = new UIVisoConfigurationPanel(this); 256 if (m_pConfigurationPanel) 257 { 258 m_pVerticalSplitter->addWidget(m_pConfigurationPanel); 259 m_panelActionMap.insert(m_pConfigurationPanel, m_pActionConfiguration); 260 m_pConfigurationPanel->hide(); 261 m_pConfigurationPanel->setVisoName(m_visoOptions.m_strVisoName); 262 m_pConfigurationPanel->setVisoCustomOptions(m_visoOptions.m_customOptions); 263 installEventFilter(m_pConfigurationPanel); 264 } 265 266 m_pCreatorOptionsPanel = new UIVisoCreatorOptionsPanel(this); 267 if (m_pCreatorOptionsPanel) 268 { 269 m_pCreatorOptionsPanel->setShowHiddenbjects(m_browserOptions.m_fShowHiddenObjects); 270 m_pMainLayout->addWidget(m_pCreatorOptionsPanel); 271 m_panelActionMap.insert(m_pCreatorOptionsPanel, m_pActionOptions); 272 m_pCreatorOptionsPanel->hide(); 273 } 274 192 275 m_pButtonBox = new QIDialogButtonBox; 193 276 if (m_pButtonBox) … … 196 279 m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape); 197 280 m_pMainLayout->addWidget(m_pButtonBox); 281 198 282 } 199 283 retranslateUi(); … … 207 291 connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UIVisoCreator::accept); 208 292 } 293 209 294 if (m_pActionConfiguration) 210 connect(m_pActionConfiguration, &QAction::triggered, this, &UIVisoCreator::slt HandleConfigurationAction);295 connect(m_pActionConfiguration, &QAction::triggered, this, &UIVisoCreator::sltPanelActionToggled); 211 296 if (m_pActionOptions) 212 connect(m_pActionOptions, &QAction::triggered, this, &UIVisoCreator::sltHandleOptionsAction); 297 connect(m_pActionOptions, &QAction::triggered, this, &UIVisoCreator::sltPanelActionToggled); 298 299 if (m_pConfigurationPanel) 300 { 301 connect(m_pConfigurationPanel, &UIVisoConfigurationPanel::sigVisoNameChanged, 302 this, &UIVisoCreator::sltHandleVisoNameChanged); 303 connect(m_pConfigurationPanel, &UIVisoConfigurationPanel::sigCustomVisoOptionsChanged, 304 this, &UIVisoCreator::sltHandleCustomVisoOptionsChanged); 305 connect(m_pConfigurationPanel, &UIVisoConfigurationPanel::sigHidePanel, 306 this, &UIVisoCreator::sltHandleHidePanel); 307 } 308 if (m_pCreatorOptionsPanel) 309 { 310 connect(m_pCreatorOptionsPanel, &UIVisoCreatorOptionsPanel::sigShowHiddenObjects, 311 this, &UIVisoCreator::sltHandleShowHiddenObjectsChange); 312 connect(m_pCreatorOptionsPanel, &UIVisoCreatorOptionsPanel::sigHidePanel, 313 this, &UIVisoCreator::sltHandleHidePanel); 314 } 213 315 } 214 316 … … 218 320 if (m_pActionConfiguration) 219 321 { 322 m_pActionConfiguration->setCheckable(true); 220 323 m_pActionConfiguration->setIcon(UIIconPool::iconSetFull(":/file_manager_options_32px.png", 221 324 ":/%file_manager_options_16px.png", … … 227 330 if (m_pActionOptions) 228 331 { 332 m_pActionOptions->setCheckable(true); 333 229 334 m_pActionOptions->setIcon(UIIconPool::iconSetFull(":/file_manager_options_32px.png", 230 335 ":/%file_manager_options_16px.png", … … 234 339 } 235 340 236 void UIVisoCreator::checkBrowserOptions(const BrowserOptions &browserOptions) 237 { 238 if (browserOptions == m_browserOptions) 239 return; 240 if (browserOptions.m_bShowHiddenObjects != m_browserOptions.m_bShowHiddenObjects) 241 { 242 if (m_pHostBrowser) 243 m_pHostBrowser->showHideHiddenObjects(browserOptions.m_bShowHiddenObjects); 244 if(m_pVisoBrowser) 245 m_pVisoBrowser->showHideHiddenObjects(browserOptions.m_bShowHiddenObjects); 246 } 247 m_browserOptions = browserOptions; 248 } 249 250 void UIVisoCreator::checkVisoOptions(const VisoOptions &visoOptions) 251 { 252 if (visoOptions == m_visoOptions) 253 return; 254 if (visoOptions.m_strVisoName != m_visoOptions.m_strVisoName) 255 { 256 if(m_pVisoBrowser) 257 m_pVisoBrowser->setVisoName(visoOptions.m_strVisoName); 258 } 259 m_visoOptions = visoOptions; 260 } 341 342 void UIVisoCreator::hidePanel(UIVisoCreatorPanel* panel) 343 { 344 if (panel && panel->isVisible()) 345 panel->setVisible(false); 346 QMap<UIVisoCreatorPanel*, QAction*>::iterator iterator = m_panelActionMap.find(panel); 347 if (iterator != m_panelActionMap.end()) 348 { 349 if (iterator.value() && iterator.value()->isChecked()) 350 iterator.value()->setChecked(false); 351 } 352 m_visiblePanelsList.removeAll(panel); 353 manageEscapeShortCut(); 354 } 355 356 void UIVisoCreator::showPanel(UIVisoCreatorPanel* panel) 357 { 358 if (panel && panel->isHidden()) 359 panel->setVisible(true); 360 QMap<UIVisoCreatorPanel*, QAction*>::iterator iterator = m_panelActionMap.find(panel); 361 if (iterator != m_panelActionMap.end()) 362 { 363 if (!iterator.value()->isChecked()) 364 iterator.value()->setChecked(true); 365 } 366 if (!m_visiblePanelsList.contains(panel)) 367 m_visiblePanelsList.push_back(panel); 368 manageEscapeShortCut(); 369 } 370 371 372 373 void UIVisoCreator::manageEscapeShortCut() 374 { 375 /* if there are no visible panels then assign esc. key to cancel button of the button box: */ 376 if (m_visiblePanelsList.isEmpty()) 377 { 378 if (m_pButtonBox && m_pButtonBox->button(QDialogButtonBox::Cancel)) 379 m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(QKeySequence(Qt::Key_Escape)); 380 return; 381 } 382 if (m_pButtonBox && m_pButtonBox->button(QDialogButtonBox::Cancel)) 383 m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(QKeySequence()); 384 385 /* Just loop thru the visible panel list and set the esc key to the 386 panel which made visible latest */ 387 for (int i = 0; i < m_visiblePanelsList.size() - 1; ++i) 388 { 389 m_visiblePanelsList[i]->setCloseButtonShortCut(QKeySequence()); 390 } 391 m_visiblePanelsList.back()->setCloseButtonShortCut(QKeySequence(Qt::Key_Escape)); 392 } -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.h
r76913 r76944 45 45 class UIVisoHostBrowser; 46 46 class UIVisoContentBrowser; 47 class UIVisoCreatorOptionsPanel; 48 class UIVisoCreatorPanel; 49 class UIVisoConfigurationPanel; 47 50 48 51 class UIVisoCreator : public QIWithRetranslateUI<QIMainDialog> … … 70 73 71 74 void sltHandleAddObjectsToViso(QStringList pathList); 72 void sltHandleOptionsAction(); 73 void sltHandleConfigurationAction(); 75 void sltPanelActionToggled(bool fChecked); 76 void sltHandleVisoNameChanged(const QString& strVisoName); 77 void sltHandleCustomVisoOptionsChanged(const QStringList &customVisoOptions); 78 void sltHandleShowHiddenObjectsChange(bool fShow); 79 void sltHandleHidePanel(UIVisoCreatorPanel *pPanel); 74 80 75 private:81 private: 76 82 77 83 void prepareObjects(); … … 81 87 void setTableRootIndex(QModelIndex index = QModelIndex() ); 82 88 void setTreeCurrentIndex(QModelIndex index = QModelIndex() ); 83 void checkBrowserOptions(const BrowserOptions &browserOptions); 84 void checkVisoOptions(const VisoOptions &visoOptions); 89 void hidePanel(UIVisoCreatorPanel *panel); 90 void showPanel(UIVisoCreatorPanel *panel); 91 /** Makes sure escape key is assigned to only a single widget. This is done by checking 92 several things in the following order: 93 - when there are no more panels visible assign it to the parent dialog 94 - grab it from the dialog as soon as a panel becomes visible again 95 - assign it to the most recently "unhidden" panel */ 96 void manageEscapeShortCut(); 85 97 86 98 QVBoxLayout *m_pMainLayout; … … 99 111 QMenu *m_pVisoContentBrowserMenu; 100 112 QString m_strMachineName; 113 UIVisoCreatorOptionsPanel *m_pCreatorOptionsPanel; 114 UIVisoConfigurationPanel *m_pConfigurationPanel; 115 QMap<UIVisoCreatorPanel*, QAction*> m_panelActionMap; 116 QList<UIVisoCreatorPanel*> m_visiblePanelsList; 101 117 }; 102 118 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreatorDefs.h
r76768 r76944 40 40 { 41 41 BrowserOptions() 42 :m_ bShowHiddenObjects(true){}42 :m_fShowHiddenObjects(true){} 43 43 bool operator==(const BrowserOptions &otherOptions) const 44 44 { 45 return m_ bShowHiddenObjects == otherOptions.m_bShowHiddenObjects;45 return m_fShowHiddenObjects == otherOptions.m_fShowHiddenObjects; 46 46 } 47 bool m_ bShowHiddenObjects;47 bool m_fShowHiddenObjects; 48 48 }; 49 49 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreatorOptionsPanel.cpp
r76943 r76944 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIVisoCreatorOptions Dialogclass implementation.3 * VBox Qt GUI - UIVisoCreatorOptionsPanel class implementation. 4 4 */ 5 5 … … 25 25 26 26 /* GUI includes: */ 27 #include "QIDialogButtonBox.h"28 27 #include "QILabel.h" 29 28 #include "QILineEdit.h" 30 29 #include "QITabWidget.h" 31 30 #include "UIVisoCreator.h" 32 #include "UIVisoCreatorOptions Dialog.h"31 #include "UIVisoCreatorOptionsPanel.h" 33 32 34 UIVisoCreatorOptionsDialog::UIVisoCreatorOptionsDialog(const BrowserOptions &browserOptions, QWidget *pParent /* =0 */) 35 : QIDialog(pParent) 36 , m_pMainLayout(0) 37 , m_pButtonBox(0) 38 , m_browserOptions(browserOptions) 33 UIVisoCreatorOptionsPanel::UIVisoCreatorOptionsPanel(QWidget *pParent /* =0 */) 34 : UIVisoCreatorPanel(pParent) 35 , m_pShowHiddenObjectsCheckBox(0) 36 , m_pShowHiddenObjectsLabel(0) 39 37 { 40 38 prepareObjects(); … … 42 40 } 43 41 44 UIVisoCreatorOptions Dialog::~UIVisoCreatorOptionsDialog()42 UIVisoCreatorOptionsPanel::~UIVisoCreatorOptionsPanel() 45 43 { 46 44 } 47 45 48 const BrowserOptions &UIVisoCreatorOptionsDialog::browserOptions() const46 QString UIVisoCreatorOptionsPanel::panelName() const 49 47 { 50 return m_browserOptions;48 return "OptionsPanel"; 51 49 } 52 50 53 void UIVisoCreatorOptionsDialog::sltHandlShowHiddenObjectsChange(int iState) 51 void UIVisoCreatorOptionsPanel::setShowHiddenbjects(bool fShow) 52 { 53 if (m_pShowHiddenObjectsCheckBox) 54 m_pShowHiddenObjectsCheckBox->setChecked(fShow); 55 } 56 57 void UIVisoCreatorOptionsPanel::retranslateUi() 58 { 59 if (m_pShowHiddenObjectsLabel) 60 m_pShowHiddenObjectsLabel->setText(UIVisoCreator::tr("Show Hidden Objects")); 61 } 62 63 void UIVisoCreatorOptionsPanel::sltHandlShowHiddenObjectsChange(int iState) 54 64 { 55 65 if (iState == static_cast<int>(Qt::Checked)) 56 m_browserOptions.m_bShowHiddenObjects = true;66 sigShowHiddenObjects(true); 57 67 else 58 m_browserOptions.m_bShowHiddenObjects = false;68 sigShowHiddenObjects(false); 59 69 } 60 70 61 void UIVisoCreatorOptions Dialog::prepareObjects()71 void UIVisoCreatorOptionsPanel::prepareObjects() 62 72 { 63 m_pMainLayout = new QGridLayout; 64 if (!m_pMainLayout) 73 if (!mainLayout()) 65 74 return; 66 75 67 QCheckBox *pShowHiddenObjectsCheckBox = new QCheckBox; 68 pShowHiddenObjectsCheckBox->setChecked(m_browserOptions.m_bShowHiddenObjects); 69 QILabel *pShowHiddenObjectsLabel = new QILabel(UIVisoCreator::tr("Show Hidden Objects")); 70 pShowHiddenObjectsLabel->setBuddy(pShowHiddenObjectsCheckBox); 71 m_pMainLayout->addWidget(pShowHiddenObjectsLabel, 0, 0); 72 m_pMainLayout->addWidget(pShowHiddenObjectsCheckBox, 0, 1); 73 connect(pShowHiddenObjectsCheckBox, &QCheckBox::stateChanged, 74 this, &UIVisoCreatorOptionsDialog::sltHandlShowHiddenObjectsChange); 75 76 m_pButtonBox = new QIDialogButtonBox; 77 if (m_pButtonBox) 78 { 79 m_pButtonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok); 80 m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape); 81 m_pMainLayout->addWidget(m_pButtonBox, 1, 0, 1, 2); 82 } 83 setLayout(m_pMainLayout); 76 m_pShowHiddenObjectsCheckBox = new QCheckBox; 77 m_pShowHiddenObjectsLabel = new QILabel(UIVisoCreator::tr("Show Hidden Objects")); 78 m_pShowHiddenObjectsLabel->setBuddy(m_pShowHiddenObjectsCheckBox); 79 mainLayout()->addWidget(m_pShowHiddenObjectsCheckBox, 0, Qt::AlignLeft); 80 mainLayout()->addWidget(m_pShowHiddenObjectsLabel, 0, Qt::AlignLeft); 81 mainLayout()->addStretch(6); 82 connect(m_pShowHiddenObjectsCheckBox, &QCheckBox::stateChanged, 83 this, &UIVisoCreatorOptionsPanel::sltHandlShowHiddenObjectsChange); 84 84 } 85 85 86 void UIVisoCreatorOptions Dialog::prepareConnections()86 void UIVisoCreatorOptionsPanel::prepareConnections() 87 87 { 88 if (m_pButtonBox)89 {90 connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UIVisoCreatorOptionsDialog::close);91 connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UIVisoCreatorOptionsDialog::accept);92 }93 88 } -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreatorOptionsPanel.h
r76943 r76944 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIVisoCreatorOptions Dialogclass declaration.3 * VBox Qt GUI - UIVisoCreatorOptionsPanel class declaration. 4 4 */ 5 5 … … 16 16 */ 17 17 18 #ifndef FEQT_INCLUDED_SRC_medium_viso_UIVisoCreatorOptions Dialog_h19 #define FEQT_INCLUDED_SRC_medium_viso_UIVisoCreatorOptions Dialog_h18 #ifndef FEQT_INCLUDED_SRC_medium_viso_UIVisoCreatorOptionsPanel_h 19 #define FEQT_INCLUDED_SRC_medium_viso_UIVisoCreatorOptionsPanel_h 20 20 #ifndef RT_WITHOUT_PRAGMA_ONCE 21 21 # pragma once 22 22 #endif 23 23 24 /* Forward declarations: */ 25 class QCheckBox; 26 class QILabel; 27 24 28 /* GUI includes: */ 25 #include " QIDialog.h"29 #include "UIVisoCreatorPanel.h" 26 30 #include "QIWithRetranslateUI.h" 27 31 #include "UIVisoCreatorDefs.h" 28 32 29 /* Forward declarations: */30 class QGridLayout;31 class QIDialogButtonBox;32 33 33 class UIVisoCreatorOptions Dialog : public QIDialog34 class UIVisoCreatorOptionsPanel : public UIVisoCreatorPanel 34 35 { 35 36 Q_OBJECT; … … 37 38 public: 38 39 39 UIVisoCreatorOptionsDialog(const BrowserOptions &browserOptions, 40 QWidget *pParent = 0); 41 ~UIVisoCreatorOptionsDialog(); 42 const BrowserOptions &browserOptions() const; 40 UIVisoCreatorOptionsPanel(QWidget *pParent = 0); 41 ~UIVisoCreatorOptionsPanel(); 42 virtual QString panelName() const /* override */; 43 void setShowHiddenbjects(bool fShow); 44 45 signals: 46 47 void sigShowHiddenObjects(bool fShow); 48 49 protected: 50 51 void retranslateUi() /* override */; 52 43 53 44 54 private slots: … … 50 60 void prepareObjects(); 51 61 void prepareConnections(); 52 QGridLayout *m_pMainLayout; 53 QIDialogButtonBox *m_pButtonBox; 54 BrowserOptions m_browserOptions; 62 63 QCheckBox *m_pShowHiddenObjectsCheckBox; 64 QILabel *m_pShowHiddenObjectsLabel; 65 55 66 friend class UIVisoCreator; 56 67 }; 57 68 58 #endif /* !FEQT_INCLUDED_SRC_medium_viso_UIVisoCreatorOptions Dialog_h */69 #endif /* !FEQT_INCLUDED_SRC_medium_viso_UIVisoCreatorOptionsPanel_h */ -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreatorPanel.cpp
r76910 r76944 27 27 #include "QIToolButton.h" 28 28 #include "UIIconPool.h" 29 #include "UIFileManager.h" 30 #include "UIFileManagerPanel.h" 29 #include "UIVisoCreatorPanel.h" 31 30 #ifdef VBOX_WS_MAC 32 31 # include "VBoxUtils-darwin.h" … … 34 33 35 34 36 UI FileManagerPanel::UIFileManagerPanel(UIFileManager *pManagerWidget,QWidget *pParent)35 UIVisoCreatorPanel::UIVisoCreatorPanel(QWidget *pParent) 37 36 : QIWithRetranslateUI<QWidget>(pParent) 38 37 , m_pMainLayout(0) 39 38 , m_pCloseButton(0) 40 , m_pFileManager(pManagerWidget)41 39 { 42 40 prepare(); 43 41 } 44 42 45 void UI FileManagerPanel::setCloseButtonShortCut(QKeySequence shortCut)43 void UIVisoCreatorPanel::setCloseButtonShortCut(QKeySequence shortCut) 46 44 { 47 45 if (!m_pCloseButton) … … 50 48 } 51 49 52 QHBoxLayout* UI FileManagerPanel::mainLayout()50 QHBoxLayout* UIVisoCreatorPanel::mainLayout() 53 51 { 54 52 return m_pMainLayout; 55 53 } 56 54 57 void UI FileManagerPanel::prepare()55 void UIVisoCreatorPanel::prepare() 58 56 { 59 57 prepareWidgets(); … … 62 60 } 63 61 64 void UI FileManagerPanel::prepareWidgets()62 void UIVisoCreatorPanel::prepareWidgets() 65 63 { 66 64 m_pMainLayout = new QHBoxLayout(this); … … 85 83 } 86 84 87 void UI FileManagerPanel::prepareConnections()85 void UIVisoCreatorPanel::prepareConnections() 88 86 { 89 87 if (m_pCloseButton) 90 connect(m_pCloseButton, &QIToolButton::clicked, this, &UI FileManagerPanel::hide);88 connect(m_pCloseButton, &QIToolButton::clicked, this, &UIVisoCreatorPanel::hide); 91 89 } 92 90 93 void UI FileManagerPanel::retranslateUi()91 void UIVisoCreatorPanel::retranslateUi() 94 92 { 95 93 if (m_pCloseButton) 96 m_pCloseButton->setToolTip( UIFileManager::tr("Close the pane"));94 m_pCloseButton->setToolTip(QApplication::translate("UIVisoCreator", "Close the pane")); 97 95 } 98 96 99 bool UI FileManagerPanel::eventFilter(QObject *pObject, QEvent *pEvent)97 bool UIVisoCreatorPanel::eventFilter(QObject *pObject, QEvent *pEvent) 100 98 { 101 99 Q_UNUSED(pObject); … … 105 103 } 106 104 107 void UI FileManagerPanel::showEvent(QShowEvent *pEvent)105 void UIVisoCreatorPanel::showEvent(QShowEvent *pEvent) 108 106 { 109 107 QWidget::showEvent(pEvent); 110 108 } 111 109 112 void UI FileManagerPanel::hideEvent(QHideEvent *pEvent)110 void UIVisoCreatorPanel::hideEvent(QHideEvent *pEvent) 113 111 { 114 112 /* Get focused widget: */ … … 118 116 if (pFocus && pFocus->parent() == this) 119 117 focusNextPrevChild(true); 120 if (m_pFileManager) 121 m_pFileManager->hidePanel(this); 118 emit sigHidePanel(this); 122 119 123 120 QWidget::hideEvent(pEvent); 124 121 } 122 123 void UIVisoCreatorPanel::addVerticalSeparator() 124 { 125 QFrame *pSeparator = new QFrame(); 126 pSeparator->setFrameShape(QFrame::VLine); 127 pSeparator->setFrameShadow(QFrame::Sunken); 128 mainLayout()->addWidget(pSeparator); 129 } -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreatorPanel.h
r76910 r76944 16 16 */ 17 17 18 #ifndef FEQT_INCLUDED_SRC_ guestctrl_UIFileManagerPanel_h19 #define FEQT_INCLUDED_SRC_ guestctrl_UIFileManagerPanel_h18 #ifndef FEQT_INCLUDED_SRC_medium_viso_UIVisoCreatorPanel_h 19 #define FEQT_INCLUDED_SRC_medium_viso_UIVisoCreatorPanel_h 20 20 #ifndef RT_WITHOUT_PRAGMA_ONCE 21 21 # pragma once … … 33 33 class QTextDocument; 34 34 class QIToolButton; 35 class UIFileManager; 35 36 36 37 37 /** QWidget extension acting as the base class for UIVMLogViewerXXXPanel widgets. */ 38 class UI FileManagerPanel : public QIWithRetranslateUI<QWidget>38 class UIVisoCreatorPanel : public QIWithRetranslateUI<QWidget> 39 39 { 40 40 Q_OBJECT; … … 42 42 public: 43 43 44 UI FileManagerPanel(UIFileManager *pManagerWidget,QWidget *pParent);44 UIVisoCreatorPanel(QWidget *pParent); 45 45 void setCloseButtonShortCut(QKeySequence shortCut); 46 46 virtual QString panelName() const = 0; 47 48 signals: 49 50 void sigHidePanel(UIVisoCreatorPanel *pPanel); 47 51 48 52 protected: … … 64 68 /** Handles the Qt hide @a pEvent. */ 65 69 void hideEvent(QHideEvent *pEvent); 70 void addVerticalSeparator(); 66 71 67 72 private: … … 70 75 QHBoxLayout *m_pMainLayout; 71 76 QIToolButton *m_pCloseButton; 72 UIFileManager *m_pFileManager;73 77 }; 74 78 75 #endif /* !FEQT_INCLUDED_SRC_ guestctrl_UIFileManagerPanel_h */79 #endif /* !FEQT_INCLUDED_SRC_medium_viso_UIVisoCreatorPanel_h */
Note:
See TracChangeset
for help on using the changeset viewer.

