VirtualBox

Changeset 88972 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
May 11, 2021 10:20:30 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
144309
Message:

FE/Qt: bugref:9930. Adding label tabs per machine

Location:
trunk/src/VBox/Frontends/VirtualBox/src/logviewer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp

    r88970 r88972  
    6161const ULONG uAllowedLogSize = _256M;
    6262
     63class UILabelTab : public QWidget
     64{
     65    Q_OBJECT;
     66
     67public:
     68
     69    UILabelTab(QWidget *pParent, const QUuid &uMachineId)
     70        : QWidget(pParent)
     71        , m_uMachineId(uMachineId)
     72    {
     73    }
     74
     75private:
     76
     77    QUuid m_uMachineId;
     78
     79};
     80
    6381/*********************************************************************************************************************************
    6482*   UITabBar definition.                                                                                        *
     
    110128    m_selectedTabColor = opt.palette.color(QPalette::Button).lighter(300);
    111129
    112     QStyle *pFusionStyle = QStyleFactory::create("Fusion");
    113     if (pFusionStyle)
    114         setStyle(pFusionStyle);
     130    // QStyle *pFusionStyle = QStyleFactory::create("Fusion");
     131    // if (pFusionStyle)
     132    //     setStyle(pFusionStyle);
    115133}
    116134
     
    125143        QStyleOptionTab opt;
    126144        initStyleOption(&opt, i);
    127 
    128         if (i == currentIndex())
    129             opt.palette.setColor(QPalette::Button, m_selectedTabColor);
    130         else
    131         {
    132             int iColorIndex = tabData(i).toInt();
    133             if (iColorIndex >= 0 && iColorIndex <= m_alternateColors.size())
    134                 opt.palette.setColor(QPalette::Button, m_alternateColors[iColorIndex]);
    135         }
    136         painter.drawControl(QStyle::CE_TabBarTab, opt);
     145        bool fLabelTab = tabData(i).toBool();
     146        // if (i == currentIndex())
     147        //     opt.palette.setColor(QPalette::Button, m_selectedTabColor);
     148        // else
     149        // {
     150        //     int iColorIndex = tabData(i).toInt();
     151        //     if (iColorIndex >= 0 && iColorIndex <= m_alternateColors.size())
     152        //         opt.palette.setColor(QPalette::Button, m_alternateColors[iColorIndex]);
     153        // }
     154        if (!fLabelTab)
     155            painter.drawControl(QStyle::CE_TabBarTabShape, opt);
     156        painter.drawControl(QStyle::CE_TabBarTabLabel, opt);
    137157    }
    138158}
     
    255275        return;
    256276    QTabBar *pTabBar = m_pTabWidget->tabBar();
    257     int iColorIndex = 0;
    258     pTabBar->setTabData(0, iColorIndex);
    259 
    260     for (int i = 1; i < pTabBar->count(); ++i)
    261     {
    262         UIVMLogPage *pLogPage = logPage(i);
    263         UIVMLogPage *pLogPagePrev = logPage(i - 1);
    264         if (!pLogPage || !pLogPagePrev)
    265             continue;
    266         /* We the machine if the tab is different than that of previous alternate the color index. */
    267         if (pLogPage->machineId() != pLogPagePrev->machineId())
    268             ++iColorIndex;
    269         pTabBar->setTabData(i, iColorIndex % 2);
     277    //int iColorIndex = 0;
     278
     279    for (int i = 0; i < pTabBar->count(); ++i)
     280    {
     281        // UIVMLogPage *pLogPage = logPage(i);
     282        // UIVMLogPage *pLogPagePrev = logPage(i - 1);
     283        // if (!pLogPage || !pLogPagePrev)
     284        //     continue;
     285
     286        // /* We the machine if the tab is different than that of previous alternate the color index. */
     287        // if (i > 0 && pLogPage->machineId() != pLogPagePrev->machineId())
     288        //     ++iColorIndex;
     289        if (qobject_cast<UILabelTab*>(m_pTabWidget->widget(i)))
     290            pTabBar->setTabData(i, true);
     291        else
     292            pTabBar->setTabData(i, false);
    270293    }
    271294}
     
    482505{
    483506    Q_UNUSED(tabIndex);
    484 
     507    if (labelTabHandler())
     508        return;
    485509    /* Dont refresh the search here as it is refreshed by the filtering mechanism
    486510       which is updated as tab current index changes (see sltFilterApplied): */
     
    884908}
    885909
    886 QPlainTextEdit* UIVMLogViewerWidget::logPage(int pIndex) const
    887 {
    888     if (m_pTabWidget)
    889         return 0;
    890     QWidget* pContainer = m_pTabWidget->widget(pIndex);
    891     if (!pContainer)
    892         return 0;
    893     QPlainTextEdit *pBrowser = pContainer->findChild<QPlainTextEdit*>();
    894     return pBrowser;
    895 }
    896 
    897910QVector<UIVMLogPage*> UIVMLogViewerWidget::logPages()
    898911{
     
    933946
    934947        /* Add page-container to viewer-container in stacked mode (manager UI case): */
    935         bool fTitleWithMachineName = m_enmEmbedding == EmbedTo_Stack;
     948        bool fTitleWithMachineName = false;//m_enmEmbedding == EmbedTo_Stack;
    936949        QString strTabTitle;
    937950        if (fTitleWithMachineName)
     
    942955        strTabTitle.append(QFileInfo(strFileName).fileName());
    943956
    944 
    945         m_pTabWidget->blockSignals(true);
    946957        int iIndex = m_pTabWidget->addTab(pLogPage, strTabTitle);
    947958        /* !!Hack alert. Setting html to text edit while th tab is not current ends up in an empty text edit: */
    948959        if (noLogsToShow)
    949960            m_pTabWidget->setCurrentIndex(iIndex);
    950         m_pTabWidget->blockSignals(false);
    951961
    952962        pLogPage->setLogContent(strLogContent, noLogsToShow);
    953963        pLogPage->setScrollBarMarkingsVector(m_pSearchPanel->matchLocationVector());
    954 
    955964    }
    956965}
     
    979988void UIVMLogViewerWidget::createLogViewerPages(const QVector<QUuid> &machineList)
    980989{
     990    if (!m_pTabWidget)
     991        return;
     992    m_pTabWidget->blockSignals(true);
     993
    981994    const CSystemProperties &sys = uiCommon().virtualBox().GetSystemProperties();
    982995    unsigned cMaxLogs = sys.GetLogHistoryCount() + 1 /*VBox.log*/ + 1 /*VBoxHardening.log*/; /** @todo Add api for getting total possible log count! */
     
    986999        if (comMachine.isNull())
    9871000            continue;
    988         bool fNoLogFileForMachine = true;
    9891001
    9901002        QUuid uMachineId = comMachine.GetId();
    9911003        QString strMachineName = comMachine.GetName();
     1004
     1005        m_pTabWidget->addTab(new UILabelTab(this, uMachineId), strMachineName);
     1006
     1007        bool fNoLogFileForMachine = true;
    9921008        for (unsigned iLogFileId = 0; iLogFileId < cMaxLogs; ++iLogFileId)
    9931009        {
     
    10101026        }
    10111027    }
     1028    m_pTabWidget->blockSignals(false);
     1029    labelTabHandler();
    10121030}
    10131031
     
    11181136}
    11191137
     1138bool UIVMLogViewerWidget::labelTabHandler()
     1139{
     1140    if (!m_pTabWidget || !qobject_cast<UILabelTab*>(m_pTabWidget->currentWidget()))
     1141        return false;
     1142    if (m_pTabWidget->currentIndex() < m_pTabWidget->count() - 1)
     1143        m_pTabWidget->setCurrentIndex(m_pTabWidget->currentIndex() + 1);
     1144    return true;
     1145}
     1146
    11201147#include "UIVMLogViewerWidget.moc"
  • trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.h

    r88903 r88972  
    171171    /** @} */
    172172
    173 
    174     /** Returns the log-page from the tab with index @a pIndex. */
    175     QPlainTextEdit* logPage(int pIndex) const;
    176173    /** Returns the newly created log-page using @a strPage filename. */
    177174    void createLogPage(const QString &strFileName, const QString &strMachineName,
     
    207204    /** Returns the content of the ith log file of @comMachine or possibly an empty string */
    208205    QString readLogFile(CMachine &comMachine, int iLogFileId);
     206    /** If the current tab is a label tab then switch to the next tab and return true. Returns false otherwise. */
     207    bool labelTabHandler();
    209208
    210209    /** Holds the widget's embedding type. */
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