comparison widgets/SelectableLabel.cpp @ 441:f8fcfbe13c8f

* Avoid waiting on uninstalled transforms mutex in TransformFactory:: getTransformInstallStatus -- we can return TransformUnknown * Don't follow link in SelectableLabel when clicking to select it * Restore lost version number in plugin param dialog
author Chris Cannam
date Tue, 28 Oct 2008 18:06:06 +0000
parents 4a5fe5471282
children 1a0dfcbffaf1
comparison
equal deleted inserted replaced
440:08d6bc698d16 441:f8fcfbe13c8f
24 { 24 {
25 setTextFormat(Qt::RichText); 25 setTextFormat(Qt::RichText);
26 // setLineWidth(2); 26 // setLineWidth(2);
27 // setFixedWidth(480); 27 // setFixedWidth(480);
28 setupStyle(); 28 setupStyle();
29 setOpenExternalLinks(true);
29 } 30 }
30 31
31 SelectableLabel::~SelectableLabel() 32 SelectableLabel::~SelectableLabel()
32 { 33 {
33 } 34 }
57 void 58 void
58 SelectableLabel::setupStyle() 59 SelectableLabel::setupStyle()
59 { 60 {
60 QPalette palette = QApplication::palette(); 61 QPalette palette = QApplication::palette();
61 62
63 setTextInteractionFlags(Qt::LinksAccessibleByKeyboard |
64 Qt::LinksAccessibleByMouse |
65 Qt::TextSelectableByMouse);
66
62 if (m_selected) { 67 if (m_selected) {
63 setWordWrap(true); 68 setWordWrap(true);
64 setStyleSheet 69 setStyleSheet
65 (QString("QLabel:hover { background: %1; color: %3; } " 70 (QString("QLabel:hover { background: %1; color: %3; } "
66 "QLabel:!hover { background: %2; color: %3 } " 71 "QLabel:!hover { background: %2; color: %3 } "
75 "QLabel:!hover { background: %2; color: %3 } " 80 "QLabel:!hover { background: %2; color: %3 } "
76 "QLabel { padding: 7px }") 81 "QLabel { padding: 7px }")
77 .arg(palette.button().color().name()) 82 .arg(palette.button().color().name())
78 .arg(palette.light().color().name()) 83 .arg(palette.light().color().name())
79 .arg(palette.text().color().name())); 84 .arg(palette.text().color().name()));
80
81 // setStyleSheet("QLabel:hover { background: #e0e0e0; color: black; } QLabel:!hover { background: white; color: black } QLabel { padding: 7px }");
82 } 85 }
83 } 86 }
84 87
85 void 88 void
86 SelectableLabel::setSelected(bool s) 89 SelectableLabel::setSelected(bool s)
103 } 106 }
104 107
105 void 108 void
106 SelectableLabel::mousePressEvent(QMouseEvent *e) 109 SelectableLabel::mousePressEvent(QMouseEvent *e)
107 { 110 {
111 m_swallowRelease = !m_selected;
108 setSelected(true); 112 setSelected(true);
113 QLabel::mousePressEvent(e);
109 emit selectionChanged(); 114 emit selectionChanged();
110 } 115 }
111 116
112 void 117 void
113 SelectableLabel::mouseDoubleClickEvent(QMouseEvent *e) 118 SelectableLabel::mouseDoubleClickEvent(QMouseEvent *e)
114 { 119 {
115 std::cerr << "mouseDoubleClickEvent" << std::endl; 120 QLabel::mouseDoubleClickEvent(e);
116 emit doubleClicked(); 121 emit doubleClicked();
122 }
123
124 void
125 SelectableLabel::mouseReleaseEvent(QMouseEvent *e)
126 {
127 if (!m_swallowRelease) QLabel::mouseReleaseEvent(e);
128 m_swallowRelease = false;
117 } 129 }
118 130
119 void 131 void
120 SelectableLabel::enterEvent(QEvent *) 132 SelectableLabel::enterEvent(QEvent *)
121 { 133 {