示例#1
0
    def contextMenuEvent(self, event):

        cmenu = QMenu(self)

        newAct = cmenu.addAction("New")
        openAct = cmenu.addAction("Open")
        quitAct = cmenu.addAction("Quit")
        action = cmenu.exec(self.mapToGlobal(event.pos()))

        if action == quitAct:
            QApplication.instance().quit()
示例#2
0
    def contextMenuEvent(self, event):
        context_menu = QMenu(self)
        exit_action = context_menu.addAction("Quit")
        action = context_menu.exec_(self.mapToGlobal(event.pos()))

        if action == exit_action:
            QApplication.instance().quit()
示例#3
0
    def initUI(self):

        menubar = self.menuBar()
        fileMenu = menubar.addMenu('File')

        impMenu = QMenu('Import', self)
        impAct = QAction('Import mail', self)
        impMenu.addAction(impAct)

        newAct = QAction('New', self)

        fileMenu.addAction(newAct)
        fileMenu.addMenu(impMenu)

        self.setGeometry(300, 300, 350, 250)
        self.setWindowTitle('Submenu')
        self.show()
示例#4
0
文件: __init__.py 项目: swavan/oneui
 def eventFilter(self, source, event):
     if event.type(
     ) == QEvent.Type.ContextMenu and source is self.mock_env_list:
         menu = QMenu()
         _copy = menu.addAction(
             QIcon(full_path("assets/images/icons/export.ico")), "Export")
         _remove = menu.addAction(
             QIcon(full_path("assets/images/icons/trash-can.ico")),
             "Remove")
         if source.itemAt(event.pos()):
             action = menu.exec(event.globalPos())
             _item = source.itemAt(event.pos())
             _id = _item.whatsThis()
             if action == _remove:
                 delete_confirmation(self, _id, self.delete)
         return True
     return super().eventFilter(source, event)
示例#5
0
class SystemTrayIcon(QSystemTrayIcon):
    def __init__(self, main_window):
        QSystemTrayIcon.__init__(self)
        self.main_window = main_window
        self.setIcon(QIcon(LOGO_PADDED_PATH))
        self.initialize_context_menu()

    def initialize_context_menu(self):
        self.menu = QMenu()
        self.version_action = self.menu.addAction(f"Version {__version__}")
        self.version_action.setEnabled(False)
        self.menu.addSeparator()
        self.open_action = self.menu.addAction("Open Control Panel",
                                               self.show_main_window)
        self.restore_action = self.menu.addAction(
            "Restore Files", self.main_window.open_restore_files)
        self.settings_action = self.menu.addAction(
            "Settings", self.main_window.open_settings)
        self.help_action = self.menu.addAction(
            "Help", lambda: webbrowser.open(SUPPORT_URL))
        self.quit_action = self.menu.addAction(
            "Quit", self.main_window.quit_application)
        self.setContextMenu(self.menu)

    def show_main_window(self):
        self.main_window.show()
        self.main_window.activateWindow()
        self.main_window.raise_()
示例#6
0
 def contextMenuEvent(self, event):
     """A simple context menu for managing images."""
     context_menu = QMenu(self) # Create menu instance
     context_menu.addAction(self.parent.sort_ascend_act)
     context_menu.addAction(self.parent.sort_descend_act)
     context_menu.addSeparator()
     context_menu.addAction(self.parent.delete_act)
     context_menu.exec(self.mapToGlobal(event.pos()))       
示例#7
0
    def contextMenuEvent(self, event):
        """Add actions to right click menu, dependent on currently active table
        """
        child = self.childAt(event.pos())

        menu = QMenu(self)
        # menu.setToolTipsVisible(True)

        table_widget = self.active_table_widget()
        for section in table_widget.context_actions.values():
            for action in section:
                name_action = f'act_{action}'
                try:
                    menu.addAction(getattr(self, name_action))
                except Exception as e:
                    try:
                        menu.addAction(getattr(table_widget, name_action))
                    except Exception as e:
                        log.warning(
                            f'Couldn\'t add action to context menu: {action}')

            menu.addSeparator()

        action = menu.exec(self.mapToGlobal(event.pos()))
