VirtualBox

Ignore:
Timestamp:
May 26, 2008 9:00:59 AM (17 years ago)
Author:
vboxsync
Message:

FE/Qt4: Moved the VBoxLicenseViewer class into a separate file.

Location:
trunk/src/VBox/Frontends/VirtualBox4
Files:
2 edited

Legend:

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

    r9095 r9105  
    521521
    522522ifeq ($(filter-out freebsd linux netbsd openbsd solaris,$(KBUILD_TARGET)),) # X11
     523ifndef VBOX_OSE
     524VirtualBox_QT_MOCHDRS += \
     525        include/VBoxLicenseViewer.h
     526VirtualBox_SOURCES += \
     527        src/VBoxLicenseViewer.cpp
     528endif
    523529VirtualBox_SOURCES += \
    524530        src/linux/XKeyboard-new.cpp
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxGlobal.cpp

    r9060 r9105  
    4747
    4848#ifdef Q_WS_X11
     49#include "VBoxLicenseViewer.h"
     50
    4951#include <QTextBrowser>
    5052#include <QScrollBar>
     
    544546
    545547#endif /* Q_WS_WIN */
    546 
    547 #ifdef Q_WS_X11
    548 /**
    549  *  This class is used to show a user license under linux.
    550  */
    551 class VBoxLicenseViewer : public QDialog
    552 {
    553     Q_OBJECT
    554 
    555 public:
    556 
    557     VBoxLicenseViewer (const QString &aFilePath)
    558         : QDialog ()
    559         , mFilePath (aFilePath)
    560         , mLicenseText (0), mAgreeButton (0), mDisagreeButton (0)
    561     {
    562         setWindowTitle ("VirtualBox License");
    563 
    564 #ifndef Q_WS_WIN
    565        /* Application icon. On Win32, it's built-in to the executable. */
    566         setWindowIcon (QIcon (":/VirtualBox_48px.png"));
    567 #endif
    568 
    569         mLicenseText = new QTextBrowser (this);
    570         mAgreeButton = new QPushButton (tr ("I &Agree"), this);
    571         mDisagreeButton = new QPushButton (tr ("I &Disagree"), this);
    572         QDialogButtonBox *dbb = new QIDialogButtonBox (this);
    573         dbb->addButton (mAgreeButton, QDialogButtonBox::AcceptRole);
    574         dbb->addButton (mDisagreeButton, QDialogButtonBox::RejectRole);
    575 
    576         connect (mLicenseText->verticalScrollBar(), SIGNAL (valueChanged (int)),
    577                  SLOT (onScrollBarMoving (int)));
    578         connect (mAgreeButton, SIGNAL (clicked()), SLOT (accept()));
    579         connect (mDisagreeButton, SIGNAL (clicked()), SLOT (reject()));
    580 
    581         QVBoxLayout *mainLayout = new QVBoxLayout (this);
    582         mainLayout->setSpacing (10);
    583         VBoxGlobal::setLayoutMargin (mainLayout, 10);
    584         mainLayout->addWidget (mLicenseText);
    585         mainLayout->addWidget (dbb);
    586 
    587         mLicenseText->verticalScrollBar()->installEventFilter (this);
    588 
    589         resize (600, 450);
    590     }
    591 
    592 public slots:
    593 
    594     int exec()
    595     {
    596         /* read & show the license file */
    597         QFile file (mFilePath);
    598         if (file.open (QIODevice::ReadOnly))
    599         {
    600             mLicenseText->setText (file.readAll());
    601             return QDialog::exec();
    602         }
    603         else
    604         {
    605             vboxProblem().cannotOpenLicenseFile (this, mFilePath);
    606             return QDialog::Rejected;
    607         }
    608     }
    609 
    610 private slots:
    611 
    612     void onScrollBarMoving (int aValue)
    613     {
    614         if (aValue == mLicenseText->verticalScrollBar()->maximum())
    615             unlockButtons();
    616     }
    617 
    618     void unlockButtons()
    619     {
    620         mAgreeButton->setEnabled (true);
    621         mDisagreeButton->setEnabled (true);
    622     }
    623 
    624 private:
    625 
    626     void showEvent (QShowEvent *aEvent)
    627     {
    628         QDialog::showEvent (aEvent);
    629         bool isScrollBarHidden = mLicenseText->verticalScrollBar()->isHidden()
    630                                  && !(windowState() & Qt::WindowMinimized);
    631         mAgreeButton->setEnabled (isScrollBarHidden);
    632         mDisagreeButton->setEnabled (isScrollBarHidden);
    633     }
    634 
    635     bool eventFilter (QObject *aObject, QEvent *aEvent)
    636     {
    637         switch (aEvent->type())
    638         {
    639             case QEvent::Hide:
    640                 if (aObject == mLicenseText->verticalScrollBar())
    641                     /* Doesn't work on wm's like ion3 where the window starts
    642                      * maximized: isActiveWindow() */
    643                     unlockButtons();
    644             default:
    645                 break;
    646         }
    647         return QDialog::eventFilter (aObject, aEvent);
    648     }
    649 
    650     QString       mFilePath;
    651     QTextBrowser *mLicenseText;
    652     QPushButton  *mAgreeButton;
    653     QPushButton  *mDisagreeButton;
    654 };
    655 #endif
    656548
    657549
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