Mercurial > hg > svgui
comparison widgets/TransformFinder.cpp @ 426:6bf3c906b7a5
* Connect up Up and Down arrows in the transform finder
author | Chris Cannam |
---|---|
date | Tue, 30 Sep 2008 10:33:28 +0000 |
parents | 4a5fe5471282 |
children | 4711b400f976 |
comparison
equal
deleted
inserted
replaced
425:4a5fe5471282 | 426:6bf3c906b7a5 |
---|---|
26 #include <QDialogButtonBox> | 26 #include <QDialogButtonBox> |
27 #include <QScrollArea> | 27 #include <QScrollArea> |
28 #include <QApplication> | 28 #include <QApplication> |
29 #include <QDesktopWidget> | 29 #include <QDesktopWidget> |
30 #include <QTimer> | 30 #include <QTimer> |
31 #include <QAction> | |
31 | 32 |
32 TransformFinder::TransformFinder(QWidget *parent) : | 33 TransformFinder::TransformFinder(QWidget *parent) : |
33 QDialog(parent), | 34 QDialog(parent), |
34 m_resultsFrame(0), | 35 m_resultsFrame(0), |
35 m_resultsLayout(0) | 36 m_resultsLayout(0) |
70 m_resultsFrame->setLayout(m_resultsLayout); | 71 m_resultsFrame->setLayout(m_resultsLayout); |
71 m_resultsScroll->setWidget(m_resultsFrame); | 72 m_resultsScroll->setWidget(m_resultsFrame); |
72 m_resultsFrame->show(); | 73 m_resultsFrame->show(); |
73 } | 74 } |
74 | 75 |
76 QAction *up = new QAction(tr("Up"), this); | |
77 up->setShortcut(tr("Up")); | |
78 connect(up, SIGNAL(triggered()), this, SLOT(up())); | |
79 addAction(up); | |
80 | |
81 QAction *down = new QAction(tr("Down"), this); | |
82 down->setShortcut(tr("Down")); | |
83 connect(down, SIGNAL(triggered()), this, SLOT(down())); | |
84 addAction(down); | |
85 | |
75 QDesktopWidget *desktop = QApplication::desktop(); | 86 QDesktopWidget *desktop = QApplication::desktop(); |
76 QRect available = desktop->availableGeometry(); | 87 QRect available = desktop->availableGeometry(); |
77 | 88 |
78 int width = available.width() / 2; | 89 int width = available.width() / 2; |
79 int height = available.height() / 2; | 90 int height = available.height() / 2; |
176 selectedText += tr("<b>%1</b><br>") | 187 selectedText += tr("<b>%1</b><br>") |
177 .arg(XmlExportable::encodeEntities(desc.name)); | 188 .arg(XmlExportable::encodeEntities(desc.name)); |
178 selectedText += tr("<small>%1</small>") | 189 selectedText += tr("<small>%1</small>") |
179 .arg(XmlExportable::encodeEntities(desc.longDescription)); | 190 .arg(XmlExportable::encodeEntities(desc.longDescription)); |
180 | 191 |
181 selectedText += tr("<ul><small>"); | 192 selectedText += tr("<br><small>"); |
182 selectedText += tr("<li>Plugin type: %1</li>") | 193 selectedText += tr(" — Plugin type: %1<br>") |
183 .arg(XmlExportable::encodeEntities(desc.type)); | 194 .arg(XmlExportable::encodeEntities(desc.type)); |
184 selectedText += tr("<li>Category: %1</li>") | 195 selectedText += tr(" — Category: %1<br>") |
185 .arg(XmlExportable::encodeEntities(desc.category)); | 196 .arg(XmlExportable::encodeEntities(desc.category)); |
186 selectedText += tr("<li>System identifier: %1</li>") | 197 selectedText += tr(" — System identifier: %1") |
187 .arg(XmlExportable::encodeEntities(desc.identifier)); | 198 .arg(XmlExportable::encodeEntities(desc.identifier)); |
188 selectedText += tr("</small></ul>"); | 199 selectedText += tr("</small>"); |
189 | 200 |
190 if (i >= m_labels.size()) { | 201 if (i >= m_labels.size()) { |
191 SelectableLabel *label = new SelectableLabel(m_resultsFrame); | 202 SelectableLabel *label = new SelectableLabel(m_resultsFrame); |
192 m_resultsLayout->addWidget(label); | 203 m_resultsLayout->addWidget(label); |
193 connect(label, SIGNAL(selectionChanged()), this, | 204 connect(label, SIGNAL(selectionChanged()), this, |
243 TransformFinder::getTransform() const | 254 TransformFinder::getTransform() const |
244 { | 255 { |
245 return m_selectedTransform; | 256 return m_selectedTransform; |
246 } | 257 } |
247 | 258 |
259 void | |
260 TransformFinder::up() | |
261 { | |
262 for (int i = 0; i < m_labels.size(); ++i) { | |
263 if (!m_labels[i]->isVisible()) continue; | |
264 if (m_labels[i]->objectName() == m_selectedTransform) { | |
265 if (i > 0) { | |
266 m_labels[i]->setSelected(false); | |
267 m_labels[i-1]->setSelected(true); | |
268 m_selectedTransform = m_labels[i-1]->objectName(); | |
269 } | |
270 return; | |
271 } | |
272 } | |
273 } | |
274 | |
275 void | |
276 TransformFinder::down() | |
277 { | |
278 for (int i = 0; i < m_labels.size(); ++i) { | |
279 if (!m_labels[i]->isVisible()) continue; | |
280 if (m_labels[i]->objectName() == m_selectedTransform) { | |
281 if (i+1 < m_labels.size() && | |
282 m_labels[i+1]->isVisible()) { | |
283 m_labels[i]->setSelected(false); | |
284 m_labels[i+1]->setSelected(true); | |
285 m_selectedTransform = m_labels[i+1]->objectName(); | |
286 } | |
287 return; | |
288 } | |
289 } | |
290 } | |
291 |