options.py 1.72 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 18 18:34:40 2018

@author: Antoine Lima, Leo Reynaert, Domitille Jehenne
"""

import logging

11 12
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QTableWidgetItem, QComboBox, QApplication
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42

from module import Module
import modules
from ui.options_ui import Ui_Form as OptionsWidget

class OptionsModule(Module):
	def __init__(self, parent):
		super().__init__(parent, OptionsWidget())

		# Button connections
		self.ui.btnSave.clicked.connect(self.ui_handleClick_btnSave)
		self.ui.btnBack.clicked.connect(self.ui_handleClick_btnBack)

	def load(self):
		logging.debug('Loading OptionsModule')
		cbb = QComboBox()
		cbb.addItem('true')
		cbb.addItem('false')
		self.ui.options.insertRow(self.ui.options.rowCount())
		self.ui.options.setItem(self.ui.options.rowCount()-1, 0, QTableWidgetItem('FullScreen'))
		self.ui.options.setCellWidget(self.ui.options.rowCount()-1, 1, cbb)

	def unload(self):
		logging.debug('Unloading OptionsModule')
		# Delete the table's content
		self.ui.options.setRowCount(0)
	
	def other(self, **kwargs):
		logging.debug('Other OptionsModule')

43 44 45 46 47 48
	def keyPressEvent(self, e):
		if e.key() == Qt.Key_Escape:
			self.ui_handleClick_btnBack()
		elif e.key() == Qt.Key_Return:
			self.ui_handleClick_btnSave()

49 50
	def ui_handleClick_btnSave(self):
		if self.ui.options.cellWidget(0, 1).currentText().lower() == 'true':
Antoine Lima's avatar
Antoine Lima committed
51
			self.parent_win.showFullScreen()
52 53
			#QWSServer::setCursorVisible(False);
			QApplication.setOverrideCursor(Qt.BlankCursor);
54
		else:
Antoine Lima's avatar
Antoine Lima committed
55
			self.parent_win.showNormal()
56
			#QWSServer.setCursorVisible(True);
57 58 59 60 61 62

		self.switchModule(modules.MenuModule)

	def ui_handleClick_btnBack(self):
		# ToDo: Maybe add a warning
		self.switchModule(modules.MenuModule)