src/main.cpp

changeset 231
a9bf6bab5ea2
parent 230
a1f3f7d9078b
child 232
8efa3a33172e
equal deleted inserted replaced
230:a1f3f7d9078b 231:a9bf6bab5ea2
250 for (auto data : ::renderStyleButtons) { 250 for (auto data : ::renderStyleButtons) {
251 QAction* action = data.memberInstance(ui); 251 QAction* action = data.memberInstance(ui);
252 action->setChecked(renderPreferences->style == data.payload); 252 action->setChecked(renderPreferences->style == data.payload);
253 } 253 }
254 ui->actionDrawAxes->setChecked(renderPreferences->drawAxes); 254 ui->actionDrawAxes->setChecked(renderPreferences->drawAxes);
255 ui->actionWireframe->setChecked(renderPreferences->wireframe);
255 }; 256 };
256 257
257 static gl::RenderPreferences loadRenderPreferences() 258 static gl::RenderPreferences loadRenderPreferences()
258 { 259 {
259 return gl::RenderPreferences{ 260 return gl::RenderPreferences{
262 .backgroundColor = setting<Setting::BackgroundColor>(), 263 .backgroundColor = setting<Setting::BackgroundColor>(),
263 .selectedColor = setting<Setting::SelectedColor>(), 264 .selectedColor = setting<Setting::SelectedColor>(),
264 .lineThickness = setting<Setting::LineThickness>(), 265 .lineThickness = setting<Setting::LineThickness>(),
265 .lineAntiAliasing = setting<Setting::LineAntiAliasing>(), 266 .lineAntiAliasing = setting<Setting::LineAntiAliasing>(),
266 .drawAxes = setting<Setting::DrawAxes>(), 267 .drawAxes = setting<Setting::DrawAxes>(),
268 .wireframe = setting<Setting::Wireframe>(),
267 }; 269 };
268 } 270 }
269 271
270 void initializeTools(Ui_MainWindow* ui, QWidget* parent) 272 void initializeTools(Ui_MainWindow* ui, QWidget* parent)
271 { 273 {
340 const auto saveSettings = [&]{ 342 const auto saveSettings = [&]{
341 setSetting<Setting::MainWindowGeometry>(mainWindow.saveGeometry()); 343 setSetting<Setting::MainWindowGeometry>(mainWindow.saveGeometry());
342 setSetting<Setting::RecentFiles>(recentlyOpenedFiles); 344 setSetting<Setting::RecentFiles>(recentlyOpenedFiles);
343 setSetting<Setting::RenderStyle>(renderPreferences.style); 345 setSetting<Setting::RenderStyle>(renderPreferences.style);
344 setSetting<Setting::DrawAxes>(renderPreferences.drawAxes); 346 setSetting<Setting::DrawAxes>(renderPreferences.drawAxes);
347 setSetting<Setting::Wireframe>(renderPreferences.wireframe);
345 libraries.storeToSettings(); 348 libraries.storeToSettings();
346 }; 349 };
347 const auto updateRecentlyOpenedDocumentsMenu = [&]{ 350 const auto updateRecentlyOpenedDocumentsMenu = [&]{
348 rebuildRecentFilesMenu(ui.menuRecentFiles, recentlyOpenedFiles, &mainWindow); 351 rebuildRecentFilesMenu(ui.menuRecentFiles, recentlyOpenedFiles, &mainWindow);
349 for (QAction* action : ui.menuRecentFiles->findChildren<QAction*>()) { 352 for (QAction* action : ui.menuRecentFiles->findChildren<QAction*>()) {
560 QObject::connect(ui.actionDrawAxes, &QAction::triggered, [&](bool drawAxes){ 563 QObject::connect(ui.actionDrawAxes, &QAction::triggered, [&](bool drawAxes){
561 renderPreferences.drawAxes = drawAxes; 564 renderPreferences.drawAxes = drawAxes;
562 saveSettings(); 565 saveSettings();
563 updateRenderPreferences(&ui, &renderPreferences, &documents); 566 updateRenderPreferences(&ui, &renderPreferences, &documents);
564 }); 567 });
568 QObject::connect(ui.actionWireframe, &QAction::triggered, [&](bool enabled){
569 renderPreferences.wireframe = enabled;
570 saveSettings();
571 updateRenderPreferences(&ui, &renderPreferences, &documents);
572 });
565 for (auto data : ::renderStyleButtons) { 573 for (auto data : ::renderStyleButtons) {
566 QAction* action = data.memberInstance(&ui); 574 QAction* action = data.memberInstance(&ui);
567 QObject::connect(action, &QAction::triggered, [&, data]{ 575 QObject::connect(action, &QAction::triggered, [&, data]{
568 renderPreferences.style = data.payload; 576 renderPreferences.style = data.payload;
569 saveSettings(); 577 saveSettings();

mercurial