5
5
#include " settingsdialog.h"
6
6
#include " ui_settingsdialog.h"
7
7
8
+ #include < QDebug>
9
+
8
10
SettingsDialog::SettingsDialog (QWidget *parent) :
9
11
QDialog(parent),
10
12
m_ui(new Ui::SettingsDialog)
11
13
{
12
14
m_ui->setupUi (this );
13
15
16
+ #ifdef Q_WS_WIN
17
+ QString settingDirName = " Basket of Password" ;
18
+ #else
19
+ QString settingDirName = " .basketpwd" ;
20
+ #endif
21
+
22
+ QString defPath = QString (QDir::homePath () + QDir::separator () + settingDirName);
23
+
14
24
QSettings set;
15
- QString defaultPath = set.value (tr (" PathToDef" ), QString (QDir::currentPath () )).toString ();
25
+ QString defaultPath = set.value (tr (" PathToDef" ), QString (defPath )).toString ();
16
26
int csi = set.value (tr (" DontCloseApp" ), m_ui->checkBoxDontClose ->checkState ()).toInt ();
17
27
int csort_raw = set.value (tr (SORTING), true ).toInt ();
18
28
Qt::CheckState cs = csi == 0 ? Qt::Unchecked : Qt::Checked;
19
29
Qt::CheckState csort = csort_raw == 0 ? Qt::Unchecked : Qt::Checked;
20
30
m_ui->checkBoxDontClose ->setCheckState (cs);
21
31
m_ui->lineEditDefaultPath ->setText (defaultPath);
22
32
m_ui->checkBoxSort ->setCheckState (csort);
33
+
34
+ /* Colors */
35
+ selectedColor = set.value (tr (" ItemColor" ), QColor (Qt::darkBlue)).value <QColor>();
36
+ setColorToItLabel (selectedColor);
23
37
}
24
38
SettingsDialog::~SettingsDialog ()
25
39
{
@@ -46,7 +60,7 @@ QString SettingsDialog::getIdent() const
46
60
return m_ui->lineEditIdent ->text ();
47
61
}
48
62
49
- void SettingsDialog::on_pushButton_clicked ()
63
+ void SettingsDialog::on_pushButtonSelectDir_clicked ()
50
64
{
51
65
QString oldPath = m_ui->lineEditDefaultPath ->text ();
52
66
QString dir = QFileDialog::getExistingDirectory (this , trUtf8 (" Выберите папку" ),
@@ -79,10 +93,30 @@ void SettingsDialog::on_buttonBox_clicked(QAbstractButton* button)
79
93
80
94
set.setValue (tr (" DontCloseApp" ), m_ui->checkBoxDontClose ->checkState ());
81
95
set.setValue (tr (SORTING), m_ui->checkBoxSort ->checkState ());
96
+ set.setValue (tr (" ItemColor" ), selectedColor);
82
97
accept ();
83
98
}
84
99
else if ( m_ui->buttonBox ->buttonRole ( button ) == QDialogButtonBox::RejectRole )
85
100
reject ();
86
101
87
102
}
88
103
104
+ void SettingsDialog::on_pushButtonSelectColor_clicked ()
105
+ {
106
+ // FIXME: maybe QT bug here O_o
107
+ QString tempDir = m_ui->lineEditDefaultPath ->text ();
108
+ QColor sd_color = QColorDialog::getColor ( selectedColor, this ); // , tr("Выберите цвет"));
109
+ if ( sd_color.isValid () ) {
110
+ selectedColor = sd_color;
111
+ setColorToItLabel (selectedColor);
112
+ }
113
+
114
+ // FIXME: maybe QT bug here O_o
115
+ if ( tempDir != m_ui->lineEditDefaultPath ->text () )
116
+ m_ui->lineEditDefaultPath ->setText (tempDir);
117
+ }
118
+ void SettingsDialog::setColorToItLabel ( QColor &clr )
119
+ {
120
+ QString ls = tr (" <html><head/><body><p><span style=\" color:%1;\" >Цвет записей:</span></p></body></html>" ).arg (clr.name ());
121
+ m_ui->labelColorItems ->setText (ls);
122
+ }
0 commit comments