23 #include "cfgchatlogspage.h"
24 #include "ui_cfgchatlogspage.h"
26 #include "irc/configuration/chatlogscfg.h"
27 #include <QDesktopServices>
28 #include <QFileDialog>
30 #include <QMessageBox>
33 DClass<CfgChatLogsPage> :
public Ui::CfgChatLogsPage
44 d->lblDirWarning->hide();
46 this->connect(d->leDir, SIGNAL(editingFinished()),
47 SIGNAL(validationRequested()));
50 CfgChatLogsPage::~CfgChatLogsPage()
54 void CfgChatLogsPage::browseStorageDirectory()
56 QString path = QFileDialog::getExistingDirectory(
this,
57 tr(
"Browse chat logs storage directory"), d->leDir->text());
60 d->leDir->setText(path);
65 bool CfgChatLogsPage::checkDir(
const QString &directory)
67 if (directory.trimmed().isEmpty())
69 QMessageBox::critical(
this, tr(
"Directory error"), tr(
"Directory not specified."));
73 QFileInfo dir(directory);
76 QMessageBox::critical(
this, tr(
"Directory error"), tr(
"Directory doesn't exist."));
79 QString validationError = validateChatLogsPath(directory);
80 if (!validationError.isEmpty())
82 QMessageBox::critical(
this, tr(
"Directory error"), validationError);
88 void CfgChatLogsPage::exploreStorageDirectory()
90 QString path = d->leDir->text().trimmed();
93 QDesktopServices::openUrl(QString(
"file:///%1").arg(
94 QDir::toNativeSeparators(path)));
101 d->leDir->setText(cfg.chatLogsRootDir());
102 d->cbStoreLogs->setChecked(cfg.isStoreLogs());
103 d->cbRestoreLogs->setChecked(cfg.isRestoreChatFromLogs());
104 d->groupRemoveOldArchives->setChecked(cfg.isRemoveOldLogs());
105 d->spinLogRemovalAge->setValue(cfg.oldLogsRemovalDaysThreshold());
111 cfg.setChatLogsRootDir(d->leDir->text().trimmed());
112 cfg.setStoreLogs(d->cbStoreLogs->isChecked());
113 cfg.setRestoreChatFromLogs(d->cbRestoreLogs->isChecked());
114 cfg.setRemoveOldLogs(d->groupRemoveOldArchives->isChecked());
115 cfg.setOldLogsRemovalDaysThreshold(d->spinLogRemovalAge->value());
120 QString error = validateChatLogsPath(d->leDir->text().trimmed());
121 d->lblDirWarning->setToolTip(error);
122 d->lblDirWarning->setVisible(!error.isEmpty());
126 QString CfgChatLogsPage::validateChatLogsPath(
const QFileInfo &path)
const
128 if (path.exists() && !path.isDir())
129 return tr(
"Specified path isn't a directory.");