Changeset 74177 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Sep 10, 2018 10:22:54 AM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.cpp
r74138 r74177 5 5 6 6 /* 7 * Copyright (C) 2012-201 7Oracle Corporation7 * Copyright (C) 2012-2018 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 <QVBoxLayout>24 23 # include <QStatusBar> 25 24 # include <QStyle> 25 # include <QVBoxLayout> 26 26 27 27 /* GUI includes: */ … … 42 42 , m_pChooserView(0) 43 43 { 44 /* Prepare palette: */ 45 preparePalette(); 46 47 /* Prepare layout: */ 48 prepareLayout(); 49 50 /* Prepare model: */ 51 prepareModel(); 52 53 /* Prepare view: */ 54 prepareView(); 55 56 /* Prepare connections: */ 57 prepareConnections(); 58 59 /* Load: */ 60 load(); 44 /* Prepare: */ 45 prepare(); 61 46 } 62 47 63 48 UIChooser::~UIChooser() 64 49 { 65 /* Save: */66 save();50 /* Cleanup: */ 51 cleanup(); 67 52 } 68 53 69 UIActionPool *UIChooser::actionPool() const54 UIActionPool *UIChooser::actionPool() const 70 55 { 71 56 return managerWidget()->actionPool(); … … 118 103 } 119 104 105 void UIChooser::prepare() 106 { 107 /* Prepare palette: */ 108 preparePalette(); 109 /* Prepare layout: */ 110 prepareLayout(); 111 /* Prepare model: */ 112 prepareModel(); 113 /* Prepare view: */ 114 prepareView(); 115 /* Prepare connections: */ 116 prepareConnections(); 117 118 /* Load settings: */ 119 loadSettings(); 120 } 121 120 122 void UIChooser::preparePalette() 121 123 { … … 130 132 void UIChooser::prepareLayout() 131 133 { 132 /* Setupmain-layout: */134 /* Create main-layout: */ 133 135 m_pMainLayout = new QVBoxLayout(this); 134 const int iR = qApp->style()->pixelMetric(QStyle::PM_LayoutRightMargin) / 9; 135 m_pMainLayout->setContentsMargins(0, 0, iR, 0); 136 m_pMainLayout->setSpacing(0); 136 if (m_pMainLayout) 137 { 138 /* Configure main-layout: */ 139 m_pMainLayout->setContentsMargins(0, 0, 0, 0); 140 m_pMainLayout->setSpacing(0); 141 } 137 142 } 138 143 139 144 void UIChooser::prepareModel() 140 145 { 141 /* Setupchooser-model: */146 /* Create chooser-model: */ 142 147 m_pChooserModel = new UIChooserModel(this); 143 148 } … … 147 152 /* Setup chooser-view: */ 148 153 m_pChooserView = new UIChooserView(this); 149 m_pChooserView->setScene(m_pChooserModel->scene()); 150 m_pChooserView->show(); 151 setFocusProxy(m_pChooserView); 152 m_pMainLayout->addWidget(m_pChooserView); 154 if (m_pChooserView) 155 { 156 /* Configure chooser-view. */ 157 m_pChooserView->setScene(m_pChooserModel->scene()); 158 m_pChooserView->show(); 159 setFocusProxy(m_pChooserView); 160 161 /* Add into layout: */ 162 m_pMainLayout->addWidget(m_pChooserView); 163 } 153 164 } 154 165 … … 156 167 { 157 168 /* Setup chooser-model connections: */ 158 connect(m_pChooserModel, SIGNAL(sigRootItemMinimumWidthHintChanged(int)),159 m_pChooserView, SLOT(sltMinimumWidthHintChanged(int)));160 connect(m_pChooserModel, SIGNAL(sigRootItemMinimumHeightHintChanged(int)),161 m_pChooserView, SLOT(sltMinimumHeightHintChanged(int)));162 connect(m_pChooserModel, SIGNAL(sigFocusChanged(UIChooserItem*)),163 m_pChooserView, SLOT(sltFocusChanged(UIChooserItem*)));169 connect(m_pChooserModel, &UIChooserModel::sigRootItemMinimumWidthHintChanged, 170 m_pChooserView, &UIChooserView::sltMinimumWidthHintChanged); 171 connect(m_pChooserModel, &UIChooserModel::sigRootItemMinimumHeightHintChanged, 172 m_pChooserView, &UIChooserView::sltMinimumHeightHintChanged); 173 connect(m_pChooserModel, &UIChooserModel::sigFocusChanged, 174 m_pChooserView, &UIChooserView::sltFocusChanged); 164 175 165 176 /* Setup chooser-view connections: */ 166 connect(m_pChooserView, SIGNAL(sigResized()),167 m_pChooserModel, SLOT(sltHandleViewResized()));177 connect(m_pChooserView, &UIChooserView::sigResized, 178 m_pChooserModel, &UIChooserModel::sltHandleViewResized); 168 179 } 169 180 170 void UIChooser::load ()181 void UIChooser::loadSettings() 171 182 { 172 183 /* Prepare model: */ … … 174 185 } 175 186 176 void UIChooser::save ()187 void UIChooser::saveSettings() 177 188 { 178 189 /* Cleanup model: */ … … 180 191 } 181 192 193 void UIChooser::cleanup() 194 { 195 /* Save settings: */ 196 saveSettings(); 197 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.h
r74138 r74177 5 5 6 6 /* 7 * Copyright (C) 2012-201 7Oracle Corporation7 * Copyright (C) 2012-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 #ifndef __ UIChooser_h__19 #define __ UIChooser_h__18 #ifndef ___UIChooser_h___ 19 #define ___UIChooser_h___ 20 20 21 21 /* Qt includes: */ … … 25 25 #include "UIChooserItem.h" 26 26 27 /* Forward declartions: */ 28 class UIVirtualMachineItem; 27 /* Forward declarations: */ 29 28 class QVBoxLayout; 30 class UIVirtualBoxManagerWidget;31 29 class UIActionPool; 32 30 class UIChooserModel; 33 31 class UIChooserView; 34 class QStatusBar; 32 class UIVirtualBoxManagerWidget; 33 class UIVirtualMachineItem; 35 34 36 /* Graphics selector widget:*/35 /** QWidget extension used as VM chooser pane. */ 37 36 class UIChooser : public QWidget 38 37 { … … 41 40 signals: 42 41 43 /* Notifier: Selection change: */ 44 void sigSelectionChanged(); 42 /** @name General stuff. 43 * @{ */ 44 /** Notifies listeners about selection changed. */ 45 void sigSelectionChanged(); 45 46 46 /* Notifier: Sliding stuff:*/47 void sigSlidingStarted();47 /** Notifies listeners about sliding started. */ 48 void sigSlidingStarted(); 48 49 49 /* Notifiers: Toggle stuff: */ 50 void sigToggleStarted(); 51 void sigToggleFinished(); 50 /** Notifies listeners about toggling started. */ 51 void sigToggleStarted(); 52 /** Notifies listeners about toggling finished. */ 53 void sigToggleFinished(); 54 /** @} */ 52 55 53 /* Notifier: Group-saving stuff: */ 54 void sigGroupSavingStateChanged(); 56 /** @name Group saving stuff. 57 * @{ */ 58 /** Notifies listeners about group saving state change. */ 59 void sigGroupSavingStateChanged(); 60 /** @} */ 55 61 56 62 public: 57 63 58 /* Constructor/destructor:*/64 /** Constructs chooser pane passing @a pParent to the base-class. */ 59 65 UIChooser(UIVirtualBoxManagerWidget *pParent); 60 ~UIChooser(); 66 /** Destructs chooser pane. */ 67 virtual ~UIChooser() /* override */; 61 68 62 /** Returns the manager-widget reference. */63 UIVirtualBoxManagerWidget *managerWidget() const { return m_pManagerWidget; }64 /** Returns the action-poolreference. */65 UIActionPool* actionPool() const;69 /** @name General stuff. 70 * @{ */ 71 /** Returns the manager-widget reference. */ 72 UIVirtualBoxManagerWidget *managerWidget() const { return m_pManagerWidget; } 66 73 67 /** Return the Chooser-model instance. */ 68 UIChooserModel *model() const { return m_pChooserModel; } 69 /** Return the Chooser-view instance. */ 70 UIChooserView *view() const { return m_pChooserView; } 74 /** Returns the action-pool reference. */ 75 UIActionPool *actionPool() const; 71 76 72 /* API: Current-item stuff: */ 73 bool isGroupItemSelected() const; 74 bool isGlobalItemSelected() const; 75 bool isMachineItemSelected() const; 76 UIVirtualMachineItem *currentItem() const; 77 QList<UIVirtualMachineItem*> currentItems() const; 78 bool isSingleGroupSelected() const; 79 bool isAllItemsOfOneGroupSelected() const; 77 /** Return the Chooser-model instance. */ 78 UIChooserModel *model() const { return m_pChooserModel; } 79 /** Return the Chooser-view instance. */ 80 UIChooserView *view() const { return m_pChooserView; } 81 /** @} */ 80 82 81 /* API: Group-saving stuff: */ 82 bool isGroupSavingInProgress() const; 83 /** @name Current item stuff. 84 * @{ */ 85 /** Returns whether group item is selected. */ 86 bool isGroupItemSelected() const; 87 /** Returns whether global item is selected. */ 88 bool isGlobalItemSelected() const; 89 /** Returns whether machine item is selected. */ 90 bool isMachineItemSelected() const; 91 /** Returns current item. */ 92 UIVirtualMachineItem *currentItem() const; 93 /** Returns current items. */ 94 QList<UIVirtualMachineItem*> currentItems() const; 95 /** Returns whether single group is selected. */ 96 bool isSingleGroupSelected() const; 97 /** Returns whether all machine items of one group is selected. */ 98 bool isAllItemsOfOneGroupSelected() const; 99 /** @} */ 100 101 /** @name Group saving stuff. 102 * @{ */ 103 /** Returns whether group saving is in progress. */ 104 bool isGroupSavingInProgress() const; 105 /** @} */ 83 106 84 107 public slots: 85 108 86 /** Handles toolbar resize to @a newSize. */ 87 void sltHandleToolbarResize(const QSize &newSize); 109 /** @name General stuff. 110 * @{ */ 111 /** Handles toolbar resize to @a newSize. */ 112 void sltHandleToolbarResize(const QSize &newSize); 113 /** @} */ 88 114 89 115 private: 90 116 91 /* Helpers: Prepare stuff: */ 92 void preparePalette(); 93 void prepareLayout(); 94 void prepareModel(); 95 void prepareView(); 96 void prepareConnections(); 97 void load(); 117 /** @name Prepare/Cleanup cascade. 118 * @{ */ 119 /** Prepares all. */ 120 void prepare(); 121 /** Prepares palette. */ 122 void preparePalette(); 123 /** Prepares layout. */ 124 void prepareLayout(); 125 /** Prepares model. */ 126 void prepareModel(); 127 /** Prepares view. */ 128 void prepareView(); 129 /** Prepares connections. */ 130 void prepareConnections(); 131 /** Loads settings. */ 132 void loadSettings(); 98 133 99 /* Helper: Cleanup stuff: */ 100 void save(); 134 /** Saves settings. */ 135 void saveSettings(); 136 /** Cleanups all. */ 137 void cleanup(); 138 /** @} */ 101 139 102 /** Holds the manager-widget reference. */ 103 UIVirtualBoxManagerWidget *m_pManagerWidget; 140 /** @name General stuff. 141 * @{ */ 142 /** Holds the manager-widget reference. */ 143 UIVirtualBoxManagerWidget *m_pManagerWidget; 104 144 105 /* Variables: */ 106 QVBoxLayout *m_pMainLayout; 107 UIChooserModel *m_pChooserModel; 108 UIChooserView *m_pChooserView; 145 /** Holds the main layout instane. */ 146 QVBoxLayout *m_pMainLayout; 147 /** Holds the chooser model instane. */ 148 UIChooserModel *m_pChooserModel; 149 /** Holds the chooser view instane. */ 150 UIChooserView *m_pChooserView; 151 /** @} */ 109 152 }; 110 153 111 #endif /* __UIChooser_h__ */ 112 154 #endif /* !___UIChooser_h___ */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp
r74138 r74177 712 712 } 713 713 714 void UIChooserModel::sltHandleViewResized() 715 { 716 /* Relayout: */ 717 updateLayout(); 718 } 719 714 720 void UIChooserModel::sltMachineStateChanged(QString strId, KMachineState) 715 721 { … … 778 784 /* Update machine-items with passed id: */ 779 785 mainRoot()->updateAllItems(strId); 780 }781 782 void UIChooserModel::sltHandleViewResized()783 {784 /* Relayout: */785 updateLayout();786 786 } 787 787 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h
r74138 r74177 161 161 bool isGroupSavingInProgress() const; 162 162 163 public slots: 164 165 /* Handler: Chooser-view stuff: */ 166 void sltHandleViewResized(); 167 163 168 private slots: 164 169 … … 169 174 void sltSessionStateChanged(QString strId, KSessionState state); 170 175 void sltSnapshotChanged(QString strId, QString strSnapshotId); 171 172 /* Handler: Chooser-view stuff: */173 void sltHandleViewResized();174 176 175 177 /* Handler: Focus-item stuff: */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserView.h
r74085 r74177 46 46 UIChooser *chooser() const { return m_pChooser; } 47 47 48 p rivateslots:48 public slots: 49 49 50 50 /* Handlers: Size-hint stuff: */
Note:
See TracChangeset
for help on using the changeset viewer.