Commit 8b8213c4 authored by David Jarvie's avatar David Jarvie

Use previously selected directory as default in sound file picker

parent 28a301ee
......@@ -2130,11 +2130,11 @@ QString browseFile(const QString& caption, QString& defaultDir, const QString& i
if (!initialFile.isEmpty())
fileDlg->setSelection(initialFile);
if (fileDlg->exec() != QDialog::Accepted)
return fileDlg ? QString("") : QString();
return fileDlg ? QString() : QString();
KUrl url = fileDlg->selectedUrl();
if (url.isEmpty())
return QString("");
defaultDir = url.isLocalFile() ? url.toLocalFile() : url.path();
return QString();
defaultDir = url.isLocalFile() ? url.upUrl().toLocalFile() : url.directory();
return (mode & KFile::LocalOnly) ? url.pathOrUrl() : url.prettyUrl();
}
......
/*
* sounddlg.cpp - sound file selection and configuration dialog and widget
* Program: kalarm
* Copyright © 2005-2011 by David Jarvie <djarvie@kde.org>
* Copyright © 2005-2012 by David Jarvie <djarvie@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -137,6 +137,7 @@ void SoundDlg::slotButtonClicked(int button)
= Class SoundWidget
= Select a sound file and configure how to play it.
=============================================================================*/
QString SoundWidget::mDefaultDir;
SoundWidget::SoundWidget(bool showPlay, bool showRepeat, QWidget* parent)
: QWidget(parent),
......
/*
* sounddlg.h - sound file selection and configuration dialog and widget
* Program: kalarm
* Copyright © 2005-2007,2009-2011 by David Jarvie <djarvie@kde.org>
* Copyright © 2005-2007,2009-2012 by David Jarvie <djarvie@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -72,6 +72,7 @@ class SoundWidget : public QWidget
void playFinished();
private:
static QString mDefaultDir; // current default directory for mFileEdit
QPushButton* mFilePlay;
LineEdit* mFileEdit;
PushButton* mFileBrowseButton;
......@@ -84,7 +85,6 @@ class SoundWidget : public QWidget
SpinBox* mFadeTime;
KHBox* mFadeVolumeBox;
Slider* mFadeSlider;
QString mDefaultDir; // current default directory for mFileEdit
mutable KUrl mUrl;
mutable QString mValidatedFile;
Phonon::MediaObject* mPlayer;
......
/*
* soundpicker.cpp - widget to select a sound file or a beep
* Program: kalarm
* Copyright © 2002-2011 by David Jarvie <djarvie@kde.org>
* Copyright © 2002-2012 by David Jarvie <djarvie@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -20,6 +20,7 @@
#include "kalarm.h"
#include "autoqpointer.h"
#include "combobox.h"
#include "functions.h"
#include "kalarmapp.h"
......@@ -261,28 +262,27 @@ void SoundPicker::slotTypeSelected(int id)
void SoundPicker::slotPickFile()
{
KUrl oldfile = mFile;
KUrl file = mFile;
SoundDlg dlg(mFile.prettyUrl(), mVolume, mFadeVolume, mFadeSeconds, mRepeatPause, i18nc("@title:window", "Sound File"), this);
dlg.setReadOnly(mReadOnly);
bool accepted = (dlg.exec() == QDialog::Accepted);
// Use AutoQPointer to guard against crash on application exit while
// the dialogue is still open. It prevents double deletion (both on
// deletion of EditAlarmDlg, and on return from this function).
AutoQPointer<SoundDlg> dlg = new SoundDlg(mFile.prettyUrl(), mVolume, mFadeVolume, mFadeSeconds, mRepeatPause, i18nc("@title:window", "Sound File"), this);
dlg->setReadOnly(mReadOnly);
bool accepted = (dlg->exec() == QDialog::Accepted);
if (mReadOnly)
return;
if (accepted)
{
float volume, fadeVolume;
int fadeTime;
dlg.getVolume(volume, fadeVolume, fadeTime);
file = dlg.getFile();
mRepeatPause = dlg.repeatPause();
dlg->getVolume(volume, fadeVolume, fadeTime);
KUrl file = dlg->getFile();
if (!file.isEmpty())
mFile = file;
mRepeatPause = dlg->repeatPause();
mVolume = volume;
mFadeVolume = fadeVolume;
mFadeSeconds = fadeTime;
}
if (!file.isEmpty())
{
mFile = file;
mDefaultDir = dlg.defaultDir();
}
if (mFile.isEmpty())
{
// No audio file is selected, so revert to previously selected option
......
/*
* soundpicker.h - widget to select a sound file or a beep
* Program: kalarm
* Copyright © 2002,2004-2011 by David Jarvie <djarvie@kde.org>
* Copyright © 2002,2004-2012 by David Jarvie <djarvie@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -117,7 +117,6 @@ class SoundPicker : public QFrame
ComboBox* mTypeCombo;
KHBox* mTypeBox;
PushButton* mFilePicker;
QString mDefaultDir;
KUrl mFile; // sound file to play when alarm is triggered
float mVolume; // volume for file, or < 0 to not set volume
float mFadeVolume; // initial volume for file, or < 0 for no fading
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment