VirtualBox

Changeset 77412 in vbox


Ignore:
Timestamp:
Feb 21, 2019 6:25:37 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
128973
Message:

VBoxDbg: Moved the title management to the VBoxDbgBaseWindow class, combining the approaches in the console and statistics windows.

Location:
trunk/src/VBox/Debugger
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Debugger/VBoxDbgBase.cpp

    r76553 r77412  
    163163
    164164
    165 VBoxDbgBaseWindow::VBoxDbgBaseWindow(VBoxDbgGui *a_pDbgGui, QWidget *a_pParent)
    166     : QWidget(a_pParent, Qt::Window), VBoxDbgBase(a_pDbgGui), m_fPolished(false),
    167     m_x(INT_MAX), m_y(INT_MAX), m_cx(0), m_cy(0)
    168 {
     165VBoxDbgBaseWindow::VBoxDbgBaseWindow(VBoxDbgGui *a_pDbgGui, QWidget *a_pParent, const char *a_pszTitle)
     166    : QWidget(a_pParent, Qt::Window), VBoxDbgBase(a_pDbgGui), m_pszTitle(a_pszTitle), m_fPolished(false)
     167    , m_x(INT_MAX), m_y(INT_MAX), m_cx(0), m_cy(0)
     168{
     169    /* Set the title, using the parent one as prefix when possible: */
     170    if (!parent())
     171    {
     172        QString strMachineName = a_pDbgGui->getMachineName();
     173        if (strMachineName.isEmpty())
     174            setWindowTitle(QString("VBoxDbg - %1").arg(m_pszTitle));
     175        else
     176            setWindowTitle(QString("%1 - VBoxDbg - %2").arg(strMachineName).arg(m_pszTitle));
     177    }
     178    else
     179    {
     180        setWindowTitle(QString("%1 - %2").arg(parentWidget()->windowTitle()).arg(m_pszTitle));
     181
     182        /* Install an event filter so we can make adjustments when the parent title changes: */
     183        parent()->installEventFilter(this);
     184    }
    169185}
    170186
     
    215231    vPolishSizeAndPos();
    216232    return fRc;
     233}
     234
     235
     236bool VBoxDbgBaseWindow::eventFilter(QObject *pWatched, QEvent *pEvent)
     237{
     238    /* We're only interested in title changes to the parent so we can amend our own title: */
     239    if (   pWatched == parent()
     240        && pEvent->type() == QEvent::WindowTitleChange)
     241        setWindowTitle(QString("%1 - %2").arg(parentWidget()->windowTitle()).arg(m_pszTitle));
     242
     243    /* Forward to base-class: */
     244    return QWidget::eventFilter(pWatched, pEvent);
    217245}
    218246
  • trunk/src/VBox/Debugger/VBoxDbgBase.h

    r76564 r77412  
    134134     * @param   a_pDbgGui   Pointer to the debugger gui object.
    135135     * @param   a_pParent   Pointer to the parent object.
    136      */
    137     VBoxDbgBaseWindow(VBoxDbgGui *a_pDbgGui, QWidget *a_pParent);
     136     * @param   a_pszTitle  The window title string (persistent, not copied).
     137     */
     138    VBoxDbgBaseWindow(VBoxDbgGui *a_pDbgGui, QWidget *a_pParent, const char *a_pszTitle);
    138139
    139140    /**
     
    168169
    169170    /**
     171     * Event filter for various purposes (mainly title bar).
     172     *
     173     * @param  pWatched         The object event came to.
     174     * @param  pEvent           The event being handled.
     175     */
     176    virtual bool eventFilter(QObject *pWatched, QEvent *pEvent);
     177
     178    /**
    170179     * Internal worker for polishing the size and position (X11 hacks).
    171180     */
     
    177186    QSize vGuessBorderSizes();
    178187
    179 
    180188private:
     189    /** The Window title string (inflexible, read only). */
     190    const char *m_pszTitle;
    181191    /** Whether we've done the size polishing in showEvent or not. */
    182192    bool m_fPolished;
  • trunk/src/VBox/Debugger/VBoxDbgConsole.cpp

    r77409 r77412  
    484484
    485485VBoxDbgConsole::VBoxDbgConsole(VBoxDbgGui *a_pDbgGui, QWidget *a_pParent/* = NULL*/, IVirtualBox *a_pVirtualBox/* = NULL */)
    486     : VBoxDbgBaseWindow(a_pDbgGui, a_pParent), m_pOutput(NULL), m_pInput(NULL), m_fInputRestoreFocus(false),
     486    : VBoxDbgBaseWindow(a_pDbgGui, a_pParent, "Console"), m_pOutput(NULL), m_pInput(NULL), m_fInputRestoreFocus(false),
    487487    m_pszInputBuf(NULL), m_cbInputBuf(0), m_cbInputBufAlloc(0),
    488488    m_pszOutputBuf(NULL), m_cbOutputBuf(0), m_cbOutputBufAlloc(0),
     
    490490    m_fTerminate(false), m_fThreadTerminated(false)
    491491{
    492     QString strMachineName;
    493     if (a_pDbgGui)
    494         strMachineName = a_pDbgGui->getMachineName();
    495 
    496     if (strMachineName.isEmpty())
    497         setWindowTitle("VBoxDbg - Console");
    498     else
    499         setWindowTitle(QString("%1 - VBoxDbg - Console").arg(strMachineName));
    500492    /*
    501493     * Create the output text box.
  • trunk/src/VBox/Debugger/VBoxDbgGui.cpp

    r77409 r77412  
    257257}
    258258
     259
    259260QString
    260261VBoxDbgGui::getMachineName() const
     
    267268    {
    268269        strName = QString::fromUtf16(bstr);
    269     }
    270     SysFreeString(bstr);
     270        SysFreeString(bstr);
     271    }
    271272    return strName;
    272273}
     274
    273275
    274276void
  • trunk/src/VBox/Debugger/VBoxDbgStatsQt.cpp

    r76553 r77412  
    30403040
    30413041VBoxDbgStats::VBoxDbgStats(VBoxDbgGui *a_pDbgGui, const char *pszPat/* = NULL*/, unsigned uRefreshRate/* = 0*/, QWidget *pParent/* = NULL*/)
    3042     : VBoxDbgBaseWindow(a_pDbgGui, pParent), m_PatStr(pszPat), m_pPatCB(NULL), m_uRefreshRate(0), m_pTimer(NULL), m_pView(NULL)
    3043 {
    3044     /* Assign window-title: */
    3045     if (parent())
    3046     {
    3047         setWindowTitle(QString("%1 - Statistics").arg(parentWidget()->windowTitle()));
    3048         parent()->installEventFilter(this);
    3049     }
    3050     else
    3051         setWindowTitle("VBoxDbg - Statistics");
    3052 
     3042    : VBoxDbgBaseWindow(a_pDbgGui, pParent, "Statistics")
     3043    , m_PatStr(pszPat), m_pPatCB(NULL), m_uRefreshRate(0), m_pTimer(NULL), m_pView(NULL)
     3044{
    30533045    /*
    30543046     * On top, a horizontal box with the pattern field, buttons and refresh interval.
     
    31613153
    31623154
    3163 bool VBoxDbgStats::eventFilter(QObject *pWatched, QEvent *pEvent)
    3164 {
    3165     /* Skip events which are not related to our parent: */
    3166     if (pWatched != parent())
    3167         return VBoxDbgBaseWindow::eventFilter(pWatched, pEvent);
    3168 
    3169     /* Depending on event-type: */
    3170     switch (pEvent->type())
    3171     {
    3172         case QEvent::WindowTitleChange: setWindowTitle(QString("%1 - Statistics").arg(parentWidget()->windowTitle())); break;
    3173         default: break;
    3174     }
    3175 
    3176     /* Call to base-class: */
    3177     return VBoxDbgBaseWindow::eventFilter(pWatched, pEvent);
    3178 }
    3179 
    3180 
    31813155void
    31823156VBoxDbgStats::apply(const QString &Str)
  • trunk/src/VBox/Debugger/VBoxDbgStatsQt.h

    r76564 r77412  
    204204    virtual void closeEvent(QCloseEvent *a_pCloseEvt);
    205205
    206     /**
    207      * Event filter for various purposes.
    208      *
    209      * @param  pWatched         The object event came to.
    210      * @param  pEvent           The event being handled.
    211      */
    212     virtual bool eventFilter(QObject *pWatched, QEvent *pEvent);
    213 
    214206protected slots:
    215207    /** Apply the activated combobox pattern. */
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