~ubuntu-branches/ubuntu/trusty/virtualbox-ose/trusty

« back to all changes in this revision

Viewing changes to src/VBox/Frontends/VirtualBox/src/VBoxVMLogViewer.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2009-12-18 16:44:29 UTC
  • mfrom: (0.3.3 upstream) (0.4.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091218164429-jd34ccexpv5na11a
Tags: 3.1.2-dfsg-1ubuntu1
* Merge from Debian unstable (LP: #498219), remaining changes:
  - Disable update action
    - debian/patches/u01-disable-update-action.dpatch
  - VirtualBox should go in Accessories, not in System tools (LP: #288590)
    - debian/virtualbox-ose-qt.files/virtualbox-ose.desktop
  - Add Apport hook
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Add Launchpad integration
    - debian/control
    - debian/lpi-bug.xpm
    - debian/patches/u02-lp-integration.dpatch
* Fixes the following bugs:
  - Kernel module fails to build with Linux >= 2.6.32 (LP: #474625)
  - X.Org drivers need to be rebuilt against X-Server 1.7 (LP: #495935)
  - The *-source packages try to build the kernel modules even though the
    kernel headers aren't available (LP: #473334)
* Replace *-source packages with transitional packages for *-dkms.
* Adapt u01-disable-update-action.dpatch and u02-lp-integration.dpatch for
  new upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 * additional information or have any questions.
21
21
 */
22
22
 
23
 
#include <VBoxVMLogViewer.h>
24
 
#include <VBoxGlobal.h>
25
 
#include <VBoxProblemReporter.h>
 
23
#include "VBoxVMLogViewer.h"
 
24
#include "VBoxGlobal.h"
 
25
#include "VBoxProblemReporter.h"
 
26
#include "VBoxSpecialControls.h"
 
27
#include "VBoxUtils.h"
26
28
 
27
29
/* Qt includes */
28
30
#include <QStyle>
30
32
#include <QTextEdit>
31
33
#include <QLineEdit>
32
34
#include <QLabel>
33
 
#include <QToolButton>
34
35
#include <QCheckBox>
35
36
#include <QDir>
36
37
#include <QScrollBar>
120
121
#ifdef Q_WS_MAC
121
122
    /* We have to force this to get the default button L&F on the mac. */
122
123
    defaultButton()->setEnabled (true);
 
124
# ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS
 
125
    logsFrameLayout->setSpacing (4);
 
126
# endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */
123
127
#endif /* Q_WS_MAC */
124
128
    /* Loading language constants */
125
129
    retranslateUi();
296
300
            mFirstRun = false;
297
301
        }
298
302
    }
 
303
 
 
304
    /* Make sure the log view widget has the focus */
 
305
    QWidget *w = currentLogPage();
 
306
    if (w)
 
307
        w->setFocus();
299
308
}
300
309
 
301
310
void VBoxVMLogViewer::loadLogFile (const QString &aFileName)
338
347
    , mViewer (aViewer)
339
348
    , mButtonClose (0)
340
349
    , mSearchName (0), mSearchString (0)
341
 
    , mButtonPrev (0), mButtonNext (0)
 
350
    , mButtonsNextPrev (0)
342
351
    , mCaseSensitive (0)
343
352
    , mWarningSpacer (0), mWarningIcon (0), mWarningString (0)
344
353
{
345
 
    mButtonClose = new QToolButton (this);
346
 
    mButtonClose->setAutoRaise (true);
347
 
    mButtonClose->setFocusPolicy (Qt::TabFocus);
348
 
    mButtonClose->setShortcut (QKeySequence (Qt::Key_Escape));
 
354
    mButtonClose = new VBoxMiniCancelButton (this);
349
355
    connect (mButtonClose, SIGNAL (clicked()), this, SLOT (hide()));
350
 
    mButtonClose->setIcon (VBoxGlobal::iconSet (":/delete_16px.png",
351
 
                                                ":/delete_dis_16px.png"));
352
356
 
353
357
    mSearchName = new QLabel (this);
354
 
    mSearchString = new QLineEdit (this);
 
358
    mSearchString = new VBoxSearchField (this);
355
359
    mSearchString->setSizePolicy (QSizePolicy::Preferred,
356
360
                                  QSizePolicy::Fixed);
357
361
    connect (mSearchString, SIGNAL (textChanged (const QString &)),
358
362
             this, SLOT (findCurrent (const QString &)));
359
363
 
360
 
    mButtonNext = new QToolButton (this);
361
 
    mButtonNext->setEnabled (false);
362
 
    mButtonNext->setAutoRaise (true);
363
 
    mButtonNext->setFocusPolicy (Qt::TabFocus);
364
 
    mButtonNext->setToolButtonStyle (Qt::ToolButtonTextBesideIcon);
365
 
    connect (mButtonNext, SIGNAL (clicked()), this, SLOT (findNext()));
366
 
    mButtonNext->setIcon (VBoxGlobal::iconSet (":/list_movedown_16px.png",
367
 
                                               ":/list_movedown_disabled_16px.png"));
368
 
 
369
 
    mButtonPrev = new QToolButton (this);
370
 
    mButtonPrev->setEnabled (false);
371
 
    mButtonPrev->setAutoRaise (true);
372
 
    mButtonPrev->setFocusPolicy (Qt::TabFocus);
373
 
    mButtonPrev->setToolButtonStyle (Qt::ToolButtonTextBesideIcon);
374
 
    connect (mButtonPrev, SIGNAL (clicked()), this, SLOT (findBack()));
375
 
    mButtonPrev->setIcon (VBoxGlobal::iconSet (":/list_moveup_16px.png",
376
 
                                               ":/list_moveup_disabled_16px.png"));
 
364
    mButtonsNextPrev = new VBoxSegmentedButton (2, this);
 
365
    mButtonsNextPrev->setEnabled (0, false);
 
366
    mButtonsNextPrev->setIcon (0, VBoxGlobal::iconSet (":/list_movedown_16px.png",
 
367
                                                       ":/list_movedown_disabled_16px.png"));
 
368
    mButtonsNextPrev->setEnabled (1, false);
 
369
    mButtonsNextPrev->setIcon (1, VBoxGlobal::iconSet (":/list_moveup_16px.png",
 
370
                                                       ":/list_moveup_disabled_16px.png"));
 
371
    connect (mButtonsNextPrev, SIGNAL (clicked (int)), this, SLOT (find (int)));
377
372
 
378
373
    mCaseSensitive = new QCheckBox (this);
379
374
 
391
386
    QSpacerItem *spacer = new QSpacerItem (0, 0, QSizePolicy::Expanding,
392
387
                                                 QSizePolicy::Minimum);
393
388
 
 
389
#ifdef VBOX_DARWIN_USE_NATIVE_CONTROLS
 
390
    QFont font = mSearchName->font();
 
391
    font.setPointSize (::darwinSmallFontSize());
 
392
    mSearchName->setFont (font);
 
393
    mCaseSensitive->setFont (font);
 
394
    mWarningString->setFont (font);
 
395
#endif /* VBOX_DARWIN_USE_NATIVE_CONTROLS */
 
396
 
394
397
    QHBoxLayout *mainLayout = new QHBoxLayout (this);
395
398
    mainLayout->setSpacing (5);
396
399
    mainLayout->setContentsMargins (0, 0, 0, 0);
397
400
    mainLayout->addWidget (mButtonClose);
398
401
    mainLayout->addWidget (mSearchName);
399
402
    mainLayout->addWidget (mSearchString);
400
 
    mainLayout->addWidget (mButtonNext);
401
 
    mainLayout->addWidget (mButtonPrev);
 
403
    mainLayout->addWidget (mButtonsNextPrev);
402
404
    mainLayout->addWidget (mCaseSensitive);
403
405
    mainLayout->addItem   (mWarningSpacer);
404
406
    mainLayout->addWidget (mWarningIcon);
418
420
    mSearchName->setText (tr ("Find "));
419
421
    mSearchString->setToolTip (tr ("Enter a search string here"));
420
422
 
421
 
    VBoxGlobal::setTextLabel (mButtonPrev, tr ("&Previous"));
422
 
    mButtonPrev->setToolTip (tr ("Search for the previous occurrence "
423
 
                                 "of the string"));
424
 
 
425
 
    VBoxGlobal::setTextLabel (mButtonNext, tr ("&Next"));
426
 
    mButtonNext->setToolTip (tr ("Search for the next occurrence of "
427
 
                                 "the string"));
 
423
    mButtonsNextPrev->setTitle (0, tr ("&Next"));
 
424
    mButtonsNextPrev->setToolTip (0, tr ("Search for the next occurrence of "
 
425
                                         "the string"));
 
426
 
 
427
    mButtonsNextPrev->setTitle (1, tr ("&Previous"));
 
428
    mButtonsNextPrev->setToolTip (1, tr ("Search for the previous occurrence "
 
429
                                         "of the string"));
 
430
 
428
431
 
429
432
    mCaseSensitive->setText (tr ("C&ase Sensitive"));
430
433
    mCaseSensitive->setToolTip (tr ("Perform case sensitive search "
435
438
 
436
439
void VBoxLogSearchPanel::findCurrent (const QString &aSearchString)
437
440
{
438
 
    mButtonNext->setEnabled (aSearchString.length());
439
 
    mButtonPrev->setEnabled (aSearchString.length());
 
441
    mButtonsNextPrev->setEnabled (0, aSearchString.length());
 
442
    mButtonsNextPrev->setEnabled (1, aSearchString.length());
440
443
    toggleWarning (!aSearchString.length());
441
444
    if (aSearchString.length())
442
445
        search (true, true);
493
496
 
494
497
bool VBoxLogSearchPanel::eventFilter (QObject *aObject, QEvent *aEvent)
495
498
{
 
499
    /* Check that the object is a child of the parent of the search panel. If
 
500
     * not do not proceed, cause we get all key events from all windows here. */
 
501
    QObject *pp = aObject;
 
502
    while(pp && pp != parentWidget()) { pp = pp->parent(); };
 
503
    if (!pp)
 
504
        return false;
496
505
    switch (aEvent->type())
497
506
    {
498
507
        case QEvent::KeyPress:
506
515
                 e->QInputEvent::modifiers() & Qt::KeypadModifier) &&
507
516
                (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return))
508
517
            {
509
 
                mButtonNext->animateClick();
 
518
                mButtonsNextPrev->animateClick (0);
510
519
                return true;
511
520
            }
512
521
            /* handle other search next/previous shortcuts */
513
522
            else if (e->key() == Qt::Key_F3)
514
523
            {
515
524
                if (e->QInputEvent::modifiers() == 0)
516
 
                    mButtonNext->animateClick();
 
525
                    mButtonsNextPrev->animateClick (0);
517
526
                else if (e->QInputEvent::modifiers() == Qt::ShiftModifier)
518
 
                    mButtonPrev->animateClick();
 
527
                    mButtonsNextPrev->animateClick (1);
519
528
                return true;
520
529
            }
521
530
            /* handle ctrl-f key combination as a shortcut to
572
581
{
573
582
    mWarningSpacer->changeSize (aHide ? 0 : 16, 0, QSizePolicy::Fixed,
574
583
                                                   QSizePolicy::Minimum);
 
584
    if (!aHide)
 
585
        mSearchString->markError();
 
586
    else
 
587
        mSearchString->unmarkError();
575
588
    mWarningIcon->setHidden (aHide);
576
589
    mWarningString->setHidden (aHide);
577
590
}
578
591
 
 
592
void VBoxLogSearchPanel::find (int aButton)
 
593
{
 
594
    if (aButton == 0)
 
595
        findNext();
 
596
    else
 
597
        findBack();
 
598
}