Mercurial > hg > sonic-visualiser
diff main/MainWindow.cpp @ 430:45bfc5962c33 templating
Add some "proper" default templates; ensure default template is updated in menu if our template file disappears
author | Chris Cannam |
---|---|
date | Wed, 11 May 2011 13:52:00 +0100 |
parents | ba07505d20e2 |
children | ee927c1b7941 |
line wrap: on
line diff
--- a/main/MainWindow.cpp Wed May 11 11:06:20 2011 +0100 +++ b/main/MainWindow.cpp Wed May 11 13:52:00 2011 +0100 @@ -1655,20 +1655,26 @@ settings.beginGroup("MainWindow"); QString deflt = settings.value("sessiontemplate", "").toString(); setDefaultSessionTemplate(deflt == "" ? "default" : deflt); - settings.endGroup(); QActionGroup *templatesGroup = new QActionGroup(this); - QAction *action = new QAction(tr("Default"), this); - action->setObjectName("default"); - connect(action, SIGNAL(triggered()), this, SLOT(changeTemplate())); - action->setCheckable(true); - action->setChecked(deflt == "" || deflt == "default"); - templatesGroup->addAction(action); - m_templatesMenu->addAction(action); + bool haveFoundDefault = false; + + QAction *defaultAction = new QAction(tr("Default"), this); + defaultAction->setObjectName("default"); + connect(defaultAction, SIGNAL(triggered()), this, SLOT(changeTemplate())); + defaultAction->setCheckable(true); + if (deflt == "" || deflt == "default") { + defaultAction->setChecked(true); + haveFoundDefault = true; + } + templatesGroup->addAction(defaultAction); + m_templatesMenu->addAction(defaultAction); m_templatesMenu->addSeparator(); + QAction *action = 0; + QStringList templates = ResourceFinder().getResourceFiles("templates", "svt"); bool havePersonal = false; @@ -1685,13 +1691,24 @@ action = new QAction(t, this); connect(action, SIGNAL(triggered()), this, SLOT(changeTemplate())); action->setCheckable(true); - action->setChecked(deflt == t); + if (deflt == t) { + action->setChecked(true); + haveFoundDefault = true; + } templatesGroup->addAction(action); m_templatesMenu->addAction(action); } if (!templates.empty()) m_templatesMenu->addSeparator(); + if (!haveFoundDefault) { + defaultAction->setChecked(true); + setDefaultSessionTemplate("default"); + settings.setValue("sessiontemplate", ""); + } + + settings.endGroup(); + action = new QAction(tr("Save Template from Current Session..."), this); connect(action, SIGNAL(triggered()), this, SLOT(saveSessionAsTemplate())); m_templatesMenu->addAction(action);