VirtualBox

Changeset 81110 in vbox


Ignore:
Timestamp:
Oct 4, 2019 9:57:56 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
133735
Message:

FE/Qt: bugref:6143. Refactoring

Location:
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp

    r80048 r81110  
    2121#include <QColorDialog>
    2222#include <QComboBox>
     23#include <QDir>
    2324#include <QFile>
    2425#include <QGroupBox>
     
    2829#include <QLineEdit>
    2930#include <QListWidget>
    30 #include <QMenu>
    3131#include <QPainter>
    3232#include <QPicture>
    33 #include <QPushButton>
    3433#include <QSplitter>
    3534#include <QStatusBar>
     
    4342/* GUI includes: */
    4443#include "UIDesktopWidgetWatchdog.h"
    45 #include "QIDialogButtonBox.h"
    46 #include "QIFileDialog.h"
    4744#include "UIExtraDataManager.h"
    4845#include "UIIconPool.h"
     
    5148#include "UISession.h"
    5249#include "UISoftKeyboard.h"
    53 #include "QIToolButton.h"
    5450#include "UICommon.h"
    5551#ifdef VBOX_WS_MAC
    5652# include "VBoxUtils-darwin.h"
    5753#endif
    58 
    59 /* COM includes: */
    60 #include "CGuest.h"
    61 #include "CEventSource.h"
    6254
    6355/* Forward declarations: */
     
    154146    QUuid    m_uId;
    155147    QString  m_strName;
    156     QVector<UISoftKeyboardRow>  m_rows;
     148    QVector<UISoftKeyboardRow>    m_rows;
    157149    QMap<int, UISoftKeyboardKey*> m_lockKeys;
    158150};
    159151
    160152/*********************************************************************************************************************************
    161 *   UILayoutEditor definition.                                                                                  *
     153*   UIKeyboardLayoutEditor definition.                                                                                  *
    162154*********************************************************************************************************************************/
    163155
    164 class UILayoutEditor : public QIWithRetranslateUI<QWidget>
     156class UIKeyboardLayoutEditor : public QIWithRetranslateUI<QWidget>
    165157{
    166158    Q_OBJECT;
     
    174166public:
    175167
    176     UILayoutEditor(QWidget *pParent = 0);
     168    UIKeyboardLayoutEditor(QWidget *pParent = 0);
    177169    void setKey(UISoftKeyboardKey *pKey);
    178170    void setLayoutToEdit(UISoftKeyboardLayout *pLayout);
     
    196188private:
    197189
    198     void prepareObjects();
    199     void prepareConnections();
     190    void     prepareObjects();
     191    void     prepareConnections();
    200192    QWidget *prepareKeyCaptionEditWidgets();
    201     void resetKeyWidgets();
     193    void     resetKeyWidgets();
    202194    QGridLayout *m_pEditorLayout;
    203195    QToolButton *m_pGoBackButton;
    204     QGroupBox *m_pSelectedKeyGroupBox;
    205     QGroupBox *m_pCaptionEditGroupBox;
    206 
    207     QComboBox *m_pPhysicalLayoutCombo;
    208     QLabel *m_pTitleLabel;
    209     QLabel *m_pPhysicalLayoutLabel;
    210     QLabel *m_pLayoutNameLabel;
    211     QLabel *m_pLayoutNativeNameLabel;
    212     QLabel *m_pScanCodeLabel;
    213     QLabel *m_pPositionLabel;
    214     QLabel *m_pBaseCaptionLabel;
    215     QLabel *m_pShiftCaptionLabel;
    216     QLabel *m_pAltGrCaptionLabel;
    217     QLabel *m_pShiftAltGrCaptionLabel;
    218 
    219     QLineEdit *m_pLayoutNameEdit;
    220     QLineEdit *m_pLayoutNativeNameEdit;
    221     QLineEdit *m_pScanCodeEdit;
    222     QLineEdit *m_pPositionEdit;
    223     QLineEdit *m_pBaseCaptionEdit;
    224     QLineEdit *m_pShiftCaptionEdit;
    225     QLineEdit *m_pAltGrCaptionEdit;
    226     QLineEdit *m_pShiftAltGrCaptionEdit;
     196    QGroupBox   *m_pSelectedKeyGroupBox;
     197    QGroupBox   *m_pCaptionEditGroupBox;
     198    QComboBox   *m_pPhysicalLayoutCombo;
     199    QLabel      *m_pTitleLabel;
     200    QLabel      *m_pPhysicalLayoutLabel;
     201    QLabel      *m_pLayoutNameLabel;
     202    QLabel      *m_pLayoutNativeNameLabel;
     203    QLabel      *m_pScanCodeLabel;
     204    QLabel      *m_pPositionLabel;
     205    QLabel      *m_pBaseCaptionLabel;
     206    QLabel      *m_pShiftCaptionLabel;
     207    QLabel      *m_pAltGrCaptionLabel;
     208    QLabel      *m_pShiftAltGrCaptionLabel;
     209    QLineEdit   *m_pLayoutNameEdit;
     210    QLineEdit   *m_pLayoutNativeNameEdit;
     211    QLineEdit   *m_pScanCodeEdit;
     212    QLineEdit   *m_pPositionEdit;
     213    QLineEdit   *m_pBaseCaptionEdit;
     214    QLineEdit   *m_pShiftCaptionEdit;
     215    QLineEdit   *m_pAltGrCaptionEdit;
     216    QLineEdit   *m_pShiftAltGrCaptionEdit;
    227217
    228218    /** The key which is being currently edited. Might be Null. */
     
    238228class UILayoutSelector : public QIWithRetranslateUI<QWidget>
    239229{
     230
    240231    Q_OBJECT;
    241232
     
    285276class UISoftKeyboardRow
    286277{
     278
    287279public:
    288280
     
    382374    void updateState(bool fPressed);
    383375
    384     QRect      m_keyGeometry;
     376    QRect    m_keyGeometry;
    385377    /** Stores the key polygon in local coordinates. */
    386     QPolygon   m_polygon;
     378    QPolygon m_polygon;
    387379    KeyType  m_enmType;
    388380    KeyState m_enmState;
    389381    /** Key width as it is read from the xml file. */
    390     int        m_iWidth;
     382    int      m_iWidth;
    391383    /** Key height as it is read from the xml file. */
    392     int        m_iHeight;
    393     int        m_iSpaceWidthAfter;
    394     LONG       m_scanCode;
     384    int      m_iHeight;
     385    int      m_iSpaceWidthAfter;
     386    LONG     m_scanCode;
    395387    QVector<LONG> m_scanCodePrefix;
    396388
     
    404396
    405397    /** Key's position in the layout. */
    406     int        m_iPosition;
     398    int  m_iPosition;
    407399    UISoftKeyboardWidget  *m_pParentWidget;
    408 
    409400    LONG m_iUsageId;
    410401    LONG m_iUsagePage;
    411 
    412402    bool m_fIsNumPadKey;
    413403    bool m_fIsOSMenuKey;
     
    476466private:
    477467
     468    QMap<int, KeyCaptions> m_keyCapMap;
     469    QMap<int, QPicture>    m_pictureMap;
     470
    478471    /** The UUID of the physical layout used by this layout. */
    479     QUuid m_physicalLayoutUuid;
    480 
    481     QMap<int, KeyCaptions> m_keyCapMap;
    482     QMap<int, QPicture> m_pictureMap;
    483 
     472    QUuid   m_physicalLayoutUuid;
    484473    /** This is the English name of the layout. */
    485474    QString m_strName;
     
    497486class UISoftKeyboardColorTheme
    498487{
     488
    499489public:
    500490
     
    506496
    507497private:
     498
    508499    QVector<QColor> m_colors;
    509500};
     
    517508{
    518509    Q_OBJECT;
     510
    519511    enum Mode
    520512    {
     
    554546    void deleteCurrentLayout();
    555547    void toggleEditMode(bool fIsEditMode);
    556     /** Is called when the captions in UISoftKeyboardKey is changed and forward this changes to
    557       * corresponding UISoftKeyboardLayout */
    558     //void updateKeyCaptionsInLayout(UISoftKeyboardKey *pKey);
     548
    559549    void saveCurentLayoutToFile();
    560550    void copyCurentLayout();
     
    638628    int   m_iRightMargin;
    639629    int   m_iBottomMargin;
    640 
    641     Mode     m_enmMode;
    642 
    643     bool m_fHideOSMenuKeys;
    644     bool m_fHideNumPad;
     630    Mode  m_enmMode;
     631    bool  m_fHideOSMenuKeys;
     632    bool  m_fHideNumPad;
    645633};
    646634
     
    711699    virtual void retranslateUi() /* override */;
    712700
    713 private slots:
    714 
    715 
    716701private:
    717702
     
    847832
    848833/*********************************************************************************************************************************
    849 *   UILayoutEditor implementation.                                                                                  *
     834*   UIKeyboardLayoutEditor implementation.                                                                                  *
    850835*********************************************************************************************************************************/
    851836
    852 UILayoutEditor::UILayoutEditor(QWidget *pParent /* = 0 */)
     837UIKeyboardLayoutEditor::UIKeyboardLayoutEditor(QWidget *pParent /* = 0 */)
    853838    :QIWithRetranslateUI<QWidget>(pParent)
    854839    , m_pEditorLayout(0)
     
    882867}
    883868
    884 void UILayoutEditor::setKey(UISoftKeyboardKey *pKey)
     869void UIKeyboardLayoutEditor::setKey(UISoftKeyboardKey *pKey)
    885870{
    886871    if (m_pKey == pKey || !m_pLayout)
     
    923908}
    924909
    925 void UILayoutEditor::setLayoutToEdit(UISoftKeyboardLayout *pLayout)
     910void UIKeyboardLayoutEditor::setLayoutToEdit(UISoftKeyboardLayout *pLayout)
    926911{
    927912    if (m_pLayout == pLayout)
     
    947932}
    948933
    949 void UILayoutEditor::setPhysicalLayoutList(const QVector<UISoftKeyboardPhysicalLayout> &physicalLayouts)
     934void UIKeyboardLayoutEditor::setPhysicalLayoutList(const QVector<UISoftKeyboardPhysicalLayout> &physicalLayouts)
    950935{
    951936    if (!m_pPhysicalLayoutCombo)
     
    956941}
    957942
    958 void UILayoutEditor::retranslateUi()
     943void UIKeyboardLayoutEditor::retranslateUi()
    959944{
    960945    if (m_pTitleLabel)
     
    997982}
    998983
    999 void UILayoutEditor::sltKeyBaseCaptionChange(const QString &strCaption)
     984void UIKeyboardLayoutEditor::sltKeyBaseCaptionChange(const QString &strCaption)
    1000985{
    1001986    if (!m_pKey || !m_pLayout)
     
    1007992}
    1008993
    1009 void UILayoutEditor::sltKeyShiftCaptionChange(const QString &strCaption)
     994void UIKeyboardLayoutEditor::sltKeyShiftCaptionChange(const QString &strCaption)
    1010995{
    1011996    if (!m_pKey || !m_pLayout)
     
    10171002}
    10181003
    1019 void UILayoutEditor::sltKeyAltGrCaptionChange(const QString &strCaption)
     1004void UIKeyboardLayoutEditor::sltKeyAltGrCaptionChange(const QString &strCaption)
    10201005{
    10211006    if (!m_pKey || !m_pLayout)
     
    10271012}
    10281013
    1029 void UILayoutEditor::sltKeyShiftAltGrCaptionChange(const QString &strCaption)
     1014void UIKeyboardLayoutEditor::sltKeyShiftAltGrCaptionChange(const QString &strCaption)
    10301015{
    10311016    if (!m_pKey || !m_pLayout)
     
    10371022}
    10381023
    1039 void UILayoutEditor::sltPhysicalLayoutChanged()
     1024void UIKeyboardLayoutEditor::sltPhysicalLayoutChanged()
    10401025{
    10411026    if (!m_pPhysicalLayoutCombo || !m_pLayout)
     
    10471032}
    10481033
    1049 void UILayoutEditor::sltLayoutNameChanged(const QString &strName)
     1034void UIKeyboardLayoutEditor::sltLayoutNameChanged(const QString &strName)
    10501035{
    10511036    if (!m_pLayout || m_pLayout->name() == strName)
     
    10551040}
    10561041
    1057 void UILayoutEditor::sltLayoutNativeNameChanged(const QString &strNativeName)
     1042void UIKeyboardLayoutEditor::sltLayoutNativeNameChanged(const QString &strNativeName)
    10581043{
    10591044    if (!m_pLayout || m_pLayout->nativeName() == strNativeName)
     
    10631048}
    10641049
    1065 void UILayoutEditor::prepareObjects()
     1050void UIKeyboardLayoutEditor::prepareObjects()
    10661051{
    10671052    m_pEditorLayout = new QGridLayout;
     
    10741059    m_pGoBackButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    10751060    m_pGoBackButton->setIcon(UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowBack));
    1076     //m_pGoBackButton->setStyleSheet("QToolButton { border: 0px none black; margin: 0px 0px 0px 0px; } QToolButton::menu-indicator {image: none;}");
    10771061    m_pGoBackButton->setAutoRaise(true);
    10781062    m_pEditorLayout->addWidget(m_pGoBackButton, 0, 0, 1, 1);
    1079     connect(m_pGoBackButton, &QToolButton::clicked, this, &UILayoutEditor::sigGoBackButton);
     1063    connect(m_pGoBackButton, &QToolButton::clicked, this, &UIKeyboardLayoutEditor::sigGoBackButton);
    10801064    m_pTitleLabel = new QLabel;
    10811065    pTitleLayout->addWidget(m_pTitleLabel);
     
    10891073    m_pEditorLayout->addWidget(m_pLayoutNativeNameLabel, 2, 0, 1, 1);
    10901074    m_pEditorLayout->addWidget(m_pLayoutNativeNameEdit, 2, 1, 1, 1);
    1091     connect(m_pLayoutNativeNameEdit, &QLineEdit::textChanged, this, &UILayoutEditor::sltLayoutNativeNameChanged);
     1075    connect(m_pLayoutNativeNameEdit, &QLineEdit::textChanged, this, &UIKeyboardLayoutEditor::sltLayoutNativeNameChanged);
    10921076
    10931077
     
    10971081    m_pEditorLayout->addWidget(m_pLayoutNameLabel, 3, 0, 1, 1);
    10981082    m_pEditorLayout->addWidget(m_pLayoutNameEdit, 3, 1, 1, 1);
    1099     connect(m_pLayoutNameEdit, &QLineEdit::textChanged, this, &UILayoutEditor::sltLayoutNameChanged);
     1083    connect(m_pLayoutNameEdit, &QLineEdit::textChanged, this, &UIKeyboardLayoutEditor::sltLayoutNameChanged);
    11001084
    11011085
     
    11061090    m_pEditorLayout->addWidget(m_pPhysicalLayoutCombo, 4, 1, 1, 1);
    11071091    connect(m_pPhysicalLayoutCombo, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
    1108             this, &UILayoutEditor::sltPhysicalLayoutChanged);
     1092            this, &UIKeyboardLayoutEditor::sltPhysicalLayoutChanged);
    11091093
    11101094    m_pSelectedKeyGroupBox = new QGroupBox;
     
    11411125}
    11421126
    1143 QWidget *UILayoutEditor::prepareKeyCaptionEditWidgets()
     1127QWidget *UIKeyboardLayoutEditor::prepareKeyCaptionEditWidgets()
    11441128{
    11451129    m_pCaptionEditGroupBox = new QGroupBox;
     
    11591143    pCaptionEditorLayout->addWidget(m_pBaseCaptionLabel, 0, 0);
    11601144    pCaptionEditorLayout->addWidget(m_pBaseCaptionEdit, 0, 1);
    1161     connect(m_pBaseCaptionEdit, &QLineEdit::textChanged, this, &UILayoutEditor::sltKeyBaseCaptionChange);
     1145    connect(m_pBaseCaptionEdit, &QLineEdit::textChanged, this, &UIKeyboardLayoutEditor::sltKeyBaseCaptionChange);
    11621146
    11631147    m_pShiftCaptionLabel = new QLabel;
     
    11661150    pCaptionEditorLayout->addWidget(m_pShiftCaptionLabel, 1, 0);
    11671151    pCaptionEditorLayout->addWidget(m_pShiftCaptionEdit, 1, 1);
    1168     connect(m_pShiftCaptionEdit, &QLineEdit::textChanged, this, &UILayoutEditor::sltKeyShiftCaptionChange);
     1152    connect(m_pShiftCaptionEdit, &QLineEdit::textChanged, this, &UIKeyboardLayoutEditor::sltKeyShiftCaptionChange);
    11691153
    11701154    m_pAltGrCaptionLabel = new QLabel;
     
    11731157    pCaptionEditorLayout->addWidget(m_pAltGrCaptionLabel, 2, 0);
    11741158    pCaptionEditorLayout->addWidget(m_pAltGrCaptionEdit, 2, 1);
    1175     connect(m_pAltGrCaptionEdit, &QLineEdit::textChanged, this, &UILayoutEditor::sltKeyAltGrCaptionChange);
     1159    connect(m_pAltGrCaptionEdit, &QLineEdit::textChanged, this, &UIKeyboardLayoutEditor::sltKeyAltGrCaptionChange);
    11761160
    11771161    m_pShiftAltGrCaptionLabel = new QLabel;
     
    11801164    pCaptionEditorLayout->addWidget(m_pShiftAltGrCaptionLabel, 3, 0);
    11811165    pCaptionEditorLayout->addWidget(m_pShiftAltGrCaptionEdit, 3, 1);
    1182     connect(m_pShiftAltGrCaptionEdit, &QLineEdit::textChanged, this, &UILayoutEditor::sltKeyShiftAltGrCaptionChange);
     1166    connect(m_pShiftAltGrCaptionEdit, &QLineEdit::textChanged, this, &UIKeyboardLayoutEditor::sltKeyShiftAltGrCaptionChange);
    11831167
    11841168
     
    11891173}
    11901174
    1191 void UILayoutEditor::reset()
     1175void UIKeyboardLayoutEditor::reset()
    11921176{
    11931177    if (m_pLayoutNameEdit)
     
    11961180}
    11971181
    1198 void UILayoutEditor::resetKeyWidgets()
     1182void UIKeyboardLayoutEditor::resetKeyWidgets()
    11991183{
    12001184    if (m_pScanCodeEdit)
     
    13211305    m_pCloseButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    13221306    m_pCloseButton->setIcon(UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_DialogCancel));
    1323     //m_pCloseButton->setStyleSheet("QToolButton { border: 0px none black; margin: 0px 0px 0px 0px; } QToolButton::menu-indicator {image: none;}");
    13241307    m_pCloseButton->setAutoRaise(true);
    13251308    connect(m_pCloseButton, &QToolButton::clicked, this, &UILayoutSelector::sigCloseLayoutList);
     
    21232106            painter.drawPolygon(key.polygon());
    21242107
    2125             //m_pCurrentKeyboardLayout->drawText(key.position(), key.keyGeometry(), painter);
    21262108            m_pCurrentKeyboardLayout->drawTextInRect(key.position(), key.keyGeometry(), painter);
    21272109
     
    34863468    , m_pCenterWidget(pCenterWidget)
    34873469    , m_pMainLayout(0)
    3488     , m_pKeyboardWidget(0)
    34893470    , m_strMachineName(strMachineName)
    34903471    , m_pSplitter(0)
    34913472    , m_pSidePanelWidget(0)
     3473    , m_pKeyboardWidget(0)
    34923474    , m_pLayoutEditor(0)
    34933475    , m_pLayoutSelector(0)
     
    37193701        m_pSidePanelWidget->addWidget(m_pLayoutSelector);
    37203702
    3721     m_pLayoutEditor = new UILayoutEditor;
     3703    m_pLayoutEditor = new UIKeyboardLayoutEditor;
    37223704    if (m_pLayoutEditor)
    37233705        m_pSidePanelWidget->addWidget(m_pLayoutEditor);
     
    37663748    connect(m_pLayoutSelector, &UILayoutSelector::sigDeleteLayout, this, &UISoftKeyboard::sltDeleteLayout);
    37673749    connect(m_pLayoutSelector, &UILayoutSelector::sigCopyLayout, this, &UISoftKeyboard::sltCopyLayout);
    3768     connect(m_pLayoutEditor, &UILayoutEditor::sigGoBackButton, this, &UISoftKeyboard::sltShowLayoutSelector);
    3769     connect(m_pLayoutEditor, &UILayoutEditor::sigLayoutEdited, this, &UISoftKeyboard::sltLayoutEdited);
    3770     connect(m_pLayoutEditor, &UILayoutEditor::sigKeyCaptionsEdited, this, &UISoftKeyboard::sltKeyCaptionsEdited);
     3750    connect(m_pLayoutEditor, &UIKeyboardLayoutEditor::sigGoBackButton, this, &UISoftKeyboard::sltShowLayoutSelector);
     3751    connect(m_pLayoutEditor, &UIKeyboardLayoutEditor::sigLayoutEdited, this, &UISoftKeyboard::sltLayoutEdited);
     3752    connect(m_pLayoutEditor, &UIKeyboardLayoutEditor::sigKeyCaptionsEdited, this, &UISoftKeyboard::sltKeyCaptionsEdited);
    37713753
    37723754    connect(m_pStatusBarWidget, &UISoftKeyboardStatusBarWidget::sigShowHideSidePanel, this, &UISoftKeyboard::sltShowHideSidePanel);
     
    38123794    const QRect desktopRect = gpDesktop->availableGeometry(this);
    38133795    int iDefaultWidth = desktopRect.width() / 2;
    3814     int iDefaultHeight = iDefaultWidth * fKeyboardAspectRatio;//desktopRect.height() * 3 / 4;
     3796    int iDefaultHeight = iDefaultWidth * fKeyboardAspectRatio;
    38153797    QRect defaultGeometry(0, 0, iDefaultWidth, iDefaultHeight);
    38163798
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h

    r79781 r81110  
    2323
    2424/* Qt includes: */
    25 #include <QWidget>
     25#include <QMainWindow>
    2626
    2727/* COM includes: */
    28 #include "COMEnums.h"
    29 #include "CGuest.h"
    30 #include "CEventListener.h"
     28#include "COMDefs.h"
    3129
    3230/* GUI includes: */
    33 #include "QIManagerDialog.h"
    3431#include "QIWithRetranslateUI.h"
    3532
    3633/* Forward declarations: */
     34class CKeyboard;
    3735class QHBoxLayout;
    38 class QVBoxLayout;
    3936class QToolButton;
    40 class UILayoutEditor;
     37class UIKeyboardLayoutEditor;
    4138class UILayoutSelector;
    4239class UISession;
    4340class UISoftKeyboardKey;
    44 class UISoftKeyboardLayout;
    4541class UISoftKeyboardSettingsWidget;
    4642class UISoftKeyboardStatusBarWidget;
     
    107103    QWidget       *m_pCenterWidget;
    108104    QHBoxLayout   *m_pMainLayout;
    109     UISoftKeyboardWidget       *m_pKeyboardWidget;
    110     QString           m_strMachineName;
    111     QSplitter        *m_pSplitter;
    112     QStackedWidget   *m_pSidePanelWidget;
    113     UILayoutEditor  *m_pLayoutEditor;
    114     UILayoutSelector *m_pLayoutSelector;
     105    QString        m_strMachineName;
     106    QSplitter      *m_pSplitter;
     107    QStackedWidget *m_pSidePanelWidget;
     108    UISoftKeyboardWidget   *m_pKeyboardWidget;
     109    UIKeyboardLayoutEditor *m_pLayoutEditor;
     110    UILayoutSelector       *m_pLayoutSelector;
    115111
    116112    UISoftKeyboardSettingsWidget  *m_pSettingsWidget;
    117113    UISoftKeyboardStatusBarWidget *m_pStatusBarWidget;
    118 
    119114};
    120115
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette