-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettingsdialog.cpp
More file actions
108 lines (96 loc) · 2.45 KB
/
settingsdialog.cpp
File metadata and controls
108 lines (96 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include "settingsdialog.h"
#include "ui_settingsdialog.h"
#include <QFileDialog>
#include <QSettings>
#include <QDebug>
#include <QTranslator>
SettingsDialog::SettingsDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::SettingsDialog)
{
ui->setupUi(this);
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
QSettings::NativeFormat);
QVariant v = settings.value("My Pictures");
if (!v.isNull())
{
ui->downloadLoc->setText(v.toString() + "\\flickrFotos");
}
else
{
ui->downloadLoc->setText(QDir::homePath() + "/flickrFotos");
}
}
SettingsDialog::~SettingsDialog()
{
delete ui;
}
void SettingsDialog::setDownloadLoc(const QString& downloadLoc)
{
ui->downloadLoc->setText(downloadLoc);
}
void SettingsDialog::setQuality(const Quality& quality)
{
if (quality == Best)
ui->rbBest->setChecked(true);
else
ui->rbGood->setChecked(true);
}
void SettingsDialog::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
QString SettingsDialog::getDownloadLoc() const
{
return ui->downloadLoc->text();
}
Quality SettingsDialog::getQuality() const
{
if (ui->rbBest->isChecked())
return Best;
return Good;
}
void SettingsDialog::dirDialog()
{
QFileDialog dialog(this, tr("Download to"));
dialog.setFileMode(QFileDialog::DirectoryOnly);
dialog.setDirectory(getDownloadLoc());
if (dialog.exec())
{
ui->downloadLoc->setText(dialog.directory().absolutePath());
}
}
//QFileDialog dialog(this, tr("Download photos to"));
//dialog.setFileMode(QFileDialog::DirectoryOnly);
//dialog.setDirectory(QDir::home());
//if (dialog.exec())
//{
// m_downloadLoc = dialog.directory();
// m_downloadLoc = cdDir(m_downloadLoc, "flickrFotos");
//
// m_settings->setValue("downloadLocation", m_downloadLoc.absolutePath());
// }
QString SettingsDialog::getLanguageFromText(QString lang)
{
if (lang == "Nederlands")
return "nl";
if (lang == "Deutch")
return "de";
return "en";
}
void SettingsDialog::setLanguage(QString lang)
{
if (lang == "")
return;
qDebug() << "setting lang to " << getLanguageFromText(lang) << " lang " << lang;
QTranslator translator;
translator.load(QString("flickrphotos_") + getLanguageFromText(lang));
QApplication::installTranslator(&translator);
}