[Kst] extragear/graphics/kst/src/libkstapp

Barth Netterfield netterfield at astro.utoronto.ca
Tue Nov 21 08:52:18 CET 2006


SVN commit 606640 by netterfield:

Make the change file dialog into an apply/ok/cancel dialog, rather than
an apply/cancel dialog.



 M  +31 -15    changefiledialog.ui  
 M  +10 -3     kstchangefiledialog_i.cpp  
 M  +2 -2      kstchangefiledialog_i.h  


--- trunk/extragear/graphics/kst/src/libkstapp/changefiledialog.ui #606639:606640
@@ -1,4 +1,4 @@
-<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
 <class>KstChangeFileDialog</class>
 <widget class="QDialog">
     <property name="name">
@@ -8,14 +8,14 @@
         <rect>
             <x>0</x>
             <y>0</y>
-            <width>481</width>
+            <width>487</width>
             <height>600</height>
         </rect>
     </property>
     <property name="caption">
         <string>Change Data File</string>
     </property>
-    <grid>
+    <vbox>
         <property name="name">
             <cstring>unnamed</cstring>
         </property>
@@ -25,7 +25,7 @@
         <property name="spacing">
             <number>6</number>
         </property>
-        <widget class="QButtonGroup" row="0" column="0">
+        <widget class="QButtonGroup">
             <property name="name">
                 <cstring>buttonGroup1</cstring>
             </property>
@@ -168,7 +168,7 @@
                 </widget>
             </grid>
         </widget>
-        <widget class="QButtonGroup" row="1" column="0">
+        <widget class="QButtonGroup">
             <property name="name">
                 <cstring>buttonGroup2</cstring>
             </property>
@@ -301,20 +301,14 @@
                 </widget>
             </grid>
         </widget>
-        <widget class="QLayoutWidget" row="2" column="0">
+        <widget class="QLayoutWidget">
             <property name="name">
-                <cstring>Layout33</cstring>
+                <cstring>layout9</cstring>
             </property>
             <hbox>
                 <property name="name">
                     <cstring>unnamed</cstring>
                 </property>
-                <property name="margin">
-                    <number>0</number>
-                </property>
-                <property name="spacing">
-                    <number>6</number>
-                </property>
                 <spacer>
                     <property name="name">
                         <cstring>Spacer15</cstring>
@@ -327,7 +321,7 @@
                     </property>
                     <property name="sizeHint">
                         <size>
-                            <width>20</width>
+                            <width>180</width>
                             <height>20</height>
                         </size>
                     </property>
@@ -339,25 +333,47 @@
                     <property name="text">
                         <string>&amp;Apply</string>
                     </property>
+                    <property name="accel">
+                        <string>Alt+A</string>
+                    </property>
                     <property name="whatsThis" stdset="0">
                         <string>Apply new source file to selected vectors.</string>
                     </property>
                 </widget>
                 <widget class="QPushButton">
                     <property name="name">
+                        <cstring>ChangeFileOK</cstring>
+                    </property>
+                    <property name="text">
+                        <string>&amp;OK</string>
+                    </property>
+                    <property name="accel">
+                        <string>Alt+O</string>
+                    </property>
+                    <property name="whatsThis" stdset="0">
+                        <string>Apply new source file to selected vectors.</string>
+                    </property>
+                </widget>
+                <widget class="QPushButton">
+                    <property name="name">
                         <cstring>ChangeFileCancel</cstring>
                     </property>
                     <property name="text">
                         <string>&amp;Close</string>
                     </property>
+                    <property name="accel">
+                        <string>Alt+C</string>
+                    </property>
                     <property name="whatsThis" stdset="0">
                         <string>Close dialog without applying further changes.</string>
                     </property>
                 </widget>
             </hbox>
         </widget>
-    </grid>
+    </vbox>
 </widget>
+<customwidgets>
+</customwidgets>
 <connections>
     <connection>
         <sender>ChangeFileCancel</sender>
--- trunk/extragear/graphics/kst/src/libkstapp/kstchangefiledialog_i.cpp #606639:606640
@@ -51,6 +51,7 @@
   connect(ChangeFileSelectAll, SIGNAL(clicked()), _filter, SLOT(clear()));
   connect(ChangeFileSelectAll, SIGNAL(clicked()), this, SLOT(selectAll()));
   connect(ChangeFileApply, SIGNAL(clicked()), this, SLOT(applyFileChange()));
+  connect(ChangeFileOK, SIGNAL(clicked()), this, SLOT(OKFileChange()));
   connect(_allFromFile, SIGNAL(clicked()), _filter, SLOT(clear()));
   connect(_allFromFile, SIGNAL(clicked()), this, SLOT(allFromFile()));
   connect(_duplicateSelected, SIGNAL(toggled(bool)), _duplicateDependents, SLOT(setEnabled(bool)));
@@ -124,8 +125,13 @@
   raise();
 }
 
+void KstChangeFileDialogI::OKFileChange() {
+  if (applyFileChange()) {
+    reject();
+  }
+}
 
-void KstChangeFileDialogI::applyFileChange() {
+bool KstChangeFileDialogI::applyFileChange() {
   KstDataSourcePtr file;
   KST::dataSourceList.lock().writeLock();
   KstDataSourceList::Iterator it = KST::dataSourceList.findReusableFileName(_dataFile->url());
@@ -137,12 +143,12 @@
     if (!file || !file->isValid()) {
       KST::dataSourceList.lock().unlock();
       KMessageBox::sorry(this, i18n("The file could not be loaded."));
-      return;
+      return false;
     }
     if (file->isEmpty()) {
       KST::dataSourceList.lock().unlock();
       KMessageBox::sorry(this, i18n("The file does not contain data."));
-      return;
+      return false;
     }
     KST::dataSourceList.append(file);
   } else {
@@ -287,6 +293,7 @@
 
   // force an update in case we're in paused mode
   KstApp::inst()->forceUpdate();
+  return true;
 }
 
 
--- trunk/extragear/graphics/kst/src/libkstapp/kstchangefiledialog_i.h #606639:606640
@@ -45,8 +45,8 @@
     bool _first;
 
   private slots:
-    void applyFileChange();
-
+    bool applyFileChange();
+    void OKFileChange();
     void updateSelection(const QString&);
 
   signals:


More information about the Kst mailing list