From 90b1567d1360916ab360165bb9ef1792f1e6279f Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Tue, 3 Jul 2012 18:37:24 +0300 Subject: [PATCH] Remember column sizes in torrent addition dialog --- src/addnewtorrentdialog.cpp | 19 +++++++++++++++++++ src/addnewtorrentdialog.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/src/addnewtorrentdialog.cpp b/src/addnewtorrentdialog.cpp index 0fb43a05b..6dec0435d 100644 --- a/src/addnewtorrentdialog.cpp +++ b/src/addnewtorrentdialog.cpp @@ -82,15 +82,34 @@ AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent) : ui->label_combo->addItem(label); } showAdvancedSettings(false); + loadState(); } AddNewTorrentDialog::~AddNewTorrentDialog() { + saveState(); delete ui; if (m_contentModel) delete m_contentModel; } +void AddNewTorrentDialog::loadState() +{ + QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); + settings.beginGroup(QString::fromUtf8("AddNewTorrentDialog")); + QByteArray state = settings.value("treeHeaderState").toByteArray(); + if (!state.isEmpty()) + ui->content_tree->header()->restoreState(state); +} + +void AddNewTorrentDialog::saveState() +{ + QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); + settings.beginGroup(QString::fromUtf8("AddNewTorrentDialog")); + if (m_contentModel) + settings.setValue("treeHeaderState", ui->content_tree->header()->saveState()); +} + void AddNewTorrentDialog::showTorrent(const QString &torrent_path, const QString& from_url) { AddNewTorrentDialog dlg; diff --git a/src/addnewtorrentdialog.h b/src/addnewtorrentdialog.h index fb4bde13a..f6d8b078d 100644 --- a/src/addnewtorrentdialog.h +++ b/src/addnewtorrentdialog.h @@ -72,6 +72,8 @@ private: void saveSavePathHistory() const; int indexOfSavePath(const QString& save_path); void updateFileNameInSavePaths(const QString& new_filename); + void loadState(); + void saveState(); private: Ui::AddNewTorrentDialog *ui;