From 998b161696ce8bb5d47482b683ff1051727aaaaf Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Mon, 9 Nov 2009 19:30:13 +0000 Subject: [PATCH] - Save files list column width --- src/GUI.cpp | 1 + src/propertiesWidget.ui | 28 ++++++++++++++++++++-------- src/propertieswidget.cpp | 25 +++++++++++++++++++++++-- src/propertieswidget.h | 2 ++ 4 files changed, 46 insertions(+), 10 deletions(-) diff --git a/src/GUI.cpp b/src/GUI.cpp index c48deb4f3..4ce60dc65 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -247,6 +247,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis // Load Window state and sizes readSettings(); + properties->readSettings(); if(settings.value(QString::fromUtf8("Preferences/General/StartMinimized"), false).toBool()) { this->setWindowState(Qt::WindowMinimized); diff --git a/src/propertiesWidget.ui b/src/propertiesWidget.ui index 3f478397d..fcaf9c771 100644 --- a/src/propertiesWidget.ui +++ b/src/propertiesWidget.ui @@ -7,7 +7,7 @@ 0 0 756 - 333 + 303 @@ -19,13 +19,22 @@ 16777215 - 333 + 303 Form + + + + + 0 + + + 0 + @@ -821,12 +830,6 @@ false - - true - - - true - @@ -886,6 +889,15 @@ + + 5 + + + 4 + + + 5 + diff --git a/src/propertieswidget.cpp b/src/propertieswidget.cpp index 5157c1ab0..d2638fe0c 100644 --- a/src/propertieswidget.cpp +++ b/src/propertieswidget.cpp @@ -116,8 +116,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, TransferListWidget *transfer } PropertiesWidget::~PropertiesWidget() { - QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); - settings.setValue("TorrentProperties/Visible", state==VISIBLE); + saveSettings(); delete refreshTimer; if(progressBarUpdater) delete progressBarUpdater; @@ -218,6 +217,28 @@ void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) { loadDynamicData(); } +void PropertiesWidget::readSettings() { + QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); + QVariantList contentColsWidths = settings.value(QString::fromUtf8("TorrentProperties/filesColsWidth"), QVariantList()).toList(); + if(contentColsWidths.empty()) { + filesList->header()->resizeSection(0, filesList->width()/2.); + } else { + for(int i=0; isetColumnWidth(i, contentColsWidths.at(i).toInt()); + } + } +} + +void PropertiesWidget::saveSettings() { + QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); + settings.setValue("TorrentProperties/Visible", state==VISIBLE); + QVariantList contentColsWidths; + for(int i=0; icolumnCount()-1; ++i) { + contentColsWidths.append(filesList->columnWidth(i)); + } + settings.setValue(QString::fromUtf8("TorrentProperties/filesColsWidth"), contentColsWidths); +} + void PropertiesWidget::loadDynamicData() { if(!h.is_valid()) return; try { diff --git a/src/propertieswidget.h b/src/propertieswidget.h index 549b9ff01..adb44dde1 100644 --- a/src/propertieswidget.h +++ b/src/propertieswidget.h @@ -112,6 +112,8 @@ public slots: void reduce(); void slide(); void clear(); + void readSettings(); + void saveSettings(); public: PropertiesWidget(QWidget *parent, TransferListWidget *transferList, bittorrent* BTSession);