示例#8
0
文件: __init__.py 项目: swavan/oneui
    def eventFilter(self, source, event):
        if event.type(
        ) == QEvent.Type.ContextMenu and source is self.mock_endpoints:
            menu = QMenu()
            _copy = menu.addAction(
                QIcon(full_path("assets/images/icons/copy.ico")), "Copy")
            _toggle = menu.addAction(
                QIcon(full_path("assets/images/icons/toggle.ico")), "Toggle")
            _remove = menu.addAction(
                QIcon(full_path("assets/images/icons/trash-can.ico")),
                "Remove")

            if source.itemAt(event.pos()):
                action = menu.exec(event.globalPos())
                _item = source.itemAt(event.pos())
                _id = _item.whatsThis()
                if action == _copy:
                    copy_endpoint(endpoint_ids=[_id])
                elif action == _toggle:
                    self.toggle_endpoint(_id)
                elif action == _remove:
                    delete_confirmation(self, _id, self.delete)
            return True
        return super().eventFilter(source, event)
示例#9
0
class TrayIcon(QSystemTrayIcon):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.showMenu()
        self.other()

    def showMenu(self):
        "设计托盘的菜单,这里我实现了一个二级菜单"
        self.menu = QMenu()
        self.menu1 = QMenu()
        self.showAction1 = QAction("显示消息1", self, triggered=self.showM)
        self.showAction2 = QAction("显示消息2", self, triggered=self.showM)
        self.quitAction = QAction("退出", self, triggered=self.quit)

        self.menu1.addAction(self.showAction1)
        self.menu1.addAction(self.showAction2)
        self.menu.addMenu(self.menu1)

        self.menu.addAction(self.showAction1)
        self.menu.addAction(self.showAction2)
        self.menu.addAction(self.quitAction)
        self.menu1.setTitle("二级菜单")
        self.setContextMenu(self.menu)

    def other(self):
        self.activated.connect(self.iconClied)
        # 把鼠标点击图标的信号和槽连接
        self.messageClicked.connect(self.mClied)
        # 把鼠标点击弹出消息的信号和槽连接
        self.setIcon(QIcon("ico.ico"))
        self.icon = self.icon()
        # 设置图标

    def iconClied(self, reason):
        "鼠标点击icon传递的信号会带有一个整形的值,1是表示单击右键,2是双击,3是单击左键,4是用鼠标中键点击"
        if reason.value in (2, 3):
            pw = self.parent()
            if pw.isVisible():
                pw.hide()
            else:
                pw.show()
        print(reason.value)

    def mClied(self):
        self.showMessage("提示", "你点了消息", self.icon)

    def showM(self):
        self.showMessage("测试", "我是消息", self.icon)

    def quit(self):
        "保险起见,为了完整的退出"
        self.setVisible(False)
        self.parent().exit()
        QApplication.quit()
        sys.exit()
示例#10
0
 def show_context_menu(self, pos):
     item = self.itemAt(pos)
     if not item:
         return
     m = QMenu(self)
     m.addAction(_('Close tabs to the bottom'),
                 partial(self.close_tabs_to_bottom, item))
     m.addAction(_('Close other tabs'), partial(self.close_other_tabs,
                                                item))
     m.addAction(_('Close this tree'), partial(self.close_tree, item))
     m.exec(self.mapToGlobal(pos))
