@@ -34,6 +34,7 | |||
|
34 | 34 | #include <QDir> |
|
35 | 35 | #include <QFileDialog> |
|
36 | 36 | #include <QToolBar> |
|
37 | #include <QToolButton> | |
|
37 | 38 | #include <memory.h> |
|
38 | 39 | |
|
39 | 40 | //#include <omp.h> |
@@ -116,95 +117,53 MainWindow::MainWindow(QWidget *parent) | |||
|
116 | 117 | openLeftInspectorAction->setCheckable(true); |
|
117 | 118 | openRightInspectorAction->setCheckable(true); |
|
118 | 119 | |
|
120 | auto openInspector = [this](bool checked, bool right, auto action) { | |
|
119 | 121 | |
|
120 | // NOTE: These lambda could be factorized. Be careful of theirs parameters | |
|
121 | // Lambda that defines what's happened when clicking on the leftSidePaneInspector open button | |
|
122 | auto openLeftInspector = [this, openLeftInspectorAction](bool checked) { | |
|
122 | action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"}); | |
|
123 | 123 | |
|
124 | if (checked) { | |
|
125 | openLeftInspectorAction->setIcon(QIcon{ | |
|
126 | ":/icones/next.png", | |
|
127 | }); | |
|
128 | } | |
|
129 | else { | |
|
130 | openLeftInspectorAction->setIcon(QIcon{ | |
|
131 | ":/icones/previous.png", | |
|
132 | }); | |
|
133 | } | |
|
124 | auto &lastInspectorSize | |
|
125 | = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize; | |
|
126 | ||
|
127 | auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size() | |
|
128 | : m_Ui->leftMainInspectorWidget->size(); | |
|
134 | 129 | |
|
135 | 130 | // Update of the last opened geometry |
|
136 | 131 | if (checked) { |
|
137 |
|
|
|
132 | lastInspectorSize = nextInspectorSize; | |
|
138 | 133 | } |
|
139 | 134 | |
|
140 |
auto startSize = |
|
|
135 | auto startSize = lastInspectorSize; | |
|
141 | 136 | auto endSize = startSize; |
|
142 | 137 | endSize.setWidth(0); |
|
143 | 138 | |
|
139 | auto splitterInspectorIndex | |
|
140 | = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX; | |
|
141 | ||
|
144 | 142 | auto currentSizes = m_Ui->splitter->sizes(); |
|
145 | 143 | if (checked) { |
|
146 | 144 | // adjust sizes individually here, e.g. |
|
147 | currentSizes[LEFTMAININSPECTORWIDGETSPLITTERINDEX] | |
|
148 |
|
|
|
149 | currentSizes[VIEWPLITTERINDEX] += impl->m_LastOpenLeftInspectorSize.width(); | |
|
145 | currentSizes[splitterInspectorIndex] -= lastInspectorSize.width(); | |
|
146 | currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width(); | |
|
150 | 147 | m_Ui->splitter->setSizes(currentSizes); |
|
151 | 148 | } |
|
152 | 149 | else { |
|
153 | 150 | // adjust sizes individually here, e.g. |
|
154 | currentSizes[LEFTMAININSPECTORWIDGETSPLITTERINDEX] | |
|
155 |
|
|
|
156 | currentSizes[VIEWPLITTERINDEX] -= impl->m_LastOpenLeftInspectorSize.width(); | |
|
151 | currentSizes[splitterInspectorIndex] += lastInspectorSize.width(); | |
|
152 | currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width(); | |
|
157 | 153 | m_Ui->splitter->setSizes(currentSizes); |
|
158 | 154 | } |
|
159 | 155 | |
|
160 | 156 | }; |
|
161 | 157 | |
|
162 | // Lambda that defines what's happened when clicking on the SidePaneInspector open button | |
|
163 | auto openRightInspector = [this, openRightInspectorAction](bool checked) { | |
|
164 | 158 | |
|
165 | if (checked) { | |
|
166 | openRightInspectorAction->setIcon(QIcon{ | |
|
167 | ":/icones/previous.png", | |
|
159 | connect(openLeftInspectorAction, &QAction::triggered, | |
|
160 | [openInspector, openLeftInspectorAction](bool checked) { | |
|
161 | openInspector(checked, false, openLeftInspectorAction); | |
|
168 | 162 | }); |
|
169 | } | |
|
170 | else { | |
|
171 | openRightInspectorAction->setIcon(QIcon{ | |
|
172 | ":/icones/next.png", | |
|
163 | connect(openRightInspectorAction, &QAction::triggered, | |
|
164 | [openInspector, openRightInspectorAction](bool checked) { | |
|
165 | openInspector(checked, true, openRightInspectorAction); | |
|
173 | 166 | }); |
|
174 | } | |
|
175 | ||
|
176 | ||
|
177 | // Update of the last opened geometry | |
|
178 | if (checked) { | |
|
179 | impl->m_LastOpenRightInspectorSize = m_Ui->rightMainInspectorWidget->size(); | |
|
180 | } | |
|
181 | ||
|
182 | auto startSize = impl->m_LastOpenRightInspectorSize; | |
|
183 | auto endSize = startSize; | |
|
184 | endSize.setWidth(0); | |
|
185 | ||
|
186 | auto currentSizes = m_Ui->splitter->sizes(); | |
|
187 | if (checked) { | |
|
188 | // adjust sizes individually here, e.g. | |
|
189 | currentSizes[RIGHTMAININSPECTORWIDGETSPLITTERINDEX] | |
|
190 | -= impl->m_LastOpenRightInspectorSize.width(); | |
|
191 | currentSizes[VIEWPLITTERINDEX] += impl->m_LastOpenRightInspectorSize.width(); | |
|
192 | m_Ui->splitter->setSizes(currentSizes); | |
|
193 | } | |
|
194 | else { | |
|
195 | // adjust sizes individually here, e.g. | |
|
196 | currentSizes[RIGHTMAININSPECTORWIDGETSPLITTERINDEX] | |
|
197 | += impl->m_LastOpenRightInspectorSize.width(); | |
|
198 | currentSizes[VIEWPLITTERINDEX] -= impl->m_LastOpenRightInspectorSize.width(); | |
|
199 | m_Ui->splitter->setSizes(currentSizes); | |
|
200 | } | |
|
201 | ||
|
202 | }; | |
|
203 | ||
|
204 | ||
|
205 | connect(openLeftInspectorAction, &QAction::triggered, openLeftInspector); | |
|
206 | connect(openRightInspectorAction, &QAction::triggered, openRightInspector); | |
|
207 | ||
|
208 | 167 | |
|
209 | 168 | this->menuBar()->addAction(tr("File")); |
|
210 | 169 | auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar")); |
General Comments 0
You need to be logged in to leave comments.
Login now