Changeset 44520 in vbox
- Timestamp:
- Feb 1, 2013 7:21:56 PM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.ui
r43106 r44520 3 3 VBox frontends: Qt4 GUI ("VirtualBox"): 4 4 5 Copyright (C) 2008-201 2Oracle Corporation5 Copyright (C) 2008-2013 Oracle Corporation 6 6 7 7 This file is part of VirtualBox Open Source Edition (OSE), as … … 107 107 <customwidget> 108 108 <class>UIHotKeyEditor</class> 109 <extends>QL abel</extends>109 <extends>QLineEdit</extends> 110 110 <header>UIHotKeyEditor.h</header> 111 111 </customwidget> -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHotKeyEditor.cpp
r41689 r44520 7 7 8 8 /* 9 * Copyright (C) 2006-201 1Oracle Corporation9 * Copyright (C) 2006-2013 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 18 18 */ 19 19 20 /* Local includes */ 21 #include "UIHotKeyEditor.h" 22 #include "VBoxGlobal.h" 23 24 /* Global includes */ 20 /* Qt includes: */ 25 21 #include <QApplication> 26 22 #include <QStyleOption> … … 28 24 #include <QKeyEvent> 29 25 #include <QTimer> 26 27 /* GUI includes: */ 28 #include "UIHotKeyEditor.h" 29 #include "VBoxGlobal.h" 30 30 31 31 #ifdef Q_WS_WIN … … 299 299 300 300 UIHotKeyEditor::UIHotKeyEditor(QWidget *pParent) 301 : QL abel(pParent)301 : QLineEdit(pParent) 302 302 , m_pReleaseTimer(0) 303 303 , m_fStartNewSequence(true) … … 305 305 /* Configure widget: */ 306 306 setAttribute(Qt::WA_NativeWindow); 307 setFrameStyle(QFrame::StyledPanel | Sunken);308 307 setAlignment(Qt::AlignCenter); 309 setFocusPolicy(Qt::StrongFocus); 310 setAutoFillBackground(true); 311 312 /* Setup palette: */ 313 QPalette p = palette(); 314 p.setColor(QPalette::Active, QPalette::Foreground, p.color(QPalette::Active, QPalette::Text)); 315 p.setColor(QPalette::Active, QPalette::Background, p.color(QPalette::Active, QPalette::Base)); 316 setPalette(p); 308 setContextMenuPolicy(Qt::NoContextMenu); 309 connect(this, SIGNAL(selectionChanged()), this, SLOT(sltDeselect())); 317 310 318 311 /* Setup release-pending-keys timer: */ … … 365 358 } 366 359 367 QSize UIHotKeyEditor::sizeHint() const 368 { 369 ensurePolished(); 370 QFontMetrics fm(font()); 371 int h = qMax(fm.lineSpacing(), 14) + 2; 372 int w = fm.width('x') * 17; 373 int m = frameWidth() * 2; 374 QStyleOption option; 375 option.initFrom(this); 376 return (style()->sizeFromContents(QStyle::CT_LineEdit, &option, 377 QSize(w + m, h + m).expandedTo(QApplication::globalStrut()), 378 this)); 379 } 380 381 QSize UIHotKeyEditor::minimumSizeHint() const 382 { 383 ensurePolished(); 384 QFontMetrics fm = fontMetrics(); 385 int h = fm.height() + qMax(2, fm.leading()); 386 int w = fm.maxWidth(); 387 int m = frameWidth() * 2; 388 return QSize(w + m, h + m); 360 void UIHotKeyEditor::sltDeselect() 361 { 362 deselect(); 389 363 } 390 364 … … 501 475 #endif /* Q_WS_MAC */ 502 476 503 void UIHotKeyEditor::focusInEvent(QFocusEvent *pEvent) 504 { 505 QLabel::focusInEvent(pEvent); 506 507 QPalette p = palette(); 508 p.setColor(QPalette::Active, QPalette::Foreground, p.color(QPalette::Active, QPalette::HighlightedText)); 509 p.setColor(QPalette::Active, QPalette::Background, p.color(QPalette::Active, QPalette::Highlight)); 510 setPalette(p); 511 } 512 513 void UIHotKeyEditor::focusOutEvent(QFocusEvent *pEvent) 514 { 515 QLabel::focusOutEvent(pEvent); 516 517 QPalette p = palette(); 518 p.setColor(QPalette::Active, QPalette::Foreground, p.color(QPalette::Active, QPalette::Text)); 519 p.setColor(QPalette::Active, QPalette::Background, p.color(QPalette::Active, QPalette::Base)); 520 setPalette(p); 521 } 522 523 void UIHotKeyEditor::paintEvent(QPaintEvent *pEvent) 524 { 525 if (hasFocus()) 526 { 527 QStylePainter painter(this); 528 QStyleOptionFocusRect option; 529 option.initFrom(this); 530 option.backgroundColor = palette().color(QPalette::Background); 531 option.rect = contentsRect(); 532 painter.drawPrimitive(QStyle::PE_FrameFocusRect, option); 533 } 534 QLabel::paintEvent(pEvent); 477 void UIHotKeyEditor::keyPressEvent(QKeyEvent *pEvent) 478 { 479 /* Ignore most of key presses... */ 480 switch (pEvent->key()) 481 { 482 case Qt::Key_Tab: 483 case Qt::Key_Backtab: 484 case Qt::Key_Escape: 485 return QLineEdit::keyPressEvent(pEvent); 486 default: 487 break; 488 } 489 } 490 491 void UIHotKeyEditor::keyReleaseEvent(QKeyEvent *pEvent) 492 { 493 /* Ignore most of key presses... */ 494 switch (pEvent->key()) 495 { 496 case Qt::Key_Tab: 497 case Qt::Key_Backtab: 498 case Qt::Key_Escape: 499 return QLineEdit::keyReleaseEvent(pEvent); 500 default: 501 break; 502 } 503 } 504 505 void UIHotKeyEditor::mousePressEvent(QMouseEvent *pEvent) 506 { 507 /* Handle like for usual QWidget: */ 508 QWidget::mousePressEvent(pEvent); 509 } 510 511 void UIHotKeyEditor::mouseReleaseEvent(QMouseEvent *pEvent) 512 { 513 /* Handle like for usual QWidget: */ 514 QWidget::mouseReleaseEvent(pEvent); 535 515 } 536 516 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHotKeyEditor.h
r35862 r44520 6 6 7 7 /* 8 * Copyright (C) 2006-201 1Oracle Corporation8 * Copyright (C) 2006-2013 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 20 20 #define ___UIHotKeyEditor_h___ 21 21 22 /* Global includes*/23 #include <QL abel>22 /* Qt includes: */ 23 #include <QLineEdit> 24 24 #include <QMap> 25 25 #include <QSet> … … 48 48 } 49 49 50 class UIHotKeyEditor : public QL abel50 class UIHotKeyEditor : public QLineEdit 51 51 { 52 52 Q_OBJECT; … … 55 55 56 56 UIHotKeyEditor(QWidget *pParent); 57 virtual~UIHotKeyEditor();57 ~UIHotKeyEditor(); 58 58 59 59 void setCombo(const QString &strKeyCombo); 60 60 QString combo() const; 61 61 62 QSize sizeHint() const;63 QSize minimumSizeHint() const;64 65 62 public slots: 66 63 64 void sltDeselect(); 67 65 void sltClear(); 68 66 … … 80 78 #endif /* Q_WS_MAC */ 81 79 82 void focusInEvent(QFocusEvent *pEvent); 83 void focusOutEvent(QFocusEvent *pEvent); 84 void paintEvent(QPaintEvent *pEvent); 80 void keyPressEvent(QKeyEvent *pEvent); 81 void keyReleaseEvent(QKeyEvent *pEvent); 82 void mousePressEvent(QMouseEvent *pEvent); 83 void mouseReleaseEvent(QMouseEvent *pEvent); 85 84 86 85 private slots: … … 100 99 bool m_fStartNewSequence; 101 100 102 #ifdef RT_OS_DARWIN101 #ifdef Q_WS_MAC 103 102 /* The current modifier key mask. Used to figure out which modifier 104 103 * key was pressed when we get a kEventRawKeyModifiersChanged event. */ 105 104 uint32_t m_uDarwinKeyModifiers; 106 #endif /* RT_OS_DARWIN*/105 #endif /* Q_WS_MAC */ 107 106 }; 108 107
Note:
See TracChangeset
for help on using the changeset viewer.