VirtualBox

Changeset 77677 in vbox for trunk


Ignore:
Timestamp:
Mar 13, 2019 1:07:35 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
129313
Message:

FE/Qt: bugref:9378. Adding a vm search widget to chooser pane vm list. no search functionality yet.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
7 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r77636 r77677  
    625625        src/manager/chooser/UIChooserNodeGlobal.h \
    626626        src/manager/chooser/UIChooserNodeMachine.h \
     627        src/manager/chooser/UIChooserSearchWidget.h \
    627628        src/manager/details/UIDetails.h \
    628629        src/manager/details/UIDetailsContextMenu.h \
     
    10501051        src/manager/chooser/UIChooserNodeGlobal.cpp \
    10511052        src/manager/chooser/UIChooserNodeMachine.cpp \
     1053        src/manager/chooser/UIChooserSearchWidget.cpp \
    10521054        src/manager/details/UIDetails.cpp \
    10531055        src/manager/details/UIDetailsContextMenu.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.cpp

    r77305 r77677  
    803803        setName(QApplication::translate("UIActionPool", "&Sort"));
    804804        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. */
     809class UIActionSimpleSelectorMachinePerformSearch : public UIActionSimple
     810{
     811    Q_OBJECT;
     812
     813public:
     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
     820protected:
     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"));
    805839    }
    806840};
     
    27122746    m_pool[UIActionIndexST_M_Machine_S_CreateShortcut] = new UIActionSimpleSelectorCommonPerformCreateShortcut(this);
    27132747    m_pool[UIActionIndexST_M_Machine_S_SortParent] = new UIActionSimpleSelectorMachinePerformSortParent(this);
     2748    m_pool[UIActionIndexST_M_Machine_S_Search] = new UIActionSimpleSelectorMachinePerformSearch(this);
    27142749
    27152750    /* Global Tools actions: */
     
    30523087    pMenu->addSeparator();
    30533088    pMenu->addAction(action(UIActionIndexST_M_Machine_S_SortParent));
     3089    pMenu->addAction(action(UIActionIndexST_M_Machine_S_Search));
    30543090
    30553091    /* Mark menu as valid: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.h

    r77305 r77677  
    115115    UIActionIndexST_M_Machine_S_CreateShortcut,
    116116    UIActionIndexST_M_Machine_S_SortParent,
     117    UIActionIndexST_M_Machine_S_Search,
    117118
    118119    /* Global Tools actions: */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp

    r77655 r77677  
    3939#include "UIChooserNodeGlobal.h"
    4040#include "UIChooserNodeMachine.h"
     41#include "UIChooserView.h"
    4142#include "UIExtraDataManager.h"
    4243#include "UIMessageCenter.h"
     
    776777    /* Sorting group: */
    777778    currentItem()->sortItems();
     779}
     780
     781void UIChooserModel::sltMachineSearch()
     782{
     783    UIChooserView *pChooserView = qobject_cast<UIChooserView*>(scene()->views()[0]);
     784    if (!pChooserView)
     785        return;
     786    pChooserView->toggleSearchWidget();
    778787}
    779788
     
    13361345        m_pContextMenuMachine->addSeparator();
    13371346        m_pContextMenuMachine->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_SortParent));
     1347        m_pContextMenuMachine->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Search));
    13381348    }
    13391349}
     
    14001410    connect(actionPool()->action(UIActionIndexST_M_Group_S_Sort), SIGNAL(triggered()),
    14011411            this, SLOT(sltSortGroup()));
     1412    connect(actionPool()->action(UIActionIndexST_M_Machine_S_Search), SIGNAL(triggered()),
     1413            this, SLOT(sltMachineSearch()));
    14021414
    14031415    /* Setup group saving connections: */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h

    r77638 r77677  
    277277        /** Handles group sort request. */
    278278        void sltSortGroup();
     279        /** Handles machine search request. */
     280        void sltMachineSearch();
    279281        /** Handles group destroy request. */
    280282        void sltUngroupSelectedGroup();
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserSearchWidget.cpp

    r77661 r77677  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIChooser class implementation.
     3 * VBox Qt GUI - UIChooserSearchWidget class implementation.
    44 */
    55
     
    2020
    2121/* 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"
    2724
     25UIChooserSearchWidget::UIChooserSearchWidget(QWidget *pParent)
     26    : QIWithRetranslateUI<QWidget>(pParent)
     27    , m_pLineEdit(0)
     28    , m_pMainLayout(0)
    2829
    29 UIChooser::UIChooser(UIVirtualBoxManagerWidget *pParent)
    30     : QWidget(pParent)
    31     , m_pManagerWidget(pParent)
    32     , m_pMainLayout(0)
    33     , m_pChooserModel(0)
    34     , m_pChooserView(0)
    3530{
    36     /* Prepare: */
    37     prepare();
     31    prepareWidgets();
     32    prepareConnections();
    3833}
    3934
    40 UIChooser::~UIChooser()
     35void UIChooserSearchWidget::prepareWidgets()
    4136{
    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);
    4449}
    4550
    46 UIActionPool *UIChooser::actionPool() const
     51void UIChooserSearchWidget::prepareConnections()
    4752{
    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)
    13554    {
    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);
    13957    }
    14058}
    14159
    142 void UIChooser::prepareModel()
     60void UIChooserSearchWidget::showEvent(QShowEvent *pEvent)
    14361{
    144     /* Create chooser-model: */
    145     m_pChooserModel = new UIChooserModel(this);
     62    Q_UNUSED(pEvent);
     63    if (m_pLineEdit)
     64        m_pLineEdit->setFocus();
    14665}
    14766
    148 void UIChooser::prepareView()
     67void UIChooserSearchWidget::retranslateUi()
    14968{
    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     }
    16269}
    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  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIChooser class declaration.
     3 * VBox Qt GUI - UIChooserSearchWidget class declaration.
    44 */
    55
     
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_manager_chooser_UIChooser_h
    19 #define FEQT_INCLUDED_SRC_manager_chooser_UIChooser_h
     18#ifndef FEQT_INCLUDED_SRC_manager_chooser_UIChooserSearchWidget_h
     19#define FEQT_INCLUDED_SRC_manager_chooser_UIChooserSearchWidget_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
     
    2626
    2727/* GUI includes: */
    28 #include "UIExtraDataDefs.h"
     28#include "QIWithRetranslateUI.h"
    2929
    3030/* Forward declarations: */
    31 class QVBoxLayout;
    32 class UIActionPool;
    33 class UIChooserModel;
    34 class UIChooserView;
    35 class UIVirtualBoxManagerWidget;
    36 class UIVirtualMachineItem;
     31class QHBoxLayout;
     32class QILineEdit;
    3733
    38 /** QWidget extension used as VM Chooser-pane. */
    39 class UIChooser : public QWidget
     34/** QWidget extension used as virtual machine search widget in the VM Chooser-pane. */
     35class UIChooserSearchWidget : public QIWithRetranslateUI<QWidget>
    4036{
    4137    Q_OBJECT;
     
    4339signals:
    4440
    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);
    6942
    7043public:
    7144
    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);
    7646
    77     /** @name General stuff.
    78       * @{ */
    79         /** Returns the manager-widget reference. */
    80         UIVirtualBoxManagerWidget *managerWidget() const { return m_pManagerWidget; }
     47protected:
    8148
    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 */;
    11651
    11752public slots:
    11853
    119     /** @name General stuff.
    120       * @{ */
    121         /** Handles toolbar resize to @a newSize. */
    122         void sltHandleToolbarResize(const QSize &newSize);
    123     /** @} */
    124 
    12554private 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     /** @} */
    13255
    13356private:
    13457
    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();
    15160
    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;
    17063};
    17164
    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  
    2424#include "UIChooserItem.h"
    2525#include "UIChooserModel.h"
     26#include "UIChooserSearchWidget.h"
    2627#include "UIChooserView.h"
    2728
     
    9495    : QIWithRetranslateUI<QIGraphicsView>(pParent)
    9596    , m_pChooser(pParent)
     97    , m_pSearchWidget(0)
    9698    , m_iMinimumWidthHint(0)
    9799{
    98100    /* Prepare: */
    99101    prepare();
     102}
     103
     104void UIChooserView::toggleSearchWidget()
     105{
     106    if (!m_pSearchWidget)
     107        return;
     108    m_pSearchWidget->setVisible(!m_pSearchWidget->isVisible());
     109    if (m_pSearchWidget->isVisible())
     110        updateSearchWidget();
    100111}
    101112
     
    141152    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    142153
     154    /* Create the search widget (hidden): */
     155    m_pSearchWidget = new UIChooserSearchWidget(this);
     156    m_pSearchWidget->hide();
     157
    143158    /* Update scene-rect: */
    144159    updateSceneRect();
     160
     161    /* Update the location and size of the search widget: */
     162    updateSearchWidget();
    145163
    146164    /* Apply language settings: */
     
    166184    /* Update scene-rect: */
    167185    updateSceneRect();
     186    updateSearchWidget();
    168187}
    169188
     
    172191    setSceneRect(0, 0, m_iMinimumWidthHint, height());
    173192}
     193
     194void 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  
    2828/* Forward declarations: */
    2929class UIChooser;
     30class UIChooserSearchWidget;
    3031
    3132/** QIGraphicsView extension used as VM chooser pane view. */
     
    4950        /** Returns the chooser reference. */
    5051        UIChooser *chooser() const { return m_pChooser; }
     52        /** Shows/hides machine search widget. */
     53        void toggleSearchWidget();
    5154    /** @} */
    5255
     
    8487        /** Updates scene rectangle. */
    8588        void updateSceneRect();
     89        /** Updates search widget's geometry. */
     90        void updateSearchWidget();
    8691    /** @} */
     92
    8793
    8894    /** @name General stuff.
     
    9096        /** Holds the chooser pane reference. */
    9197        UIChooser *m_pChooser;
     98        /** Holds the search widget instance reference. */
     99        UIChooserSearchWidget *m_pSearchWidget;
    92100    /** @} */
    93101
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette