src/mainwindow.cpp

changeset 1353
48374309f3d1
parent 1350
eb2d3bc4fc73
child 1369
1e2391b78d17
equal deleted inserted replaced
1352:55fbbd4bdf86 1353:48374309f3d1
83 83
84 m_quickColors = m_guiUtilities->loadQuickColorList(); 84 m_quickColors = m_guiUtilities->loadQuickColorList();
85 updateActions(); 85 updateActions();
86 86
87 // Connect all actions and save default sequences 87 // Connect all actions and save default sequences
88 applyToActions ([&](QAction* act) 88 applyToActions([&](QAction* action)
89 { 89 {
90 connect (act, SIGNAL (triggered()), this, SLOT (actionTriggered())); 90 connect(action, SIGNAL (triggered()), this, SLOT (actionTriggered()));
91 m_defaultShortcuts[act] = act->shortcut(); 91 m_defaultShortcuts[action] = action->shortcut();
92 }); 92 });
93 connect( 93 connect(
94 ui.header, 94 ui.header,
95 &HeaderEdit::descriptionChanged, 95 &HeaderEdit::descriptionChanged,
96 this, 96 this,
774 774
775 // --------------------------------------------------------------------------------------------------------------------- 775 // ---------------------------------------------------------------------------------------------------------------------
776 // 776 //
777 void MainWindow::saveShortcuts() 777 void MainWindow::saveShortcuts()
778 { 778 {
779 applyToActions ([&](QAction* act) 779 applyToActions([&](QAction* action)
780 { 780 {
781 QString const key = "shortcut_" + act->objectName(); 781 QString const key = "shortcut_" + action->objectName();
782 782
783 if (m_defaultShortcuts[act] != act->shortcut()) 783 if (m_defaultShortcuts[action] != action->shortcut())
784 settingsObject().setValue(key, act->shortcut()); 784 settingsObject().setValue(key, action->shortcut());
785 else 785 else
786 settingsObject().remove(key); 786 settingsObject().remove(key);
787 }); 787 });
788 } 788 }
789 789
790 // --------------------------------------------------------------------------------------------------------------------- 790 // ---------------------------------------------------------------------------------------------------------------------
791 // 791 //
792 void MainWindow::applyToActions (std::function<void(QAction*)> function) 792 void MainWindow::applyToActions(function<void(QAction*)> function)
793 { 793 {
794 for (QAction* act : findChildren<QAction*>()) 794 for (QAction* act : findChildren<QAction*>())
795 { 795 {
796 if (not act->objectName().isEmpty()) 796 if (not act->objectName().isEmpty())
797 function (act); 797 function (act);

mercurial