diff main/MainWindow.cpp @ 1355:86cd0e81ed07 subdivide-instants

Implement "Subdivide Selected Instants". Also add the relabel command to the history, which I previously forgot to do!
author Chris Cannam
date Fri, 25 Nov 2016 09:38:53 +0000
parents ed3009a50f81
children 3ef81d81b767
line wrap: on
line diff
--- a/main/MainWindow.cpp	Thu Nov 24 17:10:40 2016 +0000
+++ b/main/MainWindow.cpp	Fri Nov 25 09:38:53 2016 +0000
@@ -842,6 +842,12 @@
     connect(this, SIGNAL(canRenumberInstants(bool)), action, SLOT(setEnabled(bool)));
 //    m_keyReference->registerShortcut(action);
     menu->addAction(action);
+            
+    action = new QAction(tr("Subdivide Selected Instants..."), this);
+    action->setStatusTip(tr("Add new instants at regular intervals between the selected instants"));
+    connect(action, SIGNAL(triggered()), this, SLOT(subdivideInstants()));
+    connect(this, SIGNAL(canSubdivideInstants(bool)), action, SLOT(setEnabled(bool)));
+    menu->addAction(action);
 }
 
 void
@@ -4392,6 +4398,28 @@
 }
 
 void
+MainWindow::subdivideInstants()
+{
+    QSettings settings;
+    settings.beginGroup("MainWindow");
+    int n = settings.value("subdivisions", 4).toInt();
+    
+    bool ok;
+
+    n = QInputDialog::getInt(this,
+                             tr("Subdivide instants"),
+                             tr("Number of subdivisions:"),
+                             n, 2, 96, 1, &ok);
+
+    if (ok) {
+        settings.setValue("subdivisions", n);
+        subdivideInstantsBy(n);
+    }
+
+    settings.endGroup();
+}
+
+void
 MainWindow::modelGenerationFailed(QString transformName, QString message)
 {
     emit hideSplash();