def initUI(self): layout = QtWidgets.QVBoxLayout() layout.setContentsMargins(self.padding, self.padding, self.padding, self.padding) spacer = 10 # Set the title self.title = QtWidgets.QLabel() self.title.setStyleSheet("color: yellow; font-size:24px") layout.addWidget(self.title) # Set up the display label self.selectionText = QtWidgets.QLabel() self.selectionText.setStyleSheet("color:white; font-size:24px") layout.addWidget(self.selectionText) # Set up the image box that will be used to display the image self.pic = QtWidgets.QLabel() layout.addWidget(self.pic) # Set up the window self.setWindowTitle(f"Fast Expand Hints") self.setWindowIcon(QtGui.QIcon(innerPath('src/OverlayIcon.ico'))) self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.WindowDoesNotAcceptFocus | QtCore.Qt.WindowTransparentForInput) self.setStyleSheet("background-color: black;") sg = QtWidgets.QDesktopWidget().screenGeometry(0) width = int(sg.width() * 425 / 1920) height = int(width * 270 / 425) self.setGeometry(0, 0, width, height) self.move(sg.width() - self.width(), sg.bottom() - self.height()) self.setLayout(layout)
def __init__(self, parent=None): super().__init__() self.p = parent self.setWindowTitle(f'Debug window') self.setWindowIcon(QtGui.QIcon(innerPath('src/OverlayIcon.ico'))) self.setGeometry(1200, 1000, 600, 60) self.debug_code = QtWidgets.QLineEdit(self) self.debug_code.setGeometry(QtCore.QRect(0, 10, 450, 20)) self.debug_code.setPlaceholderText('write code here') self.debug_button = QtWidgets.QPushButton(self) self.debug_button.setGeometry(QtCore.QRect(500, 10, 75, 25)) self.debug_button.setText('Debug') self.debug_button.setShortcut("Return") self.debug_button.clicked.connect(self.run_script) self.result = QtWidgets.QLabel(self) self.result.setGeometry(QtCore.QRect(2, 35, 500, 20)) self.show()
def __init__(self, geometry=None, process_names=None, parent=None): super().__init__(parent) if geometry == None: self.setGeometry(0, 0, 260, 400) sg = QtWidgets.QDesktopWidget().screenGeometry(0) self.move(sg.width() - self.width() - 10, sg.top() + 210) else: self.setGeometry(*geometry) self.setWindowTitle('Performance overaly position') self.setWindowIcon(QtGui.QIcon(innerPath('src/OverlayIcon.ico'))) # Move to top-right self.setStyleSheet('color: white') self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowTransparentForInput | QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.CoverWindow | QtCore.Qt.NoDropShadowWindowHint | QtCore.Qt.WindowDoesNotAcceptFocus) self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True) # Data self.restart() # Inits some data self.iter = 1000 # Length of whole loop in miliseconds self.sc2process_names = process_names self.fixed = True self.started = False # SC2 widgets self.layout = QtWidgets.QGridLayout() self.layout.setAlignment(QtCore.Qt.AlignTop) self.layout.setVerticalSpacing(2) self.setLayout(self.layout) self.la_sc2 = QtWidgets.QLabel() self.la_sc2.setText('<b>StarCraft II</b>') self.layout.addWidget(self.la_sc2, 0, 0, 1, 2) self.la_sc2_memory = QtWidgets.QLabel() self.la_sc2_memory.setText('RAM') self.layout.addWidget(self.la_sc2_memory, 1, 0, 1, 1) self.la_sc2_memory_value = QtWidgets.QLabel() self.layout.addWidget(self.la_sc2_memory_value, 1, 1, 1, 1) self.la_sc2_read = QtWidgets.QLabel() self.la_sc2_read.setText('Read') self.layout.addWidget(self.la_sc2_read, 2, 0, 1, 1) self.la_sc2_read_value = QtWidgets.QLabel() self.layout.addWidget(self.la_sc2_read_value, 2, 1, 1, 1) self.la_sc2_read_value_total = QtWidgets.QLabel() self.layout.addWidget(self.la_sc2_read_value_total, 3, 1, 1, 1) self.la_sc2_write = QtWidgets.QLabel() self.la_sc2_write.setText('Write') self.layout.addWidget(self.la_sc2_write, 4, 0, 1, 1) self.la_sc2_write_value = QtWidgets.QLabel() self.layout.addWidget(self.la_sc2_write_value, 4, 1, 1, 1) self.la_sc2_write_value_total = QtWidgets.QLabel() self.layout.addWidget(self.la_sc2_write_value_total, 5, 1, 1, 1) self.la_spacer = QtWidgets.QLabel() self.la_spacer.setText('') self.layout.addWidget(self.la_spacer, 6, 0, 1, 1) self.la_sc2_cpu = QtWidgets.QLabel() self.la_sc2_cpu.setText('<b>CPUc</b>') self.layout.addWidget(self.la_sc2_cpu, 7, 0, 1, 1) self.la_sc2_cpu_value = QtWidgets.QLabel() self.layout.addWidget(self.la_sc2_cpu_value, 7, 1, 1, 1) # System widgets self.la_system = QtWidgets.QLabel() self.la_system.setText('<b>System</b>') self.layout.addWidget(self.la_system, 0, 2, 1, 2) self.la_memory = QtWidgets.QLabel() self.la_memory.setText('RAM') self.layout.addWidget(self.la_memory, 1, 2, 1, 1) self.la_memory_value = QtWidgets.QLabel() self.layout.addWidget(self.la_memory_value, 1, 3, 1, 1) self.la_download = QtWidgets.QLabel() self.la_download.setText('Down') self.layout.addWidget(self.la_download, 2, 2, 1, 1) self.la_download_value = QtWidgets.QLabel() self.layout.addWidget(self.la_download_value, 2, 3, 1, 1) self.la_download_value_total = QtWidgets.QLabel() self.layout.addWidget(self.la_download_value_total, 3, 3, 1, 1) self.la_upload = QtWidgets.QLabel() self.la_upload.setText('Upload') self.layout.addWidget(self.la_upload, 4, 2, 1, 1) self.la_upload_value = QtWidgets.QLabel() self.layout.addWidget(self.la_upload_value, 4, 3, 1, 1) self.la_upload_value_total = QtWidgets.QLabel() self.layout.addWidget(self.la_upload_value_total, 5, 3, 1, 1) self.la_cpu = QtWidgets.QLabel() self.la_cpu.setText('<b>CPU utilization</b>') self.layout.addWidget(self.la_cpu, 7, 2, 1, 2) self.cpu_cores = dict() for idx in range(psutil.cpu_count()): self.cpu_cores[('label', idx)] = QtWidgets.QLabel() self.cpu_cores[('label', idx)].setText(f"CPU{idx}") self.cpu_cores[('label', idx)].setAlignment(QtCore.Qt.AlignRight) self.layout.addWidget(self.cpu_cores[('label', idx)], 8 + idx, 2, 1, 1) self.cpu_cores[('value', idx)] = QtWidgets.QLabel() self.cpu_cores[('value', idx)].setAlignment(QtCore.Qt.AlignLeft) self.layout.addWidget(self.cpu_cores[('value', idx)], 8 + idx, 3, 1, 1) self.cpu_cores['total_label'] = QtWidgets.QLabel() self.cpu_cores['total_label'].setAlignment(QtCore.Qt.AlignRight) self.cpu_cores['total_label'].setText('total') self.layout.addWidget(self.cpu_cores['total_label'], 8 + idx + 1, 2, 1, 1) self.cpu_cores['total'] = QtWidgets.QLabel() self.cpu_cores['total'].setAlignment(QtCore.Qt.AlignLeft) self.layout.addWidget(self.cpu_cores['total'], 8 + idx + 1, 3, 1, 1) # Headers headers = {self.la_sc2, self.la_system, self.la_cpu} for item in headers: item.setAlignment(QtCore.Qt.AlignCenter) # Labels labels = { self.la_upload, self.la_download, self.la_memory, self.la_sc2_read, self.la_sc2_write, self.la_sc2_cpu, self.la_sc2_memory } for item in labels: item.setAlignment(QtCore.Qt.AlignRight) # Values values = { self.la_download_value_total, self.la_upload_value_total, self.la_sc2_read_value_total, self.la_sc2_write_value_total, self.la_upload_value, self.la_download_value, self.la_memory_value, self.la_sc2_read_value, self.la_sc2_write_value, self.la_sc2_cpu_value, self.la_sc2_memory_value } for item in values: item.setAlignment(QtCore.Qt.AlignLeft) # Add shadows to everything for item in headers.union(labels).union(values).union( {self.cpu_cores[i] for i in self.cpu_cores}): shadow = QtWidgets.QGraphicsDropShadowEffect() shadow.setBlurRadius(3) shadow.setOffset(1) shadow.setColor(QtGui.QColor(0, 0, 0)) item.setGraphicsEffect(shadow)
def __init__(self, parent): super().__init__() self.p = parent # Reset keyboard threads self.bt_reset_keyboard = QtWidgets.QPushButton(self) self.bt_reset_keyboard.setGeometry(QtCore.QRect(830, 15, 125, 25)) self.bt_reset_keyboard.setText('Reset keyboard') self.bt_reset_keyboard.setToolTip('Resets keyboard threads.\nThis might fix issues if hotkeys are not reacting.') self.bt_reset_keyboard.clicked.connect(self.p.reset_keyboard_thread) # Links self.fr_links = QtWidgets.QFrame(self) self.fr_links.setGeometry(QtCore.QRect(15, 15, 550, 235)) self.fr_links.setAutoFillBackground(True) self.fr_links.setFrameShape(QtWidgets.QFrame.StyledPanel) self.fr_links.setFrameShadow(QtWidgets.QFrame.Plain) # Maguro.one self.img_blog = QtWidgets.QLabel(self.fr_links) self.img_blog.setGeometry(QtCore.QRect(30, 20, 31, 41)) self.img_blog.setPixmap(QtGui.QPixmap(innerPath("src/maguro.jpg"))) self.blog = QtWidgets.QLabel(self.fr_links) self.blog.setGeometry(QtCore.QRect(80, 20, 131, 41)) self.blog.setText('<a href="www.maguro.one">Maguro.one</a>') # My discord self.img_discord = QtWidgets.QLabel(self.fr_links) self.img_discord.setGeometry(QtCore.QRect(30, 70, 41, 51)) self.img_discord.setPixmap(QtGui.QPixmap(innerPath("src/mdiscord.png"))) self.discord = QtWidgets.QLabel(self.fr_links) self.discord.setGeometry(QtCore.QRect(80, 80, 131, 31)) self.discord.setText('<a href="https://discord.gg/FtGdhqD">My discord</a>') # Twitter self.img_twitter = QtWidgets.QLabel(self.fr_links) self.img_twitter.setGeometry(QtCore.QRect(30, 120, 41, 51)) self.img_twitter.setPixmap(QtGui.QPixmap(innerPath("src/twitter.png"))) self.twitter = QtWidgets.QLabel(self.fr_links) self.twitter.setGeometry(QtCore.QRect(80, 130, 160, 31)) self.twitter.setText('<a href="https://twitter.com/FluffyMaguro">@FluffyMaguro</a>') # GitHub self.img_github = QtWidgets.QLabel(self.fr_links) self.img_github.setGeometry(QtCore.QRect(30, 175, 41, 41)) self.img_github.setPixmap(QtGui.QPixmap(innerPath("src/github.png"))) self.github = QtWidgets.QLabel(self.fr_links) self.github.setGeometry(QtCore.QRect(80, 175, 200, 41)) self.github.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.github.setText('<a href="https://github.com/FluffyMaguro/SC2_Coop_overlay">Overlay on GitHub</a>') # Subreddit self.img_reddit = QtWidgets.QLabel(self.fr_links) self.img_reddit.setGeometry(QtCore.QRect(300, 20, 41, 41)) self.img_reddit.setPixmap(QtGui.QPixmap(innerPath("src/reddit.png"))) self.reddit = QtWidgets.QLabel(self.fr_links) self.reddit.setGeometry(QtCore.QRect(350, 20, 161, 41)) self.reddit.setText('<a href="https://www.reddit.com/r/starcraft2coop/">Co-op subreddit</a>') # Forums self.img_battlenet = QtWidgets.QLabel(self.fr_links) self.img_battlenet.setGeometry(QtCore.QRect(300, 70, 41, 51)) self.img_battlenet.setPixmap(QtGui.QPixmap(innerPath("src/sc2.png"))) self.battlenet = QtWidgets.QLabel(self.fr_links) self.battlenet.setGeometry(QtCore.QRect(350, 80, 131, 31)) self.battlenet.setText('<a href="https://us.forums.blizzard.com/en/sc2/c/co-op-missions-discussion">Co-op forums</a>') # Co-op discord self.img_coop_discord = QtWidgets.QLabel(self.fr_links) self.img_coop_discord.setGeometry(QtCore.QRect(300, 130, 31, 41)) self.img_coop_discord.setPixmap(QtGui.QPixmap(innerPath("src/discord.png"))) self.coop_discord = QtWidgets.QLabel(self.fr_links) self.coop_discord.setGeometry(QtCore.QRect(350, 130, 141, 31)) self.coop_discord.setText('<a href="https://discord.gg/VQnXMdm">Co-op discord</a>') # Donate self.fr_donate = QtWidgets.QFrame(self) self.fr_donate.setGeometry(QtCore.QRect(15, 270, 550, 100)) self.fr_donate.setAutoFillBackground(True) self.fr_donate.setFrameShape(QtWidgets.QFrame.StyledPanel) self.fr_donate.setFrameShadow(QtWidgets.QFrame.Plain) self.img_paypal = QtWidgets.QLabel(self.fr_donate) self.img_paypal.setGeometry(QtCore.QRect(210, 14, 200, 41)) self.img_paypal.setPixmap(QtGui.QPixmap(innerPath("src/paypal.png"))) self.paypal = QtWidgets.QLabel(self.fr_donate) self.paypal.setGeometry(QtCore.QRect(170, 47, 250, 41)) self.paypal.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.paypal.setText('<a href="https://www.paypal.com/paypalme/FluffyMaguro">Donate if you feel generous</a>') # Styling for item in {self.blog, self.reddit, self.twitter, self.github, self.discord, self.battlenet, self.paypal, self.coop_discord}: item.setStyleSheet("font-size: 18px") item.setOpenExternalLinks(True)
def __init__(self, parent, APPVERSION): super().__init__() self.p = parent ch_distance = 20 # Start with Windows self.CH_StartWithWindows = QtWidgets.QCheckBox(self) self.CH_StartWithWindows.setGeometry( QtCore.QRect(20, ch_distance, 230, 17)) self.CH_StartWithWindows.setText("Start with Windows") self.CH_StartWithWindows.setToolTip( "The app will start automatically with Windows") # Start minimized self.CH_StartMinimized = QtWidgets.QCheckBox(self) self.CH_StartMinimized.setGeometry( QtCore.QRect(20, 2 * ch_distance, 230, 17)) self.CH_StartMinimized.setText("Start minimized") self.CH_StartMinimized.setToolTip("The app will start minimized") # Enable logging self.CH_EnableLogging = QtWidgets.QCheckBox(self) self.CH_EnableLogging.setGeometry( QtCore.QRect(20, 4 * ch_distance, 230, 17)) self.CH_EnableLogging.setText("Enable logging") self.CH_EnableLogging.setToolTip( f"App logs will be saved into a text file") # Show session hidden self.CH_ShowSession = QtWidgets.QCheckBox(self) self.CH_ShowSession.setGeometry( QtCore.QRect(20, 5 * ch_distance, 300, 17)) self.CH_ShowSession.setText("Show session stats") self.CH_ShowSession.setToolTip( "Shows how many games you played and won in the current session on the overlay" ) # Show player winrate and notes self.CH_ShowPlayerWinrates = QtWidgets.QCheckBox(self) self.CH_ShowPlayerWinrates.setGeometry( QtCore.QRect(20, 6 * ch_distance, 230, 17)) self.CH_ShowPlayerWinrates.setText("Show player winrates and notes") self.CH_ShowPlayerWinrates.setToolTip( "The number of games and winrate you had with your ally will be shown when a game starts.\nPlayer note will show as well if specified. Requires restart to enable." ) # Mnimized when clicked self.CH_MinimizeToTray = QtWidgets.QCheckBox(self) self.CH_MinimizeToTray.setGeometry( QtCore.QRect(20, 3 * ch_distance, 300, 17)) self.CH_MinimizeToTray.setText("Minimize to tray") self.CH_MinimizeToTray.setToolTip( "On closing the app will minimize to tray. The app can be closed there." ) # Duration self.SP_Duration = QtWidgets.QSpinBox(self) self.SP_Duration.setGeometry(QtCore.QRect(250, 20, 42, 22)) self.LA_Duration = QtWidgets.QLabel(self) self.LA_Duration.setGeometry(QtCore.QRect(300, 20, 191, 21)) self.LA_Duration.setText("Duration") self.LA_Duration.setToolTip( "How long the overlay will show after a new game is analysed.") # Monitor self.SP_Monitor = QtWidgets.QSpinBox(self) self.SP_Monitor.setGeometry(QtCore.QRect(360, 20, 42, 22)) self.SP_Monitor.setMinimum(1) self.SP_Monitor.setToolTip( "Determines on which monitor the overlay will be shown") self.LA_Monitor = QtWidgets.QLabel(self) self.LA_Monitor.setGeometry(QtCore.QRect(410, 20, 47, 20)) self.LA_Monitor.setText("Monitor") self.LA_Monitor.setToolTip( "Determines on which monitor the overlay will be shown") # Charts self.CH_ShowCharts = QtWidgets.QCheckBox(self) self.CH_ShowCharts.setGeometry( QtCore.QRect(250, 3 * ch_distance, 300, 17)) self.CH_ShowCharts.setText("Show charts") self.CH_ShowCharts.setToolTip("Show charts on overlay") self.CH_ShowCharts.clicked.connect(self.p.show_charts) # Dark theme self.CH_DarkTheme = QtWidgets.QCheckBox(self) self.CH_DarkTheme.setGeometry( QtCore.QRect(250, 4 * ch_distance, 300, 17)) self.CH_DarkTheme.setText("Dark theme") self.CH_DarkTheme.setToolTip("Enables dark theme. Requires restart!") self.CH_DarkTheme.stateChanged.connect(self.p.change_theme) # Fast expand self.CH_FastExpand = QtWidgets.QCheckBox(self) self.CH_FastExpand.setGeometry( QtCore.QRect(250, 5 * ch_distance, 300, 17)) self.CH_FastExpand.setText("Fast expand hints") self.CH_FastExpand.setToolTip( "Show fast expand hint dialogue when a new game starts.\n" f"maps: {', '.join(FastExpandSelector.valid_maps)}\n" f"commanders: {', '.join(FastExpandSelector.valid_commanders)}") # Force hidden self.CH_ForceHideOverlay = QtWidgets.QCheckBox(self) self.CH_ForceHideOverlay.setGeometry( QtCore.QRect(250, 6 * ch_distance, 300, 17)) self.CH_ForceHideOverlay.setText("Don\'t show overlay on-screen") self.CH_ForceHideOverlay.setToolTip( "The overlay won't show directly on your screen. You can use this setting\nfor example when it's meant to be visible only on stream." ) # Replay folder self.LA_AccountFolder = QtWidgets.QLabel(self) self.LA_AccountFolder.setGeometry(QtCore.QRect(520, 15, 350, 16)) self.LA_AccountFolder.setText( "Change locations of StarCraft II account folder and screenshot folder" ) self.BT_ChooseFolder = QtWidgets.QPushButton(self) self.BT_ChooseFolder.setGeometry(QtCore.QRect(520, 36, 150, 25)) self.BT_ChooseFolder.setText('Account folder') self.BT_ChooseFolder.setToolTip( 'Choose your account folder.\nThis is usually not necessary and the app will find its location automatically.' ) self.BT_ChooseFolder.clicked.connect(self.p.findReplayFolder) self.LA_CurrentReplayFolder = QtWidgets.QLabel(self) self.LA_CurrentReplayFolder.setEnabled(False) self.LA_CurrentReplayFolder.setGeometry(QtCore.QRect(520, 53, 400, 31)) # Screenshot folder self.BT_ScreenshotLocation = QtWidgets.QPushButton(self) self.BT_ScreenshotLocation.setGeometry(QtCore.QRect(520, 90, 150, 25)) self.BT_ScreenshotLocation.setText('Screenshot folder') self.BT_ScreenshotLocation.setToolTip( 'Choose the folder where screenshots are saved') self.BT_ScreenshotLocation.clicked.connect( self.p.chooseScreenshotFolder) self.LA_ScreenshotLocation = QtWidgets.QLabel(self) self.LA_ScreenshotLocation.setEnabled(False) self.LA_ScreenshotLocation.setGeometry(QtCore.QRect(520, 108, 400, 31)) # Info label self.LA_InfoLabel = QtWidgets.QLabel(self) self.LA_InfoLabel.setGeometry(QtCore.QRect(20, 560, 800, 20)) # Apply self.BT_MainApply = QtWidgets.QPushButton(self) self.BT_MainApply.setGeometry(QtCore.QRect(867, 400, 75, 25)) self.BT_MainApply.setText('Apply') self.BT_MainApply.clicked.connect(self.p.saveSettings) # Reset self.BT_MainReset = QtWidgets.QPushButton(self) self.BT_MainReset.setGeometry(QtCore.QRect(785, 400, 75, 25)) self.BT_MainReset.setText('Reset') self.BT_MainReset.clicked.connect(self.p.resetSettings) self.BT_MainReset.setToolTip( "Resets all settings on this tab apart from login for starcraft2coop.com" ) # Screenshot self.BT_Screenshot = QtWidgets.QPushButton(self) self.BT_Screenshot.setGeometry(QtCore.QRect(19, 400, 157, 40)) self.BT_Screenshot.setText('Overlay screenshot') self.BT_Screenshot.setToolTip( 'Take screenshot of the overlay and save it on your desktop or chosen location' ) self.BT_Screenshot.clicked.connect(self.p.save_screenshot) ### Hotkey frame self.FR_HotkeyFrame = QtWidgets.QFrame(self) self.FR_HotkeyFrame.setGeometry(QtCore.QRect(20, 170, 411, 211)) self.FR_HotkeyFrame.setAutoFillBackground(True) self.FR_HotkeyFrame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.FR_HotkeyFrame.setFrameShadow(QtWidgets.QFrame.Plain) # Label self.LA_Hotkeys = QtWidgets.QLabel(self.FR_HotkeyFrame) self.LA_Hotkeys.setGeometry(QtCore.QRect(0, 10, 411, 20)) self.LA_Hotkeys.setStyleSheet("font-weight: bold") self.LA_Hotkeys.setAlignment(QtCore.Qt.AlignCenter) self.LA_Hotkeys.setText("Hotkeys") # Show/hide self.BT_ShowHide = QtWidgets.QPushButton(self.FR_HotkeyFrame) self.BT_ShowHide.setGeometry(QtCore.QRect(19, 50, 115, 25)) self.BT_ShowHide.setText("Show / Hide") self.BT_ShowHide.clicked.connect(MF.keyboard_SHOWHIDE) self.KEY_ShowHide = MUI.CustomKeySequenceEdit(self.FR_HotkeyFrame) self.KEY_ShowHide.setGeometry(QtCore.QRect(20, 80, 113, 20)) self.KEY_ShowHide.setToolTip( 'The key for both showing and hiding the overlay') self.KEY_ShowHide.keySequenceChanged.connect(self.p.hotkey_changed) # Show self.BT_Show = QtWidgets.QPushButton(self.FR_HotkeyFrame) self.BT_Show.setGeometry(QtCore.QRect(149, 50, 115, 25)) self.BT_Show.setText("Show") self.BT_Show.clicked.connect(MF.keyboard_SHOW) self.KEY_Show = MUI.CustomKeySequenceEdit(self.FR_HotkeyFrame) self.KEY_Show.setGeometry(QtCore.QRect(150, 80, 113, 20)) self.KEY_Show.setToolTip('The key for just showing the overlay') self.KEY_Show.keySequenceChanged.connect(self.p.hotkey_changed) # Hide self.BT_Hide = QtWidgets.QPushButton(self.FR_HotkeyFrame) self.BT_Hide.setGeometry(QtCore.QRect(279, 50, 115, 25)) self.BT_Hide.setText("Hide") self.BT_Hide.clicked.connect(MF.keyboard_HIDE) self.KEY_Hide = MUI.CustomKeySequenceEdit(self.FR_HotkeyFrame) self.KEY_Hide.setGeometry(QtCore.QRect(280, 80, 113, 20)) self.KEY_Hide.setToolTip('The key for just hiding the overlay') self.KEY_Hide.keySequenceChanged.connect(self.p.hotkey_changed) # Newer self.BT_Newer = QtWidgets.QPushButton(self.FR_HotkeyFrame) self.BT_Newer.setGeometry(QtCore.QRect(19, 120, 115, 25)) self.BT_Newer.setText("Show newer replay") self.BT_Newer.clicked.connect(MF.keyboard_NEWER) self.KEY_Newer = MUI.CustomKeySequenceEdit(self.FR_HotkeyFrame) self.KEY_Newer.setGeometry(QtCore.QRect(20, 150, 113, 20)) self.KEY_Newer.setToolTip( 'The key for showing a newer replay than is currently displayed') self.KEY_Newer.keySequenceChanged.connect(self.p.hotkey_changed) # Older self.BT_Older = QtWidgets.QPushButton(self.FR_HotkeyFrame) self.BT_Older.setGeometry(QtCore.QRect(149, 120, 115, 25)) self.BT_Older.setText("Show older replay") self.BT_Older.clicked.connect(MF.keyboard_OLDER) self.KEY_Older = MUI.CustomKeySequenceEdit(self.FR_HotkeyFrame) self.KEY_Older.setGeometry(QtCore.QRect(150, 150, 113, 20)) self.KEY_Older.setToolTip( 'The key for showing an older replay than is currently displayed') self.KEY_Older.keySequenceChanged.connect(self.p.hotkey_changed) # Winrates self.BT_Winrates = QtWidgets.QPushButton(self.FR_HotkeyFrame) self.BT_Winrates.setGeometry(QtCore.QRect(279, 120, 115, 25)) self.BT_Winrates.setText("Show player info") self.BT_Winrates.clicked.connect(MF.keyboard_PLAYERWINRATES) self.KEY_Winrates = MUI.CustomKeySequenceEdit(self.FR_HotkeyFrame) self.KEY_Winrates.setGeometry(QtCore.QRect(280, 150, 113, 20)) self.KEY_Winrates.setToolTip( 'The key for showing the last player winrates and notes') self.KEY_Winrates.keySequenceChanged.connect(self.p.hotkey_changed) # Colors self.FR_CustomizeColors = QtWidgets.QFrame(self) self.FR_CustomizeColors.setGeometry(QtCore.QRect(445, 170, 241, 211)) self.FR_CustomizeColors.setAutoFillBackground(True) self.FR_CustomizeColors.setFrameShape(QtWidgets.QFrame.StyledPanel) self.FR_CustomizeColors.setFrameShadow(QtWidgets.QFrame.Plain) # Customize colors self.LA_CustomizeColors = QtWidgets.QLabel(self.FR_CustomizeColors) self.LA_CustomizeColors.setGeometry(QtCore.QRect(0, 10, 241, 20)) self.LA_CustomizeColors.setStyleSheet("font-weight: bold") self.LA_CustomizeColors.setAlignment(QtCore.Qt.AlignCenter) self.LA_CustomizeColors.setText("Customize colors") # Note self.LA_More = QtWidgets.QLabel(self.FR_CustomizeColors) self.LA_More.setEnabled(False) self.LA_More.setGeometry(QtCore.QRect(0, 19, 241, 31)) self.LA_More.setAlignment(QtCore.Qt.AlignCenter) self.LA_More.setText("more via editing custom.css") color_x_offset = 50 color_height = 20 color_width = 140 self.LA_P1 = QtWidgets.QPushButton(self.FR_CustomizeColors) self.LA_P1.setGeometry( QtCore.QRect(color_x_offset, 70, color_width, color_height)) self.LA_P1.clicked.connect(lambda: self.openColorDialog(self.LA_P1)) self.LA_P2 = QtWidgets.QPushButton(self.FR_CustomizeColors) self.LA_P2.setGeometry( QtCore.QRect(color_x_offset, 100, color_width, color_height)) self.LA_P2.clicked.connect(lambda: self.openColorDialog(self.LA_P2)) self.LA_Amon = QtWidgets.QPushButton(self.FR_CustomizeColors) self.LA_Amon.setGeometry( QtCore.QRect(color_x_offset, 130, color_width, color_height)) self.LA_Amon.clicked.connect( lambda: self.openColorDialog(self.LA_Amon)) self.LA_Mastery = QtWidgets.QPushButton(self.FR_CustomizeColors) self.LA_Mastery.setGeometry( QtCore.QRect(color_x_offset, 160, color_width, color_height)) self.LA_Mastery.clicked.connect( lambda: self.openColorDialog(self.LA_Mastery)) # Aom self.FR_Aom = QtWidgets.QFrame(self) self.FR_Aom.setGeometry(QtCore.QRect(700, 170, 241, 211)) self.FR_Aom.setAutoFillBackground(True) self.FR_Aom.setFrameShape(QtWidgets.QFrame.StyledPanel) self.FR_Aom.setFrameShadow(QtWidgets.QFrame.Plain) self.LA_AomPage = QtWidgets.QLabel(self.FR_Aom) self.LA_AomPage.setGeometry(QtCore.QRect(0, 10, 241, 20)) self.LA_AomPage.setStyleSheet("font-weight: bold") self.LA_AomPage.setAlignment(QtCore.Qt.AlignCenter) self.LA_AomPage.setText("Settings for starcraft2coop.com") self.ED_AomAccount = QtWidgets.QLineEdit(self.FR_Aom) self.ED_AomAccount.setGeometry(QtCore.QRect(62, 70, 121, 20)) self.ED_AomAccount.setAlignment(QtCore.Qt.AlignCenter) self.ED_AomAccount.setPlaceholderText("account name") self.ED_AomSecretKey = QtWidgets.QLineEdit(self.FR_Aom) self.ED_AomSecretKey.setGeometry(QtCore.QRect(62, 100, 121, 20)) self.ED_AomSecretKey.setAlignment(QtCore.Qt.AlignCenter) self.ED_AomSecretKey.setPlaceholderText("secret key") self.ED_AomSecretKey.setEchoMode( QtWidgets.QLineEdit.PasswordEchoOnEdit) self.BT_AomTest = QtWidgets.QPushButton(self.FR_Aom) self.BT_AomTest.setGeometry(QtCore.QRect(75, 160, 85, 25)) self.BT_AomTest.clicked.connect(self.validateAOM) self.BT_AomTest.setText("Verify") self.BT_AomTest.setToolTip( "Test if the combination of the account name and the secret key is valid" ) # Manual parse self.BT_ManualParse = QtWidgets.QPushButton(self) self.BT_ManualParse.setGeometry(QtCore.QRect(185, 400, 157, 40)) self.BT_ManualParse.setText("Parse replay") self.BT_ManualParse.setToolTip( "Parse selected replay, show it on the overlay, and save data to a json file." ) self.BT_ManualParse.clicked.connect(self.parse_replay) # Paypal x = 835 y = 520 self.IMG_Front_Donate = QtWidgets.QLabel(self) self.IMG_Front_Donate.setGeometry(QtCore.QRect(835, y, 145, 50)) self.IMG_Front_Donate.setPixmap( QtGui.QPixmap(innerPath("src/paypal.png"))) self.IMG_Front_Donate.setGraphicsEffect(MUI.get_shadow()) self.BT_Front_Donate = QtWidgets.QPushButton(self) self.BT_Front_Donate.setGeometry(QtCore.QRect(x - 5, y, 140, 50)) self.BT_Front_Donate.clicked.connect(self.paypal_clicked) self.BT_Front_Donate.setStyleSheet( "QPushButton {border: 0px; background: transparent}") self.BT_Front_Donate.setToolTip(f'Donate to support this app') # Version self.LA_Version = QtWidgets.QLabel(self) self.LA_Version.setGeometry(QtCore.QRect(825, 560, 141, 20)) self.LA_Version.setAlignment(QtCore.Qt.AlignBottom | QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing) self.LA_Version.setText( f"The app is up to date (v{str(APPVERSION)[0]}.{str(APPVERSION)[1:]})" ) self.LA_Version.setEnabled(False)
def __init__(self, chat_font_scale=1.3, geometry=None, parent=None): super().__init__(parent) if geometry == None: self.setGeometry(700, 300, 500, 500) else: self.setGeometry(*geometry) self.setWindowIcon(QtGui.QIcon(innerPath('src/OverlayIcon.ico'))) self.setWindowTitle('Twitch chat position') # Flags for transparency self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowTransparentForInput | QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.CoverWindow | QtCore.Qt.NoDropShadowWindowHint | QtCore.Qt.WindowDoesNotAcceptFocus) self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True) font = self.font() font.setPointSize(int(font.pointSize() * chat_font_scale)) self.setFont(font) self.fixed = True self.max_messages = 30 self.colors = [ '#7878FF', '#FF5858', 'yellow', 'purple', '#DAA520', '#94C237', 'pink', '#00E700', '#ED551E' ] self.color_index = 0 self.users = dict() # Create scroll area so old messages can disappear on top self.scroll_area = QtWidgets.QScrollArea(self) self.scroll_area.setFrameShape(QtWidgets.QFrame.NoFrame) self.scroll_area.setFrameShadow(QtWidgets.QFrame.Plain) self.scroll_area.setStyleSheet('background-color: transparent') self.scroll_area.setWidgetResizable(True) self.scroll_area.setVerticalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) # Contents will be here self.scroll_area_contents = QtWidgets.QWidget() self.scroll_area.setWidget(self.scroll_area_contents) self.scroll_area_contents_layout = QtWidgets.QVBoxLayout() self.scroll_area_contents_layout.setSpacing(0) self.scroll_area_contents.setLayout(self.scroll_area_contents_layout) # Put scroll area into a widget so it fills the parent when resized self.main_layout = QtWidgets.QHBoxLayout() self.main_layout.addWidget(self.scroll_area) self.scroll_area.setSizePolicy( QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)) self.main_layout.setContentsMargins(0, 0, 0, 0) self.setLayout(self.main_layout) """ Fill messages. To be thread safe, all elements are already created, and updating will be just changing text. We can't create and change parents in non-primary thread. That counts even for using <b></b> tags. """ self.messages = list() self.layouts = list() for i in range(self.max_messages): new_widget = ChatMessage(self.scroll_area_contents) new_layout = QtWidgets.QHBoxLayout() new_layout.setAlignment(QtCore.Qt.AlignLeft) new_layout.addWidget(new_widget.time) new_layout.addWidget(new_widget.user) new_layout.addWidget(new_widget.message) new_layout.setContentsMargins(0, 0, 0, 0) new_layout.setSpacing(0) self.scroll_area_contents_layout.addLayout(new_layout) self.messages.append(new_widget) self.layouts.append(new_layout) # Finalize self.show()