diff --git a/src/properties.ui b/src/properties.ui
index 5d4a9560a..0abc01505 100644
--- a/src/properties.ui
+++ b/src/properties.ui
@@ -5,7 +5,7 @@
0
0
- 538
+ 594
567
diff --git a/src/properties_imp.cpp b/src/properties_imp.cpp
index ffd8c37a5..0e7d643a8 100644
--- a/src/properties_imp.cpp
+++ b/src/properties_imp.cpp
@@ -30,6 +30,8 @@
#include
#include
#include
+#include
+#include
// Constructor
properties::properties(QWidget *parent, bittorrent *BTSession, QTorrentHandle &h): QDialog(parent), h(h), BTSession(BTSession), changedFilteredfiles(false), hash(h.hash()) {
@@ -118,6 +120,7 @@ properties::properties(QWidget *parent, bittorrent *BTSession, QTorrentHandle &h
updateInfosTimer = new QTimer(this);
connect(updateInfosTimer, SIGNAL(timeout()), this, SLOT(updateInfos()));
updateInfosTimer->start(3000);
+ loadSettings();
}
properties::~properties(){
@@ -155,6 +158,36 @@ void properties::addFilesToTree(file *root, QStandardItem *parent) {
}
}
+void properties::writeSettings() {
+ QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
+ settings.beginGroup(QString::fromUtf8("PropWindow"));
+ settings.setValue(QString::fromUtf8("size"), size());
+ settings.setValue(QString::fromUtf8("pos"), pos());
+ settings.endGroup();
+}
+
+void properties::loadSettings() {
+ QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
+ resize(settings.value(QString::fromUtf8("PropWindow/size"), size()).toSize());
+ move(settings.value(QString::fromUtf8("PropWindow/pos"), screenCenter()).toPoint());
+}
+
+// Center window
+QPoint properties::screenCenter() const{
+ int scrn = 0;
+ QWidget *w = this->topLevelWidget();
+
+ if(w)
+ scrn = QApplication::desktop()->screenNumber(w);
+ else if(QApplication::desktop()->isVirtualDesktop())
+ scrn = QApplication::desktop()->screenNumber(QCursor::pos());
+ else
+ scrn = QApplication::desktop()->screenNumber(this);
+
+ QRect desk(QApplication::desktop()->availableGeometry(scrn));
+ return QPoint((desk.width() - this->frameGeometry().width()) / 2, (desk.height() - this->frameGeometry().height()) / 2);
+}
+
// priority is the new priority of given item
void properties::updateParentsPriority(QStandardItem *item, int priority) {
QStandardItem *parent = item->parent();
diff --git a/src/properties_imp.h b/src/properties_imp.h
index 3ebb522c2..ec59479d3 100644
--- a/src/properties_imp.h
+++ b/src/properties_imp.h
@@ -74,6 +74,8 @@ class properties : public QDialog, private Ui::properties{
void updateParentsPriority(QStandardItem *item, int priority);
void updatePriorities(QStandardItem *item);
void getPriorities(QStandardItem *parent, int *priorities);
+ void writeSettings();
+ void loadSettings();
signals:
void filteredFilesChanged(QString hash);
@@ -86,6 +88,9 @@ class properties : public QDialog, private Ui::properties{
bool allFiltered() const;
bool savePiecesPriorities();
int* loadPiecesPriorities();
+
+ protected:
+ QPoint screenCenter() const;
};
#endif