From 6bd27d441a1192246748c3cb3e4e61563270216c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Heli=20Hyv=C3=A4ttinen?= Date: Sun, 19 Jun 2011 11:41:53 +0300 Subject: [PATCH] Revert "Changed the default save directory" 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 | 2 +- debian/kitchenalert.postinst | 4 ++++ src/kitchenalertmainwindow.cpp | 34 +++++++++++++++++----------------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/debian/kitchenalert.dirs b/debian/kitchenalert.dirs index 178020c..1f2739b 100644 --- a/debian/kitchenalert.dirs +++ b/debian/kitchenalert.dirs @@ -1 +1 @@ -/home/user/MyDocs/KitchenAlert/ +/home/user/KitchenAlert/ diff --git a/debian/kitchenalert.postinst b/debian/kitchenalert.postinst index 908ae73..aa3a41a 100644 --- a/debian/kitchenalert.postinst +++ b/debian/kitchenalert.postinst @@ -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 diff --git a/src/kitchenalertmainwindow.cpp b/src/kitchenalertmainwindow.cpp index 849640a..f5fbfa5 100644 --- a/src/kitchenalertmainwindow.cpp +++ b/src/kitchenalertmainwindow.cpp @@ -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()) { -- 1.7.9.5