mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 13:23:34 -07:00
Add option to disable torrent state colors
This commit is contained in:
parent
66f3cf7e67
commit
ba6acc9478
9 changed files with 65 additions and 22 deletions
|
@ -186,6 +186,19 @@ void Preferences::setAlternatingRowColors(const bool b)
|
||||||
setValue(u"Preferences/General/AlternatingRowColors"_s, 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
|
bool Preferences::getProgressBarFollowsTextColor() const
|
||||||
{
|
{
|
||||||
return value(u"GUI/TransferList/ProgressBarFollowsTextColor"_s, false);
|
return value(u"GUI/TransferList/ProgressBarFollowsTextColor"_s, false);
|
||||||
|
|
|
@ -113,6 +113,8 @@ public:
|
||||||
void showSpeedInTitleBar(bool show);
|
void showSpeedInTitleBar(bool show);
|
||||||
bool useAlternatingRowColors() const;
|
bool useAlternatingRowColors() const;
|
||||||
void setAlternatingRowColors(bool b);
|
void setAlternatingRowColors(bool b);
|
||||||
|
bool useTorrentStatesColors() const;
|
||||||
|
void setUseTorrentStatesColors(bool value);
|
||||||
bool getProgressBarFollowsTextColor() const;
|
bool getProgressBarFollowsTextColor() const;
|
||||||
void setProgressBarFollowsTextColor(bool value);
|
void setProgressBarFollowsTextColor(bool value);
|
||||||
bool getHideZeroValues() const;
|
bool getHideZeroValues() const;
|
||||||
|
|
|
@ -261,7 +261,9 @@ void OptionsDialog::loadBehaviorTabOptions()
|
||||||
|
|
||||||
m_ui->confirmDeletion->setChecked(pref->confirmTorrentDeletion());
|
m_ui->confirmDeletion->setChecked(pref->confirmTorrentDeletion());
|
||||||
m_ui->checkAltRowColors->setChecked(pref->useAlternatingRowColors());
|
m_ui->checkAltRowColors->setChecked(pref->useAlternatingRowColors());
|
||||||
|
m_ui->checkUseTorrentStatesColors->setChecked(pref->useTorrentStatesColors());
|
||||||
m_ui->checkProgressBarFollowsTextColor->setChecked(pref->getProgressBarFollowsTextColor());
|
m_ui->checkProgressBarFollowsTextColor->setChecked(pref->getProgressBarFollowsTextColor());
|
||||||
|
m_ui->checkProgressBarFollowsTextColor->setEnabled(m_ui->checkProgressBarFollowsTextColor->isChecked());
|
||||||
m_ui->checkHideZero->setChecked(pref->getHideZeroValues());
|
m_ui->checkHideZero->setChecked(pref->getHideZeroValues());
|
||||||
m_ui->comboHideZero->setCurrentIndex(pref->getHideZeroComboValues());
|
m_ui->comboHideZero->setCurrentIndex(pref->getHideZeroComboValues());
|
||||||
m_ui->comboHideZero->setEnabled(m_ui->checkHideZero->isChecked());
|
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->confirmDeletion, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||||
connect(m_ui->checkAltRowColors, &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->checkProgressBarFollowsTextColor, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||||
connect(m_ui->checkHideZero, &QAbstractButton::toggled, m_ui->comboHideZero, &QWidget::setEnabled);
|
connect(m_ui->checkHideZero, &QAbstractButton::toggled, m_ui->comboHideZero, &QWidget::setEnabled);
|
||||||
connect(m_ui->checkHideZero, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
connect(m_ui->checkHideZero, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||||
|
@ -485,6 +489,7 @@ void OptionsDialog::saveBehaviorTabOptions() const
|
||||||
|
|
||||||
pref->setConfirmTorrentDeletion(m_ui->confirmDeletion->isChecked());
|
pref->setConfirmTorrentDeletion(m_ui->confirmDeletion->isChecked());
|
||||||
pref->setAlternatingRowColors(m_ui->checkAltRowColors->isChecked());
|
pref->setAlternatingRowColors(m_ui->checkAltRowColors->isChecked());
|
||||||
|
pref->setUseTorrentStatesColors(m_ui->checkUseTorrentStatesColors->isChecked());
|
||||||
pref->setProgressBarFollowsTextColor(m_ui->checkProgressBarFollowsTextColor->isChecked());
|
pref->setProgressBarFollowsTextColor(m_ui->checkProgressBarFollowsTextColor->isChecked());
|
||||||
pref->setHideZeroValues(m_ui->checkHideZero->isChecked());
|
pref->setHideZeroValues(m_ui->checkHideZero->isChecked());
|
||||||
pref->setHideZeroComboValues(m_ui->comboHideZero->currentIndex());
|
pref->setHideZeroComboValues(m_ui->comboHideZero->currentIndex());
|
||||||
|
|
|
@ -297,6 +297,16 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkUseTorrentStatesColors">
|
||||||
|
<property name="text">
|
||||||
|
<string>Use different text colors by torrent states</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="checkProgressBarFollowsTextColor">
|
<widget class="QCheckBox" name="checkProgressBarFollowsTextColor">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Bittorrent Client using Qt and libtorrent.
|
* Bittorrent Client using Qt and libtorrent.
|
||||||
|
* Copyright (C) 2025 Vladimir Golovnev <glassez@yandex.ru>
|
||||||
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
|
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
|
@ -34,16 +35,10 @@
|
||||||
#include "transferlistmodel.h"
|
#include "transferlistmodel.h"
|
||||||
|
|
||||||
TransferListDelegate::TransferListDelegate(QObject *parent)
|
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
|
QSize TransferListDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
// Reimplementing sizeHint() because the 'name' column contains text+icon.
|
// Reimplementing sizeHint() because the 'name' column contains text+icon.
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Bittorrent Client using Qt and libtorrent.
|
* Bittorrent Client using Qt and libtorrent.
|
||||||
|
* Copyright (C) 2025 Vladimir Golovnev <glassez@yandex.ru>
|
||||||
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
|
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
|
@ -40,7 +41,6 @@ class TransferListDelegate final : public QStyledItemDelegate
|
||||||
public:
|
public:
|
||||||
explicit TransferListDelegate(QObject *parent);
|
explicit TransferListDelegate(QObject *parent);
|
||||||
|
|
||||||
QWidget *createEditor(QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const override;
|
|
||||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Bittorrent Client using Qt and libtorrent.
|
* Bittorrent Client using Qt and libtorrent.
|
||||||
* Copyright (C) 2015-2024 Vladimir Golovnev <glassez@yandex.ru>
|
* Copyright (C) 2015-2025 Vladimir Golovnev <glassez@yandex.ru>
|
||||||
* Copyright (C) 2010 Christophe Dumez <chris@qbittorrent.org>
|
* Copyright (C) 2010 Christophe Dumez <chris@qbittorrent.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* 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
|
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());
|
const BitTorrent::Torrent *torrent = m_torrentList.value(index.row());
|
||||||
if (!torrent) return {};
|
if (!torrent)
|
||||||
|
return {};
|
||||||
|
|
||||||
switch (role)
|
switch (role)
|
||||||
{
|
{
|
||||||
case Qt::ForegroundRole:
|
case Qt::ForegroundRole:
|
||||||
|
if (m_useTorrentStatesColors)
|
||||||
return m_stateThemeColors.value(torrent->state());
|
return m_stateThemeColors.value(torrent->state());
|
||||||
|
break;
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
return displayValue(torrent, index.column());
|
return displayValue(torrent, index.column());
|
||||||
case UnderlyingDataRole:
|
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)
|
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());
|
BitTorrent::Torrent *const torrent = m_torrentList.value(index.row());
|
||||||
if (!torrent) return false;
|
if (!torrent)
|
||||||
|
return false;
|
||||||
|
|
||||||
// Category and Name columns can be edited
|
// Category and Name columns can be edited
|
||||||
switch (index.column())
|
switch (index.column())
|
||||||
|
@ -646,10 +652,10 @@ void TransferListModel::addTorrents(const QList<BitTorrent::Torrent *> &torrents
|
||||||
|
|
||||||
Qt::ItemFlags TransferListModel::flags(const QModelIndex &index) const
|
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);
|
||||||
return QAbstractListModel::flags(index) | Qt::ItemIsEditable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BitTorrent::Torrent *TransferListModel::torrentHandle(const QModelIndex &index) const
|
BitTorrent::Torrent *TransferListModel::torrentHandle(const QModelIndex &index) const
|
||||||
|
@ -717,11 +723,22 @@ void TransferListModel::configure()
|
||||||
hideZeroValuesMode = HideZeroValuesMode::Always;
|
hideZeroValuesMode = HideZeroValuesMode::Always;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isDataChanged = false;
|
||||||
|
|
||||||
if (m_hideZeroValuesMode != hideZeroValuesMode)
|
if (m_hideZeroValuesMode != hideZeroValuesMode)
|
||||||
{
|
{
|
||||||
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()
|
void TransferListModel::loadUIThemeResources()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Bittorrent Client using Qt and libtorrent.
|
* Bittorrent Client using Qt and libtorrent.
|
||||||
* Copyright (C) 2015-2024 Vladimir Golovnev <glassez@yandex.ru>
|
* Copyright (C) 2015-2025 Vladimir Golovnev <glassez@yandex.ru>
|
||||||
* Copyright (C) 2010 Christophe Dumez <chris@qbittorrent.org>
|
* Copyright (C) 2010 Christophe Dumez <chris@qbittorrent.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
|
@ -135,6 +135,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
HideZeroValuesMode m_hideZeroValuesMode = HideZeroValuesMode::Never;
|
HideZeroValuesMode m_hideZeroValuesMode = HideZeroValuesMode::Never;
|
||||||
|
bool m_useTorrentStatesColors = false;
|
||||||
|
|
||||||
// cached icons
|
// cached icons
|
||||||
QIcon m_checkingIcon;
|
QIcon m_checkingIcon;
|
||||||
|
|
|
@ -130,14 +130,14 @@ namespace
|
||||||
|
|
||||||
TransferListWidget::TransferListWidget(IGUIApplication *app, QWidget *parent)
|
TransferListWidget::TransferListWidget(IGUIApplication *app, QWidget *parent)
|
||||||
: GUIApplicationComponent(app, parent)
|
: GUIApplicationComponent(app, parent)
|
||||||
, m_listModel {new TransferListModel {this}}
|
, m_listModel {new TransferListModel(this)}
|
||||||
, m_sortFilterModel {new TransferListSortModel {this}}
|
, m_sortFilterModel {new TransferListSortModel(this)}
|
||||||
{
|
{
|
||||||
// Load settings
|
// Load settings
|
||||||
const bool columnLoaded = loadSettings();
|
const bool columnLoaded = loadSettings();
|
||||||
|
|
||||||
// Create and apply delegate
|
// Create and apply delegate
|
||||||
setItemDelegate(new TransferListDelegate {this});
|
setItemDelegate(new TransferListDelegate(this));
|
||||||
|
|
||||||
m_sortFilterModel->setDynamicSortFilter(true);
|
m_sortFilterModel->setDynamicSortFilter(true);
|
||||||
m_sortFilterModel->setSourceModel(m_listModel);
|
m_sortFilterModel->setSourceModel(m_listModel);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue