diff --git a/src/base/preferences.cpp b/src/base/preferences.cpp
index ef0ad708b..c8cd49d1d 100644
--- a/src/base/preferences.cpp
+++ b/src/base/preferences.cpp
@@ -186,6 +186,19 @@ void Preferences::setAlternatingRowColors(const bool b)
setValue(u"Preferences/General/AlternatingRowColors"_s, b);
}
+bool Preferences::useTorrentStatesColors() const
+{
+ return value(u"GUI/TransferList/UseTorrentStatesColors"_s, true);
+}
+
+void Preferences::setUseTorrentStatesColors(const bool value)
+{
+ if (value == useTorrentStatesColors())
+ return;
+
+ setValue(u"GUI/TransferList/UseTorrentStatesColors"_s, value);
+}
+
bool Preferences::getProgressBarFollowsTextColor() const
{
return value(u"GUI/TransferList/ProgressBarFollowsTextColor"_s, false);
diff --git a/src/base/preferences.h b/src/base/preferences.h
index bf08fde3d..0da55ab99 100644
--- a/src/base/preferences.h
+++ b/src/base/preferences.h
@@ -113,6 +113,8 @@ public:
void showSpeedInTitleBar(bool show);
bool useAlternatingRowColors() const;
void setAlternatingRowColors(bool b);
+ bool useTorrentStatesColors() const;
+ void setUseTorrentStatesColors(bool value);
bool getProgressBarFollowsTextColor() const;
void setProgressBarFollowsTextColor(bool value);
bool getHideZeroValues() const;
diff --git a/src/gui/optionsdialog.cpp b/src/gui/optionsdialog.cpp
index 70eb43c43..557c5569c 100644
--- a/src/gui/optionsdialog.cpp
+++ b/src/gui/optionsdialog.cpp
@@ -261,7 +261,9 @@ void OptionsDialog::loadBehaviorTabOptions()
m_ui->confirmDeletion->setChecked(pref->confirmTorrentDeletion());
m_ui->checkAltRowColors->setChecked(pref->useAlternatingRowColors());
+ m_ui->checkUseTorrentStatesColors->setChecked(pref->useTorrentStatesColors());
m_ui->checkProgressBarFollowsTextColor->setChecked(pref->getProgressBarFollowsTextColor());
+ m_ui->checkProgressBarFollowsTextColor->setEnabled(m_ui->checkProgressBarFollowsTextColor->isChecked());
m_ui->checkHideZero->setChecked(pref->getHideZeroValues());
m_ui->comboHideZero->setCurrentIndex(pref->getHideZeroComboValues());
m_ui->comboHideZero->setEnabled(m_ui->checkHideZero->isChecked());
@@ -390,6 +392,8 @@ void OptionsDialog::loadBehaviorTabOptions()
connect(m_ui->confirmDeletion, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkAltRowColors, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
+ connect(m_ui->checkUseTorrentStatesColors, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
+ connect(m_ui->checkUseTorrentStatesColors, &QAbstractButton::toggled, m_ui->checkProgressBarFollowsTextColor, &QWidget::setEnabled);
connect(m_ui->checkProgressBarFollowsTextColor, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkHideZero, &QAbstractButton::toggled, m_ui->comboHideZero, &QWidget::setEnabled);
connect(m_ui->checkHideZero, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
@@ -485,6 +489,7 @@ void OptionsDialog::saveBehaviorTabOptions() const
pref->setConfirmTorrentDeletion(m_ui->confirmDeletion->isChecked());
pref->setAlternatingRowColors(m_ui->checkAltRowColors->isChecked());
+ pref->setUseTorrentStatesColors(m_ui->checkUseTorrentStatesColors->isChecked());
pref->setProgressBarFollowsTextColor(m_ui->checkProgressBarFollowsTextColor->isChecked());
pref->setHideZeroValues(m_ui->checkHideZero->isChecked());
pref->setHideZeroComboValues(m_ui->comboHideZero->currentIndex());
diff --git a/src/gui/optionsdialog.ui b/src/gui/optionsdialog.ui
index 4ac59453c..a0afed167 100644
--- a/src/gui/optionsdialog.ui
+++ b/src/gui/optionsdialog.ui
@@ -297,6 +297,16 @@
+ -
+
+
+ Use different text colors by torrent states
+
+
+ true
+
+
+
-
diff --git a/src/gui/transferlistdelegate.cpp b/src/gui/transferlistdelegate.cpp
index 8bc41e45d..098a136e5 100644
--- a/src/gui/transferlistdelegate.cpp
+++ b/src/gui/transferlistdelegate.cpp
@@ -1,5 +1,6 @@
/*
* Bittorrent Client using Qt and libtorrent.
+ * Copyright (C) 2025 Vladimir Golovnev
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
@@ -34,16 +35,10 @@
#include "transferlistmodel.h"
TransferListDelegate::TransferListDelegate(QObject *parent)
- : QStyledItemDelegate {parent}
+ : QStyledItemDelegate(parent)
{
}
-QWidget *TransferListDelegate::createEditor(QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const
-{
- // No editor here
- return nullptr;
-}
-
QSize TransferListDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
// Reimplementing sizeHint() because the 'name' column contains text+icon.
diff --git a/src/gui/transferlistdelegate.h b/src/gui/transferlistdelegate.h
index 01194d118..6a87519a3 100644
--- a/src/gui/transferlistdelegate.h
+++ b/src/gui/transferlistdelegate.h
@@ -1,5 +1,6 @@
/*
* Bittorrent Client using Qt and libtorrent.
+ * Copyright (C) 2025 Vladimir Golovnev
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
@@ -40,7 +41,6 @@ class TransferListDelegate final : public QStyledItemDelegate
public:
explicit TransferListDelegate(QObject *parent);
- QWidget *createEditor(QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const override;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
diff --git a/src/gui/transferlistmodel.cpp b/src/gui/transferlistmodel.cpp
index 0298db047..f72443a7e 100644
--- a/src/gui/transferlistmodel.cpp
+++ b/src/gui/transferlistmodel.cpp
@@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt and libtorrent.
- * Copyright (C) 2015-2024 Vladimir Golovnev
+ * Copyright (C) 2015-2025 Vladimir Golovnev
* Copyright (C) 2010 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
@@ -533,15 +533,19 @@ QVariant TransferListModel::internalValue(const BitTorrent::Torrent *torrent, co
QVariant TransferListModel::data(const QModelIndex &index, const int role) const
{
- if (!index.isValid()) return {};
+ if (!index.isValid())
+ return {};
const BitTorrent::Torrent *torrent = m_torrentList.value(index.row());
- if (!torrent) return {};
+ if (!torrent)
+ return {};
switch (role)
{
case Qt::ForegroundRole:
- return m_stateThemeColors.value(torrent->state());
+ if (m_useTorrentStatesColors)
+ return m_stateThemeColors.value(torrent->state());
+ break;
case Qt::DisplayRole:
return displayValue(torrent, index.column());
case UnderlyingDataRole:
@@ -604,10 +608,12 @@ QVariant TransferListModel::data(const QModelIndex &index, const int role) const
bool TransferListModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
- if (!index.isValid() || (role != Qt::DisplayRole)) return false;
+ if (!index.isValid() || (role != Qt::DisplayRole))
+ return false;
BitTorrent::Torrent *const torrent = m_torrentList.value(index.row());
- if (!torrent) return false;
+ if (!torrent)
+ return false;
// Category and Name columns can be edited
switch (index.column())
@@ -646,10 +652,10 @@ void TransferListModel::addTorrents(const QList &torrents
Qt::ItemFlags TransferListModel::flags(const QModelIndex &index) const
{
- if (!index.isValid()) return Qt::NoItemFlags;
+ if (!index.isValid())
+ return Qt::NoItemFlags;
- // Explicitly mark as editable
- return QAbstractListModel::flags(index) | Qt::ItemIsEditable;
+ return QAbstractListModel::flags(index);
}
BitTorrent::Torrent *TransferListModel::torrentHandle(const QModelIndex &index) const
@@ -717,11 +723,22 @@ void TransferListModel::configure()
hideZeroValuesMode = HideZeroValuesMode::Always;
}
+ bool isDataChanged = false;
+
if (m_hideZeroValuesMode != hideZeroValuesMode)
{
m_hideZeroValuesMode = hideZeroValuesMode;
- emit dataChanged(index(0, 0), index((rowCount() - 1), (columnCount() - 1)));
+ isDataChanged = true;
}
+
+ if (const bool useTorrentStatesColors = pref->useTorrentStatesColors(); m_useTorrentStatesColors != useTorrentStatesColors)
+ {
+ m_useTorrentStatesColors = useTorrentStatesColors;
+ isDataChanged = true;
+ }
+
+ if (isDataChanged)
+ emit dataChanged(index(0, 0), index((rowCount() - 1), (columnCount() - 1)));
}
void TransferListModel::loadUIThemeResources()
diff --git a/src/gui/transferlistmodel.h b/src/gui/transferlistmodel.h
index 306beee0b..6034e4940 100644
--- a/src/gui/transferlistmodel.h
+++ b/src/gui/transferlistmodel.h
@@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt and libtorrent.
- * Copyright (C) 2015-2024 Vladimir Golovnev
+ * Copyright (C) 2015-2025 Vladimir Golovnev
* Copyright (C) 2010 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
@@ -135,6 +135,7 @@ private:
};
HideZeroValuesMode m_hideZeroValuesMode = HideZeroValuesMode::Never;
+ bool m_useTorrentStatesColors = false;
// cached icons
QIcon m_checkingIcon;
diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp
index f78dd8481..b2ed64ee7 100644
--- a/src/gui/transferlistwidget.cpp
+++ b/src/gui/transferlistwidget.cpp
@@ -130,14 +130,14 @@ namespace
TransferListWidget::TransferListWidget(IGUIApplication *app, QWidget *parent)
: GUIApplicationComponent(app, parent)
- , m_listModel {new TransferListModel {this}}
- , m_sortFilterModel {new TransferListSortModel {this}}
+ , m_listModel {new TransferListModel(this)}
+ , m_sortFilterModel {new TransferListSortModel(this)}
{
// Load settings
const bool columnLoaded = loadSettings();
// Create and apply delegate
- setItemDelegate(new TransferListDelegate {this});
+ setItemDelegate(new TransferListDelegate(this));
m_sortFilterModel->setDynamicSortFilter(true);
m_sortFilterModel->setSourceModel(m_listModel);