- Timestamp:
- Mar 13, 2019 1:07:35 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 129313
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 7 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r77636 r77677 625 625 src/manager/chooser/UIChooserNodeGlobal.h \ 626 626 src/manager/chooser/UIChooserNodeMachine.h \ 627 src/manager/chooser/UIChooserSearchWidget.h \ 627 628 src/manager/details/UIDetails.h \ 628 629 src/manager/details/UIDetailsContextMenu.h \ … … 1050 1051 src/manager/chooser/UIChooserNodeGlobal.cpp \ 1051 1052 src/manager/chooser/UIChooserNodeMachine.cpp \ 1053 src/manager/chooser/UIChooserSearchWidget.cpp \ 1052 1054 src/manager/details/UIDetails.cpp \ 1053 1055 src/manager/details/UIDetailsContextMenu.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.cpp
r77305 r77677 803 803 setName(QApplication::translate("UIActionPool", "&Sort")); 804 804 setStatusTip(QApplication::translate("UIActionPool", "Sort group of first selected virtual machine alphabetically")); 805 } 806 }; 807 808 /** Simple action extension, used as 'Machine Search' action class. */ 809 class UIActionSimpleSelectorMachinePerformSearch : public UIActionSimple 810 { 811 Q_OBJECT; 812 813 public: 814 815 /** Constructs action passing @a pParent to the base-class. */ 816 UIActionSimpleSelectorMachinePerformSearch(UIActionPool *pParent) 817 : UIActionSimple(pParent, ":/sort_16px.png", ":/sort_disabled_16px.png") 818 {} 819 820 protected: 821 822 /** Returns shortcut extra-data ID. */ 823 virtual QString shortcutExtraDataID() const /* override */ 824 { 825 return QString("SearchVM"); 826 } 827 828 /** Returns default shortcut. */ 829 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */ 830 { 831 return QKeySequence("Ctrl+F"); 832 } 833 834 /** Handles translation event. */ 835 virtual void retranslateUi() /* override */ 836 { 837 setName(QApplication::translate("UIActionPool", "S&earch")); 838 setStatusTip(QApplication::translate("UIActionPool", "Search virtual machines with respect to a search term")); 805 839 } 806 840 }; … … 2712 2746 m_pool[UIActionIndexST_M_Machine_S_CreateShortcut] = new UIActionSimpleSelectorCommonPerformCreateShortcut(this); 2713 2747 m_pool[UIActionIndexST_M_Machine_S_SortParent] = new UIActionSimpleSelectorMachinePerformSortParent(this); 2748 m_pool[UIActionIndexST_M_Machine_S_Search] = new UIActionSimpleSelectorMachinePerformSearch(this); 2714 2749 2715 2750 /* Global Tools actions: */ … … 3052 3087 pMenu->addSeparator(); 3053 3088 pMenu->addAction(action(UIActionIndexST_M_Machine_S_SortParent)); 3089 pMenu->addAction(action(UIActionIndexST_M_Machine_S_Search)); 3054 3090 3055 3091 /* Mark menu as valid: */ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.h
r77305 r77677 115 115 UIActionIndexST_M_Machine_S_CreateShortcut, 116 116 UIActionIndexST_M_Machine_S_SortParent, 117 UIActionIndexST_M_Machine_S_Search, 117 118 118 119 /* Global Tools actions: */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp
r77655 r77677 39 39 #include "UIChooserNodeGlobal.h" 40 40 #include "UIChooserNodeMachine.h" 41 #include "UIChooserView.h" 41 42 #include "UIExtraDataManager.h" 42 43 #include "UIMessageCenter.h" … … 776 777 /* Sorting group: */ 777 778 currentItem()->sortItems(); 779 } 780 781 void UIChooserModel::sltMachineSearch() 782 { 783 UIChooserView *pChooserView = qobject_cast<UIChooserView*>(scene()->views()[0]); 784 if (!pChooserView) 785 return; 786 pChooserView->toggleSearchWidget(); 778 787 } 779 788 … … 1336 1345 m_pContextMenuMachine->addSeparator(); 1337 1346 m_pContextMenuMachine->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_SortParent)); 1347 m_pContextMenuMachine->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Search)); 1338 1348 } 1339 1349 } … … 1400 1410 connect(actionPool()->action(UIActionIndexST_M_Group_S_Sort), SIGNAL(triggered()), 1401 1411 this, SLOT(sltSortGroup())); 1412 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Search), SIGNAL(triggered()), 1413 this, SLOT(sltMachineSearch())); 1402 1414 1403 1415 /* Setup group saving connections: */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h
r77638 r77677 277 277 /** Handles group sort request. */ 278 278 void sltSortGroup(); 279 /** Handles machine search request. */ 280 void sltMachineSearch(); 279 281 /** Handles group destroy request. */ 280 282 void sltUngroupSelectedGroup(); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserSearchWidget.cpp
r77661 r77677 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIChooser class implementation.3 * VBox Qt GUI - UIChooserSearchWidget class implementation. 4 4 */ 5 5 … … 20 20 21 21 /* GUI includes: */ 22 #include "UIChooser.h" 23 #include "UIChooserModel.h" 24 #include "UIChooserView.h" 25 #include "UIVirtualBoxManagerWidget.h" 26 #include "VBoxGlobal.h" 22 #include "QILineEdit.h" 23 #include "UIChooserSearchWidget.h" 27 24 25 UIChooserSearchWidget::UIChooserSearchWidget(QWidget *pParent) 26 : QIWithRetranslateUI<QWidget>(pParent) 27 , m_pLineEdit(0) 28 , m_pMainLayout(0) 28 29 29 UIChooser::UIChooser(UIVirtualBoxManagerWidget *pParent)30 : QWidget(pParent)31 , m_pManagerWidget(pParent)32 , m_pMainLayout(0)33 , m_pChooserModel(0)34 , m_pChooserView(0)35 30 { 36 /* Prepare: */37 prepare ();31 prepareWidgets(); 32 prepareConnections(); 38 33 } 39 34 40 UIChooser::~UIChooser()35 void UIChooserSearchWidget::prepareWidgets() 41 36 { 42 /* Cleanup: */ 43 cleanup(); 37 m_pMainLayout = new QHBoxLayout; 38 if (!m_pMainLayout) 39 return; 40 m_pMainLayout->setSpacing(2); 41 m_pMainLayout->setContentsMargins(0, 0, 0, 0); 42 m_pLineEdit = new QILineEdit; 43 if (m_pLineEdit) 44 { 45 m_pMainLayout->addWidget(m_pLineEdit); 46 } 47 48 setLayout(m_pMainLayout); 44 49 } 45 50 46 UIActionPool *UIChooser::actionPool() const 51 void UIChooserSearchWidget::prepareConnections() 47 52 { 48 return managerWidget()->actionPool(); 49 } 50 51 UIVirtualMachineItem *UIChooser::currentItem() const 52 { 53 return m_pChooserModel->currentMachineItem(); 54 } 55 56 QList<UIVirtualMachineItem*> UIChooser::currentItems() const 57 { 58 return m_pChooserModel->currentMachineItems(); 59 } 60 61 bool UIChooser::isGroupItemSelected() const 62 { 63 return m_pChooserModel->isGroupItemSelected(); 64 } 65 66 bool UIChooser::isGlobalItemSelected() const 67 { 68 return m_pChooserModel->isGlobalItemSelected(); 69 } 70 71 bool UIChooser::isMachineItemSelected() const 72 { 73 return m_pChooserModel->isMachineItemSelected(); 74 } 75 76 bool UIChooser::isSingleGroupSelected() const 77 { 78 return m_pChooserModel->isSingleGroupSelected(); 79 } 80 81 bool UIChooser::isAllItemsOfOneGroupSelected() const 82 { 83 return m_pChooserModel->isAllItemsOfOneGroupSelected(); 84 } 85 86 bool UIChooser::isGroupSavingInProgress() const 87 { 88 return m_pChooserModel->isGroupSavingInProgress(); 89 } 90 91 void UIChooser::sltHandleToolbarResize(const QSize &newSize) 92 { 93 /* Pass height to a model: */ 94 model()->setGlobalItemHeightHint(newSize.height()); 95 } 96 97 void UIChooser::sltToolMenuRequested(UIToolClass enmClass, const QPoint &position) 98 { 99 /* Translate scene coordinates to global one: */ 100 emit sigToolMenuRequested(enmClass, mapToGlobal(view()->mapFromScene(position))); 101 } 102 103 void UIChooser::prepare() 104 { 105 /* Prepare palette: */ 106 preparePalette(); 107 /* Prepare layout: */ 108 prepareLayout(); 109 /* Prepare model: */ 110 prepareModel(); 111 /* Prepare view: */ 112 prepareView(); 113 /* Prepare connections: */ 114 prepareConnections(); 115 116 /* Load settings: */ 117 loadSettings(); 118 } 119 120 void UIChooser::preparePalette() 121 { 122 /* Setup palette: */ 123 setAutoFillBackground(true); 124 QPalette pal = palette(); 125 QColor bodyColor = pal.color(QPalette::Active, QPalette::Midlight).darker(110); 126 pal.setColor(QPalette::Window, bodyColor); 127 setPalette(pal); 128 } 129 130 void UIChooser::prepareLayout() 131 { 132 /* Create main-layout: */ 133 m_pMainLayout = new QVBoxLayout(this); 134 if (m_pMainLayout) 53 if (m_pLineEdit) 135 54 { 136 /* Configure main-layout: */ 137 m_pMainLayout->setContentsMargins(0, 0, 0, 0); 138 m_pMainLayout->setSpacing(0); 55 connect(m_pLineEdit, &QILineEdit::textEdited, 56 this, &UIChooserSearchWidget::sigSearchTermChanged); 139 57 } 140 58 } 141 59 142 void UIChooser ::prepareModel()60 void UIChooserSearchWidget::showEvent(QShowEvent *pEvent) 143 61 { 144 /* Create chooser-model: */ 145 m_pChooserModel = new UIChooserModel(this); 62 Q_UNUSED(pEvent); 63 if (m_pLineEdit) 64 m_pLineEdit->setFocus(); 146 65 } 147 66 148 void UIChooser ::prepareView()67 void UIChooserSearchWidget::retranslateUi() 149 68 { 150 /* Setup chooser-view: */151 m_pChooserView = new UIChooserView(this);152 if (m_pChooserView)153 {154 /* Configure chooser-view. */155 m_pChooserView->setScene(m_pChooserModel->scene());156 m_pChooserView->show();157 setFocusProxy(m_pChooserView);158 159 /* Add into layout: */160 m_pMainLayout->addWidget(m_pChooserView);161 }162 69 } 163 164 void UIChooser::prepareConnections()165 {166 /* Setup chooser-model connections: */167 connect(m_pChooserModel, &UIChooserModel::sigRootItemMinimumWidthHintChanged,168 m_pChooserView, &UIChooserView::sltMinimumWidthHintChanged);169 connect(m_pChooserModel, &UIChooserModel::sigToolMenuRequested,170 this, &UIChooser::sltToolMenuRequested);171 172 /* Setup chooser-view connections: */173 connect(m_pChooserView, &UIChooserView::sigResized,174 m_pChooserModel, &UIChooserModel::sltHandleViewResized);175 }176 177 void UIChooser::loadSettings()178 {179 /* Init model: */180 m_pChooserModel->init();181 }182 183 void UIChooser::saveSettings()184 {185 /* Deinit model: */186 m_pChooserModel->deinit();187 }188 189 void UIChooser::cleanup()190 {191 /* Save settings: */192 saveSettings();193 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserSearchWidget.h
r77661 r77677 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIChooser class declaration.3 * VBox Qt GUI - UIChooserSearchWidget class declaration. 4 4 */ 5 5 … … 16 16 */ 17 17 18 #ifndef FEQT_INCLUDED_SRC_manager_chooser_UIChooser _h19 #define FEQT_INCLUDED_SRC_manager_chooser_UIChooser _h18 #ifndef FEQT_INCLUDED_SRC_manager_chooser_UIChooserSearchWidget_h 19 #define FEQT_INCLUDED_SRC_manager_chooser_UIChooserSearchWidget_h 20 20 #ifndef RT_WITHOUT_PRAGMA_ONCE 21 21 # pragma once … … 26 26 27 27 /* GUI includes: */ 28 #include " UIExtraDataDefs.h"28 #include "QIWithRetranslateUI.h" 29 29 30 30 /* Forward declarations: */ 31 class QVBoxLayout; 32 class UIActionPool; 33 class UIChooserModel; 34 class UIChooserView; 35 class UIVirtualBoxManagerWidget; 36 class UIVirtualMachineItem; 31 class QHBoxLayout; 32 class QILineEdit; 37 33 38 /** QWidget extension used as VM Chooser-pane. */39 class UIChooser : public QWidget34 /** QWidget extension used as virtual machine search widget in the VM Chooser-pane. */ 35 class UIChooserSearchWidget : public QIWithRetranslateUI<QWidget> 40 36 { 41 37 Q_OBJECT; … … 43 39 signals: 44 40 45 /** @name General stuff. 46 * @{ */ 47 /** Notifies listeners about selection changed. */ 48 void sigSelectionChanged(); 49 /** Notifies listeners about selection invalidated. */ 50 void sigSelectionInvalidated(); 51 52 /** Notifies listeners about sliding started. */ 53 void sigSlidingStarted(); 54 55 /** Notifies listeners about toggling started. */ 56 void sigToggleStarted(); 57 /** Notifies listeners about toggling finished. */ 58 void sigToggleFinished(); 59 60 /** Notifies listeners about tool popup-menu request for certain tool @a enmClass and in specified @a position. */ 61 void sigToolMenuRequested(UIToolClass enmClass, const QPoint &position); 62 /** @} */ 63 64 /** @name Group saving stuff. 65 * @{ */ 66 /** Notifies listeners about group saving state change. */ 67 void sigGroupSavingStateChanged(); 68 /** @} */ 41 void sigSearchTermChanged(const QString &strSearchTerm); 69 42 70 43 public: 71 44 72 /** Constructs Chooser-pane passing @a pParent to the base-class. */ 73 UIChooser(UIVirtualBoxManagerWidget *pParent); 74 /** Destructs Chooser-pane. */ 75 virtual ~UIChooser() /* override */; 45 UIChooserSearchWidget(QWidget *pParent); 76 46 77 /** @name General stuff. 78 * @{ */ 79 /** Returns the manager-widget reference. */ 80 UIVirtualBoxManagerWidget *managerWidget() const { return m_pManagerWidget; } 47 protected: 81 48 82 /** Returns the action-pool reference. */ 83 UIActionPool *actionPool() const; 84 85 /** Return the Chooser-model instance. */ 86 UIChooserModel *model() const { return m_pChooserModel; } 87 /** Return the Chooser-view instance. */ 88 UIChooserView *view() const { return m_pChooserView; } 89 /** @} */ 90 91 /** @name Current item stuff. 92 * @{ */ 93 /** Returns current item. */ 94 UIVirtualMachineItem *currentItem() const; 95 /** Returns a list of current items. */ 96 QList<UIVirtualMachineItem*> currentItems() const; 97 98 /** Returns whether group item is selected. */ 99 bool isGroupItemSelected() const; 100 /** Returns whether global item is selected. */ 101 bool isGlobalItemSelected() const; 102 /** Returns whether machine item is selected. */ 103 bool isMachineItemSelected() const; 104 105 /** Returns whether single group is selected. */ 106 bool isSingleGroupSelected() const; 107 /** Returns whether all machine items of one group is selected. */ 108 bool isAllItemsOfOneGroupSelected() const; 109 /** @} */ 110 111 /** @name Group saving stuff. 112 * @{ */ 113 /** Returns whether group saving is in progress. */ 114 bool isGroupSavingInProgress() const; 115 /** @} */ 49 void showEvent(QShowEvent *pEvent); 50 virtual void retranslateUi() /* override */; 116 51 117 52 public slots: 118 53 119 /** @name General stuff.120 * @{ */121 /** Handles toolbar resize to @a newSize. */122 void sltHandleToolbarResize(const QSize &newSize);123 /** @} */124 125 54 private slots: 126 127 /** @name General stuff.128 * @{ */129 /** Handles signal about tool popup-menu request for certain tool @a enmClass and in specified @a position. */130 void sltToolMenuRequested(UIToolClass enmClass, const QPoint &position);131 /** @} */132 55 133 56 private: 134 57 135 /** @name Prepare/Cleanup cascade. 136 * @{ */ 137 /** Prepares all. */ 138 void prepare(); 139 /** Prepares palette. */ 140 void preparePalette(); 141 /** Prepares layout. */ 142 void prepareLayout(); 143 /** Prepares model. */ 144 void prepareModel(); 145 /** Prepares view. */ 146 void prepareView(); 147 /** Prepares connections. */ 148 void prepareConnections(); 149 /** Loads settings. */ 150 void loadSettings(); 58 void prepareWidgets(); 59 void prepareConnections(); 151 60 152 /** Saves settings. */ 153 void saveSettings(); 154 /** Cleanups all. */ 155 void cleanup(); 156 /** @} */ 157 158 /** @name General stuff. 159 * @{ */ 160 /** Holds the manager-widget reference. */ 161 UIVirtualBoxManagerWidget *m_pManagerWidget; 162 163 /** Holds the main layout instane. */ 164 QVBoxLayout *m_pMainLayout; 165 /** Holds the Chooser-model instane. */ 166 UIChooserModel *m_pChooserModel; 167 /** Holds the Chooser-view instane. */ 168 UIChooserView *m_pChooserView; 169 /** @} */ 61 QILineEdit *m_pLineEdit; 62 QHBoxLayout *m_pMainLayout; 170 63 }; 171 64 172 #endif /* !FEQT_INCLUDED_SRC_manager_chooser_UIChooser _h */65 #endif /* !FEQT_INCLUDED_SRC_manager_chooser_UIChooserSearchWidget_h */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserView.cpp
r77228 r77677 24 24 #include "UIChooserItem.h" 25 25 #include "UIChooserModel.h" 26 #include "UIChooserSearchWidget.h" 26 27 #include "UIChooserView.h" 27 28 … … 94 95 : QIWithRetranslateUI<QIGraphicsView>(pParent) 95 96 , m_pChooser(pParent) 97 , m_pSearchWidget(0) 96 98 , m_iMinimumWidthHint(0) 97 99 { 98 100 /* Prepare: */ 99 101 prepare(); 102 } 103 104 void UIChooserView::toggleSearchWidget() 105 { 106 if (!m_pSearchWidget) 107 return; 108 m_pSearchWidget->setVisible(!m_pSearchWidget->isVisible()); 109 if (m_pSearchWidget->isVisible()) 110 updateSearchWidget(); 100 111 } 101 112 … … 141 152 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 142 153 154 /* Create the search widget (hidden): */ 155 m_pSearchWidget = new UIChooserSearchWidget(this); 156 m_pSearchWidget->hide(); 157 143 158 /* Update scene-rect: */ 144 159 updateSceneRect(); 160 161 /* Update the location and size of the search widget: */ 162 updateSearchWidget(); 145 163 146 164 /* Apply language settings: */ … … 166 184 /* Update scene-rect: */ 167 185 updateSceneRect(); 186 updateSearchWidget(); 168 187 } 169 188 … … 172 191 setSceneRect(0, 0, m_iMinimumWidthHint, height()); 173 192 } 193 194 void UIChooserView::updateSearchWidget() 195 { 196 if (!m_pSearchWidget || !m_pSearchWidget->isVisible()) 197 return; 198 int iHeight = m_pSearchWidget->height(); 199 QRect widgetRect(0, height() - iHeight, 200 width(), iHeight); 201 m_pSearchWidget->setGeometry(widgetRect); 202 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserView.h
r77228 r77677 28 28 /* Forward declarations: */ 29 29 class UIChooser; 30 class UIChooserSearchWidget; 30 31 31 32 /** QIGraphicsView extension used as VM chooser pane view. */ … … 49 50 /** Returns the chooser reference. */ 50 51 UIChooser *chooser() const { return m_pChooser; } 52 /** Shows/hides machine search widget. */ 53 void toggleSearchWidget(); 51 54 /** @} */ 52 55 … … 84 87 /** Updates scene rectangle. */ 85 88 void updateSceneRect(); 89 /** Updates search widget's geometry. */ 90 void updateSearchWidget(); 86 91 /** @} */ 92 87 93 88 94 /** @name General stuff. … … 90 96 /** Holds the chooser pane reference. */ 91 97 UIChooser *m_pChooser; 98 /** Holds the search widget instance reference. */ 99 UIChooserSearchWidget *m_pSearchWidget; 92 100 /** @} */ 93 101
Note:
See TracChangeset
for help on using the changeset viewer.