1 /***************************************************************************
2 * *
3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 3 of the License, or *
6 * (at your option) any later version. *
7 * *
8 ***************************************************************************/
9
10 #include "SettingsLog.h"
11 #include "WulforUtil.h"
12
13 #include "dcpp/SettingsManager.h"
14
15 #include <QDir>
16 #include <QFileDialog>
17
18 using namespace dcpp;
19
SettingsLog(QWidget * parent)20 SettingsLog::SettingsLog(QWidget *parent) :
21 QWidget(parent)
22 {
23 setupUi(this);
24
25 init();
26 }
27
init()28 void SettingsLog::init(){
29 lineEdit_LOGDIR->setText(_q(SETTING(LOG_DIRECTORY)));
30
31 groupBox_MAINCHAT->setChecked(BOOLSETTING(LOG_MAIN_CHAT));
32 lineEdit_CHATFMT->setText(_q(SETTING(LOG_FORMAT_MAIN_CHAT)));
33 lineEdit_FILE_CHATFMT->setText(_q(SETTING(LOG_FILE_MAIN_CHAT)));
34
35 groupBox_PM->setChecked(BOOLSETTING(LOG_PRIVATE_CHAT));
36 lineEdit_PMFMT->setText(_q(SETTING(LOG_FORMAT_PRIVATE_CHAT)));
37 lineEdit_FILE_PMFMT->setText(_q(SETTING(LOG_FILE_PRIVATE_CHAT)));
38
39 groupBox_DOWN->setChecked(BOOLSETTING(LOG_DOWNLOADS));
40 lineEdit_DOWNFMT->setText(_q(SETTING(LOG_FORMAT_POST_DOWNLOAD)));
41 lineEdit_FILE_DOWNFMT->setText(_q(SETTING(LOG_FILE_DOWNLOAD)));
42
43 groupBox_UP->setChecked(BOOLSETTING(LOG_UPLOADS));
44 lineEdit_UPFMT->setText(_q(SETTING(LOG_FORMAT_POST_UPLOAD)));
45 lineEdit_FILE_UPFMT->setText(_q(SETTING(LOG_FILE_UPLOAD)));
46
47 groupBox_FINISH_DOWN->setChecked(BOOLSETTING(LOG_FINISHED_DOWNLOADS));
48 lineEdit_FINISH_DOWNFMT->setText(_q(SETTING(LOG_FORMAT_POST_FINISHED_DOWNLOAD)));
49 lineEdit_FILE_FINISH_DOWNFMT->setText(_q(SETTING(LOG_FILE_FINISHED_DOWNLOAD)));
50
51 checkBox_FILELIST->setChecked(BOOLSETTING(LOG_FILELIST_TRANSFERS));
52 checkBox_STAT->setChecked(BOOLSETTING(LOG_STATUS_MESSAGES));
53 checkBox_SYSTEM->setChecked(BOOLSETTING(LOG_SYSTEM));
54 checkBox_REPORT_ALTERNATES->setChecked(BOOLSETTING(REPORT_ALTERNATES));
55
56 groupBox_SPYLOG->setChecked(BOOLSETTING(LOG_SPY));
57 lineEdit_SPYFMT->setText(_q(SETTING(LOG_FORMAT_SPY)));
58 lineEdit_FILE_SPYFMT->setText(_q(SETTING(LOG_FILE_SPY)));
59
60 toolButton_BROWSE->setIcon(WulforUtil::getInstance()->getPixmap(WulforUtil::eiFOLDER_BLUE));
61
62 connect(toolButton_BROWSE, SIGNAL(clicked()), this, SLOT(slotBrowse()));
63 }
64
ok()65 void SettingsLog::ok(){
66 SettingsManager *sm = SettingsManager::getInstance();
67
68 QString path = lineEdit_LOGDIR->text();
69 if (!path.isEmpty() && !path.endsWith(QDir::separator()))
70 path += QDir::separator();
71
72 sm->set(SettingsManager::LOG_DIRECTORY, _tq(path));
73 sm->set(SettingsManager::LOG_MAIN_CHAT, groupBox_MAINCHAT->isChecked());
74 sm->set(SettingsManager::LOG_FORMAT_MAIN_CHAT, _tq(lineEdit_CHATFMT->text()));
75 sm->set(SettingsManager::LOG_FILE_MAIN_CHAT, _tq(lineEdit_FILE_CHATFMT->text()));
76 sm->set(SettingsManager::LOG_PRIVATE_CHAT, groupBox_PM->isChecked());
77 sm->set(SettingsManager::LOG_FORMAT_PRIVATE_CHAT, _tq(lineEdit_PMFMT->text()));
78 sm->set(SettingsManager::LOG_FILE_PRIVATE_CHAT, _tq(lineEdit_FILE_PMFMT->text()));
79 sm->set(SettingsManager::LOG_DOWNLOADS, groupBox_DOWN->isChecked());
80 sm->set(SettingsManager::LOG_FORMAT_POST_DOWNLOAD, _tq(lineEdit_DOWNFMT->text()));
81 sm->set(SettingsManager::LOG_FILE_DOWNLOAD, _tq(lineEdit_FILE_DOWNFMT->text()));
82 sm->set(SettingsManager::LOG_UPLOADS, groupBox_UP->isChecked());
83 sm->set(SettingsManager::LOG_FORMAT_POST_UPLOAD, _tq(lineEdit_UPFMT->text()));
84 sm->set(SettingsManager::LOG_FILE_UPLOAD, _tq(lineEdit_FILE_UPFMT->text()));
85 sm->set(SettingsManager::LOG_FINISHED_DOWNLOADS, groupBox_FINISH_DOWN->isChecked());
86 sm->set(SettingsManager::LOG_FORMAT_POST_FINISHED_DOWNLOAD, _tq(lineEdit_FINISH_DOWNFMT->text()));
87 sm->set(SettingsManager::LOG_FILE_FINISHED_DOWNLOAD, _tq(lineEdit_FILE_FINISH_DOWNFMT->text()));
88 sm->set(SettingsManager::LOG_SYSTEM, checkBox_SYSTEM->isChecked());
89 sm->set(SettingsManager::LOG_STATUS_MESSAGES, checkBox_STAT->isChecked());
90 sm->set(SettingsManager::LOG_FILELIST_TRANSFERS, checkBox_FILELIST->isChecked());
91 sm->set(SettingsManager::LOG_SPY, groupBox_SPYLOG->isChecked());
92 sm->set(SettingsManager::REPORT_ALTERNATES, checkBox_REPORT_ALTERNATES->isChecked());
93 }
94
slotBrowse()95 void SettingsLog::slotBrowse(){
96 QString dir = QFileDialog::getExistingDirectory(this, tr("Choose the directory"), lineEdit_LOGDIR->text());
97
98 if (!dir.isEmpty()){
99 dir = QDir::toNativeSeparators(dir);
100
101 if (!dir.endsWith(QDir::separator()))
102 dir += QDir::separator();
103
104 lineEdit_LOGDIR->setText(dir);
105 }
106 }
107