Permalink
Browse files

Rewrite GUI

  • Loading branch information...
1 parent 44159e6 commit 8fcbad57fa221dc71ab88d7763b7908f7264ae74 @LuqueDaniel committed Jan 11, 2013
@@ -22,10 +22,10 @@
__author__ = 'Daniel Luque'
__mail__ = 'danielluque14@gmail.com'
__url__ = 'http://luquedaniel.github.com/Minecraft_backup'
-__source__ = 'http://github.com/LuqueDaniel/Minecraft_backup.git'
+__source__ = 'http://github.com/LuqueDaniel/Minecraft_backup'
__version__ = '1.0'
__version_name__ = 'Dirt'
-__license__ = 'GPL3'
+__license__ = 'GPL v3'
__docu__ = """Minecraft Backup Manager is an application for managing Minecraft
backups quickly and easily."""
@@ -21,16 +21,10 @@
from PyQt4.QtGui import QDesktopWidget
-def center_widget(widget, parent=None):
+def center_widget(widget):
"""Center widget in screen"""
- if parent is None:
- center_widget = widget.frameGeometry()
- center = QDesktopWidget().availableGeometry().center()
- center_widget.moveCenter(center)
- widget.move(center_widget.topLeft())
- else:
- center_widget = widget.frameGeometry()
- center = parent.geometry().center()
- center_widget.moveCenter(center)
- widget.move(center_widget.topLeft())
+ center_widget = widget.frameGeometry()
+ center = QDesktopWidget().availableGeometry().center()
+ center_widget.moveCenter(center)
+ widget.move(center_widget.topLeft())
@@ -38,58 +38,41 @@ class about_minebackup(QDialog):
def __init__(self, parent=None):
QDialog.__init__(self, parent)
-
self.setWindowTitle('About Minecraft Backup')
self.setMaximumSize(QSize(0, 0))
- vbox = QVBoxLayout(self)
-
#Header
self.header = QLabel()
self.header.setPixmap(QPixmap(IMAGES['minebackup_icon_128']))
- hbox = QHBoxLayout()
- hbox.addWidget(self.header)
-
#title_label
self.label_title = QLabel('<h1>Minecraft Backup Manager</h1>', self)
self.label_title.setAlignment(Qt.AlignRight)
self.label_title.setTextFormat(Qt.RichText)
- hbox.addWidget(self.label_title)
- vbox.addLayout(hbox)
-
- #label_description
- self.label_description = QLabel(
-"""Minecraft Backup Manager is an application for managing Minecraft
-backups quickly and easily.""")
-
- vbox.addWidget(self.label_description)
-
- #label_version
- self.label_version = QLabel('Version: %s (%s)' % (
+ #LAYOUTS
+ #Horizontal Layout
+ self.hbox = QHBoxLayout()
+ self.hbox.addWidget(self.header)
+ self.hbox.addWidget(self.label_title)
+
+ #Vertical Layout
+ self.vbox = QVBoxLayout(self)
+ self.vbox.addLayout(self.hbox)
+ #Label Docu
+ self.vbox.addWidget(QLabel(minecraft_backup.__docu__))
+ #Label version
+ self.vbox.addWidget(QLabel('Version: %s (%s)' % (
minecraft_backup.__version__,
- minecraft_backup.__version_name__))
-
- vbox.addWidget(self.label_version)
-
- self.label_author = QLabel('Author: %s' % minecraft_backup.__author__)
-
- vbox.addWidget(self.label_author)
-
- #label_license
- self.label_license = QLabel('License: %s' % (
- minecraft_backup.__license__))
-
- vbox.addWidget(self.label_license)
-
- self.label_project_url = QLabel('Website: <a href="%s">%s</a>' % (
- minecraft_backup.__url__, minecraft_backup.__url__))
-
- vbox.addWidget(self.label_project_url)
-
- #label_source
- self.label_source = QLabel('Source: <a href="%s">%s</a>' % (
- minecraft_backup.__source__, minecraft_backup.__source__))
-
- vbox.addWidget(self.label_source)
+ minecraft_backup.__version_name__)))
+ #Label Author
+ self.vbox.addWidget(QLabel('Author: %s' % minecraft_backup.__author__))
+ #Label License
+ self.vbox.addWidget(QLabel('License: %s' % (
+ minecraft_backup.__license__)))
+ #Label Website Url
+ self.vbox.addWidget(QLabel('Website: <a href="%s">%s</a>' % (
+ minecraft_backup.__url__, minecraft_backup.__url__)))
+ #Label Source
+ self.vbox.addWidget(QLabel('Source: <a href="%s">%s</a>' % (
+ minecraft_backup.__source__, minecraft_backup.__source__)))
@@ -21,7 +21,6 @@
# Minecraft Backu Manager
from minecraft_backup.core.configuration import load_config
from minecraft_backup.core.configuration import save_new_config
-from minecraft_backup.gui.center_widget import center_widget
# PyQt4.QtGui
from PyQt4.QtGui import QDialog
@@ -30,54 +29,59 @@
from PyQt4.QtGui import QPushButton
from PyQt4.QtGui import QFileDialog
from PyQt4.QtGui import QDialogButtonBox
+from PyQt4.QtGui import QVBoxLayout
+from PyQt4.QtGui import QHBoxLayout
# PyQt4.QtCore
from PyQt4.QtCore import SIGNAL
-from PyQt4.QtCore import QRect
+from PyQt4.QtCore import QSize
class config_window(QDialog):
def __init__(self, parent=None):
QDialog.__init__(self, parent)
- self.setGeometry(0, 0, 500, 400)
- self.setMaximumSize(500, 400)
- self.setMinimumSize(500, 400)
+ self.setMaximumSize(QSize(0, 0))
+ self.setMinimumSize(500, 0)
self.setWindowTitle('Minecraft Backup Manager - Configuration')
- center_widget(self, parent)
- # STANNDARD BUTTONS
+ #STANNDARD BUTTONS
self.button_box = QDialogButtonBox(self)
- self.button_box.setGeometry(QRect(150, 360, 341, 32))
self.button_box.setStandardButtons(QDialogButtonBox.Cancel |
QDialogButtonBox.Save)
- # LABELS
- self.label_save_folder = self.generate_label('Save Folder', 15, 20)
-
- # input_save_folder
+ #input_save_folder
self.input_save_folder = QLineEdit(self)
- self.input_save_folder.setGeometry(QRect(100, 17, 290, 25))
self.input_save_folder.setText(load_config('save_backup_folder'))
self.input_save_folder.setToolTip('Default folder save backup')
- # change_save_folder
+ #change_save_folder
self.btn_save_folder = QPushButton('Change', self)
- self.btn_save_folder.move(400, 16)
- # CONNECT SIGNALS
+ #LAYOUTS
+ #Save Folder Layout
+ self.layout_save_folder = QHBoxLayout()
+ self.layout_save_folder.addWidget(QLabel('Save folder:', self))
+ self.layout_save_folder.addWidget(self.input_save_folder)
+ self.layout_save_folder.addWidget(self.btn_save_folder)
+
+ #Button Box Layout
+ self.layout_button_box = QHBoxLayout()
+ self.layout_button_box.setContentsMargins(0, 25, 0, 0)
+ self.layout_button_box.addWidget(self.button_box)
+
+ #Vertical Container Layout
+ self.Vcontainer = QVBoxLayout(self)
+ self.Vcontainer.addLayout(self.layout_save_folder)
+ self.Vcontainer.addLayout(self.layout_button_box)
+
+ #CONNECT SIGNALS
self.connect(self.btn_save_folder, SIGNAL('clicked()'),
self.change_save_folder)
self.connect(self.button_box, SIGNAL('accepted()'),
self.save_configurations)
self.connect(self.button_box, SIGNAL('rejected()'), self.close)
- def generate_label(self, text, h, v):
- self.label = QLabel(self)
- self.label.setText(text)
- self.label.adjustSize()
- self.label.move(h, v)
-
def change_save_folder(self):
self.file_dialog = QFileDialog.getExistingDirectory(self,
'Change Default folder save backup',
@@ -21,7 +21,6 @@
# Minecraft Backup Manager
from minecraft_backup.core.configuration import load_config
from minecraft_backup.core.backup_manager import make_backup_thread
-from minecraft_backup.gui.center_widget import center_widget
from minecraft_backup.gui.msg_box import msg_no_backup_name
from minecraft_backup.gui.msg_box import msg_name_exists
from minecraft_backup.gui.msg_box import msg_dir_exists
@@ -33,9 +32,12 @@
from PyQt4.QtGui import QLineEdit
from PyQt4.QtGui import QPushButton
from PyQt4.QtGui import QFileDialog
+from PyQt4.QtGui import QVBoxLayout
+from PyQt4.QtGui import QHBoxLayout
# PyQt4.QtCore
-from PyQt4.QtCore import QRect
+from PyQt4.QtCore import Qt
+from PyQt4.QtCore import QSize
from PyQt4.QtCore import SIGNAL
# os
@@ -46,51 +48,59 @@ class new_backup_window(QDialog):
def __init__(self, parent=None):
QDialog.__init__(self, parent)
- self.setGeometry(QRect(0, 0, 450, 200))
- self.setMaximumSize(450, 200)
- self.setMinimumSize(450, 200)
+ self.setMaximumSize(QSize(0, 0))
+ self.setMinimumSize(450, 0)
self.setWindowTitle('Create a new backup')
- center_widget(self, parent)
- # STANNDARD BUTTONS
- self.btn_cancel = QPushButton('Cancel', self)
- self.btn_cancel.setGeometry(QRect(135, 160, 80, 28))
- self.btn_cancel.setAutoDefault(False)
-
- # btn_create_backup
- self.btn_create_backup = QPushButton('Create backup', self)
- self.btn_create_backup.setGeometry(QRect(235, 160, 200, 28))
-
- # LABELS
- self.generate_label('Name', 15, 20)
- self.generate_label('Save folder', 15, 70)
-
- # input_backup_name
+ #input_backup_name
self.input_backup_name = QLineEdit(self)
- self.input_backup_name.setGeometry(QRect(100, 17, 335, 25))
- self.input_backup_name.text().toUtf8()
self.input_backup_name.setToolTip('Name of backup')
self.input_backup_name.setFocus()
- # btn_change_save_backup
+ #btn_change_save_backup
self.btn_change_save_backup = QPushButton(
load_config('save_backup_folder'), self)
- self.btn_change_save_backup.setGeometry(QRect(100, 64, 335, 30))
+ self.btn_change_save_backup.sizeHint()
self.btn_change_save_backup.setAutoDefault(False)
- # CONNECT SIGNALS
+ #btn_cancel
+ self.btn_cancel = QPushButton('Cancel', self)
+ self.btn_cancel.setAutoDefault(False)
+
+ #btn_create_backup
+ self.btn_create_backup = QPushButton('Create backup', self)
+
+ #LAYOUTS
+ #Backup name layout
+ self.layout_name = QHBoxLayout()
+ self.layout_name.addWidget(QLabel('Name:', self))
+ self.layout_name.addWidget(self.input_backup_name)
+
+ #Save Backup Folder Layout
+ self.layout_save_folder = QHBoxLayout()
+ self.layout_save_folder.addWidget(QLabel('Save folder:', self))
+ self.layout_save_folder.addWidget(self.btn_change_save_backup,
+ Qt.AlignCenter)
+
+ #Standard Buttons Layout
+ self.layout_standard_buttons = QHBoxLayout()
+ self.layout_standard_buttons.setContentsMargins(90, 25, 0, 0)
+ self.layout_standard_buttons.addWidget(self.btn_cancel)
+ self.layout_standard_buttons.addWidget(self.btn_create_backup)
+
+ #Vertical Container Layout
+ self.Vcontainer = QVBoxLayout(self)
+ self.Vcontainer.addLayout(self.layout_name)
+ self.Vcontainer.addLayout(self.layout_save_folder)
+ self.Vcontainer.addLayout(self.layout_standard_buttons)
+
+ #CONNECT SIGNALS
self.connect(self.btn_change_save_backup, SIGNAL('clicked()'),
self.change_save_backup)
self.connect(self.btn_cancel, SIGNAL('clicked()'), self.close)
self.connect(self.btn_create_backup, SIGNAL('clicked()'),
self.create_backup)
- def generate_label(self, text, h, v):
- self.label = QLabel(self)
- self.label.setText(text)
- self.label.adjustSize()
- self.label.move(h, v)
-
def change_save_backup(self):
self.file_dialog = QFileDialog.getExistingDirectory(self,
'Select folder saved for backup',
@@ -69,7 +69,9 @@ def __init__(self):
self.setMaximumSize(700, 520)
center_widget(self)
- self.header()
+ self.header_label = QLabel(self)
+ self.header_label.resize(700, 170)
+ self.header_label.setPixmap(QPixmap(IMAGES['header']))
# btn_config
self.btn_config = QPushButton(QIcon(IMAGES['config_icon']), '', self)
@@ -153,11 +155,6 @@ def restore_backup(self):
restore_backup(unicode(self.backup_name))
msg_restore_finishied(self, self.backup_name)
- def header(self):
- self.header_label = QLabel(self)
- self.header_label.resize(700, 170)
- self.header_label.setPixmap(QPixmap(IMAGES['header']))
-
def enabled_buttons(self):
self.btn_remove_backup.setEnabled(True)
self.btn_restore_backup.setEnabled(True)

0 comments on commit 8fcbad5

Please sign in to comment.