Remember column sizes in torrent addition dialog

This commit is contained in:
Christophe Dumez 2012-07-03 18:37:24 +03:00
parent 41132d39ae
commit 90b1567d13
2 changed files with 21 additions and 0 deletions

View File

@ -82,15 +82,34 @@ AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent) :
ui->label_combo->addItem(label); ui->label_combo->addItem(label);
} }
showAdvancedSettings(false); showAdvancedSettings(false);
loadState();
} }
AddNewTorrentDialog::~AddNewTorrentDialog() AddNewTorrentDialog::~AddNewTorrentDialog()
{ {
saveState();
delete ui; delete ui;
if (m_contentModel) if (m_contentModel)
delete 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) void AddNewTorrentDialog::showTorrent(const QString &torrent_path, const QString& from_url)
{ {
AddNewTorrentDialog dlg; AddNewTorrentDialog dlg;

View File

@ -72,6 +72,8 @@ private:
void saveSavePathHistory() const; void saveSavePathHistory() const;
int indexOfSavePath(const QString& save_path); int indexOfSavePath(const QString& save_path);
void updateFileNameInSavePaths(const QString& new_filename); void updateFileNameInSavePaths(const QString& new_filename);
void loadState();
void saveState();
private: private:
Ui::AddNewTorrentDialog *ui; Ui::AddNewTorrentDialog *ui;