mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-21 16:07:23 -06:00
Implement file logger.
This commit is contained in:
@@ -113,9 +113,9 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<y>-190</y>
|
||||
<width>486</width>
|
||||
<height>702</height>
|
||||
<height>732</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
@@ -470,6 +470,153 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="checkFileLog">
|
||||
<property name="title">
|
||||
<string>Log file</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_11">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Save path:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="textFileLogPath"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="browseFileLogDir">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkFileLogBackup">
|
||||
<property name="text">
|
||||
<string>Backup the log file after:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinFileLogSize">
|
||||
<property name="suffix">
|
||||
<string> MB</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_10">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkFileLogDelete">
|
||||
<property name="text">
|
||||
<string>Delete backup logs older than:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinFileLogAge">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>365</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>6</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboFileLogAgeType">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string comment="Delete backup logs older than 10 months">days</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string comment="Delete backup logs older than 10 months">months</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string comment="Delete backup logs older than 10 years">years</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_16">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
|
||||
@@ -167,6 +167,16 @@ options_imp::options_imp(QWidget *parent)
|
||||
connect(checkAssociateTorrents, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||
connect(checkAssociateMagnetLinks, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||
#endif
|
||||
connect(checkFileLog, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||
connect(textFileLogPath, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
|
||||
connect(checkFileLogBackup, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||
connect(checkFileLogBackup, SIGNAL(toggled(bool)), spinFileLogSize, SLOT(setEnabled(bool)));
|
||||
connect(checkFileLogDelete, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||
connect(checkFileLogDelete, SIGNAL(toggled(bool)), spinFileLogAge, SLOT(setEnabled(bool)));
|
||||
connect(checkFileLogDelete, SIGNAL(toggled(bool)), comboFileLogAgeType, SLOT(setEnabled(bool)));
|
||||
connect(spinFileLogSize, SIGNAL(valueChanged(int)), this, SLOT(enableApplyButton()));
|
||||
connect(spinFileLogAge, SIGNAL(valueChanged(int)), this, SLOT(enableApplyButton()));
|
||||
connect(comboFileLogAgeType, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton()));
|
||||
// Downloads tab
|
||||
connect(textSavePath, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
|
||||
connect(radioBtnEnableSubcategories, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||
@@ -434,6 +444,13 @@ void options_imp::saveOptions()
|
||||
checkAssociateMagnetLinks->setEnabled(!checkAssociateMagnetLinks->isChecked());
|
||||
}
|
||||
#endif
|
||||
pref->setFileLogEnabled(checkFileLog->isChecked());
|
||||
pref->setFileLogPath(Utils::Fs::fromNativePath(textFileLogPath->text()));
|
||||
pref->setFileLogBackup(checkFileLogBackup->isChecked());
|
||||
pref->setFileLogMaxSize(spinFileLogSize->value());
|
||||
pref->setFileLogDeleteOld(checkFileLogDelete->isChecked());
|
||||
pref->setFileLogAge(spinFileLogAge->value());
|
||||
pref->setFileLogAgeType(comboFileLogAgeType->currentIndex());
|
||||
// End General preferences
|
||||
|
||||
auto session = BitTorrent::Session::instance();
|
||||
@@ -588,6 +605,8 @@ void options_imp::loadOptions()
|
||||
int intValue;
|
||||
qreal floatValue;
|
||||
QString strValue;
|
||||
bool fileLogBackup = true;
|
||||
bool fileLogDelete = true;
|
||||
const Preferences* const pref = Preferences::instance();
|
||||
|
||||
// General preferences
|
||||
@@ -621,6 +640,19 @@ void options_imp::loadOptions()
|
||||
checkAssociateMagnetLinks->setChecked(Preferences::isMagnetLinkAssocSet());
|
||||
checkAssociateMagnetLinks->setEnabled(!checkAssociateMagnetLinks->isChecked());
|
||||
#endif
|
||||
|
||||
checkFileLog->setChecked(pref->fileLogEnabled());
|
||||
textFileLogPath->setText(Utils::Fs::toNativePath(pref->fileLogPath()));
|
||||
fileLogBackup = pref->fileLogBackup();
|
||||
checkFileLogBackup->setChecked(fileLogBackup);
|
||||
spinFileLogSize->setEnabled(fileLogBackup);
|
||||
fileLogDelete = pref->fileLogDeleteOld();
|
||||
checkFileLogDelete->setChecked(fileLogDelete);
|
||||
spinFileLogAge->setEnabled(fileLogDelete);
|
||||
comboFileLogAgeType->setEnabled(fileLogDelete);
|
||||
spinFileLogSize->setValue(pref->fileLogMaxSize());
|
||||
spinFileLogAge->setValue(pref->fileLogAge());
|
||||
comboFileLogAgeType->setCurrentIndex(pref->fileLogAgeType());
|
||||
// End General preferences
|
||||
|
||||
auto session = BitTorrent::Session::instance();
|
||||
@@ -1293,6 +1325,19 @@ QString options_imp::askForExportDir(const QString& currentExportPath)
|
||||
return dir;
|
||||
}
|
||||
|
||||
void options_imp::on_browseFileLogDir_clicked()
|
||||
{
|
||||
const QString path = Utils::Fs::expandPathAbs(Utils::Fs::fromNativePath(textFileLogPath->text()));
|
||||
QDir pathDir(path);
|
||||
QString dir;
|
||||
if (!path.isEmpty() && pathDir.exists())
|
||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), pathDir.absolutePath());
|
||||
else
|
||||
dir = QFileDialog::getExistingDirectory(this, tr("Choose a save directory"), QDir::homePath());
|
||||
if (!dir.isNull())
|
||||
textFileLogPath->setText(Utils::Fs::toNativePath(dir));
|
||||
}
|
||||
|
||||
void options_imp::on_browseExportDirButton_clicked()
|
||||
{
|
||||
const QString newExportDir = askForExportDir(textExportDir->text());
|
||||
|
||||
@@ -83,6 +83,7 @@ private slots:
|
||||
void handleScanFolderViewSelectionChanged();
|
||||
void on_IpFilterRefreshBtn_clicked();
|
||||
void handleIPFilterParsed(bool error, int ruleCount);
|
||||
void on_browseFileLogDir_clicked();
|
||||
void on_browseExportDirButton_clicked();
|
||||
void on_browseExportDirFinButton_clicked();
|
||||
void on_browseFilterButton_clicked();
|
||||
|
||||
Reference in New Issue
Block a user