VirtualBox

Ignore:
Timestamp:
Jun 18, 2014 1:43:25 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: 6065: Keyboard shortcut settings UI: Make sure shorcuts are updated upon change, do not wait for separate activate trigger.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
6 edited

Legend:

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

    r51493 r51649  
    478478        src/selector/UIVMDesktop.cpp \
    479479        src/settings/UISettingsDialogSpecific.cpp \
     480        src/settings/global/UIGlobalSettingsInput.cpp \
    480481        src/settings/machine/UIMachineSettingsStorage.cpp \
    481482        src/settings/machine/UIMachineSettingsUSB.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.cpp

    r51396 r51649  
    534534
    535535
     536/** Own QStyledItemDelegate implementation. */
     537class UIStyledItemDelegate : public QStyledItemDelegate
     538{
     539    Q_OBJECT;
     540
     541public:
     542
     543    /** Constructor. */
     544    UIStyledItemDelegate(QObject *pParent) : QStyledItemDelegate(pParent) {}
     545
     546private:
     547
     548    /** Returns the widget used to edit the item specified by @a index for editing.
     549      * The @a pParent widget and style @a option are used to control how the editor widget appears.
     550      * Besides Qt description copy-pasted above we are installing the hook to redirect editor's sigCommitData signal. */
     551    QWidget* createEditor(QWidget *pParent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
     552};
     553
     554QWidget* UIStyledItemDelegate::createEditor(QWidget *pParent, const QStyleOptionViewItem &option, const QModelIndex &index) const
     555{
     556    /* Call to base-class to get actual editor created: */
     557    QWidget *pEditor = QStyledItemDelegate::createEditor(pParent, option, index);
     558    /* All the stuff we actually need from UIStyledItemDelegate is to redirect this one signal: */
     559    if (qobject_cast<UIHotKeyEditor*>(pEditor) || qobject_cast<UIHostComboEditor*>(pEditor))
     560        connect(pEditor, SIGNAL(sigCommitData(QWidget*)), this, SIGNAL(commitData(QWidget*)));
     561    /* Return actual editor: */
     562    return pEditor;
     563}
     564
     565
    536566UIHotKeyTable::UIHotKeyTable(QWidget *pParent, UIHotKeyTableModel *pModel, const QString &strObjectName)
    537567    : QTableView(pParent)
     
    558588    horizontalHeader()->setResizeMode(UIHotKeyTableSection_Value, QHeaderView::Stretch);
    559589
    560     /* Register delegate editor: */
    561     if (QAbstractItemDelegate *pAbstractItemDelegate = itemDelegate())
    562     {
    563         if (QStyledItemDelegate *pStyledItemDelegate = qobject_cast<QStyledItemDelegate*>(pAbstractItemDelegate))
    564         {
    565             /* Create new item editor factory: */
    566             QItemEditorFactory *pNewItemEditorFactory = new QItemEditorFactory;
    567 
    568             /* Register UIHotKeyEditor as the UIHotKey editor: */
    569             int iHotKeyTypeId = qRegisterMetaType<UIHotKey>();
    570             QStandardItemEditorCreator<UIHotKeyEditor> *pHotKeyItemEditorCreator = new QStandardItemEditorCreator<UIHotKeyEditor>();
    571             pNewItemEditorFactory->registerEditor((QVariant::Type)iHotKeyTypeId, pHotKeyItemEditorCreator);
    572 
    573             /* Register UIHostComboEditor as the UIHostComboWrapper: */
    574             int iHostComboTypeId = qRegisterMetaType<UIHostComboWrapper>();
    575             QStandardItemEditorCreator<UIHostComboEditor> *pHostComboItemEditorCreator = new QStandardItemEditorCreator<UIHostComboEditor>();
    576             pNewItemEditorFactory->registerEditor((QVariant::Type)iHostComboTypeId, pHostComboItemEditorCreator);
    577 
    578             /* Set configured item editor factory for table delegate: */
    579             pStyledItemDelegate->setItemEditorFactory(pNewItemEditorFactory);
    580         }
    581     }
     590    /* Reinstall delegate: */
     591    delete itemDelegate();
     592    UIStyledItemDelegate *pStyledItemDelegate = new UIStyledItemDelegate(this);
     593    setItemDelegate(pStyledItemDelegate);
     594
     595    /* Create new item editor factory: */
     596    QItemEditorFactory *pNewItemEditorFactory = new QItemEditorFactory;
     597
     598    /* Register UIHotKeyEditor as the UIHotKey editor: */
     599    int iHotKeyTypeId = qRegisterMetaType<UIHotKey>();
     600    QStandardItemEditorCreator<UIHotKeyEditor> *pHotKeyItemEditorCreator = new QStandardItemEditorCreator<UIHotKeyEditor>();
     601    pNewItemEditorFactory->registerEditor((QVariant::Type)iHotKeyTypeId, pHotKeyItemEditorCreator);
     602
     603    /* Register UIHostComboEditor as the UIHostComboWrapper: */
     604    int iHostComboTypeId = qRegisterMetaType<UIHostComboWrapper>();
     605    QStandardItemEditorCreator<UIHostComboEditor> *pHostComboItemEditorCreator = new QStandardItemEditorCreator<UIHostComboEditor>();
     606    pNewItemEditorFactory->registerEditor((QVariant::Type)iHostComboTypeId, pHostComboItemEditorCreator);
     607
     608    /* Set configured item editor factory for table delegate: */
     609    pStyledItemDelegate->setItemEditorFactory(pNewItemEditorFactory);
    582610}
    583611
     
    592620}
    593621
     622#include "UIGlobalSettingsInput.moc"
     623
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHostComboEditor.cpp

    r51401 r51649  
    323323}
    324324
     325void UIHostComboEditor::sltCommitData()
     326{
     327    /* Commit data to the listener: */
     328    emit sigCommitData(this);
     329}
     330
    325331void UIHostComboEditor::prepare()
    326332{
     
    338344            /* Configure UIHostComboEditorPrivate instance: */
    339345            setFocusProxy(m_pEditor);
     346            connect(m_pEditor, SIGNAL(sigDataChanged()), this, SLOT(sltCommitData()));
    340347        }
    341348        /* Create 'clear' tool-button: */
     
    446453    /* Move the focus to text-field: */
    447454    setFocus();
     455    /* Notify data changed: */
     456    emit sigDataChanged();
    448457}
    449458
     
    704713        if (m_pressedKeys.isEmpty())
    705714            m_fStartNewSequence = true;
     715        /* Notify data changed: */
     716        emit sigDataChanged();
    706717    }
    707718    /* Make sure the user see what happens: */
     
    732743            m_pressedKeys << iKeyCode;
    733744            m_shownKeys.insert(iKeyCode, UINativeHotKey::toString(iKeyCode));
    734 
    735745            /* Remember what we already started a sequence: */
    736746            m_fStartNewSequence = false;
     747            /* Notify data changed: */
     748            emit sigDataChanged();
    737749        }
    738750    }
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHostComboEditor.h

    r50553 r51649  
    8282    Q_PROPERTY(UIHostComboWrapper combo READ combo WRITE setCombo USER true);
    8383
     84signals:
     85
     86    /** Notifies listener about data should be committed. */
     87    void sigCommitData(QWidget *pThis);
     88
    8489public:
    8590
    8691    /** Constructs host-combo editor for passed @a pParent. */
    8792    UIHostComboEditor(QWidget *pParent);
     93
     94private slots:
     95
     96    /** Notifies listener about data should be committed. */
     97    void sltCommitData();
    8898
    8999private:
     
    110120{
    111121    Q_OBJECT;
     122
     123signals:
     124
     125    /** Notifies parent about data changed. */
     126    void sigDataChanged();
    112127
    113128public:
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHotKeyEditor.cpp

    r50041 r51649  
    152152    /* Move the focut to text-field: */
    153153    m_pLineEdit->setFocus();
     154    /* Commit data to the listener: */
     155    emit sigCommitData(this);
    154156}
    155157
     
    162164    /* Move the focut to text-field: */
    163165    m_pLineEdit->setFocus();
     166    /* Commit data to the listener: */
     167    emit sigCommitData(this);
    164168}
    165169
     
    436440    /* Save what we've got: */
    437441    m_hotKey.setSequence(strSequence);
     442    /* Commit data to the listener: */
     443    emit sigCommitData(this);
    438444}
    439445
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHotKeyEditor.h

    r50041 r51649  
    9494    Q_PROPERTY(UIHotKey hotKey READ hotKey WRITE setHotKey USER true);
    9595
     96signals:
     97
     98    /** Notifies listener about data should be committed. */
     99    void sigCommitData(QWidget *pThis);
     100
    96101public:
    97102
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