VirtualBox

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


Ignore:
Timestamp:
Jun 2, 2007 12:36:48 PM (18 years ago)
Author:
vboxsync
Message:

1952: Easy way to store the RELEASE log using the GUI:

  1. Removed on/of action logic from the LogViewer.
  2. Log text browser is 80 chars wide by default.
  3. Tab widget margin 10 px wide.
  4. Date+Time in the file name to save as is not have leading zeros stripped.
  5. The entire tab widget is disabled when there are no logs and an appropriate message is shown inside.
  6. The log window is not always "on-top" of the main selector and have its own task bar entry.
Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxSelectorWnd.h

    r2981 r2996  
    7272    void vmDiscard();
    7373    void vmRefresh();
    74     void vmShowLogs (bool);
     74    void vmShowLogs();
    7575
    7676    void refreshVMList();
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp

    r2983 r2996  
    420420    vmShowLogsAction->setIconSet (VBoxGlobal::iconSet (
    421421        "show_logs_16px.png", "show_logs_disabled_16px.png"));
    422     vmShowLogsAction->setToggleAction (true);
    423422
    424423    helpContentsAction = new QAction (this, "helpContentsAction");
     
    576575    connect (vmDiscardAction, SIGNAL (activated()), this, SLOT (vmDiscard()));
    577576    connect (vmRefreshAction, SIGNAL (activated()), this, SLOT (vmRefresh()));
    578     connect (vmShowLogsAction, SIGNAL (toggled (bool)), this, SLOT (vmShowLogs (bool)));
     577    connect (vmShowLogsAction, SIGNAL (activated()), this, SLOT (vmShowLogs()));
    579578
    580579    connect (helpContentsAction, SIGNAL (activated()), this, SLOT(showHelpContents()));
     
    927926}
    928927
    929 void VBoxSelectorWnd::vmShowLogs (bool aOn)
    930 {
    931     if (aOn)
    932     {
    933         VBoxVMLogViewer *logViewer = new VBoxVMLogViewer (this,
    934             "logViewer", WType_TopLevel | WDestructiveClose);
    935         VBoxVMListBoxItem *item = (VBoxVMListBoxItem *) vmListBox->selectedItem();
    936         CMachine machine = item->machine();
    937         logViewer->setup (machine, vmShowLogsAction);
    938         logViewer->show();
    939     }
     928void VBoxSelectorWnd::vmShowLogs()
     929{
     930    VBoxVMListBoxItem *item = (VBoxVMListBoxItem *) vmListBox->selectedItem();
     931    CMachine machine = item->machine();
     932    VBoxVMLogViewer::createLogViewer (machine);
    940933}
    941934
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMLogViewer.ui

    r2988 r2996  
    3737        <property name="name">
    3838            <cstring>unnamed</cstring>
     39        </property>
     40        <property name="margin">
     41            <number>10</number>
    3942        </property>
    4043        <property name="spacing">
     
    159162</forwards>
    160163<variables>
     164    <variable access="private">static VBoxVMLogViewer *mSelf;</variable>
     165    <variable access="private">bool mFirstRun;</variable>
    161166    <variable access="private">bool mIsPolished;</variable>
    162167    <variable access="private">QSizeGrip *mSizeGrip;</variable>
    163168    <variable access="private">CMachine mMachine;</variable>
    164     <variable access="private">QAction *mAction;</variable>
    165169    <variable access="private">QTabWidget *mLogList;</variable>
    166170    <variable access="private">QStringList mLogFilesList;</variable>
     
    169173<slots>
    170174    <slot access="pritave">refresh()</slot>
    171     <slot access="private">suicide (bool)</slot>
    172175    <slot access="private">save()</slot>
    173176</slots>
    174177<functions>
     178    <function specifier="static">createLogViewer( CMachine&amp; )</function>
    175179    <function access="private">init()</function>
    176180    <function access="private">destroy()</function>
     181    <function>setup( CMachine &amp; )</function>
     182    <function returnType="const CMachine&amp;">machine()</function>
    177183    <function access="pritave">languageChangeImp()</function>
    178184    <function access="pritave" returnType="QPushButton*">searchDefaultButton()</function>
     
    182188    <function access="protected">showEvent( QShowEvent* )</function>
    183189    <function access="protected">resizeEvent( QResizeEvent* )</function>
    184     <function>setup( CMachine &amp;, QAction* )</function>
    185190    <function access="pritave">loadLogFile( const QString &amp; )</function>
    186191    <function access="pritave" returnType="QTextBrowser*">createLogPage( const QString &amp; )</function>
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMLogViewer.ui.h

    r2988 r2996  
    3131
    3232
     33VBoxVMLogViewer *VBoxVMLogViewer::mSelf = 0;
     34void VBoxVMLogViewer::createLogViewer (CMachine &aMachine)
     35{
     36    if (!mSelf)
     37    {
     38        /* creating new log viewer if there is no one existing */
     39        mSelf = new VBoxVMLogViewer (0, "VBoxVMLogViewer",
     40                                     WType_TopLevel | WDestructiveClose);
     41    }
     42
     43    if (mSelf->machine() != aMachine)
     44    {
     45        /* re-read new machine data if the machine was changed or
     46         * the log-viewer is opened for the first time */
     47        mSelf->setup (aMachine);
     48    }
     49
     50    mSelf->show();
     51    mSelf->setWindowState (mSelf->windowState() & ~WindowMinimized);
     52    mSelf->setActiveWindow();
     53}
     54
     55
    3356void VBoxVMLogViewer::init()
    3457{
     58    /* prepare dialog to first run */
     59    mFirstRun = true;
     60
    3561    /* dialog initially is not polished */
    3662    mIsPolished = false;
     
    6389void VBoxVMLogViewer::destroy()
    6490{
    65     /* switch the related toggle action off */
    66     mAction->setOn (false);
     91    mSelf = 0;
     92}
     93
     94
     95void VBoxVMLogViewer::setup (CMachine &aMachine)
     96{
     97    /* saving related machine */
     98    mMachine = aMachine;
     99
     100    /* reading log files */
     101    refresh();
     102
     103    /* loading language constants */
     104    languageChangeImp();
     105}
     106
     107
     108const CMachine& VBoxVMLogViewer::machine()
     109{
     110    return mMachine;
    67111}
    68112
     
    200244
    201245
    202 void VBoxVMLogViewer::setup (CMachine &aMachine, QAction *aAction)
    203 {
    204     /* saving predefined variables */
    205     mMachine = aMachine;
    206     mAction = aAction;
    207 
    208     /* setup self-destruction handler */
    209     connect (mAction, SIGNAL (toggled (bool)), this, SLOT (suicide (bool)));
    210 
    211     /* reading log files */
    212     refresh();
    213 
    214     /* loading language constants */
    215     languageChangeImp();
    216 }
    217 
    218 
    219246void VBoxVMLogViewer::refresh()
    220247{
     
    247274        QTextBrowser *dummyLog = createLogPage ("VBox.log");
    248275        dummyLog->setTextFormat (Qt::RichText);
     276        dummyLog->setWordWrap (QTextEdit::WidgetWidth);
    249277        dummyLog->setText (tr ("<p>No log files found. Press the <b>Refresh</b> "
    250278            "button to rescan the log folder <nobr><b>%1</b></nobr>.</p>")
     
    252280    }
    253281
     282    /* restore previous tab-widget margin which was reseted when
     283     * the tab widget's children was removed */
     284    mLogList->setMargin (10);
     285
    254286    /* show the first tab widget's page after the refresh */
    255287    mLogList->showPage (mLogList->page(0));
     288
     289    /* enable/disable save button & tab widget according log presence */
    256290    mSaveButton->setEnabled (isAnyLogPresent);
     291    mLogList->setEnabled (isAnyLogPresent);
     292
     293    if (mFirstRun)
     294    {
     295        /* resize the whole log-viewer to fit 80 symbols in text-browser for
     296         * the first time started */
     297        QTextBrowser *firstPage = static_cast<QTextBrowser*> (mLogList->page(0));
     298        int fullWidth = firstPage->fontMetrics().width (QChar ('x')) * 80 +
     299                        firstPage->verticalScrollBar()->width() +
     300                        firstPage->frameWidth() * 2 +
     301                        1 * 2 /* some one-pixel margin */ +
     302                        mLogList->margin() * 2 +
     303                        centralWidget()->layout()->margin() * 2;
     304        resize (fullWidth, height());
     305        mFirstRun = false;
     306    }
    257307}
    258308
     
    280330    font.setFamily ("Courier New,courier");
    281331    logViewer->setFont (font);
     332    logViewer->setWordWrap (QTextEdit::NoWrap);
     333    logViewer->setVScrollBarMode (QScrollView::AlwaysOn);
    282334    mLogList->addTab (logViewer, aName);
    283335    return logViewer;
     
    285337
    286338
    287 void VBoxVMLogViewer::suicide (bool aNo)
    288 {
    289     if (!aNo) close();
    290 }
    291 
    292 
    293339void VBoxVMLogViewer::save()
    294340{
    295341    /* prepare "save as" dialog */
    296     QDate date = QDate::currentDate();
    297     QTime time = QTime::currentTime();
    298     QString defaultFileName = QString ("%1-%2-%3-%4-%5-%6-%7.log")
    299         .arg (mMachine.GetName())
    300         .arg (date.year()).arg (date.month()).arg (date.day())
    301         .arg (time.hour()).arg (time.minute()).arg (time.second());
    302     QString defaultFullName = QDir::convertSeparators (QDir::home().absPath() + "/" +
    303                                                        defaultFileName);
     342    QDate fullDate = QDate::currentDate();
     343    QTime fullTime = QTime::currentTime();
     344    QString date = fullDate.toString ("yyyy-MM-dd");
     345    QString time = fullTime.toString ("hh-mm-ss");
     346    QString defaultFileName = QString ("%1-%2-%3.log")
     347        .arg (mMachine.GetName()).arg (date).arg (time);
     348    QString defaultFullName = QDir::convertSeparators (QDir::home().absPath() +
     349                                                       "/" + defaultFileName);
    304350
    305351    QString newFileName = QFileDialog::getSaveFileName (defaultFullName,
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