VirtualBox

Changeset 83616 in vbox for trunk


Ignore:
Timestamp:
Apr 8, 2020 8:55:56 AM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9686. Working on the dialog menu. now it is better

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.cpp

    r83608 r83616  
    28272827
    28282828/** Toggle action extension, used as 'Toggle Columns' action class. */
    2829 class UIActionMenuSelectorVMResourceMonitorToggleColumns : public UIActionToggle
     2829class UIActionMenuSelectorVMResourceMonitorToggleColumns : public UIActionMenu
    28302830{
    28312831    Q_OBJECT;
     
    28352835    /** Constructs action passing @a pParent to the base-class. */
    28362836    UIActionMenuSelectorVMResourceMonitorToggleColumns(UIActionPool *pParent)
    2837         : UIActionToggle(pParent)
    2838     {
    2839         setShortcutContext(Qt::WidgetWithChildrenShortcut);
    2840         setIcon(UIIconPool::iconSetFull(":/cloud_profile_edit_32px.png",          ":/cloud_profile_edit_16px.png",
    2841                                         ":/cloud_profile_edit_disabled_32px.png", ":/cloud_profile_edit_disabled_16px.png"));
    2842     }
    2843 
    2844 protected:
    2845 
    2846     /** Returns shortcut extra-data ID. */
    2847     virtual QString shortcutExtraDataID() const /* override */
    2848     {
    2849         return QString("ToggleVMResourceMonitorColumns");
    2850     }
    2851 
    2852     /** Returns default shortcut. */
    2853     virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
    2854     {
    2855         return QKeySequence();
    2856     }
    2857 
    2858     /** Handles translation event. */
    2859     virtual void retranslateUi() /* override */
    2860     {
     2837        : UIActionMenu(pParent, ":/exit_16px.png")
     2838    {}
     2839
     2840protected:
     2841
     2842    /** Handles translation event. */
     2843    virtual void retranslateUi() /* override */
     2844    {
     2845        setName(QApplication::translate("UIActionPool", "Columns"));
    28612846        setIconText(QApplication::translate("UIActionPool", "Columns"));
    2862         setName(QApplication::translate("UIActionPool", "Add Remove Columns"));
    2863         //setShortcutScope(QApplication::translate("UIActionPool", "Cloud Profile Manager"));
    2864         setStatusTip(QApplication::translate("UIActionPool", "Open context menu to disable/menu table columns"));
    2865         setToolTip(  QApplication::translate("UIActionPool", "Open context menu to disable/menu table columns")
     2847        setStatusTip(QApplication::translate("UIActionPool", "Show/Hide Columns"));
     2848        setToolTip(  QApplication::translate("UIActionPool", "Show/Hide Columns")
    28662849                   + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
    28672850    }
     
    30072990    /* VM resource Monitor actions: */
    30082991    m_pool[UIActionIndexST_M_VMResourceMonitor] = new UIActionMenuVMResourceMonitor(this);
    3009     m_pool[UIActionIndexST_M_VMResourceMonitor_T_Columns] = new UIActionMenuSelectorVMResourceMonitorToggleColumns(this);
     2992    m_pool[UIActionIndexST_M_VMResourceMonitor_M_Columns] = new UIActionMenuSelectorVMResourceMonitorToggleColumns(this);
    30102993
    30112994    /* 'Group' action groups: */
     
    36053588    /* Clear contents: */
    36063589    pMenu->clear();
    3607 
    3608     addAction(pMenu, action(UIActionIndexST_M_VMResourceMonitor_T_Columns));
     3590    addAction(pMenu, action(UIActionIndexST_M_VMResourceMonitor_M_Columns));
    36093591}
    36103592
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.h

    r83608 r83616  
    166166    /* VM resource Monitor actions: */
    167167    UIActionIndexST_M_VMResourceMonitor,
    168     UIActionIndexST_M_VMResourceMonitor_T_Columns,
     168    UIActionIndexST_M_VMResourceMonitor_M_Columns,
    169169
    170170    /* Maximum index: */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp

    r83482 r83616  
    2020#include <QStackedWidget>
    2121#include <QStyle>
     22#include <QToolButton>
    2223#include <QVBoxLayout>
    2324
     
    672673                case UIToolType_VMResourceMonitor:
    673674                {
    674                     m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_VMResourceMonitor_T_Columns));
     675                    m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_VMResourceMonitor_M_Columns));
     676                    QToolButton *pButton =
     677                        qobject_cast<QToolButton*>(m_pToolBar->widgetForAction(actionPool()->action(UIActionIndexST_M_VMResourceMonitor_M_Columns)));
     678                    if (pButton)
     679                    {
     680                        pButton->setPopupMode(QToolButton::InstantPopup);
     681                        pButton->setAutoRaise(true);
     682                    }
     683
    675684                    break;
    676685                }
  • trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource/UIResourceMonitor.cpp

    r83610 r83616  
    274274    UIResourceMonitorProxyModel(QObject *parent = 0);
    275275    void dataUpdate();
    276     void reFilter();
    277 
    278 protected:
    279 
    280     //virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const /* override */;
    281     /** Section (column) visibility is controlled by the QHeaderView (see UIVMResourceMonitorTableView::updateColumVisibility)
    282      *  to have somewhat meaningful column resizing. */
    283     //virtual bool filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const /* override */;
    284 
    285 private:
    286 
    287276};
    288277
     
    331320    /* Used to find machines by uid. key is the machine uid and int is the index to m_itemList */
    332321    QMap<QUuid, int>               m_itemMap;
    333     QMap<int, QString> m_columnCaptions;
     322    QMap<int, QString> m_columnTitles;
    334323    QTimer *m_pTimer;
    335324    /** @name The following are used during UIPerformanceCollector::QueryMetricsData(..)
     
    868857}
    869858
    870 void UIResourceMonitorProxyModel::reFilter()
    871 {
    872     emit layoutAboutToBeChanged();
    873     invalidateFilter();
    874     emit layoutChanged();
    875 }
    876 
    877 /* See the function definition comment: */
    878 // bool UIResourceMonitorProxyModel::filterAcceptsColumn(int iSourceColumn, const QModelIndex &sourceParent) const
    879 // {
    880 //     Q_UNUSED(sourceParent);
    881 //     UIResourceMonitorModel* pModel = qobject_cast<UIResourceMonitorModel*>(sourceModel());
    882 //     if (!pModel)
    883 //         return true;
    884 //     return pModel->columnVisible(iSourceColumn);
    885 // }
    886 
    887859
    888860/*********************************************************************************************************************************
     
    945917{
    946918    if (role == Qt::DisplayRole && orientation == Qt::Horizontal)
    947         return m_columnCaptions.value((VMResourceMonitorColumn)section, QString());;
     919        return m_columnTitles.value((VMResourceMonitorColumn)section, QString());;
    948920    return QVariant();
    949921}
     
    951923void UIResourceMonitorModel::setColumnCaptions(const QMap<int, QString>& captions)
    952924{
    953     m_columnCaptions = captions;
     925    m_columnTitles = captions;
    954926}
    955927
     
    1005977    ULONG aPctVMM;
    1006978
    1007     // bool fRAMColumns = columnVisible(VMResourceMonitorColumn_RAMUsedAndTotal)
    1008     //     || columnVisible(VMResourceMonitorColumn_RAMUsedPercentage);
    1009979    bool fCPUColumns = columnVisible(VMResourceMonitorColumn_CPUVMMLoad) || columnVisible(VMResourceMonitorColumn_CPUGuestLoad);
    1010980    bool fNetworkColumns = columnVisible(VMResourceMonitorColumn_NetworkUpRate)
     
    1018988    bool fVMExitColumn = columnVisible(VMResourceMonitorColumn_VMExits);
    1019989
     990    /* Host's RAM usage is obtained from IHost not from IPerformanceCollectior: */
    1020991    getHostRAMStats();
    1021992
    1022     /* RAM usage and Host CPU: */
    1023     //if (!m_performanceMonitor.isNull() && fRAMColumns)
     993    /* RAM usage and Host Stats: */
    1024994    queryPerformanceCollector();
    1025995
     
    12751245    , m_fIsCurrentTool(true)
    12761246{
    1277     /* Prepare: */
    12781247    prepare();
    12791248}
     
    13081277void UIResourceMonitorWidget::retranslateUi()
    13091278{
    1310     m_columnCaptions[VMResourceMonitorColumn_Name] = tr("VM Name");
    1311     m_columnCaptions[VMResourceMonitorColumn_CPUGuestLoad] = tr("CPU Guest");
    1312     m_columnCaptions[VMResourceMonitorColumn_CPUVMMLoad] = tr("CPU VMM");
    1313     m_columnCaptions[VMResourceMonitorColumn_RAMUsedAndTotal] = tr("RAM Used/Total");
    1314     m_columnCaptions[VMResourceMonitorColumn_RAMUsedPercentage] = tr("RAM %");
    1315     m_columnCaptions[VMResourceMonitorColumn_NetworkUpRate] = tr("Network Up Rate");
    1316     m_columnCaptions[VMResourceMonitorColumn_NetworkDownRate] = tr("Network Down Rate");
    1317     m_columnCaptions[VMResourceMonitorColumn_NetworkUpTotal] = tr("Network Up Total");
    1318     m_columnCaptions[VMResourceMonitorColumn_NetworkDownTotal] = tr("Network Down Total");
    1319     m_columnCaptions[VMResourceMonitorColumn_DiskIOReadRate] = tr("Disk Read Rate");
    1320     m_columnCaptions[VMResourceMonitorColumn_DiskIOWriteRate] = tr("Disk Write Rate");
    1321     m_columnCaptions[VMResourceMonitorColumn_DiskIOReadTotal] = tr("Disk Read Total");
    1322     m_columnCaptions[VMResourceMonitorColumn_DiskIOWriteTotal] = tr("Disk Write Total");
    1323     m_columnCaptions[VMResourceMonitorColumn_VMExits] = tr("VM Exits");
     1279    m_columnTitles[VMResourceMonitorColumn_Name] = tr("VM Name");
     1280    m_columnTitles[VMResourceMonitorColumn_CPUGuestLoad] = tr("CPU Guest");
     1281    m_columnTitles[VMResourceMonitorColumn_CPUVMMLoad] = tr("CPU VMM");
     1282    m_columnTitles[VMResourceMonitorColumn_RAMUsedAndTotal] = tr("RAM Used/Total");
     1283    m_columnTitles[VMResourceMonitorColumn_RAMUsedPercentage] = tr("RAM %");
     1284    m_columnTitles[VMResourceMonitorColumn_NetworkUpRate] = tr("Network Up Rate");
     1285    m_columnTitles[VMResourceMonitorColumn_NetworkDownRate] = tr("Network Down Rate");
     1286    m_columnTitles[VMResourceMonitorColumn_NetworkUpTotal] = tr("Network Up Total");
     1287    m_columnTitles[VMResourceMonitorColumn_NetworkDownTotal] = tr("Network Down Total");
     1288    m_columnTitles[VMResourceMonitorColumn_DiskIOReadRate] = tr("Disk Read Rate");
     1289    m_columnTitles[VMResourceMonitorColumn_DiskIOWriteRate] = tr("Disk Write Rate");
     1290    m_columnTitles[VMResourceMonitorColumn_DiskIOReadTotal] = tr("Disk Read Total");
     1291    m_columnTitles[VMResourceMonitorColumn_DiskIOWriteTotal] = tr("Disk Write Total");
     1292    m_columnTitles[VMResourceMonitorColumn_VMExits] = tr("VM Exits");
    13241293    if (m_pModel)
    1325         m_pModel->setColumnCaptions(m_columnCaptions);
     1294        m_pModel->setColumnCaptions(m_columnTitles);
    13261295    computeMinimumColumnWidths();
    13271296}
     
    13411310    QIWithRetranslateUI<QWidget>::paintEvent(pEvent);
    13421311}
    1343 
    13441312
    13451313void UIResourceMonitorWidget::prepare()
     
    13811349    {
    13821350        layout()->addWidget(m_pTableView);
    1383         // m_pTableView->setContextMenuPolicy(Qt::CustomContextMenu);
    1384         // connect(m_pTableView, &QTableView::customContextMenuRequested,
    1385         //         this, &UIResourceMonitorWidget::sltCreateContextMenu);
    13861351        m_pProxyModel->setSourceModel(m_pModel);
    13871352        m_pTableView->setModel(m_pProxyModel);
    13881353        m_pTableView->setItemDelegate(new UIVMResourceMonitorDelegate);
    13891354        m_pTableView->setSelectionMode(QAbstractItemView::NoSelection);
    1390         /* m_pTableView->setSelectionMode(QAbstractItemView::SingleSelection);
    1391            m_pTableView->setSelectionBehavior(QAbstractItemView::SelectRows);*/
    13921355        m_pTableView->setShowGrid(false);
    13931356        m_pTableView->horizontalHeader()->setHighlightSections(false);
     
    14081371void UIResourceMonitorWidget::prepareActions()
    14091372{
    1410     m_pColumnVisibilityToggleMenu = new QMenu(this);
     1373    if (!m_pActionPool->action(UIActionIndexST_M_VMResourceMonitor_M_Columns))
     1374        return;
     1375    UIMenu *pMenu = m_pActionPool->action(UIActionIndexST_M_VMResourceMonitor_M_Columns)->menu();
     1376    if (!pMenu)
     1377        return;
     1378
    14111379    for (int i = 0; i < VMResourceMonitorColumn_Max; ++i)
    14121380    {
    1413         QAction *pAction = m_pColumnVisibilityToggleMenu->addAction(m_columnCaptions[i]);
     1381        QAction *pAction = pMenu->addAction(m_columnTitles[i]);
    14141382        pAction->setCheckable(true);
    1415     }
    1416 
    1417     connect(m_pActionPool->action(UIActionIndexST_M_VMResourceMonitor_T_Columns), &QAction::toggled,
    1418             this, &UIResourceMonitorWidget::sltToggleColumnSelectionMenu);
     1383        if (i == (int)VMResourceMonitorColumn_Name)
     1384            pAction->setEnabled(false);
     1385        pAction->setData(i);
     1386        pAction->setChecked(columnVisible(i));
     1387        connect(pAction, &QAction::toggled, this, &UIResourceMonitorWidget::sltHandleColumnAction);
     1388    }
    14191389    return;
    1420 //     m_pColumnSelectionMenu->setAutoFillBackground(true);
    1421 //     m_pColumnSelectionMenu->setFrameStyle(QFrame::Panel | QFrame::Plain);
    1422 //     m_pColumnSelectionMenu->hide();
    1423 //     QVBoxLayout* pLayout = new QVBoxLayout(m_pColumnSelectionMenu);
    1424 //     int iLength = 0;
    1425 //     for (int i = 0; i < VMResourceMonitorColumn_Max; ++i)
    1426 //     {
    1427 //         UIVMResourceMonitorCheckBox* pCheckBox = new UIVMResourceMonitorCheckBox;
    1428 //         QString strCaption = m_columnCaptions.value((VMResourceMonitorColumn)i, QString());
    1429 //         pCheckBox->setText(strCaption);
    1430 //         iLength = strCaption.length() > iLength ? strCaption.length() : iLength;
    1431 //         if (!pCheckBox)
    1432 //             continue;
    1433 //         pLayout->addWidget(pCheckBox);
    1434 //         pCheckBox->setData(i);
    1435 //         pCheckBox->setChecked(columnVisible(i));
    1436 //         if (i == (int)VMResourceMonitorColumn_Name)
    1437 //             pCheckBox->setEnabled(false);
    1438 //         connect(pCheckBox, &UIVMResourceMonitorCheckBox::toggled, this, &UIResourceMonitorWidget::sltHandleColumnAction);
    1439 //     }
    1440 //     QFontMetrics fontMetrics(m_pColumnSelectionMenu->font());
    1441 //     int iWidth = iLength * fontMetrics.width('x') +
    1442 //         QApplication::style()->pixelMetric(QStyle::PM_IndicatorWidth) +
    1443 //         2 * QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin) +
    1444 //         2 * QApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin);
    1445 //     m_pColumnSelectionMenu->setFixedWidth(iWidth);
    14461390}
    14471391
     
    15011445        return;
    15021446    m_pColumnVisibilityToggleMenu->exec(this->mapToGlobal(QPoint(0,0)));
    1503 
    1504     // if (!m_pColumnSelectionMenu)
    1505     //     return;
    1506     // m_pColumnSelectionMenu->setVisible(fChecked);
    1507 
    1508     // if (fChecked)
    1509     // {
    1510     //     m_pColumnSelectionMenu->move(0, 0);
    1511     //     m_pColumnSelectionMenu->raise();
    1512     //     m_pColumnSelectionMenu->resize(400, 400);
    1513     //     m_pColumnSelectionMenu->show();
    1514     //     m_pColumnSelectionMenu->setFocus();
    1515     // }
    1516     // else
    1517     //     m_pColumnSelectionMenu->hide();
    1518     //update();
    15191447}
    15201448
    15211449void UIResourceMonitorWidget::sltHandleColumnAction(bool fChecked)
    15221450{
    1523     UIVMResourceMonitorCheckBox* pSender = qobject_cast<UIVMResourceMonitorCheckBox*>(sender());
     1451    QAction* pSender = qobject_cast<QAction*>(sender());
    15241452    if (!pSender)
    15251453        return;
     
    15681496    {
    15691497        int iColumnStringWidth = columnDataStringLengths.value(i, 0);
    1570         int iColumnTitleWidth = m_columnCaptions.value(i, QString()).length();
     1498        int iColumnTitleWidth = m_columnTitles.value(i, QString()).length();
    15711499        int iMax = iColumnStringWidth > iColumnTitleWidth ? iColumnStringWidth : iColumnTitleWidth;
    15721500        columnWidthsInPixels[i] = iMax * fontMetrics.width('x') +
  • trunk/src/VBox/Frontends/VirtualBox/src/monitor/resource/UIResourceMonitor.h

    r83610 r83616  
    118118        QMenu                              *m_pColumnVisibilityToggleMenu;
    119119        /* The key is the column id (VMResourceMonitorColumn) and value is column title. */
    120         QMap<int, QString>                  m_columnCaptions;
     120        QMap<int, QString>                  m_columnTitles;
    121121        /* The key is the column id (VMResourceMonitorColumn) and value is true if the column is visible. */
    122122        QMap<int, bool>                     m_columnVisible;
Note: See TracChangeset for help on using the changeset viewer.

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