示例#11
0
class WindowCpu(QSystemTrayIcon):
    def __init__(self):
        super().__init__()
        self.menu = QMenu()
        self.usage = QAction()
        self.usage.setText("Initialised")
        self.menu.addAction(self.usage)
        self.version = QAction("Notifier ({})".format(__version__))
        self.version.setDisabled(True)
        self.menu.addAction(self.version)
        self.menu.addSeparator()
        self.menu.addAction("Quit", lambda: exit(0))
        self.setContextMenu(self.menu)
        self.setIcon(QIcon("icons/0.svg"))
        self.show()
        self.task = TaskCpu()
        self.task.start()
        self.task.on_cpu_changed.connect(
            lambda value: self.set_icon(value))  # noqa

    def set_icon(self, value):
        """
        initial  == 0 white
        [0-25)   == 1 blue
        [25-50)  == 2 green
        [50-75)  == 3 yellow
        [75-100) == 4 orange
        [100-)   == 5 red

        :param value:
        :return:
        """
        if 0 <= value < 25:
            icon = 1
        elif 25 <= value < 50:
            icon = 2
        elif 50 <= value < 75:
            icon = 3
        elif 75 <= value < 100:
            icon = 4
        else:
            icon = 5
        self.usage.setText("Usage % {}".format(value))
        self.setIcon(QIcon("icons/{}.svg".format(icon)))
