Save and restore geometry in transcoder dialog

This commit is contained in:
Jonas Kvinge 2019-03-22 23:22:23 +01:00
parent 04d34a06c7
commit d427733bfc
3 changed files with 74 additions and 6 deletions

View File

@ -101,10 +101,15 @@ TranscodeDialog::TranscodeDialog(QWidget *parent)
// Load settings
QSettings s;
s.beginGroup(kSettingsGroup);
if (s.contains("geometry")) {
restoreGeometry(s.value("geometry").toByteArray());
}
last_add_dir_ = s.value("last_add_dir", QDir::homePath()).toString();
last_import_dir_ = s.value("last_import_dir", QDir::homePath()).toString();
QString last_output_format = s.value("last_output_format", "audio/x-vorbis").toString();
s.endGroup();
for (int i = 0; i < ui_->format->count(); ++i) {
if (last_output_format == ui_->format->itemData(i).value<TranscoderPreset>().codec_mimetype_) {
ui_->format->setCurrentIndex(i);
@ -192,6 +197,7 @@ void TranscodeDialog::Start() {
QSettings s;
s.beginGroup(kSettingsGroup);
s.setValue("last_output_format", preset.codec_mimetype_);
s.endGroup();
}
@ -263,6 +269,7 @@ void TranscodeDialog::Add() {
QSettings s;
s.beginGroup(kSettingsGroup);
s.setValue("last_add_dir", last_add_dir_);
s.endGroup();
}
@ -283,9 +290,10 @@ void TranscodeDialog::Import() {
SetFilenames(filenames);
last_import_dir_ = path;
QSettings settings;
settings.beginGroup(kSettingsGroup);
settings.setValue("last_import_dir", last_import_dir_);
QSettings s;
s.beginGroup(kSettingsGroup);
s.setValue("last_import_dir", last_import_dir_);
s.endGroup();
}
@ -376,4 +384,28 @@ QString TranscodeDialog::GetOutputFileName(const QString &input, const Transcode
file_name = file_name.section('.', 0, -2);
return path + '/' + file_name + '.' + preset.extension_;
}
}
void TranscodeDialog::SaveGeometry() {
QSettings s;
s.beginGroup(kSettingsGroup);
s.setValue("geometry", saveGeometry());
s.endGroup();
}
void TranscodeDialog::accept() {
SaveGeometry();
QDialog::accept();
}
void TranscodeDialog::reject() {
SaveGeometry();
QDialog::reject();
}

View File

@ -66,6 +66,8 @@ class TranscodeDialog : public QDialog {
void LogLine(const QString message);
void Options();
void AddDestination();
void accept();
void reject();
private:
void SetWorking(bool working);
@ -73,6 +75,7 @@ class TranscodeDialog : public QDialog {
void UpdateProgress();
QString TrimPath(const QString &path) const;
QString GetOutputFileName(const QString &input, const TranscoderPreset &preset) const;
void SaveGeometry();
private:
Ui_TranscodeDialog *ui_;

View File

@ -17,7 +17,7 @@
<iconset>
<normaloff>:/icons/64x64/strawberry.png</normaloff>:/icons/64x64/strawberry.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<layout class="QVBoxLayout" name="layout_dialog">
<item>
<widget class="QGroupBox" name="input_group">
<property name="title">
@ -175,7 +175,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_1">
<layout class="QHBoxLayout" name="layout_progress">
<item>
<widget class="QLabel" name="progress_text">
<property name="sizePolicy">
@ -221,5 +221,38 @@
<tabstop>button_box</tabstop>
</tabstops>
<resources/>
<connections/>
<connections>
<connection>
<sender>button_box</sender>
<signal>accepted()</signal>
<receiver>TranscodeDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>249</x>
<y>420</y>
</hint>
<hint type="destinationlabel">
<x>249</x>
<y>223</y>
</hint>
</hints>
</connection>
<connection>
<sender>button_box</sender>
<signal>rejected()</signal>
<receiver>TranscodeDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>249</x>
<y>420</y>
</hint>
<hint type="destinationlabel">
<x>249</x>
<y>223</y>
</hint>
</hints>
</connection>
</connections>
</ui>