Mercurial > hg > svgui
comparison view/PaneStack.cpp @ 500:666cdcae5f0d
* Make it possible to switch panes by clicking on the current-pane
indicator area at left (#1935591)
author | Chris Cannam |
---|---|
date | Tue, 24 Feb 2009 12:02:19 +0000 |
parents | 5e6991aefdc5 |
children | e4e0ae491a48 |
comparison
equal
deleted
inserted
replaced
499:c5c478ee37b1 | 500:666cdcae5f0d |
---|---|
16 #include "PaneStack.h" | 16 #include "PaneStack.h" |
17 | 17 |
18 #include "Pane.h" | 18 #include "Pane.h" |
19 #include "widgets/PropertyStack.h" | 19 #include "widgets/PropertyStack.h" |
20 #include "widgets/IconLoader.h" | 20 #include "widgets/IconLoader.h" |
21 #include "widgets/ClickableLabel.h" | |
21 #include "layer/Layer.h" | 22 #include "layer/Layer.h" |
22 #include "ViewManager.h" | 23 #include "ViewManager.h" |
23 | 24 |
24 #include <QApplication> | 25 #include <QApplication> |
25 #include <QHBoxLayout> | 26 #include <QHBoxLayout> |
65 | 66 |
66 QGridLayout *layout = new QGridLayout; | 67 QGridLayout *layout = new QGridLayout; |
67 layout->setMargin(0); | 68 layout->setMargin(0); |
68 layout->setSpacing(2); | 69 layout->setSpacing(2); |
69 | 70 |
70 | |
71 // QHBoxLayout *layout = new QHBoxLayout; | |
72 | |
73 // QVBoxLayout *vlayout = new QVBoxLayout; | |
74 // layout->addLayout(vlayout); | |
75 // layout->setStretchFactor(vlayout, 0); | |
76 | |
77 QPushButton *xButton = new QPushButton(frame); | 71 QPushButton *xButton = new QPushButton(frame); |
78 xButton->setIcon(IconLoader().load("cross")); | 72 xButton->setIcon(IconLoader().load("cross")); |
79 xButton->setFixedSize(QSize(16, 16)); | 73 xButton->setFixedSize(QSize(16, 16)); |
80 xButton->setFlat(true); | 74 xButton->setFlat(true); |
81 layout->addWidget(xButton, 0, 0); | 75 layout->addWidget(xButton, 0, 0); |
82 // vlayout->setStretchFactor(xButton, 0); | |
83 connect(xButton, SIGNAL(clicked()), this, SLOT(paneDeleteButtonClicked())); | 76 connect(xButton, SIGNAL(clicked()), this, SLOT(paneDeleteButtonClicked())); |
84 | 77 |
85 QLabel *currentIndicator = new QLabel(frame); | 78 ClickableLabel *currentIndicator = new ClickableLabel(frame); |
86 // currentIndicator->setFixedWidth(QPainter(this).fontMetrics().width("x")); | 79 connect(currentIndicator, SIGNAL(clicked()), this, SLOT(indicatorClicked())); |
87 layout->addWidget(currentIndicator, 1, 0); | 80 layout->addWidget(currentIndicator, 1, 0); |
88 layout->setRowStretch(1, 20); | 81 layout->setRowStretch(1, 20); |
89 currentIndicator->setMinimumWidth(8); | 82 currentIndicator->setMinimumWidth(8); |
90 currentIndicator->setScaledContents(true); | 83 currentIndicator->setScaledContents(true); |
91 | 84 |
539 } | 532 } |
540 } | 533 } |
541 } | 534 } |
542 | 535 |
543 void | 536 void |
537 PaneStack::indicatorClicked() | |
538 { | |
539 QObject *s = sender(); | |
540 | |
541 for (size_t i = 0; i < m_panes.size(); ++i) { | |
542 if (m_panes[i].currentIndicator == s) { | |
543 setCurrentPane(m_panes[i].pane); | |
544 return; | |
545 } | |
546 } | |
547 } | |
548 | |
549 void | |
544 PaneStack::sizePanesEqually() | 550 PaneStack::sizePanesEqually() |
545 { | 551 { |
546 QList<int> sizes = m_splitter->sizes(); | 552 QList<int> sizes = m_splitter->sizes(); |
547 if (sizes.empty()) return; | 553 if (sizes.empty()) return; |
548 | 554 |