mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-01 21:28:07 -06:00
Merge pull request #15682 from Chocobo1/qt6
Store Qt6 table header states under a different key
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user