Changeset 63928 in vbox
- Timestamp:
- Sep 21, 2016 4:07:54 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 110812
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp
r63926 r63928 55 55 # include "UISelectorWindow.h" 56 56 # include "UISettingsDialogSpecific.h" 57 # include "UISpacerWidgets.h" 58 # include "UISpecialControls.h" 57 59 # include "UIToolBar.h" 58 60 # include "UIVMLogViewer.h" … … 121 123 #endif /* !VBOX_WS_MAC */ 122 124 , m_pToolBar(0) 125 , m_pSegmentedButton(0) 123 126 , m_pContainerDetails(0) 124 127 , m_pPaneChooser(0) … … 202 205 statusBar()->hide(); 203 206 } 204 }205 206 void UISelectorWindow::sltHandleDetailsContainerIndexChange(int iIndex)207 {208 if (iIndex)209 m_pContainerDetails->setCurrentWidget(m_pPaneDesktop);210 else211 m_pContainerDetails->setCurrentWidget(m_pPaneDetails);212 207 } 213 208 … … 1043 1038 } 1044 1039 1040 void UISelectorWindow::sltHandleSegmentedButtonSwitch(int iSegment) 1041 { 1042 /* Get current item: */ 1043 const UIVMItem *pItem = currentItem(); 1044 1045 /* If current item exists & accessible: */ 1046 if (pItem && pItem->accessible()) 1047 { 1048 /* Raise the required widget: */ 1049 switch (iSegment) 1050 { 1051 case SegmentType_Details: 1052 { 1053 /* Raise the details pane: */ 1054 m_pContainerDetails->setCurrentWidget(m_pPaneDetails); 1055 break; 1056 } 1057 case SegmentType_Snapshots: 1058 { 1059 /* Raise the desktop pane which contains snapshot pane for now: */ 1060 m_pContainerDetails->setCurrentWidget(m_pPaneDesktop); 1061 break; 1062 } 1063 default: 1064 break; 1065 } 1066 /* And pass the request to desktop pane afterwards: */ 1067 m_pPaneDesktop->setWidgetIndex(iSegment); 1068 } 1069 else 1070 { 1071 /* Raise the desktop pane which contains text/error details: */ 1072 m_pContainerDetails->setCurrentWidget(m_pPaneDesktop); 1073 /* And pass the request to desktop pane afterwards: */ 1074 m_pPaneDesktop->setWidgetIndex(SegmentType_Details); 1075 } 1076 } 1077 1078 void UISelectorWindow::sltPerformSegmentedButtonSwitch(int iSegment) 1079 { 1080 m_pSegmentedButton->animateClick(iSegment); 1081 } 1082 1045 1083 UIVMItem* UISelectorWindow::currentItem() const 1046 1084 { … … 1055 1093 void UISelectorWindow::updateSnapshots(UIVMItem *pItem, const CMachine &comMachine) 1056 1094 { 1057 /* Redirect call to Desktop-pane: */ 1058 m_pPaneDesktop->updateSnapshots(pItem, comMachine); 1095 /* Update segmented-button text: */ 1096 // TODO: Bring that NLS to "&Snapshots" / "&Snapshots (%1)" form 1097 // as translator should be able to translate whole sentence. 1098 // And move it from UIVMDesktop to UISelectorWindow context. 1099 QString strName = QApplication::translate("UIVMDesktop", "&Snapshots"); 1100 if (pItem) 1101 { 1102 /* Append the snapshot count (if any): */ 1103 const ULONG count = pItem->snapshotCount(); 1104 if (count) 1105 strName += QString(" (%1)").arg(count); 1106 } 1107 m_pSegmentedButton->setTitle(SegmentType_Snapshots, strName); 1108 1109 /* Update snapshot pane availability: */ 1110 if (comMachine.isNotNull()) 1111 m_pSegmentedButton->setEnabled(SegmentType_Snapshots, true); 1112 else 1113 lockSnapshots(); 1114 1115 /* Redirect call to Desktop-pane finally: */ 1116 m_pPaneDesktop->updateSnapshots(comMachine); 1059 1117 } 1060 1118 1061 1119 void UISelectorWindow::lockSnapshots() 1062 1120 { 1063 /* Redirect call to Desktop-pane: */ 1064 m_pPaneDesktop->lockSnapshots(); 1121 /* First switch to details pane: */ 1122 sltPerformSegmentedButtonSwitchToDetails(); 1123 /* Then lock the snapshot pane: */ 1124 m_pSegmentedButton->setEnabled(SegmentType_Snapshots, false); 1065 1125 } 1066 1126 … … 1079 1139 setWindowTitle(strTitle); 1080 1140 1141 /* Translate segmented-button: */ 1142 // TODO: Move that NLS from UIVMDesktop to UISelectorWindow context. 1143 m_pSegmentedButton->setTitle(SegmentType_Details, QApplication::translate("UIVMDesktop", "&Details")); 1144 1081 1145 /* Make sure details and snapshot panes are updated: */ 1082 1146 sltHandleChooserPaneIndexChange(); … … 1243 1307 qApp->installEventFilter(this); 1244 1308 #endif /* VBOX_WS_MAC */ 1309 1310 //#ifdef VBOX_WS_MAC 1311 // /* Cocoa stuff should be async.. 1312 // * Do not ask me why but otherwise 1313 // * it conflicts with native handlers. */ 1314 // QMetaObject::invokeMethod(this, "sltPerformSegmentedButtonSwitchToDetails", Qt::QueuedConnection); 1315 //#else /* !VBOX_WS_MAC */ 1316 sltPerformSegmentedButtonSwitchToDetails(); 1317 //#endif /* !VBOX_WS_MAC */ 1245 1318 } 1246 1319 … … 1689 1762 m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow)); 1690 1763 1764 /* Create/add horizontal spacer widget to align subsequent controls right: */ 1765 m_pToolBar->addWidget(new UIHorizontalSpacerWidget(this)); 1766 1767 /* Create/add segmented-button: */ 1768 m_pSegmentedButton = new UITexturedSegmentedButton(this, 2); 1769 m_pSegmentedButton->setIcon(SegmentType_Details, UIIconPool::iconSet(":/vm_settings_16px.png", 1770 ":/vm_settings_disabled_16px.png")); 1771 m_pSegmentedButton->setIcon(SegmentType_Snapshots, UIIconPool::iconSet(":/snapshot_take_16px.png", 1772 ":/snapshot_take_disabled_16px.png")); 1773 m_pToolBar->addWidget(m_pSegmentedButton); 1774 1775 /* Create/add horizontal spacer widget of fixed size for the beta label: */ 1776 QWidget *pSpace = new QWidget(this); 1777 if (vboxGlobal().isBeta()) 1778 pSpace->setFixedSize(28, 1); 1779 else 1780 pSpace->setFixedSize(10, 1); 1781 m_pToolBar->addWidget(pSpace); 1782 1783 #ifdef VBOX_WS_MAC 1784 /* Update toolbar on Mac OS X: */ 1785 m_pToolBar->updateLayout(); 1786 #endif /* VBOX_WS_MAC */ 1787 1691 1788 /* Prepare graphics VM list: */ 1692 1789 m_pPaneChooser = new UIGChooser(this); … … 1700 1797 1701 1798 /* Prepare details and snapshots tabs: */ 1702 m_pPaneDesktop = new UIVMDesktop( m_pToolBar,actionPool()->action(UIActionIndexST_M_Group_S_Refresh), this);1799 m_pPaneDesktop = new UIVMDesktop(actionPool()->action(UIActionIndexST_M_Group_S_Refresh), this); 1703 1800 1704 1801 /* Crate container: */ … … 1823 1920 #endif /* VBOX_WS_MAC */ 1824 1921 1922 /* Segmented-button connections: */ 1923 connect(m_pSegmentedButton, SIGNAL(clicked(int)), this, SLOT(sltHandleSegmentedButtonSwitch(int))); 1924 1825 1925 /* VM desktop connections: */ 1826 connect(m_pPaneDesktop, SIGNAL(sigCurrentChanged(int)), this, SLOT(sltHandleDetailsContainerIndexChange(int)));1827 1926 connect(m_pPaneDetails, SIGNAL(sigLinkClicked(const QString&, const QString&, const QString&)), 1828 1927 this, SLOT(sltOpenMachineSettingsDialog(const QString&, const QString&, const QString&))); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h
r63926 r63928 40 40 class QMenu; 41 41 class QStackedWidget; 42 class UITexturedSegmentedButton; 42 43 43 44 /** Singleton QIMainWindow extension … … 46 47 { 47 48 Q_OBJECT; 49 50 /** Segmented-button segment types. */ 51 enum SegmentType 52 { 53 SegmentType_Details = 0, 54 SegmentType_Snapshots 55 }; 48 56 49 57 public: … … 78 86 /** Handles selector-window context-menu call for passed @a position. */ 79 87 void sltShowSelectorWindowContextMenu(const QPoint &position); 80 81 /** Handles signal about Details-container @a iIndex change. */82 void sltHandleDetailsContainerIndexChange(int iIndex);83 88 84 89 /** Handles signal about Chooser-pane index change. … … 177 182 /** @} */ 178 183 184 /** @name Segmented-button stuff. 185 * @{ */ 186 /** Handles segmented-button switch. */ 187 void sltHandleSegmentedButtonSwitch(int iSegment); 188 /** Performs segmented-button switch. */ 189 void sltPerformSegmentedButtonSwitch(int iSegment); 190 /** Performs segmented-button switch to details pane. */ 191 void sltPerformSegmentedButtonSwitchToDetails() { sltPerformSegmentedButtonSwitch(SegmentType_Details); } 192 /** @} */ 193 179 194 private: 180 195 … … 299 314 UIToolBar *m_pToolBar; 300 315 316 /** Holds the segmented-button instance. */ 317 UITexturedSegmentedButton *m_pSegmentedButton; 318 301 319 /** Holds the Details-container instance. */ 302 320 QStackedWidget *m_pContainerDetails; -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMDesktop.cpp
r63925 r63928 31 31 # include "UIBar.h" 32 32 # include "UIIconPool.h" 33 # include "UISpacerWidgets.h"34 # include "UISpecialControls.h"35 33 # include "UIVMDesktop.h" 36 34 # include "UIVMItem.h" … … 220 218 } 221 219 222 UIVMDesktop::UIVMDesktop( UIToolBar *pToolBar,QAction *pRefreshAction, QWidget *pParent)220 UIVMDesktop::UIVMDesktop(QAction *pRefreshAction, QWidget *pParent) 223 221 : QIWithRetranslateUI<QWidget>(pParent) 224 222 { 225 /* Create container: */226 QWidget *pContainer = new QWidget;227 {228 /* Create layout: */229 QHBoxLayout *pLayout = new QHBoxLayout(pContainer);230 {231 /* Configure layout: */232 pLayout->setContentsMargins(0, 0, 0, 0);233 /* Create segmented-button: */234 m_pHeaderBtn = new UITexturedSegmentedButton(pContainer, 2);235 {236 /* Configure segmented-button: */237 m_pHeaderBtn->setIcon(SegmentType_Details, UIIconPool::iconSet(":/vm_settings_16px.png",238 ":/vm_settings_disabled_16px.png"));239 m_pHeaderBtn->setIcon(SegmentType_Snapshots, UIIconPool::iconSet(":/snapshot_take_16px.png",240 ":/snapshot_take_disabled_16px.png"));241 /* Add segmented-buttons into layout: */242 pLayout->addWidget(m_pHeaderBtn);243 }244 }245 }246 247 #ifdef VBOX_WS_MAC248 /* Cocoa stuff should be async...249 * Do not ask me why but otherwise250 * it conflicts with native handlers. */251 QTimer::singleShot(0, this, SLOT(sltInit()));252 #else /* !VBOX_WS_MAC */253 sltInit();254 #endif /* !VBOX_WS_MAC */255 256 223 /* Prepare main layout: */ 257 224 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 258 225 pMainLayout->setContentsMargins(0, 0, 0, 0); 259 260 /* The header to select the different pages.261 * Has different styles on the different platforms. */262 if (pToolBar)263 {264 pToolBar->addWidget(new UIHorizontalSpacerWidget(this));265 pToolBar->addWidget(pContainer);266 QWidget *pSpace = new QWidget(this);267 /* We need a little bit more space for the beta label. */268 if (vboxGlobal().isBeta())269 pSpace->setFixedSize(28, 1);270 else271 pSpace->setFixedSize(10, 1);272 pToolBar->addWidget(pSpace);273 #ifdef VBOX_WS_MAC274 pToolBar->updateLayout();275 #endif /* VBOX_WS_MAC */276 }277 else278 {279 UIBar *pBar = new UIBar(this);280 pBar->setContentWidget(pContainer);281 pMainLayout->addWidget(pBar);282 }283 226 284 227 /* Create desktop pane: */ … … 294 237 m_pStackedLayout->addWidget(m_pSnapshotsPane); 295 238 296 /* Connect the header buttons with the stack layout: */297 connect(m_pHeaderBtn, SIGNAL(clicked(int)), m_pStackedLayout, SLOT(setCurrentIndex(int)));298 connect(m_pStackedLayout, SIGNAL(currentChanged(int)), this, SIGNAL(sigCurrentChanged(int)));299 300 239 /* Translate finally: */ 301 240 retranslateUi(); … … 322 261 } 323 262 324 void UIVMDesktop::updateSnapshots(UIVMItem *pVMItem, const CMachine &comMachine) 325 { 326 /* Update snapshot segment name: */ 327 QString strName = tr("&Snapshots"); 328 if (pVMItem) 329 { 330 const ULONG count = pVMItem->snapshotCount(); 331 if (count) 332 strName += QString(" (%1)").arg(count); 333 } 334 m_pHeaderBtn->setTitle(SegmentType_Snapshots, strName); 335 336 /* Update segmented-button availability: */ 337 if (comMachine.isNotNull()) 338 m_pHeaderBtn->setEnabled(SegmentType_Snapshots, true); 339 else 340 lockSnapshots(); 341 342 /* Update snapshot pane: */ 263 void UIVMDesktop::updateSnapshots(const CMachine &comMachine) 264 { 343 265 m_pSnapshotsPane->setMachine(comMachine); 344 266 } 345 267 346 void UIVMDesktop::lockSnapshots()347 {348 m_pHeaderBtn->animateClick(SegmentType_Details);349 m_pHeaderBtn->setEnabled(SegmentType_Snapshots, false);350 }351 352 void UIVMDesktop::sltInit()353 {354 m_pHeaderBtn->animateClick(0);355 }356 357 268 void UIVMDesktop::retranslateUi() 358 269 { 359 m_pHeaderBtn->setTitle(SegmentType_Details, tr("&Details"));360 270 } 361 271 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMDesktop.h
r63924 r63928 30 30 class CMachine; 31 31 class UIVMDesktopPrivate; 32 class UITexturedSegmentedButton;33 32 class UIVMItem; 34 33 class UISnapshotPane; … … 45 44 Q_OBJECT; 46 45 47 /** Segmented-button segment types. */48 enum SegmentType49 {50 SegmentType_Details = 0,51 SegmentType_Snapshots52 };53 54 signals:55 56 /* Notifier: Current widget stuff: */57 void sigCurrentChanged(int iWidgetIndex);58 59 46 public: 60 47 61 48 /* Constructor: */ 62 UIVMDesktop( UIToolBar *pToolBar,QAction *pRefreshAction, QWidget *pParent);49 UIVMDesktop(QAction *pRefreshAction, QWidget *pParent); 63 50 64 51 /** Returns current widget index. */ … … 70 57 void updateDetailsText(const QString &strText); 71 58 void updateDetailsError(const QString &strError); 72 void updateSnapshots(UIVMItem *pVMItem, const CMachine& machine); 73 void lockSnapshots(); 74 75 private slots: 76 77 /** Initialization handler. */ 78 void sltInit(); 59 void updateSnapshots(const CMachine &comMachine); 79 60 80 61 private: … … 85 66 /* Variables: */ 86 67 QStackedLayout *m_pStackedLayout; 87 UITexturedSegmentedButton *m_pHeaderBtn;88 68 UIVMDesktopPrivate *m_pDesktopPrivate; 89 69 UISnapshotPane *m_pSnapshotsPane;
Note:
See TracChangeset
for help on using the changeset viewer.