- Timestamp:
- Jun 18, 2014 1:43:25 PM (10 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r51493 r51649 478 478 src/selector/UIVMDesktop.cpp \ 479 479 src/settings/UISettingsDialogSpecific.cpp \ 480 src/settings/global/UIGlobalSettingsInput.cpp \ 480 481 src/settings/machine/UIMachineSettingsStorage.cpp \ 481 482 src/settings/machine/UIMachineSettingsUSB.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.cpp
r51396 r51649 534 534 535 535 536 /** Own QStyledItemDelegate implementation. */ 537 class UIStyledItemDelegate : public QStyledItemDelegate 538 { 539 Q_OBJECT; 540 541 public: 542 543 /** Constructor. */ 544 UIStyledItemDelegate(QObject *pParent) : QStyledItemDelegate(pParent) {} 545 546 private: 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 554 QWidget* 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 536 566 UIHotKeyTable::UIHotKeyTable(QWidget *pParent, UIHotKeyTableModel *pModel, const QString &strObjectName) 537 567 : QTableView(pParent) … … 558 588 horizontalHeader()->setResizeMode(UIHotKeyTableSection_Value, QHeaderView::Stretch); 559 589 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); 582 610 } 583 611 … … 592 620 } 593 621 622 #include "UIGlobalSettingsInput.moc" 623 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHostComboEditor.cpp
r51401 r51649 323 323 } 324 324 325 void UIHostComboEditor::sltCommitData() 326 { 327 /* Commit data to the listener: */ 328 emit sigCommitData(this); 329 } 330 325 331 void UIHostComboEditor::prepare() 326 332 { … … 338 344 /* Configure UIHostComboEditorPrivate instance: */ 339 345 setFocusProxy(m_pEditor); 346 connect(m_pEditor, SIGNAL(sigDataChanged()), this, SLOT(sltCommitData())); 340 347 } 341 348 /* Create 'clear' tool-button: */ … … 446 453 /* Move the focus to text-field: */ 447 454 setFocus(); 455 /* Notify data changed: */ 456 emit sigDataChanged(); 448 457 } 449 458 … … 704 713 if (m_pressedKeys.isEmpty()) 705 714 m_fStartNewSequence = true; 715 /* Notify data changed: */ 716 emit sigDataChanged(); 706 717 } 707 718 /* Make sure the user see what happens: */ … … 732 743 m_pressedKeys << iKeyCode; 733 744 m_shownKeys.insert(iKeyCode, UINativeHotKey::toString(iKeyCode)); 734 735 745 /* Remember what we already started a sequence: */ 736 746 m_fStartNewSequence = false; 747 /* Notify data changed: */ 748 emit sigDataChanged(); 737 749 } 738 750 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHostComboEditor.h
r50553 r51649 82 82 Q_PROPERTY(UIHostComboWrapper combo READ combo WRITE setCombo USER true); 83 83 84 signals: 85 86 /** Notifies listener about data should be committed. */ 87 void sigCommitData(QWidget *pThis); 88 84 89 public: 85 90 86 91 /** Constructs host-combo editor for passed @a pParent. */ 87 92 UIHostComboEditor(QWidget *pParent); 93 94 private slots: 95 96 /** Notifies listener about data should be committed. */ 97 void sltCommitData(); 88 98 89 99 private: … … 110 120 { 111 121 Q_OBJECT; 122 123 signals: 124 125 /** Notifies parent about data changed. */ 126 void sigDataChanged(); 112 127 113 128 public: -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHotKeyEditor.cpp
r50041 r51649 152 152 /* Move the focut to text-field: */ 153 153 m_pLineEdit->setFocus(); 154 /* Commit data to the listener: */ 155 emit sigCommitData(this); 154 156 } 155 157 … … 162 164 /* Move the focut to text-field: */ 163 165 m_pLineEdit->setFocus(); 166 /* Commit data to the listener: */ 167 emit sigCommitData(this); 164 168 } 165 169 … … 436 440 /* Save what we've got: */ 437 441 m_hotKey.setSequence(strSequence); 442 /* Commit data to the listener: */ 443 emit sigCommitData(this); 438 444 } 439 445 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHotKeyEditor.h
r50041 r51649 94 94 Q_PROPERTY(UIHotKey hotKey READ hotKey WRITE setHotKey USER true); 95 95 96 signals: 97 98 /** Notifies listener about data should be committed. */ 99 void sigCommitData(QWidget *pThis); 100 96 101 public: 97 102
Note:
See TracChangeset
for help on using the changeset viewer.