VirtualBox

Ignore:
Timestamp:
May 3, 2021 1:09:49 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
144168
Message:

FE/Qt: bugref:9930. Implementing reload slot

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

Legend:

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

    r88242 r88834  
    13761376        setName(QApplication::translate("UIActionPool", "&Refresh"));
    13771377        setShortcutScope(QApplication::translate("UIActionPool", "Log Viewer"));
    1378         setStatusTip(QApplication::translate("UIActionPool", "Refresh selected virtual machine log"));
    1379         setToolTip(  QApplication::translate("UIActionPool", "Refresh Virtual Machine Log")
     1378        setStatusTip(QApplication::translate("UIActionPool", "Refresh the currently viewed log"));
     1379        setToolTip(  QApplication::translate("UIActionPool", "Refresh the Currently Viewed Log")
     1380                   + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
     1381    }
     1382};
     1383
     1384/** Simple action extension, used as 'Perform Reload' action class. */
     1385class UIActionMenuSelectorLogPerformReload : public UIActionSimple
     1386{
     1387    Q_OBJECT;
     1388
     1389public:
     1390
     1391    /** Constructs action passing @a pParent to the base-class. */
     1392    UIActionMenuSelectorLogPerformReload(UIActionPool *pParent)
     1393        : UIActionSimple(pParent,
     1394                         ":/log_viewer_refresh_32px.png", ":/log_viewer_refresh_16px.png",
     1395                         ":/log_viewer_refresh_disabled_32px.png", ":/log_viewer_refresh_disabled_16px.png")
     1396    {
     1397        setShortcutContext(Qt::WidgetWithChildrenShortcut);
     1398    }
     1399
     1400protected:
     1401
     1402    /** Returns shortcut extra-data ID. */
     1403    virtual QString shortcutExtraDataID() const /* override */
     1404    {
     1405        return QString("ReloadAllLogs");
     1406    }
     1407
     1408    /** Returns default shortcut. */
     1409    virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
     1410    {
     1411        return QKeySequence();
     1412    }
     1413
     1414    /** Returns standard shortcut. */
     1415    virtual QKeySequence standardShortcut(UIActionPoolType) const /* override */
     1416    {
     1417        return QKeySequence();
     1418    }
     1419
     1420    /** Handles translation event. */
     1421    virtual void retranslateUi() /* override */
     1422    {
     1423        setName(QApplication::translate("UIActionPool", "&Reload"));
     1424        setShortcutScope(QApplication::translate("UIActionPool", "Log Viewer"));
     1425        setStatusTip(QApplication::translate("UIActionPool", "Reread all the log files and refresh pages"));
     1426        setToolTip(  QApplication::translate("UIActionPool", "Reread All the Log Files and Refresh Pages")
    13801427                   + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
    13811428    }
     
    25392586    m_pool[UIActionIndex_M_Log_T_Options] = new UIActionMenuSelectorLogTogglePaneOptions(this);
    25402587    m_pool[UIActionIndex_M_Log_S_Refresh] = new UIActionMenuSelectorLogPerformRefresh(this);
     2588    m_pool[UIActionIndex_M_Log_S_Reload] = new UIActionMenuSelectorLogPerformReload(this);
    25412589    m_pool[UIActionIndex_M_Log_S_Save] = new UIActionMenuSelectorLogPerformSave(this);
    25422590
     
    29633011    /* 'Refresh' action: */
    29643012    fSeparator = addAction(pMenu, action(UIActionIndex_M_Log_S_Refresh)) || fSeparator;
     3013    fSeparator = addAction(pMenu, action(UIActionIndex_M_Log_S_Reload)) || fSeparator;
     3014
    29653015}
    29663016
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.h

    r88242 r88834  
    9696    UIActionIndex_M_Log_T_Options,
    9797    UIActionIndex_M_Log_S_Refresh,
     98    UIActionIndex_M_Log_S_Reload,
    9899    UIActionIndex_M_Log_S_Save,
    99100
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp

    r88817 r88834  
    332332}
    333333
     334void UIVMLogViewerWidget::sltReload()
     335{
     336    if (!m_pTabWidget)
     337        return;
     338
     339    m_pTabWidget->blockSignals(true);
     340    m_pTabWidget->hide();
     341
     342    removeAllLogPages();
     343    createLogViewerPages(m_machines);
     344
     345    /* re-Apply the filter settings: */
     346    if (m_pFilterPanel)
     347        m_pFilterPanel->applyFilter();
     348
     349    m_pTabWidget->blockSignals(false);
     350    setTabColorPerMachine();
     351    m_pTabWidget->show();
     352}
     353
    334354void UIVMLogViewerWidget::sltSave()
    335355{
     
    588608    connect(m_pActionPool->action(UIActionIndex_M_Log_S_Refresh), &QAction::triggered,
    589609            this, &UIVMLogViewerWidget::sltRefresh);
     610    connect(m_pActionPool->action(UIActionIndex_M_Log_S_Reload), &QAction::triggered,
     611            this, &UIVMLogViewerWidget::sltReload);
    590612    connect(m_pActionPool->action(UIActionIndex_M_Log_S_Save), &QAction::triggered,
    591613            this, &UIVMLogViewerWidget::sltSave);
     
    725747        m_pToolBar->addSeparator();
    726748        m_pToolBar->addAction(m_pActionPool->action(UIActionIndex_M_Log_S_Refresh));
     749        m_pToolBar->addAction(m_pActionPool->action(UIActionIndex_M_Log_S_Reload));
    727750
    728751#ifdef VBOX_WS_MAC
     
    843866QPlainTextEdit* UIVMLogViewerWidget::logPage(int pIndex) const
    844867{
    845     if (!m_pTabWidget->isEnabled())
     868    if (m_pTabWidget)
    846869        return 0;
    847870    QWidget* pContainer = m_pTabWidget->widget(pIndex);
     
    850873    QPlainTextEdit *pBrowser = pContainer->findChild<QPlainTextEdit*>();
    851874    return pBrowser;
     875}
     876
     877QVector<UIVMLogPage*> UIVMLogViewerWidget::logPages()
     878{
     879    QVector<UIVMLogPage*> pages;
     880    if (m_pTabWidget)
     881        return pages;
     882    for (int i = 0; i < m_pTabWidget->count(); ++i)
     883    {
     884        UIVMLogPage *pPage = logPage(i);
     885        if (pPage)
     886            pages << pPage;
     887    }
     888    return pages;
    852889}
    853890
     
    9631000    /* Remove all the tabs from tab widget, note that this does not delete tab widgets: */
    9641001    m_pTabWidget->clear();
     1002    QVector<UIVMLogPage*> pagesToRemove;
    9651003    /* Add tab widgets (log pages) back as long as machine id is not in machineList: */
    9661004    for (int i = 0; i < logPages.size(); ++i)
     
    9711009
    9721010        if (machineList.contains(id))
    973             continue;
    974         m_pTabWidget->addTab(logPages[i].first, logPages[i].second);
    975     }
     1011            pagesToRemove << logPages[i].first;
     1012        else
     1013            m_pTabWidget->addTab(logPages[i].first, logPages[i].second);
     1014    }
     1015    /* Delete all the other pages: */
     1016    qDeleteAll(pagesToRemove.begin(), pagesToRemove.end());
    9761017    m_pTabWidget->blockSignals(false);
    9771018}
    9781019
     1020void UIVMLogViewerWidget::removeAllLogPages()
     1021{
     1022    if (!m_pTabWidget)
     1023        return;
     1024
     1025    QVector<UIVMLogPage*> pagesToRemove = logPages();
     1026    m_pTabWidget->clear();
     1027    qDeleteAll(pagesToRemove.begin(), pagesToRemove.end());
     1028}
    9791029
    9801030void UIVMLogViewerWidget::resetHighlighthing()
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h

    r88817 r88834  
    101101    /** Rereads the log file shown in the current tab. */
    102102    void sltRefresh();
     103    /** Rereads all the log files . */
     104    void sltReload();
    103105    /** Handles save action triggering. */
    104106    void sltSave();
     
    179181    /** Returns the log page at tab with iIndex if it contains a log page. Return 0 otherwise. */
    180182    UIVMLogPage *logPage(int iIndex);
     183    /** Returns a vector of all the log pages of the tab widget. */
     184    QVector<UIVMLogPage*> logPages();
    181185
    182186    void createLogViewerPages(const QVector<QUuid> &machineList);
    183187    /** Removes the log pages/tabs that shows logs of the machines from @p machineList. */
    184188    void removeLogViewerPages(const QVector<QUuid> &machineList);
     189    void removeAllLogPages();
    185190    /** We alternate tab colors between two `darker and lighter` one per machine. This function goes over tabs and
    186191      * sets tab data so tab our QTabBar extension can color tabs correctly. */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp

    r88520 r88834  
    943943                    m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Log_T_Options));
    944944                    m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Log_S_Refresh));
     945                    m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Log_S_Reload));
    945946                    m_pToolBar->addSeparator();
    946947                    m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Settings));
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