mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-24 05:25:37 +00:00
- Made properties window a bit larger
- Remember properties window size and position on startup
This commit is contained in:
parent
dc651ffed3
commit
54225cd42f
@ -5,7 +5,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>538</width>
|
||||
<width>594</width>
|
||||
<height>567</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -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
|
||||
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();
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user