changeset 123:a45733cc3939 sv1-1.0pre2

* Remove tip dialog for now. I don't like it enough * Fixes to export image
author Chris Cannam
date Wed, 14 Mar 2007 14:39:39 +0000 (2007-03-14)
parents 8ad3609080b3
children 8a39597edb51
files i18n/tips_en.xml main/MainWindow.cpp main/main.cpp
diffstat 3 files changed, 66 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/i18n/tips_en.xml	Tue Mar 13 19:51:09 2007 +0000
+++ b/i18n/tips_en.xml	Wed Mar 14 14:39:39 2007 +0000
@@ -1,13 +1,16 @@
+
+<!-- Note: this tip file is not actually used, the tip of the day
+dialog has been disabled for the moment because I wasn't liking it
+enough to take the trouble to finish the tips text... -->
+
 <tips caption="Tip of the Day">
 <tip>
 <html>
-<p><b>Welcome to Sonic Visualiser!</b></p>
-<p>Sonic Visualiser is pretty complex, but you can use it for simple
-things very easily.</p>
-<p>Try importing an audio file and using the Pane
-menu to add some different views of it.</p>
-<p>Check out the links on the Help menu for tutorials and other
-documentation!</p>
+<p><b>Welcome to Sonic Visualiser!</b></p> <p>Sonic Visualiser is a
+complex application, but it's easy enough to get started with.</p>
+<p>Try importing an audio file and using the Pane menu to add some
+different views of it.</p> <p>Check out the links on the Help menu for
+tutorials and other documentation!</p>
 </html>
 </tip>
 <tip>
--- a/main/MainWindow.cpp	Tue Mar 13 19:51:09 2007 +0000
+++ b/main/MainWindow.cpp	Wed Mar 14 14:39:39 2007 +0000
@@ -2303,7 +2303,60 @@
 
     if (QFileInfo(path).suffix() == "") path += ".png";
 
-    QImage *image = pane->toNewImage();
+    bool haveSelection = m_viewManager && !m_viewManager->getSelections().empty();
+
+    QSize total, visible, selected;
+    total = pane->getImageSize();
+    visible = pane->getImageSize(pane->getFirstVisibleFrame(),
+                                 pane->getLastVisibleFrame());
+
+    size_t sf0 = 0, sf1 = 0;
+ 
+    if (haveSelection) {
+        MultiSelection::SelectionList selections = m_viewManager->getSelections();
+        sf0 = selections.begin()->getStartFrame();
+        MultiSelection::SelectionList::iterator e = selections.end();
+        --e;
+        sf1 = e->getEndFrame();
+        selected = pane->getImageSize(sf0, sf1);
+    }
+
+    QStringList items;
+    items << tr("Export the entire pane (%1x%2 pixels")
+        .arg(total.width()).arg(total.height());
+    items << tr("Export the visible area only (%1x%2 pixels)")
+        .arg(visible.width()).arg(visible.height());
+    if (haveSelection) {
+        items << tr("Export the selection extent (%1x%2 pixels)")
+            .arg(selected.width()).arg(selected.height());
+    }
+
+    QSettings settings;
+    settings.beginGroup("MainWindow");
+    int deflt = settings.value("lastimageexportregion", 0).toInt();
+    if (deflt == 2 && !haveSelection) deflt = 1;
+
+    bool ok = false;
+    QString item = ListInputDialog::getItem
+        (this, tr("Select region to export"),
+         tr("Which region of the current pane do you want to export as an image?"),
+         items, deflt, &ok);
+	    
+    if (!ok || item.isEmpty()) return;
+
+    settings.setValue("lastimageexportregion", deflt);
+
+    QImage *image = 0;
+
+    if (item == items[0]) {
+        image = pane->toNewImage();
+    } else if (item == items[1]) {
+        image = pane->toNewImage(pane->getFirstVisibleFrame(),
+                                 pane->getLastVisibleFrame());
+    } else if (haveSelection) {
+        image = pane->toNewImage(sf0, sf1);
+    }
+
     if (!image) return;
 
     if (!image->save(path, "PNG")) {
--- a/main/main.cpp	Tue Mar 13 19:51:09 2007 +0000
+++ b/main/main.cpp	Wed Mar 14 14:39:39 2007 +0000
@@ -194,12 +194,12 @@
                  QMessageBox::tr("File \"%1\" could not be opened").arg(path));
         }
     }            
-
+/*
     TipDialog tipDialog;
     if (tipDialog.isOK()) {
         tipDialog.exec();
     }
-
+*/
     int rv = application.exec();
     std::cerr << "application.exec() returned " << rv << std::endl;