mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-28 05:27:15 +03:00
Store Qt6 table header states under a different key
This commit is contained in:
parent
32698fe0be
commit
22abbc1d41
6 changed files with 101 additions and 15 deletions
|
@ -1265,12 +1265,20 @@ void Preferences::setMainGeometry(const QByteArray &geometry)
|
|||
|
||||
QByteArray Preferences::getMainVSplitterState() const
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
return value("GUI/Qt6/MainWindow/VSplitterState").toByteArray();
|
||||
#else
|
||||
return value("MainWindow/qt5/vsplitterState").toByteArray();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Preferences::setMainVSplitterState(const QByteArray &state)
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
setValue("GUI/Qt6/MainWindow/VSplitterState", state);
|
||||
#else
|
||||
setValue("MainWindow/qt5/vsplitterState", state);
|
||||
#endif
|
||||
}
|
||||
|
||||
QString Preferences::getMainLastDir() const
|
||||
|
@ -1285,12 +1293,20 @@ void Preferences::setMainLastDir(const QString &path)
|
|||
|
||||
QByteArray Preferences::getPeerListState() const
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
return value("GUI/Qt6/TorrentProperties/PeerListState").toByteArray();
|
||||
#else
|
||||
return value("TorrentProperties/Peers/qt5/PeerListState").toByteArray();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Preferences::setPeerListState(const QByteArray &state)
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
setValue("GUI/Qt6/TorrentProperties/PeerListState", state);
|
||||
#else
|
||||
setValue("TorrentProperties/Peers/qt5/PeerListState", state);
|
||||
#endif
|
||||
}
|
||||
|
||||
QString Preferences::getPropSplitterSizes() const
|
||||
|
@ -1305,12 +1321,20 @@ void Preferences::setPropSplitterSizes(const QString &sizes)
|
|||
|
||||
QByteArray Preferences::getPropFileListState() const
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
return value("GUI/Qt6/TorrentProperties/FilesListState").toByteArray();
|
||||
#else
|
||||
return value("TorrentProperties/qt5/FilesListState").toByteArray();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Preferences::setPropFileListState(const QByteArray &state)
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
setValue("GUI/Qt6/TorrentProperties/FilesListState", state);
|
||||
#else
|
||||
setValue("TorrentProperties/qt5/FilesListState", state);
|
||||
#endif
|
||||
}
|
||||
|
||||
int Preferences::getPropCurTab() const
|
||||
|
@ -1335,12 +1359,20 @@ void Preferences::setPropVisible(const bool visible)
|
|||
|
||||
QByteArray Preferences::getPropTrackerListState() const
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
return value("GUI/Qt6/TorrentProperties/TrackerListState").toByteArray();
|
||||
#else
|
||||
return value("TorrentProperties/Trackers/qt5/TrackerListState").toByteArray();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Preferences::setPropTrackerListState(const QByteArray &state)
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
setValue("GUI/Qt6/TorrentProperties/TrackerListState", state);
|
||||
#else
|
||||
setValue("TorrentProperties/Trackers/qt5/TrackerListState", state);
|
||||
#endif
|
||||
}
|
||||
|
||||
QSize Preferences::getRssGeometrySize() const
|
||||
|
@ -1355,12 +1387,20 @@ void Preferences::setRssGeometrySize(const QSize &geometry)
|
|||
|
||||
QByteArray Preferences::getRssHSplitterSizes() const
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
return value("GUI/Qt6/RSSFeedDownloader/HSplitterSizes").toByteArray();
|
||||
#else
|
||||
return value("RssFeedDownloader/qt5/hsplitterSizes").toByteArray();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Preferences::setRssHSplitterSizes(const QByteArray &sizes)
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
setValue("GUI/Qt6/RSSFeedDownloader/HSplitterSizes", sizes);
|
||||
#else
|
||||
setValue("RssFeedDownloader/qt5/hsplitterSizes", sizes);
|
||||
#endif
|
||||
}
|
||||
|
||||
QStringList Preferences::getRssOpenFolders() const
|
||||
|
@ -1375,32 +1415,56 @@ void Preferences::setRssOpenFolders(const QStringList &folders)
|
|||
|
||||
QByteArray Preferences::getRssSideSplitterState() const
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
return value("GUI/Qt6/RSSWidget/SideSplitterState").toByteArray();
|
||||
#else
|
||||
return value("GUI/RSSWidget/qt5/splitter_h").toByteArray();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Preferences::setRssSideSplitterState(const QByteArray &state)
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
setValue("GUI/Qt6/RSSWidget/SideSplitterState", state);
|
||||
#else
|
||||
setValue("GUI/RSSWidget/qt5/splitter_h", state);
|
||||
#endif
|
||||
}
|
||||
|
||||
QByteArray Preferences::getRssMainSplitterState() const
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
return value("GUI/Qt6/RSSWidget/MainSplitterState").toByteArray();
|
||||
#else
|
||||
return value("GUI/RSSWidget/qt5/splitterMain").toByteArray();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Preferences::setRssMainSplitterState(const QByteArray &state)
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
setValue("GUI/Qt6/RSSWidget/MainSplitterState", state);
|
||||
#else
|
||||
setValue("GUI/RSSWidget/qt5/splitterMain", state);
|
||||
#endif
|
||||
}
|
||||
|
||||
QByteArray Preferences::getSearchTabHeaderState() const
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
return value("GUI/Qt6/SearchTab/HeaderState").toByteArray();
|
||||
#else
|
||||
return value("SearchTab/qt5/HeaderState").toByteArray();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Preferences::setSearchTabHeaderState(const QByteArray &state)
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
setValue("GUI/Qt6/SearchTab/HeaderState", state);
|
||||
#else
|
||||
setValue("SearchTab/qt5/HeaderState", state);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Preferences::getRegexAsFilteringPatternForSearchJob() const
|
||||
|
@ -1495,12 +1559,20 @@ void Preferences::setTransSelFilter(const int index)
|
|||
|
||||
QByteArray Preferences::getTransHeaderState() const
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
return value("GUI/Qt6/TransferList/HeaderState").toByteArray();
|
||||
#else
|
||||
return value("TransferList/qt5/HeaderState").toByteArray();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Preferences::setTransHeaderState(const QByteArray &state)
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
setValue("GUI/Qt6/TransferList/HeaderState", state);
|
||||
#else
|
||||
setValue("TransferList/qt5/HeaderState", state);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Preferences::getRegexAsFilteringPatternForTransferList() const
|
||||
|
|
|
@ -82,10 +82,14 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP
|
|||
, m_ui(new Ui::AddNewTorrentDialog)
|
||||
, m_torrentParams(inParams)
|
||||
, m_storeDialogSize(SETTINGS_KEY("DialogSize"))
|
||||
, m_storeSplitterState(SETTINGS_KEY("SplitterState"))
|
||||
, m_storeDefaultCategory(SETTINGS_KEY("DefaultCategory"))
|
||||
, m_storeRememberLastSavePath(SETTINGS_KEY("RememberLastSavePath"))
|
||||
, m_storeTreeHeaderState(SETTINGS_KEY("TreeHeaderState"))
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
, m_storeSplitterState("GUI/Qt6/" SETTINGS_KEY("SplitterState"))
|
||||
#else
|
||||
, m_storeSplitterState(SETTINGS_KEY("SplitterState"))
|
||||
#endif
|
||||
{
|
||||
// TODO: set dialog file properties using m_torrentParams.filePriorities
|
||||
m_ui->setupUi(this);
|
||||
|
@ -715,8 +719,8 @@ void AddNewTorrentDialog::setupTreeview()
|
|||
|
||||
// List files in torrent
|
||||
m_contentModel->model()->setupModelData(m_torrentInfo);
|
||||
if (!m_storeTreeHeaderState.get().isEmpty())
|
||||
m_ui->contentTreeView->header()->restoreState(m_storeTreeHeaderState);
|
||||
if (const QByteArray state = m_storeTreeHeaderState; !state.isEmpty())
|
||||
m_ui->contentTreeView->header()->restoreState(state);
|
||||
|
||||
// Hide useless columns after loading the header state
|
||||
m_ui->contentTreeView->hideColumn(PROGRESS);
|
||||
|
|
|
@ -118,8 +118,8 @@ private:
|
|||
BitTorrent::AddTorrentParams m_torrentParams;
|
||||
|
||||
SettingValue<QSize> m_storeDialogSize;
|
||||
SettingValue<QByteArray> m_storeSplitterState;
|
||||
SettingValue<QString> m_storeDefaultCategory;
|
||||
SettingValue<bool> m_storeRememberLastSavePath;
|
||||
CachedSettingValue<QByteArray> m_storeTreeHeaderState;
|
||||
SettingValue<QByteArray> m_storeTreeHeaderState;
|
||||
SettingValue<QByteArray> m_storeSplitterState;
|
||||
};
|
||||
|
|
|
@ -32,20 +32,23 @@
|
|||
|
||||
#include "base/global.h"
|
||||
#include "base/net/downloadmanager.h"
|
||||
#include "base/settingsstorage.h"
|
||||
#include "cookiesmodel.h"
|
||||
#include "ui_cookiesdialog.h"
|
||||
#include "uithememanager.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define SETTINGS_KEY(name) QStringLiteral("CookiesDialog/" name)
|
||||
const QString KEY_SIZE = SETTINGS_KEY("Size");
|
||||
const QString KEY_COOKIESVIEWSTATE = SETTINGS_KEY("CookiesViewState");
|
||||
#define SETTINGS_KEY(name) "CookiesDialog/" name
|
||||
|
||||
CookiesDialog::CookiesDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, m_ui(new Ui::CookiesDialog)
|
||||
, m_cookiesModel(new CookiesModel(Net::DownloadManager::instance()->allCookies(), this))
|
||||
, m_storeDialogSize(SETTINGS_KEY("Size"))
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
, m_storeViewState("GUI/Qt6/" SETTINGS_KEY("ViewState"))
|
||||
#else
|
||||
, m_storeViewState(SETTINGS_KEY("CookiesViewState"))
|
||||
#endif
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
|
@ -61,16 +64,14 @@ CookiesDialog::CookiesDialog(QWidget *parent)
|
|||
m_cookiesModel->index(0, 0),
|
||||
QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
||||
|
||||
Utils::Gui::resize(this, SettingsStorage::instance()->loadValue<QSize>(KEY_SIZE));
|
||||
m_ui->treeView->header()->restoreState(
|
||||
SettingsStorage::instance()->loadValue<QByteArray>(KEY_COOKIESVIEWSTATE));
|
||||
Utils::Gui::resize(this, m_storeDialogSize);
|
||||
m_ui->treeView->header()->restoreState(m_storeViewState);
|
||||
}
|
||||
|
||||
CookiesDialog::~CookiesDialog()
|
||||
{
|
||||
SettingsStorage::instance()->storeValue(KEY_SIZE, size());
|
||||
SettingsStorage::instance()->storeValue(
|
||||
KEY_COOKIESVIEWSTATE, m_ui->treeView->header()->saveState());
|
||||
m_storeDialogSize = size();
|
||||
m_storeViewState = m_ui->treeView->header()->saveState();
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
#include <QDialog>
|
||||
|
||||
#include "base/settingvalue.h"
|
||||
|
||||
class CookiesModel;
|
||||
|
||||
namespace Ui
|
||||
|
@ -55,4 +57,7 @@ private slots:
|
|||
private:
|
||||
Ui::CookiesDialog *m_ui;
|
||||
CookiesModel *m_cookiesModel;
|
||||
|
||||
SettingValue<QSize> m_storeDialogSize;
|
||||
SettingValue<QByteArray> m_storeViewState;
|
||||
};
|
||||
|
|
|
@ -52,7 +52,11 @@ PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, const BitTorrent::Torr
|
|||
, m_ui(new Ui::PreviewSelectDialog)
|
||||
, m_torrent(torrent)
|
||||
, m_storeDialogSize(SETTINGS_KEY("Size"))
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
, m_storeTreeHeaderState("GUI/Qt6/" SETTINGS_KEY("HeaderState"))
|
||||
#else
|
||||
, m_storeTreeHeaderState(SETTINGS_KEY("HeaderState"))
|
||||
#endif
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
|
|
Loading…
Reference in a new issue