1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-27 06:54:20 +00:00

Make sure the main windows is initially centered

This commit is contained in:
Christophe Dumez 2011-01-22 19:51:06 +00:00
parent 0b874d9c42
commit 6580d23263
2 changed files with 13 additions and 2 deletions

View File

@ -92,7 +92,7 @@ using namespace libtorrent;
*****************************************************/
// Constructor
MainWindow::MainWindow(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), force_exit(false) {
MainWindow::MainWindow(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), m_posInitialized(false), force_exit(false) {
setupUi(this);
Preferences pref;
ui_locked = pref.isUILocked();
@ -458,7 +458,10 @@ void MainWindow::writeSettings() {
void MainWindow::readSettings() {
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
settings.beginGroup(QString::fromUtf8("MainWindow"));
restoreGeometry(settings.value("geometry").toByteArray());
if(settings.contains("geometry")) {
restoreGeometry(settings.value("geometry").toByteArray());
m_posInitialized = true;
}
const QByteArray splitterState = settings.value("vsplitterState").toByteArray();
if(splitterState.isEmpty()) {
// Default sizes
@ -680,7 +683,14 @@ void MainWindow::showEvent(QShowEvent *e) {
if(getCurrentTabWidget() == transferList) {
properties->loadDynamicData();
}
e->accept();
// Make sure the window is initially centered
if(!m_posInitialized) {
move(misc::screenCenter(this));
m_posInitialized = true;
}
}
// Called when we close the program

View File

@ -147,6 +147,7 @@ private:
// Bittorrent
QList<QPair<QTorrentHandle,QString> > unauthenticated_trackers; // Still needed?
// GUI related
bool m_posInitialized;
QTimer *guiUpdater;
HidableTabWidget *tabs;
StatusBar *status_bar;