Browse Source

Make sure the main windows is initially centered

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

14
src/mainwindow.cpp

@ -92,7 +92,7 @@ using namespace libtorrent;
*****************************************************/ *****************************************************/
// Constructor // 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); setupUi(this);
Preferences pref; Preferences pref;
ui_locked = pref.isUILocked(); ui_locked = pref.isUILocked();
@ -458,7 +458,10 @@ void MainWindow::writeSettings() {
void MainWindow::readSettings() { void MainWindow::readSettings() {
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
settings.beginGroup(QString::fromUtf8("MainWindow")); 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(); const QByteArray splitterState = settings.value("vsplitterState").toByteArray();
if(splitterState.isEmpty()) { if(splitterState.isEmpty()) {
// Default sizes // Default sizes
@ -680,7 +683,14 @@ void MainWindow::showEvent(QShowEvent *e) {
if(getCurrentTabWidget() == transferList) { if(getCurrentTabWidget() == transferList) {
properties->loadDynamicData(); properties->loadDynamicData();
} }
e->accept(); 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 // Called when we close the program

1
src/mainwindow.h

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

Loading…
Cancel
Save