VirtualBox

Ignore:
Timestamp:
Dec 1, 2011 12:03:43 PM (13 years ago)
Author:
vboxsync
Message:

FE/Qt: Moving VBoxVersion into the separate file.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxUtils.h

    r39473 r39488  
    195195};
    196196
    197 /**
    198  *  VBoxVersion represents VirtualBox version parser
    199  */
    200 class VBoxVersion
    201 {
    202 public:
    203 
    204     VBoxVersion() : m_x(-1), m_y(-1), m_z(-1) {}
    205 
    206     VBoxVersion(const QString &strVersion)
    207         : m_x(-1), m_y(-1), m_z(-1)
    208     {
    209         QStringList versionStack = strVersion.split('.');
    210         if (versionStack.size() > 0)
    211             m_x = versionStack[0].toInt();
    212         if (versionStack.size() > 1)
    213             m_y = versionStack[1].toInt();
    214         if (versionStack.size() > 2)
    215             m_z = versionStack[2].toInt();
    216     }
    217 
    218     VBoxVersion& operator=(const VBoxVersion &other) { m_x = other.x(); m_y = other.y(); m_z = other.z(); return *this; }
    219 
    220     bool isValid() const { return m_x != -1 && m_y != -1 && m_z != -1; }
    221 
    222     bool equal(const VBoxVersion &other) const { return (m_x == other.m_x) && (m_y == other.m_y) && (m_z == other.m_z); }
    223     bool operator==(const VBoxVersion &other) const { return equal(other); }
    224     bool operator!=(const VBoxVersion &other) const { return !equal(other); }
    225 
    226     bool operator<(const VBoxVersion &other) const
    227     {
    228         return (m_x <  other.m_x) ||
    229                (m_x == other.m_x && m_y <  other.m_y) ||
    230                (m_x == other.m_x && m_y == other.m_y && m_z <  other.m_z);
    231     }
    232     bool operator>(const VBoxVersion &other) const
    233     {
    234         return (m_x >  other.m_x) ||
    235                (m_x == other.m_x && m_y >  other.m_y) ||
    236                (m_x == other.m_x && m_y == other.m_y && m_z >  other.m_z);
    237     }
    238 
    239     QString toString() const
    240     {
    241         return QString("%1.%2.%3").arg(m_x).arg(m_y).arg(m_z);
    242     }
    243 
    244     int x() const { return m_x; }
    245     int y() const { return m_y; }
    246     int z() const { return m_z; }
    247 
    248 private:
    249 
    250     int m_x;
    251     int m_y;
    252     int m_z;
    253 };
    254 
    255197#ifdef Q_WS_MAC
    256198# include "VBoxUtils-darwin.h"
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxVersion.h

    r39486 r39488  
    22 *
    33 * VBox frontends: Qt GUI ("VirtualBox"):
    4  * Declarations of utility classes and functions
     4 * VBoxVersion class declaration
    55 */
    66
     
    1717 */
    1818
    19 #ifndef ___VBoxUtils_h___
    20 #define ___VBoxUtils_h___
    21 
    22 #include <iprt/types.h>
    23 
    24 /* Qt includes */
    25 #include <QMouseEvent>
    26 #include <QWidget>
    27 #include <QTextBrowser>
     19#ifndef ___VBoxVersion_h___
     20#define ___VBoxVersion_h___
    2821
    2922/**
    30  *  Simple class that filters out all key presses and releases
    31  *  got while the Alt key is pressed. For some very strange reason,
    32  *  QLineEdit accepts those combinations that are not used as accelerators,
    33  *  and inserts the corresponding characters to the entry field.
    34  */
    35 class QIAltKeyFilter : protected QObject
    36 {
    37     Q_OBJECT;
    38 
    39 public:
    40 
    41     QIAltKeyFilter (QObject *aParent) :QObject (aParent) {}
    42 
    43     void watchOn (QObject *aObject) { aObject->installEventFilter (this); }
    44 
    45 protected:
    46 
    47     bool eventFilter (QObject * /* aObject */, QEvent *aEvent)
    48     {
    49         if (aEvent->type() == QEvent::KeyPress || aEvent->type() == QEvent::KeyRelease)
    50         {
    51             QKeyEvent *pEvent = static_cast<QKeyEvent *> (aEvent);
    52             if (pEvent->modifiers() & Qt::AltModifier)
    53                 return true;
    54         }
    55         return false;
    56     }
    57 };
    58 
    59 /**
    60  *  Simple class which simulates focus-proxy rule redirecting widget
    61  *  assigned shortcut to desired widget.
    62  */
    63 class QIFocusProxy : protected QObject
    64 {
    65     Q_OBJECT;
    66 
    67 public:
    68 
    69     QIFocusProxy (QWidget *aFrom, QWidget *aTo)
    70         : QObject (aFrom), mFrom (aFrom), mTo (aTo)
    71     {
    72         mFrom->installEventFilter (this);
    73     }
    74 
    75 protected:
    76 
    77     bool eventFilter (QObject *aObject, QEvent *aEvent)
    78     {
    79         if (aObject == mFrom && aEvent->type() == QEvent::Shortcut)
    80         {
    81             mTo->setFocus();
    82             return true;
    83         }
    84         return QObject::eventFilter (aObject, aEvent);
    85     }
    86 
    87     QWidget *mFrom;
    88     QWidget *mTo;
    89 };
    90 
    91 /**
    92  *  QTextEdit reimplementation to feat some extended requirements.
    93  */
    94 class QRichTextEdit : public QTextEdit
    95 {
    96     Q_OBJECT;
    97 
    98 public:
    99 
    100     QRichTextEdit (QWidget *aParent) : QTextEdit (aParent) {}
    101 
    102     void setViewportMargins (int aLeft, int aTop, int aRight, int aBottom)
    103     {
    104         QTextEdit::setViewportMargins (aLeft, aTop, aRight, aBottom);
    105     }
    106 };
    107 
    108 /**
    109  *  QTextBrowser reimplementation to feat some extended requirements.
    110  */
    111 class QRichTextBrowser : public QTextBrowser
    112 {
    113     Q_OBJECT;
    114 
    115 public:
    116 
    117     QRichTextBrowser (QWidget *aParent) : QTextBrowser (aParent) {}
    118 
    119     void setViewportMargins (int aLeft, int aTop, int aRight, int aBottom)
    120     {
    121         QTextBrowser::setViewportMargins (aLeft, aTop, aRight, aBottom);
    122     }
    123 };
    124 
    125 class UIProxyManager
    126 {
    127 public:
    128 
    129     UIProxyManager(const QString &strProxySettings = QString())
    130         : m_fProxyEnabled(false), m_fAuthEnabled(false)
    131     {
    132         /* Parse settings: */
    133         if (!strProxySettings.isEmpty())
    134         {
    135             QStringList proxySettings = strProxySettings.split(",");
    136             if (proxySettings.size() > 0)
    137                 m_fProxyEnabled = proxySettings[0] == "proxyEnabled";
    138             if (proxySettings.size() > 1)
    139                 m_strProxyHost = proxySettings[1];
    140             if (proxySettings.size() > 2)
    141                 m_strProxyPort = proxySettings[2];
    142             if (proxySettings.size() > 3)
    143                 m_fAuthEnabled = proxySettings[3] == "authEnabled";
    144             if (proxySettings.size() > 4)
    145                 m_strAuthLogin = proxySettings[4];
    146             if (proxySettings.size() > 5)
    147                 m_strAuthPassword = proxySettings[5];
    148         }
    149     }
    150 
    151     QString toString() const
    152     {
    153         /* Serialize settings: */
    154         QString strResult;
    155         if (m_fProxyEnabled || !m_strProxyHost.isEmpty() || !m_strProxyPort.isEmpty() ||
    156             m_fAuthEnabled || !m_strAuthLogin.isEmpty() || !m_strAuthPassword.isEmpty())
    157         {
    158             QStringList proxySettings;
    159             proxySettings << QString(m_fProxyEnabled ? "proxyEnabled" : "proxyDisabled");
    160             proxySettings << m_strProxyHost;
    161             proxySettings << m_strProxyPort;
    162             proxySettings << QString(m_fAuthEnabled ? "authEnabled" : "authDisabled");
    163             proxySettings << m_strAuthLogin;
    164             proxySettings << m_strAuthPassword;
    165             strResult = proxySettings.join(",");
    166         }
    167         return strResult;
    168     }
    169 
    170     /* Proxy attribute getters: */
    171     bool proxyEnabled() const { return m_fProxyEnabled; }
    172     const QString& proxyHost() const { return m_strProxyHost; }
    173     const QString& proxyPort() const { return m_strProxyPort; }
    174     bool authEnabled() const { return m_fAuthEnabled; }
    175     const QString& authLogin() const { return m_strAuthLogin; }
    176     const QString& authPassword() const { return m_strAuthPassword; }
    177 
    178     /* Proxy attribute setters: */
    179     void setProxyEnabled(bool fProxyEnabled) { m_fProxyEnabled = fProxyEnabled; }
    180     void setProxyHost(const QString &strProxyHost) { m_strProxyHost = strProxyHost; }
    181     void setProxyPort(const QString &strProxyPort) { m_strProxyPort = strProxyPort; }
    182     void setAuthEnabled(bool fAuthEnabled) { m_fAuthEnabled = fAuthEnabled; }
    183     void setAuthLogin(const QString &strAuthLogin) { m_strAuthLogin = strAuthLogin; }
    184     void setAuthPassword(const QString &strAuthPassword) { m_strAuthPassword = strAuthPassword; }
    185 
    186 private:
    187 
    188     /* Proxy attribute variables: */
    189     bool m_fProxyEnabled;
    190     QString m_strProxyHost;
    191     QString m_strProxyPort;
    192     bool m_fAuthEnabled;
    193     QString m_strAuthLogin;
    194     QString m_strAuthPassword;
    195 };
    196 
    197 /**
    198  *  VBoxVersion represents VirtualBox version parser
     23 *  Represents VirtualBox version wrapper
    19924 */
    20025class VBoxVersion
     
    25378};
    25479
    255 #ifdef Q_WS_MAC
    256 # include "VBoxUtils-darwin.h"
    257 #endif /* Q_WS_MAC */
     80#endif // !___VBoxVersion_h___
    25881
    259 #endif // !___VBoxUtils_h___
    260 
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UIUpdateDefs.h

    r39473 r39488  
    2424
    2525/* Local includes: */
    26 #include "VBoxUtils.h"
     26#include "VBoxVersion.h"
    2727
    2828/* This structure is used to store retranslated reminder values. */
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