Browse Source

- Made properties window a bit larger

- Remember properties window size and position on startup
adaptive-webui-19844
Christophe Dumez 17 years ago
parent
commit
54225cd42f
  1. 2
      src/properties.ui
  2. 33
      src/properties_imp.cpp
  3. 5
      src/properties_imp.h

2
src/properties.ui

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>538</width>
<width>594</width>
<height>567</height>
</rect>
</property>

33
src/properties_imp.cpp

@ -30,6 +30,8 @@ @@ -30,6 +30,8 @@
#include <QMenu>
#include <QTimer>
#include <QStandardItemModel>
#include <QSettings>
#include <QDesktopWidget>
// 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 @@ -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) { @@ -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();

5
src/properties_imp.h

@ -74,6 +74,8 @@ class properties : public QDialog, private Ui::properties{ @@ -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{ @@ -86,6 +88,9 @@ class properties : public QDialog, private Ui::properties{
bool allFiltered() const;
bool savePiecesPriorities();
int* loadPiecesPriorities();
protected:
QPoint screenCenter() const;
};
#endif

Loading…
Cancel
Save