Changeset 67068 in vbox
- Timestamp:
- May 24, 2017 5:47:44 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 5 edited
- 10 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r67067 r67068 378 378 src/selector/UISelectorWindow.h \ 379 379 src/selector/UISnapshotPane.h \ 380 src/selector/UIToolsPane.h \ 380 381 src/selector/graphics/chooser/UIGChooser.h \ 381 382 src/selector/graphics/chooser/UIGChooserModel.h \ … … 686 687 src/selector/UISelectorWindow.cpp \ 687 688 src/selector/UISnapshotPane.cpp \ 689 src/selector/UIToolsPane.cpp \ 688 690 src/selector/graphics/chooser/UIGChooser.cpp \ 689 691 src/selector/graphics/chooser/UIGChooserModel.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/VirtualBox1.qrc
r67047 r67068 63 63 <file alias="disconnect_16px.png">images/disconnect_16px.png</file> 64 64 <file alias="diskimage_16px.png">images/diskimage_16px.png</file> 65 <file alias="diskimage_22px.png">images/diskimage_22px.png</file> 65 66 <file alias="diskimage_32px.png">images/diskimage_32px.png</file> 66 67 <file alias="display_hardware_16px.png">images/display_hardware_16px.png</file> … … 174 175 <file alias="help_button_pressed_mac_22px.png">images/help_button_pressed_mac_22px.png</file> 175 176 <file alias="host_iface_manager_16px.png">images/host_iface_manager_16px.png</file> 177 <file alias="host_iface_manager_22px.png">images/host_iface_manager_22px.png</file> 176 178 <file alias="host_iface_manager_32px.png">images/host_iface_manager_32px.png</file> 177 179 <file alias="hostkey_16px.png">images/hostkey_16px.png</file> -
trunk/src/VBox/Frontends/VirtualBox/VirtualBox1_hidpi.qrc
r67047 r67068 63 63 <file alias="disconnect_16px_hidpi.png">images/hidpi/disconnect_16px_hidpi.png</file> 64 64 <file alias="diskimage_16px_hidpi.png">images/hidpi/diskimage_16px_hidpi.png</file> 65 <file alias="diskimage_22px_hidpi.png">images/hidpi/diskimage_22px_hidpi.png</file> 65 66 <file alias="diskimage_32px_hidpi.png">images/hidpi/diskimage_32px_hidpi.png</file> 66 67 <file alias="display_hardware_16px_hidpi.png">images/hidpi/display_hardware_16px_hidpi.png</file> … … 174 175 <file alias="help_button_pressed_mac_22px_hidpi.png">images/hidpi/help_button_pressed_mac_22px_hidpi.png</file> 175 176 <file alias="host_iface_manager_16px_hidpi.png">images/hidpi/host_iface_manager_16px_hidpi.png</file> 177 <file alias="host_iface_manager_22px_hidpi.png">images/hidpi/host_iface_manager_22px_hidpi.png</file> 176 178 <file alias="host_iface_manager_32px_hidpi.png">images/hidpi/host_iface_manager_32px_hidpi.png</file> 177 179 <file alias="hostkey_16px_hidpi.png">images/hidpi/hostkey_16px_hidpi.png</file> -
trunk/src/VBox/Frontends/VirtualBox/VirtualBox2.qrc
r66681 r67068 140 140 <file alias="snapshot_delete_disabled_16px.png">images/snapshot_delete_disabled_16px.png</file> 141 141 <file alias="snapshot_delete_disabled_22px.png">images/snapshot_delete_disabled_22px.png</file> 142 <file alias="snapshot_manager_16px.png">images/snapshot_manager_16px.png</file> 143 <file alias="snapshot_manager_22px.png">images/snapshot_manager_22px.png</file> 142 144 <file alias="snapshot_offline_16px.png">images/snapshot_offline_16px.png</file> 143 145 <file alias="snapshot_online_16px.png">images/snapshot_online_16px.png</file> -
trunk/src/VBox/Frontends/VirtualBox/VirtualBox2_hidpi.qrc
r66681 r67068 145 145 <file alias="site_oracle_16px_hidpi.png">images/hidpi/site_oracle_16px_hidpi.png</file> 146 146 <file alias="site_warning_16px_hidpi.png">images/hidpi/site_warning_16px_hidpi.png</file> 147 <file alias="snapshot_manager_16px_hidpi.png">images/hidpi/snapshot_manager_16px_hidpi.png</file> 148 <file alias="snapshot_manager_22px_hidpi.png">images/hidpi/snapshot_manager_22px_hidpi.png</file> 147 149 <file alias="snapshot_delete_16px_hidpi.png">images/hidpi/snapshot_delete_16px_hidpi.png</file> 148 150 <file alias="snapshot_delete_22px_hidpi.png">images/hidpi/snapshot_delete_22px_hidpi.png</file> -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UIToolsPane.cpp
r67016 r67068 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI DesktopPane class implementation.3 * VBox Qt GUI - UIToolsPane class implementation. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 201 0-2016Oracle Corporation7 * Copyright (C) 2017 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 21 21 22 22 /* Qt includes: */ 23 # include <QAction>24 # include <QLabel>25 23 # include <QStackedWidget> 26 # include <QToolButton> 27 # include <QVBoxLayout> 24 # include <QTabBar> 28 25 29 26 /* GUI includes */ 30 # include "QIWithRetranslateUI.h" 31 # include "UIDesktopPane.h" 32 # include "VBoxUtils.h" 27 # include "QIToolButton.h" 28 # include "UIHostNetworkManager.h" 29 # include "UIIconPool.h" 30 # include "UIMediumManager.h" 31 # include "UIMenuToolBar.h" 32 # include "UISnapshotPane.h" 33 # include "UIToolsPane.h" 33 34 34 35 /* Other VBox includes: */ … … 38 39 39 40 40 /** QStackedWidget subclass representing container which have two panes: 41 * 1. Text pane reflecting base information about VirtualBox, 42 * 2. Error pane reflecting information about currently chosen 43 * inaccessible VM and allowing to operate over it. */ 44 class UIDesktopPanePrivate : public QIWithRetranslateUI<QStackedWidget> 45 { 46 Q_OBJECT; 47 48 public: 49 50 /** Constructs private desktop pane passing @a pParent to the base-class. 51 * @param pRefreshAction Brings the refresh action reference. */ 52 UIDesktopPanePrivate(QWidget *pParent, QAction *pRefreshAction); 53 54 /** Assigns @a strText and switches to text pane. */ 55 void setText(const QString &strText); 56 /** Assigns @a strError and switches to error pane. */ 57 void setError(const QString &strError); 58 59 protected: 60 61 /** Handles translation event. */ 62 void retranslateUi(); 63 64 /** Prepares text pane. */ 65 void prepareTextPane(); 66 /** Prepares error pane. */ 67 void prepareErrorPane(); 68 69 private: 70 71 /** Holds the text pane instance. */ 72 QRichTextBrowser *m_pText; 73 74 /** Holds the error pane container. */ 75 QWidget *m_pErrBox; 76 /** Holds the error label instance. */ 77 QLabel *m_pErrLabel; 78 /** Holds the error text-browser instance. */ 79 QTextBrowser *m_pErrText; 80 /** Holds the VM refresh button instance. */ 81 QToolButton *m_pRefreshButton; 82 /** Holds the VM refresh action reference. */ 83 QAction *m_pRefreshAction; 84 }; 85 86 87 /********************************************************************************************************************************* 88 * Class UIDesktopPanePrivate implementation. * 89 *********************************************************************************************************************************/ 90 91 UIDesktopPanePrivate::UIDesktopPanePrivate(QWidget *pParent, QAction *pRefreshAction) 92 : QIWithRetranslateUI<QStackedWidget>(pParent) 93 , m_pText(0) 94 , m_pErrBox(0), m_pErrLabel(0), m_pErrText(0) 95 , m_pRefreshButton(0), m_pRefreshAction(pRefreshAction) 96 { 97 /* Make sure refresh action was passed: */ 98 AssertMsg(m_pRefreshAction, ("Refresh action was NOT passed!")); 99 100 /* Translate finally: */ 41 UIToolsPane::UIToolsPane(QWidget *pParent /* = 0 */) 42 : QIWithRetranslateUI<QWidget>(pParent) 43 , m_pLayoutMain(0) 44 , m_pStackedWidget(0) 45 , m_pPaneSnapshots(0) 46 , m_pLayoutControls(0) 47 , m_pTabBar(0) 48 , m_pMenuToolbar(0) 49 , m_pMenu(0) 50 { 51 /* Prepare: */ 52 prepare(); 53 } 54 55 void UIToolsPane::setMachine(const CMachine &comMachine) 56 { 57 /* Update the panes: */ 58 AssertPtrReturnVoid(m_pPaneSnapshots); 59 m_pPaneSnapshots->setMachine(comMachine); 60 } 61 62 void UIToolsPane::retranslateUi() 63 { 64 /* Translate menu: */ 65 m_pMenu->menuAction()->setText(tr("More Tools")); 66 m_pMenu->setToolTip(tr("Holds a list of tools")); 67 m_pMenu->setTitle(tr("Tools")); 68 69 /* Translate actions: */ 70 m_actions[ToolsType_SnapshotManager]->setText(tr("Snapshot Manager")); 71 m_actions[ToolsType_VirtualMediaManager]->setText(tr("Virtual Media Manager")); 72 m_actions[ToolsType_HostNetworkManager]->setText(tr("Host Network Manager")); 73 74 /* Translate tab-bar: */ 75 for (int iTabIndex = 0; iTabIndex < m_pTabBar->count(); ++iTabIndex) 76 { 77 const ToolsType enmType = m_pTabBar->tabData(iTabIndex).value<ToolsType>(); 78 m_pTabBar->setTabText(iTabIndex, m_actions.value(enmType)->text()); 79 } 80 } 81 82 void UIToolsPane::sltHandleMenuToolbarTrigger() 83 { 84 /* Get the sender: */ 85 QAction *pAction = sender() ? qobject_cast<QAction*>(sender()) : 0; 86 AssertPtrReturnVoid(pAction); 87 88 /* Acquire sender's type: */ 89 const ToolsType enmType = pAction->property("ToolsType").value<ToolsType>(); 90 AssertReturnVoid(enmType != ToolsType_Invalid); 91 92 /* Add corresponding tab: */ 93 addTabBarTab(enmType, true); 94 } 95 96 void UIToolsPane::sltHandleTabBarTabMoved(int iFrom, int iTo) 97 { 98 /* Swap stack-widget pages as well: */ 99 QWidget *pWidget = m_pStackedWidget->widget(iFrom); 100 m_pStackedWidget->removeWidget(pWidget); 101 m_pStackedWidget->insertWidget(iTo, pWidget); 102 } 103 104 void UIToolsPane::sltHandleTabBarCurrentChange(int iIndex) 105 { 106 /* Activate corresponding indexes: */ 107 m_pStackedWidget->setCurrentIndex(iIndex); 108 } 109 110 void UIToolsPane::sltHandleTabBarButtonClick() 111 { 112 /* Get the sender: */ 113 QIToolButton *pButton = sender() ? qobject_cast<QIToolButton*>(sender()) : 0; 114 AssertPtrReturnVoid(pButton); 115 116 /* Acquire sender's type: */ 117 const ToolsType enmType = pButton->property("ToolsType").value<ToolsType>(); 118 AssertReturnVoid(enmType != ToolsType_Invalid); 119 120 /* Search for the tab with such type: */ 121 int iActualTabIndex = -1; 122 for (int iTabIndex = 0; iTabIndex < m_pTabBar->count(); ++iTabIndex) 123 if (m_pTabBar->tabData(iTabIndex).value<ToolsType>() == enmType) 124 iActualTabIndex = iTabIndex; 125 AssertReturnVoid(iActualTabIndex != -1); 126 127 /* Delete the tab and corresponding widget: */ 128 m_pTabBar->removeTab(iActualTabIndex); 129 QWidget *pWidget = m_pStackedWidget->widget(iActualTabIndex); 130 m_pStackedWidget->removeWidget(pWidget); 131 delete pWidget; 132 } 133 134 void UIToolsPane::prepare() 135 { 136 /* Create main layout: */ 137 m_pLayoutMain = new QVBoxLayout(this); 138 AssertPtrReturnVoid(m_pLayoutMain); 139 { 140 /* Configure layout: */ 141 m_pLayoutMain->setSpacing(0); 142 m_pLayoutMain->setContentsMargins(3, 4, 5, 0); 143 144 /* Prepare stacked-widget: */ 145 prepareStackedWidget(); 146 147 /* Create controls layout: */ 148 m_pLayoutControls = new QHBoxLayout; 149 AssertPtrReturnVoid(m_pLayoutControls); 150 { 151 /* Configure layout: */ 152 m_pLayoutControls->setSpacing(0); 153 m_pLayoutControls->setContentsMargins(0, 0, 0, 0); 154 155 /* Prepare tab-bar: */ 156 prepareTabBar(); 157 /* Prepare menu-toolbar: */ 158 prepareMenuToolbar(); 159 /* Add Snapshot Manager pane: */ 160 addTabBarTab(ToolsType_SnapshotManager, false); 161 162 /* Add into layout: */ 163 m_pLayoutMain->addLayout(m_pLayoutControls); 164 } 165 } 166 167 /* Apply language settings: */ 101 168 retranslateUi(); 102 169 } 103 170 104 void UIDesktopPanePrivate::setText(const QString &strText) 105 { 106 /* Prepare text pane if necessary: */ 107 prepareTextPane(); 108 109 /* Assign corresponding text: */ 110 m_pText->setText(strText); 111 112 /* Raise corresponding widget: */ 113 setCurrentIndex(indexOf(m_pText)); 114 } 115 116 void UIDesktopPanePrivate::setError(const QString &strError) 117 { 118 /* Prepare error pane if necessary: */ 119 prepareErrorPane(); 120 121 /* Assign corresponding text: */ 122 m_pErrText->setText(strError); 123 124 /* Raise corresponding widget: */ 125 setCurrentIndex(indexOf(m_pErrBox)); 126 } 127 128 void UIDesktopPanePrivate::retranslateUi() 129 { 130 /* Translate error-label text: */ 131 if (m_pErrLabel) 132 m_pErrLabel->setText(QApplication::translate("UIDetailsPagePrivate", 133 "The selected virtual machine is <i>inaccessible</i>. " 134 "Please inspect the error message shown below and press the " 135 "<b>Refresh</b> button if you want to repeat the accessibility check:")); 136 137 /* Translate refresh button & action text: */ 138 if (m_pRefreshAction && m_pRefreshButton) 139 { 140 m_pRefreshButton->setText(m_pRefreshAction->text()); 141 m_pRefreshButton->setIcon(m_pRefreshAction->icon()); 142 m_pRefreshButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); 143 } 144 } 145 146 void UIDesktopPanePrivate::prepareTextPane() 147 { 148 if (m_pText) 149 return; 150 151 /* Create text pane: */ 152 m_pText = new QRichTextBrowser(this); 153 m_pText->setFocusPolicy(Qt::StrongFocus); 154 m_pText->document()->setDefaultStyleSheet("a { text-decoration: none; }"); 155 /* Make text pane transparent: */ 156 m_pText->setFrameShape(QFrame::NoFrame); 157 m_pText->viewport()->setAutoFillBackground(false); 158 m_pText->setOpenLinks(false); 159 160 /* Add into the stack: */ 161 addWidget(m_pText); 162 163 /* Retranslate finally: */ 164 retranslateUi(); 165 } 166 167 void UIDesktopPanePrivate::prepareErrorPane() 168 { 169 if (m_pErrBox) 170 return; 171 172 /* Create error pane: */ 173 m_pErrBox = new QWidget; 174 175 /* Create main layout: */ 176 QVBoxLayout *pMainLayout = new QVBoxLayout(m_pErrBox); 177 #if defined(VBOX_WS_MAC) 178 pMainLayout->setContentsMargins(4, 5, 5, 5); 179 #elif defined(VBOX_WS_WIN) 180 pMainLayout->setContentsMargins(3, 5, 5, 0); 181 #elif defined(VBOX_WS_X11) 182 pMainLayout->setContentsMargins(0, 5, 5, 5); 183 #endif 184 pMainLayout->setSpacing(10); 185 186 /* Create error label: */ 187 m_pErrLabel = new QLabel(m_pErrBox); 188 m_pErrLabel->setWordWrap(true); 189 m_pErrLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 190 pMainLayout->addWidget(m_pErrLabel); 191 192 /* Create error text-browser: */ 193 m_pErrText = new QTextBrowser(m_pErrBox); 194 m_pErrText->setFocusPolicy(Qt::StrongFocus); 195 m_pErrText->document()->setDefaultStyleSheet("a { text-decoration: none; }"); 196 pMainLayout->addWidget(m_pErrText); 197 198 /* If refresh action was set: */ 199 if (m_pRefreshAction) 200 { 201 /* Create refresh button: */ 202 m_pRefreshButton = new QToolButton(m_pErrBox); 203 m_pRefreshButton->setFocusPolicy(Qt::StrongFocus); 204 205 /* Create refresh button layout: */ 206 QHBoxLayout *pButtonLayout = new QHBoxLayout; 207 pMainLayout->addLayout(pButtonLayout); 208 pButtonLayout->addStretch(); 209 pButtonLayout->addWidget(m_pRefreshButton); 210 211 /* Connect refresh button: */ 212 connect(m_pRefreshButton, SIGNAL(clicked()), m_pRefreshAction, SIGNAL(triggered())); 213 } 214 215 pMainLayout->addStretch(); 216 217 /* Add into the stack: */ 218 addWidget(m_pErrBox); 219 220 /* Retranslate finally: */ 221 retranslateUi(); 222 } 223 224 225 /********************************************************************************************************************************* 226 * Class UIDesktopPane implementation. * 227 *********************************************************************************************************************************/ 228 229 UIDesktopPane::UIDesktopPane(QAction *pRefreshAction, QWidget *pParent) 230 : QWidget(pParent) 231 { 232 /* Prepare main layout: */ 233 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 234 pMainLayout->setContentsMargins(0, 0, 0, 0); 235 236 /* Create desktop pane: */ 237 m_pDesktopPrivate = new UIDesktopPanePrivate(this, pRefreshAction); 238 239 /* Add it to the layout: */ 240 pMainLayout->addWidget(m_pDesktopPrivate); 241 } 242 243 void UIDesktopPane::updateDetailsText(const QString &strText) 244 { 245 m_pDesktopPrivate->setText(strText); 246 } 247 248 void UIDesktopPane::updateDetailsError(const QString &strError) 249 { 250 m_pDesktopPrivate->setError(strError); 251 } 252 253 #include "UIDesktopPane.moc" 254 171 void UIToolsPane::prepareStackedWidget() 172 { 173 /* Create stacked-widget: */ 174 m_pStackedWidget = new QStackedWidget; 175 AssertPtrReturnVoid(m_pStackedWidget); 176 { 177 /* Add into layout: */ 178 m_pLayoutMain->addWidget(m_pStackedWidget); 179 } 180 } 181 182 void UIToolsPane::prepareTabBar() 183 { 184 /* Create tab-bar: */ 185 m_pTabBar = new QTabBar; 186 AssertPtrReturnVoid(m_pTabBar); 187 { 188 /* Configure tab-bar: */ 189 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * 1.375; 190 m_pTabBar->setIconSize(QSize(iIconMetric, iIconMetric)); 191 m_pTabBar->setMovable(true); 192 m_pTabBar->setDrawBase(false); 193 m_pTabBar->setExpanding(false); 194 m_pTabBar->setShape(QTabBar::RoundedSouth); 195 m_pTabBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); 196 connect(m_pTabBar, &QTabBar::tabMoved, this, &UIToolsPane::sltHandleTabBarTabMoved); 197 connect(m_pTabBar, &QTabBar::currentChanged, this, &UIToolsPane::sltHandleTabBarCurrentChange); 198 199 /* Add into layout: */ 200 m_pLayoutControls->addWidget(m_pTabBar); 201 } 202 } 203 204 void UIToolsPane::prepareMenuToolbar() 205 { 206 /* Create menu-toolbar: */ 207 m_pMenuToolbar = new UIMenuToolBar; 208 AssertPtrReturnVoid(m_pMenuToolbar); 209 { 210 /* Configure menu-toolbar: */ 211 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize); 212 m_pMenuToolbar->setIconSize(QSize(iIconMetric, iIconMetric)); 213 m_pMenuToolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); 214 m_pMenuToolbar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); 215 m_pMenuToolbar->setAlignmentType(UIMenuToolBar::AlignmentType_BottomRight); 216 217 /* Prepare menu: */ 218 prepareMenu(); 219 220 /* Add into layout: */ 221 m_pLayoutControls->addWidget(m_pMenuToolbar); 222 } 223 } 224 225 void UIToolsPane::prepareMenu() 226 { 227 /* Create menu: */ 228 m_pMenu = new QMenu(m_pMenuToolbar); 229 AssertPtrReturnVoid(m_pMenu); 230 { 231 /* Configure menus: */ 232 m_pMenu->setIcon(UIIconPool::iconSet(":/vm_settings_16px.png")); 233 234 /* Create SnapShot manager action: */ 235 m_actions[ToolsType_SnapshotManager] = m_pMenu->addAction(UIIconPool::iconSetFull(":/snapshot_manager_22px.png", 236 ":/snapshot_manager_16px.png"), 237 QString(), this, &UIToolsPane::sltHandleMenuToolbarTrigger); 238 { 239 m_actions[ToolsType_SnapshotManager]-> 240 setProperty("ToolsType", QVariant::fromValue(ToolsType_SnapshotManager)); 241 } 242 243 /* Create Virtual Media manager action: */ 244 m_actions[ToolsType_VirtualMediaManager] = m_pMenu->addAction(UIIconPool::iconSetFull(":/diskimage_22px.png", 245 ":/diskimage_16px.png"), 246 QString(), this, &UIToolsPane::sltHandleMenuToolbarTrigger); 247 { 248 m_actions[ToolsType_VirtualMediaManager]-> 249 setProperty("ToolsType", QVariant::fromValue(ToolsType_VirtualMediaManager)); 250 } 251 252 /* Create Host Network manager action: */ 253 m_actions[ToolsType_HostNetworkManager] = m_pMenu->addAction(UIIconPool::iconSetFull(":/host_iface_manager_22px.png", 254 ":/host_iface_manager_16px.png"), 255 QString(), this, &UIToolsPane::sltHandleMenuToolbarTrigger); 256 { 257 m_actions[ToolsType_HostNetworkManager]-> 258 setProperty("ToolsType", QVariant::fromValue(ToolsType_HostNetworkManager)); 259 } 260 261 /* Add as tool-button into tool-bar: */ 262 m_pMenuToolbar->setMenuAction(m_pMenu->menuAction()); 263 QToolButton *pButton = qobject_cast<QToolButton*>(m_pMenuToolbar->widgetForAction(m_pMenu->menuAction())); 264 AssertPtrReturnVoid(pButton); 265 { 266 /* Configure tool-button: */ 267 pButton->setPopupMode(QToolButton::InstantPopup); 268 pButton->setAutoRaise(true); 269 } 270 } 271 } 272 273 void UIToolsPane::addTabBarTab(ToolsType enmType, bool fCloseable) 274 { 275 /* Search for a tab with such type: */ 276 int iActualTabIndex = -1; 277 for (int iTabIndex = 0; iTabIndex < m_pTabBar->count(); ++iTabIndex) 278 if (m_pTabBar->tabData(iTabIndex).value<ToolsType>() == enmType) 279 iActualTabIndex = iTabIndex; 280 281 /* If tab with such type doesn't exist: */ 282 m_pTabBar->blockSignals(true); 283 if (iActualTabIndex == -1) 284 { 285 /* Append stack-widget with corresponding page: */ 286 switch (enmType) 287 { 288 case ToolsType_SnapshotManager: 289 m_pPaneSnapshots = new UISnapshotPane; 290 m_pStackedWidget->addWidget(m_pPaneSnapshots); 291 break; 292 case ToolsType_VirtualMediaManager: 293 m_pStackedWidget->addWidget(new UIMediumManagerWidget); 294 break; 295 case ToolsType_HostNetworkManager: 296 m_pStackedWidget->addWidget(new UIHostNetworkManagerWidget); 297 break; 298 default: 299 AssertFailedReturnVoid(); 300 } 301 302 /* Append tab-bar with corresponding tab: */ 303 iActualTabIndex = m_pTabBar->addTab(m_actions.value(enmType)->icon(), m_actions.value(enmType)->text()); 304 { 305 /* Create close button if requested: */ 306 if (fCloseable) 307 { 308 QIToolButton *pButtonClose = new QIToolButton; 309 AssertPtrReturnVoid(pButtonClose); 310 { 311 /* Configure button: */ 312 pButtonClose->setIcon(UIIconPool::iconSet(":/close_16px.png")); 313 pButtonClose->setProperty("ToolsType", QVariant::fromValue(enmType)); 314 connect(pButtonClose, &QIToolButton::clicked, this, &UIToolsPane::sltHandleTabBarButtonClick); 315 /* Add into tab-bar: */ 316 m_pTabBar->setTabButton(iActualTabIndex, QTabBar::RightSide, pButtonClose); 317 } 318 } 319 /* Store the data: */ 320 m_pTabBar->setTabData(iActualTabIndex, QVariant::fromValue(enmType)); 321 } 322 } 323 324 /* Activate corresponding indexes: */ 325 m_pStackedWidget->setCurrentIndex(iActualTabIndex); 326 m_pTabBar->setCurrentIndex(iActualTabIndex); 327 m_pTabBar->blockSignals(false); 328 } 329 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UIToolsPane.h
r67016 r67068 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI DesktopPane class declaration.3 * VBox Qt GUI - UIToolsPane class declaration. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 201 0-2016Oracle Corporation7 * Copyright (C) 2017 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 #ifndef ___UI DesktopPane_h___19 #define ___UI DesktopPane_h___18 #ifndef ___UIToolsPane_h___ 19 #define ___UIToolsPane_h___ 20 20 21 21 /* Qt includes: */ 22 22 #include <QWidget> 23 23 24 /* GUI includes: */ 25 #include "QIWithRetranslateUI.h" 26 24 27 /* Forward declarations: */ 25 class UIDesktopPanePrivate; 28 class QAction; 29 class QHBoxLayout; 30 class QMenu; 31 class QStackedWidget; 32 class QTabBar; 33 class QVBoxLayout; 34 class UIMenuToolBar; 35 class UISnapshotPane; 36 class CMachine; 26 37 27 38 28 /** QWidget subclass representing container which have two panes: 29 * 1. Text details pane reflecting base information about VirtualBox, 30 * 2. Error details pane reflecting information about currently chosen 31 * inaccessible VM and allowing to operate over it. */ 32 class UIDesktopPane : public QWidget 39 /** QWidget subclass representing container for tool panes. */ 40 class UIToolsPane : public QIWithRetranslateUI<QWidget> 33 41 { 34 42 Q_OBJECT; … … 36 44 public: 37 45 38 /** Constructs desktop pane passing @a pParent to the base-class. 39 * @param pRefreshAction Brings the refresh action reference. */ 40 UIDesktopPane(QAction *pRefreshAction, QWidget *pParent); 46 /** Tools types. */ 47 enum ToolsType 48 { 49 ToolsType_Invalid, 50 ToolsType_SnapshotManager, 51 ToolsType_VirtualMediaManager, 52 ToolsType_HostNetworkManager, 53 }; 41 54 42 /** Updates @a strText details and switches to text details pane. */ 43 void updateDetailsText(const QString &strText); 44 /** Updates @a strError details and switches to error details pane. */ 45 void updateDetailsError(const QString &strError); 55 /** Constructs tools pane passing @a pParent to the base-class. */ 56 UIToolsPane(QWidget *pParent = 0); 57 58 /** Defines the @a comMachine object. */ 59 void setMachine(const CMachine &comMachine); 60 61 protected: 62 63 /** Handles translation event. */ 64 virtual void retranslateUi() /* override */; 65 66 private slots: 67 68 /** Handles menu-toolbar trigger. */ 69 void sltHandleMenuToolbarTrigger(); 70 71 /** Handles Tools tab-bar tab movement. */ 72 void sltHandleTabBarTabMoved(int iFrom, int iTo); 73 /** Handles Tools tab-bar current tab change. */ 74 void sltHandleTabBarCurrentChange(int iIndex); 75 /** Handles Tools tab-bar button click. */ 76 void sltHandleTabBarButtonClick(); 46 77 47 78 private: 48 79 49 /** Holds the private desktop pane instance. */ 50 UIDesktopPanePrivate *m_pDesktopPrivate; 80 /** Prepares all. */ 81 void prepare(); 82 /** Prepares stacked-widget. */ 83 void prepareStackedWidget(); 84 /** Prepares tab-bar. */ 85 void prepareTabBar(); 86 /** Prepares menu-toolbar. */ 87 void prepareMenuToolbar(); 88 /** Prepares menu. */ 89 void prepareMenu(); 90 91 /** Adds corresponding tab-bar tab. */ 92 void addTabBarTab(ToolsType enmType, bool fCloseable); 93 94 /** Holds the main layout isntance. */ 95 QVBoxLayout *m_pLayoutMain; 96 /** Holds the stacked-widget instance. */ 97 QStackedWidget *m_pStackedWidget; 98 /** Holds the snapshot pane. */ 99 UISnapshotPane *m_pPaneSnapshots; 100 /** Holds the controls layout instance. */ 101 QHBoxLayout *m_pLayoutControls; 102 /** Holds the tab-bar instance. */ 103 QTabBar *m_pTabBar; 104 /** Holds the menu-toolbar instance. */ 105 UIMenuToolBar *m_pMenuToolbar; 106 /** Holds the menu instance. */ 107 QMenu *m_pMenu; 108 /** Holds the menu action instances. */ 109 QMap<ToolsType, QAction*> m_actions; 51 110 }; 52 111 53 #endif /* !___UIDesktopPane_h___ */ 112 /* Make sure QVariant can eat UIToolsPane::ToolsType: */ 113 Q_DECLARE_METATYPE(UIToolsPane::ToolsType); 54 114 115 #endif /* !___UIToolsPane_h___ */ 116
Note:
See TracChangeset
for help on using the changeset viewer.