# HG changeset patch
# User Chris Cannam
# Date 1304938622 -3600
# Node ID 97cd3d2c032a954819d770fdda6b98d3ec746358
# Parent 37fb42c2d0e7d8165e94c376c02d9fc6c64e221d
Start to add templates menu; add default template
diff -r 37fb42c2d0e7 -r 97cd3d2c032a main/MainWindow.cpp
--- a/main/MainWindow.cpp Thu Apr 28 15:31:14 2011 +0100
+++ b/main/MainWindow.cpp Mon May 09 11:57:02 2011 +0100
@@ -30,6 +30,7 @@
#include "framework/TransformUserConfigurator.h"
#include "view/ViewManager.h"
#include "base/Preferences.h"
+#include "base/ResourceFinder.h"
#include "layer/WaveformLayer.h"
#include "layer/TimeRulerLayer.h"
#include "layer/TimeInstantLayer.h"
@@ -430,6 +431,12 @@
menu->addSeparator();
+ m_templatesMenu = menu->addMenu(tr("Set Session Open Template"));
+ m_templatesMenu->setTearOffEnabled(true);
+ setupTemplatesMenu();
+
+ menu->addSeparator();
+
icon = il.load("filesave");
icon.addPixmap(il.loadPixmap("filesave-22"));
action = new QAction(icon, tr("&Save Session"), this);
@@ -1623,6 +1630,49 @@
}
void
+MainWindow::setupTemplatesMenu()
+{
+ m_templatesMenu->clear();
+
+ QSettings settings;
+ settings.beginGroup("MainWindow");
+ QString deflt = settings.value("sessiontemplate", "").toString();
+ setDefaultSessionTemplate(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);
+
+ m_templatesMenu->addSeparator();
+
+ QStringList templates = ResourceFinder().getResourceFiles("templates", "xml");
+ foreach (QString t, templates) {
+ QString tname = QFileInfo(t).baseName();
+ if (tname.toLower() == "default") continue;
+ action = new QAction(tname, this);
+ action->setObjectName(t);
+ connect(action, SIGNAL(triggered()), this, SLOT(changeTemplate()));
+ action->setCheckable(true);
+ action->setChecked(deflt == tname);
+ templatesGroup->addAction(action);
+ m_templatesMenu->addAction(action);
+ }
+
+ if (!templates.empty()) m_templatesMenu->addSeparator();
+
+ action = new QAction(tr("Save Session as New Template..."), this);
+ connect(action, SIGNAL(triggered()), this, SLOT(saveSessionAsTemplate()));
+ m_templatesMenu->addAction(action);
+}
+
+void
MainWindow::setupRecentTransformsMenu()
{
m_recentTransformsMenu->clear();
@@ -2751,6 +2801,12 @@
}
void
+MainWindow::changeTemplate()
+{
+ //!!!
+}
+
+void
MainWindow::paneAdded(Pane *pane)
{
if (m_overview) m_overview->registerView(pane);
diff -r 37fb42c2d0e7 -r 97cd3d2c032a main/MainWindow.h
--- a/main/MainWindow.h Thu Apr 28 15:31:14 2011 +0100
+++ b/main/MainWindow.h Mon May 09 11:57:02 2011 +0100
@@ -83,6 +83,7 @@
virtual void openSomething();
virtual void openLocation();
virtual void openRecentFile();
+ virtual void changeTemplate();
virtual void exportAudio();
virtual void importLayer();
virtual void exportLayer();
@@ -140,6 +141,7 @@
virtual void setupRecentFilesMenu();
virtual void setupRecentTransformsMenu();
+ virtual void setupTemplatesMenu();
virtual void playSpeedChanged(int);
virtual void playSoloToggled();
@@ -190,6 +192,7 @@
QMenu *m_sliceMenu;
QMenu *m_recentFilesMenu;
QMenu *m_recentTransformsMenu;
+ QMenu *m_templatesMenu;
QMenu *m_rightButtonMenu;
QMenu *m_rightButtonLayerMenu;
QMenu *m_rightButtonTransformsMenu;
diff -r 37fb42c2d0e7 -r 97cd3d2c032a sonic-visualiser.qrc
--- a/sonic-visualiser.qrc Thu Apr 28 15:31:14 2011 +0100
+++ b/sonic-visualiser.qrc Mon May 09 11:57:02 2011 +0100
@@ -104,6 +104,7 @@
samples/stick.wav
samples/strike.wav
samples/tap.wav
+ templates/default.xml
templates/testtemplate.xml
i18n/sonic-visualiser_ru.qm
i18n/sonic-visualiser_en_GB.qm
diff -r 37fb42c2d0e7 -r 97cd3d2c032a templates/default.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/default.xml Mon May 09 11:57:02 2011 +0100
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+