-
Notifications
You must be signed in to change notification settings - Fork 0
/
configdlg.cpp
112 lines (87 loc) · 3.01 KB
/
configdlg.cpp
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
109
110
111
112
/* TimeLog - Copyright (C) 2019 Marco Hartung
*
* This file is part of TimeLog.
*
* TimeLog is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* TimeLog is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TimeLog. If not, see <http://www.gnu.org/licenses/>.
*/
#include "configdlg.h"
#include <QFileDialog>
#include "ui_configdlg.h"
ConfigDlg::ConfigDlg(QWidget *parent) :
QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint ),
ui(new Ui::ConfigDlg)
{
ui->setupUi(this);
connect( ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect( ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect( ui->pbPathChange, SIGNAL(clicked()), this, SLOT(PathChangeClicked()) );
connect( ui->pbProjAdd, SIGNAL(clicked()), this, SLOT(ProjAdd()) );
connect( ui->pbProjDel, SIGNAL(clicked()), this, SLOT(ProjDel()) );
pData = 0;
settings.ReadSettings();
setFixedSize( this->size() );
ui->groupBox_Project->setVisible(false);
ui->leDataPath->setText( settings.DataPath() );
ui->cbLogWorkTimeWithApp->setChecked( settings.LogWorkTimeWithApp() );
ui->cbStartupToTray->setChecked( settings.StartToTray() );
}
ConfigDlg::~ConfigDlg()
{
delete ui;
}
void ConfigDlg::SetData( tlData* pd ){
pData = pd;
ui->cbProj->clear();
if( pData ){
QVector<tlData::project_t> projecsts = pData->GetProjectList();
for( int i = 0; i < projecsts.size(); i++ ){
ui->cbProj->addItem( projecsts[i].Name );
}
}
}
void ConfigDlg::accept(){
settings.SetLogWorkTimeWithApp( ui->cbLogWorkTimeWithApp->isChecked() );
settings.SetStartToTray( ui->cbStartupToTray->isChecked() );
settings.SaveSettings();
this->setResult( QDialog::Accepted );
this->close();
}
void ConfigDlg::rejected(){
}
void ConfigDlg::ProjAdd(){
if( pData ){
if( pData->AddProject( ui->cbProj->currentText() ) ){
ui->cbProj->addItem( ui->cbProj->currentText() );
}
else{
//TODO add ErrorMsg]
}
}
}
void ConfigDlg::ProjDel(){
if( pData ){
if( pData->DelProject( ui->cbProj->currentText() ) ){
ui->cbProj->removeItem( ui->cbProj->currentIndex() );
}
else{
//TODO add ErrorMsg
}
}
}
void ConfigDlg::PathChangeClicked(){
QString fileName = QFileDialog::getOpenFileName( this, tr("TimeLog Data"), settings.DataPath(), tr("TimeLog Data (*.xml)") );
if( !fileName.isEmpty() ){
settings.SetDataPath( fileName );
ui->leDataPath->setText( settings.DataPath() );
}
}