[Kst] branches/work/kst/portto4/kst

Barth Netterfield netterfield at astro.utoronto.ca
Sat Aug 8 08:20:52 CEST 2009


SVN commit 1008715 by netterfield:

Fix some file dialog behaviors...



 M  +5 -0      devel-docs/Kst2Specs/FixedBugs  
 M  +1 -5      devel-docs/Kst2Specs/Wishlist  
 M  +10 -3     src/libkstapp/exportgraphicsdialog.cpp  
 M  +14 -7     src/libkstapp/exportgraphicsdialog.ui  
 M  +11 -2     src/libkstapp/pictureitem.cpp  
 M  +2 -1      src/libkstapp/viewitemdialog.h  


--- branches/work/kst/portto4/kst/devel-docs/Kst2Specs/FixedBugs #1008714:1008715
@@ -1093,3 +1093,8 @@
 --------------------
 
 Draw a line in a plot.  Resize the plot.  The line drifts away.
+
+------------
+
+Sensible filter in image dialog
+
--- branches/work/kst/portto4/kst/devel-docs/Kst2Specs/Wishlist #1008714:1008715
@@ -68,9 +68,5 @@
 
 ------------
 
-Sensible filter in image dialog
-
-------------
-
 Fixup line/arrow dimensions tab:
-  x,y instead of length/angle
\ No newline at end of file
+  x,y instead of length/angle
--- branches/work/kst/portto4/kst/src/libkstapp/exportgraphicsdialog.cpp #1008714:1008715
@@ -113,12 +113,19 @@
 
 
 void ExportGraphicsDialog::createFile() {
-  _dialogDefaults->setValue("export/filename", _saveLocation->file());
-  _dialogDefaults->setValue("export/format", _comboBoxFormats->currentText());
+  QString filename = _saveLocation->file();
+  QString format = _comboBoxFormats->currentText();
+  if (_autoExtension->isChecked()) {
+    if (QFileInfo(filename).suffix().toLower() != format.toLower()) {
+      filename += "." + format;
+    }
+  }
+  _dialogDefaults->setValue("export/filename", filename);
+  _dialogDefaults->setValue("export/format", format);
   _dialogDefaults->setValue("export/xsize", _xSize->value());
   _dialogDefaults->setValue("export/ysize", _ySize->value());
   _dialogDefaults->setValue("export/sizeOption", _comboBoxSizeOption->currentIndex());
-  emit exportGraphics(_saveLocation->file(), _comboBoxFormats->currentText(), _xSize->value(), _ySize->value(), _comboBoxSizeOption->currentIndex());
+  emit exportGraphics(filename, format, _xSize->value(), _ySize->value(), _comboBoxSizeOption->currentIndex());
 }
 
 
--- branches/work/kst/portto4/kst/src/libkstapp/exportgraphicsdialog.ui #1008714:1008715
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>402</width>
-    <height>271</height>
+    <height>278</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -38,15 +38,12 @@
    </item>
    <item row="1" column="0">
     <widget class="QLabel" name="textLabel1">
-     <property name="sizePolicy">
-      <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
-       <horstretch>0</horstretch>
-       <verstretch>0</verstretch>
-      </sizepolicy>
-     </property>
      <property name="text">
       <string>&amp;File format:</string>
      </property>
+     <property name="alignment">
+      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+     </property>
      <property name="wordWrap">
       <bool>false</bool>
      </property>
@@ -340,6 +337,16 @@
      </layout>
     </widget>
    </item>
+   <item row="2" column="0" colspan="2">
+    <widget class="QCheckBox" name="_autoExtension">
+     <property name="text">
+      <string>Automatic &amp;Extension</string>
+     </property>
+     <property name="checked">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
   </layout>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
--- branches/work/kst/portto4/kst/src/libkstapp/pictureitem.cpp #1008714:1008715
@@ -12,12 +12,14 @@
 #include "pictureitem.h"
 
 #include "debug.h"
+#include "dialogdefaults.h"
 
 #include <QDebug>
 #include <QFileDialog>
 #include <QGraphicsItem>
 #include <QGraphicsScene>
 #include <QBuffer>
+#include <QImageReader>
 
 namespace Kst {
 
@@ -68,10 +70,17 @@
 
 
 void CreatePictureCommand::createItem() {
-  QString file = QFileDialog::getOpenFileName(_view, tr("Kst: Open Image"));
+  QString start_dir = _dialogDefaults->value("picture/startdir", ".").toString();
+  QString filter = "Images (";
+  QList<QByteArray> formats = QImageReader::supportedImageFormats ();
+  for (int i=0; i<formats.size(); i++) {
+    filter += " *."+QString(formats.at(i)).toUpper() + " *." + QString(formats.at(i)).toLower();
+  }
+  filter += ")";
+  QString file = QFileDialog::getOpenFileName(_view, tr("Kst: Open Image"), start_dir, filter);
   if (file.isEmpty())
     return;
-
+  _dialogDefaults->setValue("picture/startdir", QFileInfo(file).path());
   _item = new PictureItem(_view, QImage(file));
   _view->setCursor(Qt::CrossCursor);
 
--- branches/work/kst/portto4/kst/src/libkstapp/viewitemdialog.h #1008714:1008715
@@ -48,6 +48,8 @@
 
     EditMode editMode() const { return _mode; }
 
+    DialogPage *dimensionsPage;
+    DimensionsTab *_dimensionsTab;
   public Q_SLOTS:
     void setSingleEdit();
     void setMultipleEdit();
@@ -89,7 +91,6 @@
     FillTab *_fillTab;
     StrokeTab *_strokeTab;
     LayoutTab *_layoutTab;
-    DimensionsTab *_dimensionsTab;
 };
 
 }


More information about the Kst mailing list