Revert "Changed the default save directory"
authorHeli Hyvättinen <heli.hyvattinen@kymp.net>
Sun, 19 Jun 2011 08:41:53 +0000 (11:41 +0300)
committerHeli Hyvättinen <heli.hyvattinen@kymp.net>
Sun, 19 Jun 2011 08:41:53 +0000 (11:41 +0300)
This reverts commit be3d7893a290bdbba62d4e373d000d4e72ab1e7d.

Didn't work. Package refused to install with the directory created under MyDocs due to a permission setting problem.
Going back to the original default save directory.

debian/kitchenalert.dirs
debian/kitchenalert.postinst
src/kitchenalertmainwindow.cpp

index 178020c..1f2739b 100644 (file)
@@ -1 +1 @@
-/home/user/MyDocs/KitchenAlert/ 
+/home/user/KitchenAlert/ 
index 908ae73..aa3a41a 100644 (file)
@@ -34,6 +34,10 @@ group        = alarm" >> /usr/share/policy/etc/current/pulse/xpolicy.conf
 stop pulseaudio
 start pulseaudio
 
+# give the default save directory to user "user" so it can be written to from the application 
+# (autocreating with kitchenalert.dirs gives it to root with no access rights to user)
+chown user /home/user/KitchenAlert
+
 fi
 
 exit 0
index 849640a..f5fbfa5 100644 (file)
@@ -53,7 +53,7 @@ KitchenAlertMainWindow::KitchenAlertMainWindow(QWidget *parent) :
     ui(new Ui::KitchenAlertMainWindow)
     {
       
-  defaultSaveDirectory_ = "/home/user/MyDocs/KitchenAlert";
+  defaultSaveDirectory_ = "/home/user/KitchenAlert";    
 
   ui->setupUi(this);
 
@@ -405,23 +405,9 @@ void KitchenAlertMainWindow::saveTimer()
     if (row.isValid() == false) //If there was no row selected invalid row was returned
         return;
 
-    //For consistency with loading, opens MyDocs if default directory has been removed
-
-    QString startDirectory;
-
-    if (QFile(defaultSaveDirectory_).exists())
-    {
-        startDirectory = defaultSaveDirectory_;
-    }
-    else
-    {
-        startDirectory = "/home/user/MyDocs";
-        qDebug () << "default save directory not found";
-    }
-
 
     //file name is asked. As the filename will be appended, there's no point in confirming owerwrite here
-    QString filename = QFileDialog::getSaveFileName(this, "", startDirectory, "*.kitchenalert",NULL,QFileDialog::DontConfirmOverwrite);
+    QString filename = QFileDialog::getSaveFileName(this, "", defaultSaveDirectory_, "*.kitchenalert",NULL,QFileDialog::DontConfirmOverwrite);
 
 
 
@@ -473,11 +459,25 @@ void KitchenAlertMainWindow::saveTimer()
 void KitchenAlertMainWindow::loadTimer()
 {
 
+// If the default save directory does not exist use /home/user instead (as that's what the save dialog will use)
+// This avoids a situation where save directs to a folder that cannot be accessed with open...
+
+    QString startDirectory;
+
+    if (QFile(defaultSaveDirectory_).exists())
+    {
+        startDirectory = defaultSaveDirectory_;
+    }
+    else
+    {
+        startDirectory = "/home/user/";
+        qDebug () << "default save directory not found";
+    }
 
 
  //Get the filename to open with a dialog
 
-    QString filename = QFileDialog::getOpenFileName(this,"",defaultSaveDirectory_,tr("KitchenAlert timer files (*.kitchenalert)"));
+    QString filename = QFileDialog::getOpenFileName(this,"",startDirectory,tr("KitchenAlert timer files (*.kitchenalert)"));
     if (!filename.isEmpty())
     {