23 #include "cfgchatlogspage.h"
24 #include "ui_cfgchatlogspage.h"
26 #include "datapaths.h"
27 #include "irc/configuration/chatlogscfg.h"
28 #include "templatedpathresolver.h"
29 #include <QDesktopServices>
30 #include <QFileDialog>
32 #include <QMessageBox>
36 DClass<CfgChatLogsPage> :
public Ui::CfgChatLogsPage
47 d->lblDirWarning->hide();
48 d->btnBrowseDir->setIcon(style()->standardIcon(QStyle::SP_DirOpenIcon));
50 this->connect(d->leDir, SIGNAL(editingFinished()),
51 SIGNAL(validationRequested()));
54 CfgChatLogsPage::~CfgChatLogsPage()
58 void CfgChatLogsPage::browseStorageDirectory()
60 QString path = gDefaultDataPaths->portablizePath(QFileDialog::getExistingDirectory(
this,
61 tr(
"Browse chat logs storage directory"),
65 d->leDir->setText(path);
70 bool CfgChatLogsPage::checkDir(
const QString &directory)
72 if (directory.trimmed().isEmpty())
74 QMessageBox::critical(
this, tr(
"Directory error"), tr(
"Directory not specified."));
78 QFileInfo dir(directory);
81 QMessageBox::critical(
this, tr(
"Directory error"), tr(
"Directory doesn't exist."));
84 QString validationError = validateChatLogsPath(dir);
85 if (!validationError.isEmpty())
87 QMessageBox::critical(
this, tr(
"Directory error"), validationError);
93 void CfgChatLogsPage::exploreStorageDirectory()
99 QDesktopServices::openUrl(QString(
"file:///%1").arg(
100 QDir::toNativeSeparators(dir.absolutePath())));
107 d->leDir->setText(cfg.chatLogsRootDir());
108 d->cbStoreLogs->setChecked(cfg.isStoreLogs());
109 d->cbRestoreLogs->setChecked(cfg.isRestoreChatFromLogs());
110 d->groupRemoveOldArchives->setChecked(cfg.isRemoveOldLogs());
111 d->spinLogRemovalAge->setValue(cfg.oldLogsRemovalDaysThreshold());
117 cfg.setChatLogsRootDir(d->leDir->text().trimmed());
118 cfg.setStoreLogs(d->cbStoreLogs->isChecked());
119 cfg.setRestoreChatFromLogs(d->cbRestoreLogs->isChecked());
120 cfg.setRemoveOldLogs(d->groupRemoveOldArchives->isChecked());
121 cfg.setOldLogsRemovalDaysThreshold(d->spinLogRemovalAge->value());
126 QString error = validateChatLogsPath(QFileInfo(
128 d->lblDirWarning->setToolTip(error);
129 d->lblDirWarning->setVisible(!error.isEmpty());
133 QString CfgChatLogsPage::validateChatLogsPath(
const QFileInfo &path)
const
135 if (path.exists() && !path.isDir())
136 return tr(
"The specified path isn't a directory.");