diff --git a/src/mcedit2/util/screen.py b/src/mcedit2/util/screen.py new file mode 100644 index 0000000..1decdc3 --- /dev/null +++ b/src/mcedit2/util/screen.py @@ -0,0 +1,20 @@ +""" + screen +""" +from __future__ import absolute_import, division, print_function +import logging +from PySide import QtGui, QtCore + +log = logging.getLogger(__name__) + +def centerWidgetInScreen(widget): + screen = QtGui.QApplication.desktop().availableGeometry() + w = screen.width() + h = screen.height() + margin = 0.125 + r = QtCore.QRect(screen.x() + margin * w, + screen.y() + margin * h, + w - w * 2 * margin, + h - h * 2 * margin) + + widget.setGeometry(r) diff --git a/src/mcedit2/worldlist.py b/src/mcedit2/worldlist.py index f6ced06..1359070 100644 --- a/src/mcedit2/worldlist.py +++ b/src/mcedit2/worldlist.py @@ -10,6 +10,7 @@ from mcedit2.rendering.textureatlas import TextureAtlas from mcedit2.util import profiler, minecraftinstall from mcedit2.util.load_ui import load_ui from mcedit2.util.minecraftinstall import MinecraftInstallsDialog +from mcedit2.util.screen import centerWidgetInScreen from mcedit2.util.worldloader import LoaderTimer from mcedit2.widgets.layout import Column, Row, setWidgetError @@ -127,16 +128,7 @@ class WorldListWidget(QtGui.QDialog): self.backupButton.setEnabled(False) self.configureButton.clicked.connect(self.configureClicked) - screen = QtGui.QApplication.desktop().availableGeometry() - w = screen.width() - h = screen.height() - margin = 0.125 - r = QtCore.QRect(screen.x() + margin * w, - screen.y() + margin * h, - w - w * 2 * margin, - h - h * 2 * margin) - - self.setGeometry(r) + centerWidgetInScreen(self) self.loadTimer = LoaderTimer(interval=0, timeout=self.loadTimerFired) self.loadTimer.start()