示例#12
0
class MyMainWindow(QMainWindow, Ui_fgoMainWindow):
    signalFuncBegin = pyqtSignal()
    signalFuncEnd = pyqtSignal(object)

    def __init__(self, parent=None):
        super().__init__(parent)
        self.setupUi(self)
        self.TRAY = QSystemTrayIcon(self)
        self.TRAY.setIcon(QApplication.style().standardIcon(
            QStyle.StandardPixmap.SP_MessageBoxInformation))
        self.TRAY.setToolTip('FGO-py')
        self.MENU_TRAY = QMenu(self)
        self.MENU_TRAY_QUIT = QAction('退出', self.MENU_TRAY)
        self.MENU_TRAY.addAction(self.MENU_TRAY_QUIT)
        self.MENU_TRAY_FORCEQUIT = QAction('强制退出', self.MENU_TRAY)
        self.MENU_TRAY.addAction(self.MENU_TRAY_FORCEQUIT)
        self.TRAY.setContextMenu(self.MENU_TRAY)
        self.TRAY.show()
        self.reloadTeamup()
        self.config = Config({
            'stopOnDefeated':
            (self.MENU_SETTINGS_DEFEATED, fgoKernel.schedule.stopOnDefeated),
            'stopOnKizunaReisou': (self.MENU_SETTINGS_KIZUNAREISOU,
                                   fgoKernel.schedule.stopOnKizunaReisou),
            'closeToTray': (self.MENU_CONTROL_TRAY, None),
            'stayOnTop':
            (self.MENU_CONTROL_STAYONTOP, lambda x: self.setWindowFlag(
                Qt.WindowType.WindowStaysOnTopHint, x)),
            'notifyEnable': (self.MENU_CONTROL_NOTIFY, None)
        })
        self.notifier = ServerChann(**self.config['notifyParam'])
        self.worker = Thread()
        self.signalFuncBegin.connect(self.funcBegin)
        self.signalFuncEnd.connect(self.funcEnd)
        self.TRAY.activated.connect(lambda reason: self.show(
        ) if reason == QSystemTrayIcon.ActivationReason.Trigger else None)
        self.MENU_TRAY_QUIT.triggered.connect(lambda: QApplication.quit()
                                              if self.askQuit() else None)
        self.MENU_TRAY_FORCEQUIT.triggered.connect(QApplication.quit)
        self.getDevice()

    def keyPressEvent(self, key):
        if self.MENU_CONTROL_MAPKEY.isChecked(
        ) and not key.modifiers() & ~Qt.KeyboardModifier.KeypadModifier:
            try:
                fgoKernel.device.press(chr(key.nativeVirtualKey()))
            except KeyError:
                pass
            except Exception as e:
                logger.critical(e)

    def closeEvent(self, event):
        if self.config['closeToTray']:
            self.hide()
            return event.ignore()
        if self.askQuit(): return event.accept()
        event.ignore()

    def askQuit(self):
        if self.worker.is_alive():
            if QMessageBox.warning(
                    self, 'FGO-py', '战斗正在进行,确认关闭?',
                    QMessageBox.StandardButton.Yes
                    | QMessageBox.StandardButton.No, QMessageBox.
                    StandardButton.No) != QMessageBox.StandardButton.Yes:
                return False
            fgoKernel.schedule.stop('Quit')
            self.worker.join()
        self.TRAY.hide()
        self.config.save()
        return True

    def isDeviceAvailable(self):
        if not fgoKernel.device.available:
            self.LBL_DEVICE.clear()
            QMessageBox.critical(self, 'FGO-py', '未连接设备')
            return False
        return True

    def runFunc(self, func, *args, **kwargs):
        if not self.isDeviceAvailable(): return

        def f():
            try:
                self.signalFuncBegin.emit()
                self.applyAll()
                fgoKernel.schedule.reset()
                fgoKernel.fuse.reset()
                func(*args, **kwargs)
            except fgoKernel.ScriptTerminate as e:
                logger.critical(e)
                msg = (str(e), QSystemTrayIcon.MessageIcon.Warning)
            except BaseException as e:
                logger.exception(e)
                msg = (repr(e), QSystemTrayIcon.MessageIcon.Critical)
            else:
                msg = ('Done', QSystemTrayIcon.MessageIcon.Information)
            finally:
                self.signalFuncEnd.emit(msg)
                if self.config['notifyEnable'] and not self.notifier(msg[0]):
                    logger.critical('Notify post failed')

        self.worker = Thread(
            target=f,
            name=
            f'{getattr(func,"__qualname__",getattr(type(func),"__qualname__",repr(func)))}({",".join(repr(i)for i in args)}{","if kwargs else""}{",".join("%s=%r"%i for i in kwargs.items())})'
        )
        self.worker.start()

    def funcBegin(self):
        self.BTN_ONEBATTLE.setEnabled(False)
        self.BTN_MAIN.setEnabled(False)
        self.BTN_USER.setEnabled(False)
        self.BTN_PAUSE.setEnabled(True)
        self.BTN_PAUSE.setChecked(False)
        self.BTN_STOP.setEnabled(True)
        self.BTN_STOPLATER.setEnabled(True)
        self.MENU_SCRIPT.setEnabled(False)
        self.TXT_APPLE.setValue(0)

    def funcEnd(self, msg):
        self.BTN_ONEBATTLE.setEnabled(True)
        self.BTN_MAIN.setEnabled(True)
        self.BTN_USER.setEnabled(True)
        self.BTN_PAUSE.setEnabled(False)
        self.BTN_STOP.setEnabled(False)
        self.BTN_STOPLATER.setChecked(False)
        self.BTN_STOPLATER.setEnabled(False)
        self.MENU_SCRIPT.setEnabled(True)
        self.TRAY.showMessage('FGO-py', *msg)

    def loadTeam(self, teamName):
        self.TXT_TEAM.setValue(int(self.teamup[teamName]['teamIndex']))
        (lambda skillInfo: [
            getattr(self, f'TXT_SKILL_{i}_{j}_{k}').setValue(skillInfo[i][j][
                k]) for i in range(6) for j in range(3) for k in range(4)
        ])(eval(self.teamup[teamName]['skillInfo']))
        (lambda houguInfo: [
            getattr(self, f'TXT_HOUGU_{i}_{j}').setValue(houguInfo[i][j])
            for i in range(6) for j in range(2)
        ])(eval(self.teamup[teamName]['houguInfo']))
        (lambda masterSkill: [
            getattr(self, f'TXT_MASTER_{i}_{j}').setValue(masterSkill[i][j])
            for i in range(3) for j in range(4 + (i == 2))
        ])(eval(self.teamup[teamName]['masterSkill']))

    def saveTeam(self):
        if not self.CBX_TEAM.currentText(): return
        self.teamup[self.CBX_TEAM.currentText()] = {
            'teamIndex':
            self.TXT_TEAM.value(),
            'skillInfo':
            str([[[
                getattr(self, f'TXT_SKILL_{i}_{j}_{k}').value()
                for k in range(4)
            ] for j in range(3)] for i in range(6)]).replace(' ', ''),
            'houguInfo':
            str([[
                getattr(self, f'TXT_HOUGU_{i}_{j}').value() for j in range(2)
            ] for i in range(6)]).replace(' ', ''),
            'masterSkill':
            str([[
                getattr(self, f'TXT_MASTER_{i}_{j}').value()
                for j in range(4 + (i == 2))
            ] for i in range(3)]).replace(' ', '')
        }
        with open('fgoTeamup.ini', 'w') as f:
            self.teamup.write(f)

    def resetTeam(self):
        self.loadTeam('DEFAULT')

    def getDevice(self):
        text, ok = QInputDialog.getItem(
            self, 'FGO-py', '在下拉列表中选择一个设备', l :=
            fgoKernel.Device.enumDevices(),
            l.index(fgoKernel.device.name)
            if fgoKernel.device.name and fgoKernel.device.name in l else 0,
            True, Qt.WindowType.WindowStaysOnTopHint)
        if not ok: return
        fgoKernel.device = fgoKernel.Device(text)
        self.LBL_DEVICE.setText(fgoKernel.device.name)
        self.MENU_CONTROL_MAPKEY.setChecked(False)

    def runBattle(self):
        self.runFunc(fgoKernel.Battle())

    def runUserScript(self):
        self.runFunc(fgoKernel.UserScript())

    def runMain(self):
        text, ok = QInputDialog.getItem(self, '肝哪个', '在下拉列表中选择战斗函数',
                                        ['完成战斗', '用户脚本'], 0, False)
        if ok and text:
            self.runFunc(
                fgoKernel.Main(self.TXT_APPLE.value(),
                               self.CBX_APPLE.currentIndex(), {
                                   '完成战斗': fgoKernel.Battle,
                                   '用户脚本': fgoKernel.UserScript
                               }[text]))

    def pause(self, x):
        if not x and not self.isDeviceAvailable():
            return self.BTN_PAUSE.setChecked(True)
        fgoKernel.schedule.pause()

    def stop(self):
        fgoKernel.schedule.stop('Terminate Command Effected')

    def stopLater(self, x):
        if x:
            num, ok = QInputDialog.getInt(self, '输入', '剩余的战斗数量', 1, 1, 1919810,
                                          1)
            if ok: fgoKernel.schedule.stopLater(num)
            else: self.BTN_STOPLATER.setChecked(False)
        else: fgoKernel.schedule.stopLater()

    def checkScreenshot(self):
        if not self.isDeviceAvailable(): return
        try:
            fgoKernel.Detect(0, blockFuse=True).show()
        except Exception as e:
            logger.exception(e)

    def applyAll(self):
        fgoKernel.Main.teamIndex = self.TXT_TEAM.value()
        fgoKernel.Turn.skillInfo = [[[
            getattr(self, f'TXT_SKILL_{i}_{j}_{k}').value() for k in range(4)
        ] for j in range(3)] for i in range(6)]
        fgoKernel.Turn.houguInfo = [[
            getattr(self, f'TXT_HOUGU_{i}_{j}').value() for j in range(2)
        ] for i in range(6)]
        fgoKernel.Turn.masterSkill = [[
            getattr(self, f'TXT_MASTER_{i}_{j}').value()
            for j in range(4 + (i == 2))
        ] for i in range(3)]

    def explorerHere(self):
        os.startfile('.')

    def runGacha(self):
        self.runFunc(fgoKernel.gacha)

    def runJackpot(self):
        self.runFunc(fgoKernel.jackpot)

    def runMail(self):
        self.runFunc(fgoKernel.mail)

    def runSynthesis(self):
        self.runFunc(fgoKernel.synthesis)

    def stopOnDefeated(self, x):
        self.config['stopOnDefeated'] = x

    def stopOnKizunaReisou(self, x):
        self.config['stopOnKizunaReisou'] = x

    def stopOnSpecialDrop(self):
        num, ok = QInputDialog.getInt(self, '输入', '剩余的特殊掉落数量', 1, 0, 1919810,
                                      1)
        if ok: fgoKernel.schedule.stopOnSpecialDrop(num)

    def stayOnTop(self, x):
        self.config['stayOnTop'] = x
        self.show()

    def closeToTray(self, x):
        self.config['closeToTray'] = x

    def reloadTeamup(self):
        self.teamup = IniParser('fgoTeamup.ini')
        self.CBX_TEAM.clear()
        self.CBX_TEAM.addItems(self.teamup.sections())
        self.CBX_TEAM.setCurrentIndex(-1)
        self.loadTeam('DEFAULT')

    def mapKey(self, x):
        self.MENU_CONTROL_MAPKEY.setChecked(x and self.isDeviceAvailable())

    def invoke169(self):
        if not self.isDeviceAvailable(): return
        fgoKernel.device.invoke169()

    def revoke169(self):
        if not self.isDeviceAvailable(): return
        fgoKernel.device.revoke169()

    def notify(self, x):
        self.config['notifyEnable'] = x

    def exec(self):
        s = QApplication.clipboard().text()
        if QMessageBox.information(
                self, 'FGO-py', s, QMessageBox.StandardButton.Ok | QMessageBox.
                StandardButton.Cancel) != QMessageBox.StandardButton.Ok:
            return
        try:
            exec(s)
        except BaseException as e:
            logger.exception(e)

    def about(self):
        QMessageBox.about(
            self, 'FGO-py - About', f'''
<h2>FGO-py</h2>
FGO全自动脚本
<table border="0">
  <tr><td>当前版本</td><td>{fgoKernel.__version__}</td></tr>
  <tr><td>作者</td><td>hgjazhgj</td></tr>
  <tr><td>项目地址</td><td><a href="https://github.com/hgjazhgj/FGO-py">https://github.com/hgjazhgj/FGO-py</a></td></tr>
  <tr><td>电子邮箱</td><td><a href="mailto:[email protected]">[email protected]</a></td></tr>
  <tr><td>QQ群</td><td>932481680</td></tr>
</table>
<!-- 都看到这里了真的不考虑资瓷一下吗... -->
这是我的<font color="#00A0E8">支付宝</font>/<font color="#22AB38">微信</font>收款码和Monero地址<br/>请给我打钱<br/>
<img height="116" width="116" src="data:image/bmp;base64,Qk2yAAAAAAAAAD4AAAAoAAAAHQAAAB0AAAABAAEAAAAAAHQAAAB0EgAAdBIAAAAAAAAAAAAA6KAAAP///wABYWKofU/CKEV/ZtBFXEMwRbiQUH2a5yABj+Uo/zf3AKDtsBjeNa7YcUYb2MrQ04jEa/Ioh7TO6BR150Djjo3ATKgPmGLjdfDleznImz0gcA19mxD/rx/4AVVUAH2zpfBFCgUQRSgtEEVjdRB9/R3wATtkAA=="/>
<img height="116" width="116" src="data:image/bmp;base64,Qk2yAAAAAAAAAD4AAAAoAAAAHQAAAB0AAAABAAEAAAAAAHQAAAB0EgAAdBIAAAAAAAAAAAAAOKsiAP///wABNLhYfVLBqEUYG0hFcn7gRS8QAH2Pd2ABQiVY/x1nMFWzcFhidNUwaXr3GEp1khDJzDfAuqx06ChC9hhPvmIQMJX3SCZ13ehlXB9IVtJQUAQreqj/jv/4AVVUAH0iFfBFuxUQRRAlEEX2fRB9Wl3wAdBsAA=="/>
<table border="0"><tr>
  <td><img height="148" width="148" src="data:image/bmp;base64,Qk1mAQAAAAAAAD4AAAAoAAAAJQAAACUAAAABAAEAAAAAACgBAAB0EgAAdBIAAAAAAAAAAAAAAAAAAP///wABNpugAAAAAH0Q2oL4AAAARb1nmkAAAABFZnR3IAAAAEXpv9AwAAAAfZSA10AAAAABXdMVYAAAAP8qTsdQAAAAMd998EgAAACighiQeAAAAFCt3LiwAAAAo3aTXIAAAACAQzl8SAAAAEehYzFgAAAAcZ0FlEAAAACmEjZXoAAAAD2l77w4AAAAvy27zoAAAAD4P5FWQAAAAEYVS3VwAAAAyXKhYYAAAACvQwA4OAAAALyhfNNwAAAAhuODSLAAAABIC/+BMAAAABpa6jMwAAAA6TltfQAAAAATihl8wAAAACzQ8IxIAAAA/zQAZ/gAAAABVVVUAAAAAH0qre3wAAAARXxupRAAAABFiJ3tEAAAAEUGtG0QAAAAfWa6DfAAAAABsL3cAAAAAA=="/></td>
  <td><font face="Courier New">42Cnr V9Tuz E1jiS<br/>2ucGw tzN8g F6o4y<br/>9SkHs X1eZE vtiDf<br/>4QcL1 NXvfZ PhDu7<br/>LYStW rbsQM 9UUGW<br/>nqXgh ManMB dqjEW<br/>5oaDY</font></td>
</tr></table>
''')

    def license(self):
        os.system(
            f'start notepad {"LICENSE"if os.path.isfile("LICENSE")else"../LICENSE"}'
        )
