VirtualBox

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


Ignore:
Timestamp:
Aug 17, 2023 6:35:45 AM (16 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10496, bugref:6699. Replacing the file manager's log panel.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
2 deleted
4 edited

Legend:

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

    r100880 r100890  
    845845        src/guestctrl/UIFileManagerGuestTable.h \
    846846        src/guestctrl/UIFileManagerHostTable.h \
    847         src/guestctrl/UIFileManagerLogPanel.h \
    848847        src/guestctrl/UIFileManagerOperationsPanel.h \
    849848        src/guestctrl/UIFileManagerPanel.h \
     
    10611060        src/globals/UIVirtualBoxClientEventHandler.cpp \
    10621061        src/guestctrl/UIFileManager.cpp \
    1063         src/guestctrl/UIFileManagerLogPanel.cpp \
    10641062        src/guestctrl/UIFileManagerOperationsPanel.cpp \
    10651063        src/guestctrl/UIFileManagerPanel.cpp \
     
    14261424        src/guestctrl/UIFileManagerGuestTable.cpp \
    14271425        src/guestctrl/UIFileManagerHostTable.cpp \
    1428         src/guestctrl/UIFileManagerLogPanel.cpp \
    14291426        src/guestctrl/UIFileManagerPanel.cpp \
    14301427        src/guestctrl/UIFileManagerOperationsPanel.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManager.cpp

    r100888 r100890  
    4343#include "UIFileManager.h"
    4444#include "UIFileManagerPanel.h"
    45 #include "UIFileManagerLogPanel.h"
    4645#include "UIFileManagerOperationsPanel.h"
    4746#include "UIFileManagerGuestTable.h"
     
    314313                    this, &UIFileManager::sltCopyHostToGuest);
    315314    }
    316     if (m_pLogPanel)
    317     {
    318         connect(m_pLogPanel, &UIFileManagerLogPanel::sigHidePanel,
    319                 this, &UIFileManager::sltHandleHidePanel);
    320         connect(m_pLogPanel, &UIFileManagerLogPanel::sigShowPanel,
    321                 this, &UIFileManager::sltHandleShowPanel);
    322     }
     315
    323316    if (m_pPanel)
    324317    {
     
    515508{
    516509    if (m_pPanel)
    517         m_pPanel->update();
     510        m_pPanel->updatePreferences();
    518511
    519512    for (int i = 0; i < m_pGuestTablesContainer->count(); ++i)
     
    582575    }
    583576    pSplitter->addWidget(m_pOperationsPanel);
    584     m_pLogPanel = new UIFileManagerLogPanel;
    585     if (m_pLogPanel)
    586     {
    587         m_pLogPanel->hide();
    588         m_panelActionMap.insert(m_pLogPanel, m_pActionPool->action(UIActionIndex_M_FileManager_T_Log));
    589     }
    590     pSplitter->addWidget(m_pLogPanel);
    591577}
    592578
     
    709695void UIFileManager::appendLog(const QString &strLog, const QString &strMachineName, FileManagerLogType eLogType)
    710696{
    711     if (!m_pLogPanel)
    712         return;
    713     m_pLogPanel->appendLog(strLog, strMachineName, eLogType);
     697    if (m_pPanel)
     698        m_pPanel->appendLog(strLog, strMachineName, eLogType);
    714699}
    715700
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerPanel.cpp

    r100887 r100890  
    3232#include <QSpinBox>
    3333#include <QTabWidget>
     34#include <QTextEdit>
     35#include <QTime>
    3436
    3537/* GUI includes: */
     
    3941/* Other VBox includes: */
    4042#include <iprt/assert.h>
     43
     44
     45/*********************************************************************************************************************************
     46*   UIFileManagerLogViewer definition.                                                                                   *
     47*********************************************************************************************************************************/
     48
     49class UIFileManagerLogViewer : public QTextEdit
     50{
     51
     52    Q_OBJECT;
     53
     54public:
     55
     56    UIFileManagerLogViewer(QWidget *pParent = 0);
     57
     58protected:
     59
     60    virtual void contextMenuEvent(QContextMenuEvent * event) RT_OVERRIDE;
     61
     62private slots:
     63
     64    void sltClear();
     65};
     66
     67/*********************************************************************************************************************************
     68*   UIFileManagerLogViewer implementation.                                                                                   *
     69*********************************************************************************************************************************/
     70
     71UIFileManagerLogViewer::UIFileManagerLogViewer(QWidget *pParent /* = 0 */)
     72    :QTextEdit(pParent)
     73{
     74    setUndoRedoEnabled(false);
     75    setReadOnly(true);
     76}
     77
     78void UIFileManagerLogViewer::contextMenuEvent(QContextMenuEvent *event)
     79{
     80    QMenu *menu = createStandardContextMenu();
     81
     82    QAction *pClearAction = menu->addAction(UIFileManager::tr("Clear"));
     83    connect(pClearAction, &QAction::triggered, this, &UIFileManagerLogViewer::sltClear);
     84    menu->exec(event->globalPos());
     85    delete menu;
     86}
     87
     88void UIFileManagerLogViewer::sltClear()
     89{
     90    clear();
     91}
     92
     93/*********************************************************************************************************************************
     94*   UIFileManagerPanel implementation.                                                                                   *
     95*********************************************************************************************************************************/
    4196
    4297UIFileManagerPanel::UIFileManagerPanel(QWidget *pParent, UIFileManagerOptions *pFileManagerOptions)
     
    63118    pMainLayout->addWidget(m_pTabWidget);
    64119    preparePreferencesTab();
     120    prepareLogTab();
    65121}
    66122
    67123void UIFileManagerPanel::preparePreferencesTab()
    68124{
    69     m_pPreferencesTab = new QWidget;
     125    QWidget *pPreferencesTab = new QWidget;
    70126    m_pListDirectoriesOnTopCheckBox = new QCheckBox;
    71127    m_pDeleteConfirmationCheckBox = new QCheckBox;
     
    73129    m_pShowHiddenObjectsCheckBox = new QCheckBox;
    74130
    75     AssertReturnVoid(m_pPreferencesTab);
     131    AssertReturnVoid(pPreferencesTab);
    76132    AssertReturnVoid(m_pListDirectoriesOnTopCheckBox);
    77133    AssertReturnVoid(m_pDeleteConfirmationCheckBox);
     
    104160            this, &UIFileManagerPanel::sltShowHiddenObjectsCheckBoxToggled);
    105161
    106     QGridLayout *pPreferencesLayout = new QGridLayout(m_pPreferencesTab);
     162    QGridLayout *pPreferencesLayout = new QGridLayout(pPreferencesTab);
    107163    AssertReturnVoid(pPreferencesLayout);
     164    pPreferencesLayout->setContentsMargins(0, 0, 0, 0);
     165
    108166    pPreferencesLayout->addWidget(m_pListDirectoriesOnTopCheckBox, 0, 0, 1, 1);
    109167    pPreferencesLayout->addWidget(m_pDeleteConfirmationCheckBox,   1, 0, 1, 1);
    110168    pPreferencesLayout->addWidget(m_pHumanReabableSizesCheckBox,   0, 1, 1, 1);
    111169    pPreferencesLayout->addWidget(m_pShowHiddenObjectsCheckBox,    1, 1, 1, 1);
    112 
    113     m_pTabWidget->addTab(m_pPreferencesTab, QApplication::translate("UIFileManager", "Preferences"));
     170    pPreferencesLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding), 2, 0, 1, 2);
     171
     172    m_pTabWidget->addTab(pPreferencesTab, QApplication::translate("UIFileManager", "Preferences"));
     173}
     174
     175void UIFileManagerPanel::prepareLogTab()
     176{
     177    QWidget *pLogTab = new QWidget;
     178    AssertReturnVoid(pLogTab);
     179    QHBoxLayout *pLogLayout = new QHBoxLayout(pLogTab);
     180    AssertReturnVoid(pLogLayout);
     181    pLogLayout->setContentsMargins(0, 0, 0, 0);
     182    m_pLogTextEdit = new UIFileManagerLogViewer;
     183    if (m_pLogTextEdit)
     184        pLogLayout->addWidget(m_pLogTextEdit);
     185    m_pTabWidget->addTab(pLogTab, QApplication::translate("UIFileManager", "Log"));
    114186}
    115187
     
    175247}
    176248
    177 void UIFileManagerPanel::update()
     249void UIFileManagerPanel::updatePreferences()
    178250{
    179251    if (!m_pFileManagerOptions)
     
    209281}
    210282
     283void UIFileManagerPanel::appendLog(const QString &strLog, const QString &strMachineName, FileManagerLogType eLogType)
     284{
     285    if (!m_pLogTextEdit)
     286        return;
     287    QString strStartTag("<font color=\"Black\">");
     288    QString strEndTag("</font>");
     289    if (eLogType == FileManagerLogType_Error)
     290    {
     291        strStartTag = "<b><font color=\"Red\">";
     292        strEndTag = "</font></b>";
     293    }
     294    QString strColoredLog = QString("%1 %2: %3 %4 %5").arg(strStartTag).arg(QTime::currentTime().toString("hh:mm:ss:z")).arg(strMachineName).arg(strLog).arg(strEndTag);
     295    m_pLogTextEdit->append(strColoredLog);
     296    m_pLogTextEdit->moveCursor(QTextCursor::End);
     297    m_pLogTextEdit->ensureCursorVisible();
     298}
    211299
    212300#include "UIFileManagerPanel.moc"
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerPanel.h

    r100887 r100890  
    3939class QTabWidget;
    4040class QCheckBox;
     41class UIFileManagerLogViewer;
    4142class UIFileManagerOptions;
    4243
     
    5253
    5354    UIFileManagerPanel(QWidget *pParent, UIFileManagerOptions *pFileManagerOptions);
    54     void update();
     55    void updatePreferences();
     56    void appendLog(const QString &strLog, const QString &strMachineName, FileManagerLogType eLogType);
    5557
    5658protected:
     
    6971    void prepare();
    7072    void preparePreferencesTab();
     73    void prepareLogTab();
     74
    7175    QTabWidget   *m_pTabWidget;
    7276
    7377    /** @name Preferences tab
    7478     * @{ */
    75         QWidget    *m_pPreferencesTab;
    7679        QCheckBox  *m_pListDirectoriesOnTopCheckBox;
    7780        QCheckBox  *m_pDeleteConfirmationCheckBox;
     
    8184    /** @} */
    8285
     86    /** @name Log tab
     87     * @{ */
     88        UIFileManagerLogViewer *m_pLogTextEdit;
     89    /** @} */
    8390
    8491};
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