Browse Source

Make sure the main windows is initially centered

adaptive-webui-19844
Christophe Dumez 14 years ago
parent
commit
6580d23263
  1. 12
      src/mainwindow.cpp
  2. 1
      src/mainwindow.h

12
src/mainwindow.cpp

@ -92,7 +92,7 @@ using namespace libtorrent; @@ -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() { @@ -458,7 +458,10 @@ void MainWindow::writeSettings() {
void MainWindow::readSettings() {
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
settings.beginGroup(QString::fromUtf8("MainWindow"));
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) { @@ -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

1
src/mainwindow.h

@ -147,6 +147,7 @@ private: @@ -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;

Loading…
Cancel
Save