示例#13
0
class MenuBar(QMenuBar):
    """QMenuBar instance for main window menubar.

    Assigns object instance to as QMainWindow Menubar and creates
    File and Settings submenu.
    """
    def __init__(self, parent=None, window=None):
        """Construct MenuBar instance and create submenus.

        Args:
            parent (widget, optional) Objects parent widget. Defaults to None.
            window (widget, optional) Program's main window. Defaults to None.
        """
        super().__init__(parent=parent)
        self.setObjectName("MainMenuBar")
        self.setVisible(True)
        self.setNativeMenuBar(False)
        self.window = window
        self.window.setMenuBar(self)
        self.filemenu = QMenu("File", parent=self)
        self.settings = QMenu("Preferences", parent=self)
        self.help = QMenu("Help", parent=self)
        self.addMenu(self.filemenu)
        self.addMenu(self.settings)
        self.addMenu(self.help)
        self.exitaction = QAction("&Exit")
        self.settingsaction = QAction("&Settings")
        self.newGameAction = QAction("&New Game")
        self.minimize = QAction("&Minimize")
        self.maximize = QAction("&Maximize")
        self.aboutQt = QAction("&About Qt")
        self.aboutSelf = QAction("&About")
        self.help.addAction(self.aboutQt)
        self.help.addAction(self.aboutSelf)
        self.filemenu.addAction(self.minimize)
        self.filemenu.addAction(self.maximize)
        self.filemenu.addAction(self.exitaction)
        self.settings.addAction(self.settingsaction)
        self.filemenu.addAction(self.newGameAction)
        self.aboutQt.triggered.connect(self.aboutQtMenu)
        self.minimize.triggered.connect(self.minimizeWindow)
        self.maximize.triggered.connect(self.maxamizeWindow)
        self.exitaction.triggered.connect(self.exit_app)
        self.settingsaction.triggered.connect(self.open_settings)
        self.newGameAction.triggered.connect(self.newGame)
        self.aboutSelf.triggered.connect(self.about)

    def aboutQtMenu(self):
        """Display Qt Information."""
        self.aboutQt()

    def about(self):
        """Display Program Information."""
        dialog = About(parent=self, window=self.window)
        dialog.show()

    def maxamizeWindow(self):
        """Set Window to fill screen."""
        self.window.showMaximized()

    def minimizeWindow(self):
        """Set window to hide."""
        self.showMinimized()

    def newGame(self):
        """Start New Game.

        Same as pressing NewGameButton.
        """
        self.window.resetGame()
        self.window.dealer.setPreferences()

    def open_settings(self):
        """Create a QDialog with editable options related to gameplay.

        Options include: Number of players, Number of Decks.
        """
        dialog = Settings(parent=self, window=self.window)
        dialog.open()

    def exit_app(self):
        """Quit program."""
        sys.exit()