Refactor main menu button construction.
Work on logo image loading.
This commit is contained in:
parent
bb21cc4577
commit
d196d109ce
|
@ -33,28 +33,16 @@ class MainMenuView(QtGui.QWidget):
|
||||||
|
|
||||||
def setup_components(self):
|
def setup_components(self):
|
||||||
"""Setup the components that make up the widget."""
|
"""Setup the components that make up the widget."""
|
||||||
|
self.init_justcheckers_logo()
|
||||||
|
|
||||||
# TODO Create a more compelling looking logo label, well scaled.
|
self.new_game = self.create_menu_button('&New Game')
|
||||||
self.logo_label = QtGui.QLabel('justCheckers', self)
|
self.open_game = self.create_menu_button('&Open Game')
|
||||||
logo_pixmap = QtGui.QPixmap(util.path_to_asset('logo.png'))
|
self.save_game = self.create_menu_button('&Save Game')
|
||||||
# logo_pixmap.fill(QtGui.QColor(255, 255, 255, 125))
|
|
||||||
|
|
||||||
self.logo_label.setPixmap(logo_pixmap)
|
self.about_game = self.create_menu_button('About Game')
|
||||||
|
|
||||||
self.new_game = QtGui.QPushButton('&New Game', self)
|
|
||||||
self.new_game.setEnabled(False)
|
|
||||||
self.open_game = QtGui.QPushButton('&Open Game', self)
|
|
||||||
self.open_game.setEnabled(False)
|
|
||||||
self.save_game = QtGui.QPushButton('&Save Game', self)
|
|
||||||
self.save_game.setEnabled(False)
|
|
||||||
# TODO Render buttons greyed out.
|
|
||||||
|
|
||||||
self.about_game = QtGui.QPushButton('About Game', self)
|
|
||||||
self.about_game.setEnabled(False)
|
|
||||||
# TODO Add links to site and display license inside about game widget.
|
# TODO Add links to site and display license inside about game widget.
|
||||||
self.settings = QtGui.QPushButton('Settings', self)
|
self.settings = self.create_menu_button('Settings')
|
||||||
self.settings.setEnabled(False)
|
self.exit_button = self.create_menu_button('Exit', enabled=True)
|
||||||
self.exit_button = QtGui.QPushButton('Exit', self)
|
|
||||||
self.exit_button.clicked.connect(self.exit_app)
|
self.exit_button.clicked.connect(self.exit_app)
|
||||||
|
|
||||||
widget_layout = QtGui.QVBoxLayout(self)
|
widget_layout = QtGui.QVBoxLayout(self)
|
||||||
|
@ -70,6 +58,26 @@ class MainMenuView(QtGui.QWidget):
|
||||||
widget_layout.addStretch()
|
widget_layout.addStretch()
|
||||||
self.setLayout(widget_layout)
|
self.setLayout(widget_layout)
|
||||||
|
|
||||||
|
def init_justcheckers_logo(self):
|
||||||
|
|
||||||
|
logo_pixmap = QtGui.QPixmap(util.path_to_asset('logo.png'))
|
||||||
|
view_size = self.size()
|
||||||
|
image_size = logo_pixmap.size()
|
||||||
|
logo_pixmap = logo_pixmap.scaledToWidth(view_size.width())
|
||||||
|
logo_pixmap.fill(QtGui.QColor(255, 255, 255, 125))
|
||||||
|
logo_pixmap.load(util.path_to_asset('logo.png'))
|
||||||
|
|
||||||
|
self.logo_label = QtGui.QLabel('justCheckers', self)
|
||||||
|
self.logo_label.setPixmap(logo_pixmap)
|
||||||
|
self.logo_label.setAlignment(QtCore.Qt.AlignCenter)
|
||||||
|
|
||||||
|
def create_menu_button(self, label, enabled=False):
|
||||||
|
"""Creates a menu button with a consistent look & feel."""
|
||||||
|
menu_button = QtGui.QPushButton(label, self)
|
||||||
|
menu_button.setFixedHeight(50)
|
||||||
|
menu_button.setEnabled(enabled)
|
||||||
|
return menu_button
|
||||||
|
|
||||||
def exit_app(self):
|
def exit_app(self):
|
||||||
"""Exits the application."""
|
"""Exits the application."""
|
||||||
QtCore.QCoreApplication.instance().exit()
|
QtCore.QCoreApplication.instance().exit()
|
||||||
|
|
Loading…
Reference in New Issue