def updatePreview(self, action, value): if action == 'account_font_size': self.commandLinkButton.setStyleSheet('font: %spt "TF2 Build";' % value) elif action == 'account_icon_size': self.commandLinkButton.setIconSize(QtCore.QSize(int(value), int(value))) elif action == 'account_icon': icon = QtGui.QIcon() if value != '': icon.addPixmap(QtGui.QPixmap(value)) else: icon.addPixmap(QtGui.QPixmap(returnResourcePath('images/unselected_button.png')), QtGui.QIcon.Selected, QtGui.QIcon.Off) icon.addPixmap(QtGui.QPixmap(returnResourcePath('images/selected_button.png')), QtGui.QIcon.Selected, QtGui.QIcon.On) self.commandLinkButton.setIcon(icon)
def updateAccountBoxes(self): # Get selected accounts and remove all account boxes checkedbuttons = [] for widget in self.accountButtons: if widget.isChecked(): checkedbuttons.append(str(widget.text())) widget.close() del widget self.accountButtons = [] row = 0 column = 0 numperrow = int(self.settings.get_option('Settings', 'ui_no_of_columns')) ui_account_box_font_size = self.settings.get_option('Settings', 'ui_account_box_font_size') ui_account_box_icon_size = int(self.settings.get_option('Settings', 'ui_account_box_icon_size')) ui_account_box_icon = self.settings.get_option('Settings', 'ui_account_box_icon') # Sort account boxes alphabetically sortedlist = [] for account in list(Set(self.settings.get_sections()) - Set(['Settings'])): if self.settings.get_option(account, 'account_nickname') != '': sortedlist.append((self.settings.get_option(account, 'account_nickname'), account)) else: sortedlist.append((self.settings.get_option(account, 'steam_username'), account)) for account in sorted(sortedlist): accountname = account[0] commandLinkButton = QtGui.QCommandLinkButton(self) commandLinkButton.setMinimumSize(QtCore.QSize(1, 1)) commandLinkButton.setObjectName(self.settings.get_option(account[1], 'steam_username')) icon = QtGui.QIcon() if ui_account_box_icon != '': icon.addPixmap(QtGui.QPixmap(ui_account_box_icon)) else: icon.addPixmap(QtGui.QPixmap(returnResourcePath('images/unselected_button.png')), QtGui.QIcon.Selected, QtGui.QIcon.Off) icon.addPixmap(QtGui.QPixmap(returnResourcePath('images/selected_button.png')), QtGui.QIcon.Selected, QtGui.QIcon.On) commandLinkButton.setIcon(icon) commandLinkButton.setIconSize(QtCore.QSize(ui_account_box_icon_size, ui_account_box_icon_size)) commandLinkButton.setCheckable(True) commandLinkButton.setChecked((accountname in checkedbuttons or self.settings.get_option(account[1], 'steam_username') in self.chosenSelectGroupAccounts) and self.settings.get_option(account[1], 'steam_username') not in self.chosenDeselectGroupAccounts ) commandLinkButton.setStyleSheet('font: %spt "TF2 Build";' % ui_account_box_font_size) commandLinkButton.setText(accountname) self.accountButtons.append(commandLinkButton) self.gridLayout.addWidget(commandLinkButton, row, column, 1, 1) column += 1 if column == numperrow: row += 1 column = 0
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setWindowTitle('Secret Stoat') self.vBoxLayout = QtGui.QVBoxLayout(self) self.imageLabel = QtGui.QLabel(self) self.imageLabel.setPixmap( QtGui.QPixmap(returnResourcePath('images/secret_stoat.png'))) self.vBoxLayout.addWidget(self.imageLabel) self.textLabel = QtGui.QLabel(self) self.textLabel.setText( """Praise the <b>Secret Stoat</b> and all it stands for: <b>WIN</b>.<br/> Definitions of <b>WIN</b> on the Web:<br/><br/> - be the winner in a contest or competition; be victorious; "He won the Gold Medal in skating"; "Our home team won"; "Win the game"<br/> - acquire: win something through one\'s efforts; "I acquired a passing knowledge of Chinese"; "Gain an understanding of international finance"<br/> - gain: obtain advantages, such as points, etc.; "The home team was gaining ground"<br/> - a victory (as in a race or other competition); "he was happy to get the win"<br/> - winnings: something won (especially money)<br/> - succeed: attain success or reach a desired goal; "The enterprise succeeded"; "We succeeded in getting tickets to the show"; "she struggled to overcome her handicap and won" """) self.textLabel.setWordWrap(True) self.textLabel.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) self.vBoxLayout.addWidget(self.textLabel)
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setWindowTitle('About') self.gridLayout = QtGui.QGridLayout(self) self.imageLabel = ClickableLabel(self) self.imageLabel.setPixmap( QtGui.QPixmap(returnResourcePath('images/tf2idle.png'))) self.gridLayout.addWidget(self.imageLabel, 0, 0, 1, 1) self.textLabel = QtGui.QLabel(self) self.textLabel.setTextFormat(QtCore.Qt.RichText) self.textLabel.setText( """<b>TF2Idle v%s</b><br/><br/>Developed by <a href="http://steamcommunity.com/id/Moussekateer">Moussekateer</a>. <br/><br/>Thanks to <a href="http://steamcommunity.com/id/WindPower">WindPower</a> (aka the witch) for his limitless Python knowledge. <br/><br/>Thanks to <a href="http://steamcommunity.com/id/rjackson">RJackson</a> for contributing code to TF2Idle. <br/><br/>Thanks to <a href="http://steamcommunity.com/id/stragglerastic">Lagg</a> for his <a href="http://git.optf2.com/steamodd/">Steamodd Python module</a>. <br/><br/>Thanks to <a href="http://steamcommunity.com/id/bradpitt77">Brad Pitt</a> for the <a href="http://backpack.tf/api">backpack.tf pricelist API</a>. <br/><br/>Some images used were extracted from TF2 and are the property of <a href="http://www.valvesoftware.com">Valve</a>. <br/><br/>Some images used were created by <a href="http://fabrydesign.com">Wade 'Nineaxis' Fabry</a>. <br/><br/>They are kredit to team.""" % Version.version) self.textLabel.setOpenExternalLinks(True) self.gridLayout.addWidget(self.textLabel, 0, 1, 1, 1) self.licenseImage = QtGui.QLabel() self.licenseImage.setPixmap( QtGui.QPixmap(returnResourcePath('images/creative_commons.png'))) self.gridLayout.addWidget(self.licenseImage, 1, 0, 1, 1) self.licenseLabel = QtGui.QLabel(self) self.licenseLabel.setTextFormat(QtCore.Qt.RichText) self.licenseLabel.setText( """<span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">TF2Idle</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="http://steamcommunity.com/id/moussekateer" property="cc:attributionName" rel="cc:attributionURL">Moussekateer</a> is licensed under a<br/><a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License</a>.""" ) self.licenseLabel.setOpenExternalLinks(True) self.gridLayout.addWidget(self.licenseLabel, 1, 1, 1, 1) self.buttonBox = QtGui.QDialogButtonBox(self) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok) self.buttonBox.setCenterButtons(False) self.gridLayout.addWidget(self.buttonBox, 2, 1, 1, 1) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL('accepted()'), self.accept)
def createSystemTray(self): self.tray = QtGui.QSystemTrayIcon(QtGui.QIcon(returnResourcePath('images/tf2idle.png')), self) QtCore.QObject.connect(self.tray, QtCore.SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), self.sysTrayIconActivated) self.iconMenu = QtGui.QMenu(self) openAction = self.iconMenu.addAction('Open') QtCore.QObject.connect(openAction, QtCore.SIGNAL('triggered()'), self.show) exitAction = self.iconMenu.addAction('Exit') QtCore.QObject.connect(exitAction, QtCore.SIGNAL('triggered()'), self.close) self.tray.setContextMenu(self.iconMenu) self.tray.show()
def do_GET(self): if self.path == '/favicon.png': f = open(returnResourcePath('images/tf2idle.png'), 'rb') self.send_response(200) self.send_header('Content-type', 'image/png') self.end_headers() self.wfile.write(f.read()) self.wfile.close() else: self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() self.wfile.write(self.html) self.wfile.close()
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setWindowTitle('About') self.gridLayout = QtGui.QGridLayout(self) self.imageLabel = ClickableLabel(self) self.imageLabel.setPixmap(QtGui.QPixmap(returnResourcePath('images/tf2idle.png'))) self.gridLayout.addWidget(self.imageLabel, 0, 0, 1, 1) self.textLabel = QtGui.QLabel(self) self.textLabel.setTextFormat(QtCore.Qt.RichText) self.textLabel.setText("""<b>TF2Idle v%s</b><br/><br/>Developed by <a href="http://steamcommunity.com/id/Moussekateer">Moussekateer</a>. <br/><br/>Thanks to <a href="http://steamcommunity.com/id/WindPower">WindPower</a> (aka the witch) for his limitless Python knowledge. <br/><br/>Thanks to <a href="http://steamcommunity.com/id/rjackson">RJackson</a> for contributing code to TF2Idle. <br/><br/>Thanks to <a href="http://steamcommunity.com/id/stragglerastic">Lagg</a> for his <a href="http://git.optf2.com/steamodd/">Steamodd Python module</a>. <br/><br/>Thanks to <a href="http://steamcommunity.com/id/bradpitt77">Brad Pitt</a> for the <a href="http://backpack.tf/api">backpack.tf pricelist API</a>. <br/><br/>Some images used were extracted from TF2 and are the property of <a href="http://www.valvesoftware.com">Valve</a>. <br/><br/>Some images used were created by <a href="http://fabrydesign.com">Wade 'Nineaxis' Fabry</a>. <br/><br/>They are kredit to team.""" % Version.version) self.textLabel.setOpenExternalLinks(True) self.gridLayout.addWidget(self.textLabel, 0, 1, 1, 1) self.licenseImage = QtGui.QLabel() self.licenseImage.setPixmap(QtGui.QPixmap(returnResourcePath('images/creative_commons.png'))) self.gridLayout.addWidget(self.licenseImage, 1, 0, 1, 1) self.licenseLabel = QtGui.QLabel(self) self.licenseLabel.setTextFormat(QtCore.Qt.RichText) self.licenseLabel.setText("""<span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">TF2Idle</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="http://steamcommunity.com/id/moussekateer" property="cc:attributionName" rel="cc:attributionURL">Moussekateer</a> is licensed under a<br/><a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License</a>.""") self.licenseLabel.setOpenExternalLinks(True) self.gridLayout.addWidget(self.licenseLabel, 1, 1, 1, 1) self.buttonBox = QtGui.QDialogButtonBox(self) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok) self.buttonBox.setCenterButtons(False) self.gridLayout.addWidget(self.buttonBox, 2, 1, 1, 1) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL('accepted()'), self.accept)
def createSystemTray(self): self.tray = QtGui.QSystemTrayIcon( QtGui.QIcon(returnResourcePath('images/tf2idle.png')), self) QtCore.QObject.connect( self.tray, QtCore.SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), self.sysTrayIconActivated) self.iconMenu = QtGui.QMenu(self) openAction = self.iconMenu.addAction('Open') QtCore.QObject.connect(openAction, QtCore.SIGNAL('triggered()'), self.show) exitAction = self.iconMenu.addAction('Exit') QtCore.QObject.connect(exitAction, QtCore.SIGNAL('triggered()'), self.close) self.tray.setContextMenu(self.iconMenu) self.tray.show()
def __init__(self): QtGui.QDialog.__init__(self, None) self.setWindowIcon(QtGui.QIcon(returnResourcePath('images/tf2idle.png'))) self.setWindowTitle('Enter key to continue') self.gridLayout = QtGui.QGridLayout(self) self.textLabel = QtGui.QLabel(self) self.textLabel.setText('Enter your decryption key:') self.gridLayout.addWidget(self.textLabel, 0, 0, 1, 1) self.textLineEdit = QtGui.QLineEdit(self) self.textLineEdit.setMaxLength(32) self.gridLayout.addWidget(self.textLineEdit, 0, 1, 1, 1) self.buttonBox = QtGui.QDialogButtonBox(self) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok) self.gridLayout.addWidget(self.buttonBox, 1, 1, 1, 1) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL('accepted()'), self.accept)
def __init__(self): QtGui.QDialog.__init__(self, None) self.setWindowIcon( QtGui.QIcon(returnResourcePath('images/tf2idle.png'))) self.setWindowTitle('Enter key to continue') self.gridLayout = QtGui.QGridLayout(self) self.textLabel = QtGui.QLabel(self) self.textLabel.setText('Enter your decryption key:') self.gridLayout.addWidget(self.textLabel, 0, 0, 1, 1) self.textLineEdit = QtGui.QLineEdit(self) self.textLineEdit.setMaxLength(32) self.gridLayout.addWidget(self.textLineEdit, 0, 1, 1, 1) self.buttonBox = QtGui.QDialogButtonBox(self) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok) self.gridLayout.addWidget(self.buttonBox, 1, 1, 1, 1) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL('accepted()'), self.accept)
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setWindowTitle('Secret Stoat') self.vBoxLayout = QtGui.QVBoxLayout(self) self.imageLabel = QtGui.QLabel(self) self.imageLabel.setPixmap(QtGui.QPixmap(returnResourcePath('images/secret_stoat.png'))) self.vBoxLayout.addWidget(self.imageLabel) self.textLabel = QtGui.QLabel(self) self.textLabel.setText("""Praise the <b>Secret Stoat</b> and all it stands for: <b>WIN</b>.<br/> Definitions of <b>WIN</b> on the Web:<br/><br/> - be the winner in a contest or competition; be victorious; "He won the Gold Medal in skating"; "Our home team won"; "Win the game"<br/> - acquire: win something through one\'s efforts; "I acquired a passing knowledge of Chinese"; "Gain an understanding of international finance"<br/> - gain: obtain advantages, such as points, etc.; "The home team was gaining ground"<br/> - a victory (as in a race or other competition); "he was happy to get the win"<br/> - winnings: something won (especially money)<br/> - succeed: attain success or reach a desired goal; "The enterprise succeeded"; "We succeeded in getting tickets to the show"; "she struggled to overcome her handicap and won" """) self.textLabel.setWordWrap(True) self.textLabel.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) self.vBoxLayout.addWidget(self.textLabel)
def updateWindow(self, construct=False): self.mainwindow.htoolBar.clear() self.mainwindow.vtoolBar.clear() # Add vertical toolbar actions addAccountIcon = QtGui.QIcon() addAccountIcon.addPixmap(QtGui.QPixmap(returnResourcePath('images/add_account.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.addAccountAction = self.mainwindow.vtoolBar.addAction(addAccountIcon, 'Add account') QtCore.QObject.connect(self.addAccountAction, QtCore.SIGNAL('triggered()'), self.openAccountDialog) editAccountIcon = QtGui.QIcon() editAccountIcon.addPixmap(QtGui.QPixmap(returnResourcePath('images/edit_account.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.editAccountAction = self.mainwindow.vtoolBar.addAction(editAccountIcon, 'Edit account') QtCore.QObject.connect(self.editAccountAction, QtCore.SIGNAL('triggered()'), curry(self.openAccountDialog, editAccount=True)) removeAccountIcon = QtGui.QIcon() removeAccountIcon.addPixmap(QtGui.QPixmap(returnResourcePath('images/remove_account.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.deleteAccountsAction = self.mainwindow.vtoolBar.addAction(removeAccountIcon, 'Delete account') QtCore.QObject.connect(self.deleteAccountsAction, QtCore.SIGNAL('triggered()'), self.deleteAccounts) self.mainwindow.vtoolBar.addSeparator() selectGroupIcon = QtGui.QIcon() selectGroupIcon.addPixmap(QtGui.QPixmap(returnResourcePath('images/select_group.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.selectGroupsAction = self.mainwindow.vtoolBar.addAction(selectGroupIcon, 'Select Groups') QtCore.QObject.connect(self.selectGroupsAction, QtCore.SIGNAL('triggered()'), self.selectGroups) viewBackpackIcon = QtGui.QIcon() viewBackpackIcon.addPixmap(QtGui.QPixmap(returnResourcePath('images/backpack.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.viewBackpackAction = self.mainwindow.vtoolBar.addAction(viewBackpackIcon, 'View backpack') QtCore.QObject.connect(self.viewBackpackAction, QtCore.SIGNAL('triggered()'), self.openBackpack) # Add horizontal toolbar actions switchToLogViewIcon = QtGui.QIcon() switchToLogViewIcon.addPixmap(QtGui.QPixmap(returnResourcePath('images/arrow_right.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.switchToLogViewAction = self.mainwindow.htoolBar.addAction(switchToLogViewIcon, 'Drop log view') QtCore.QObject.connect(self.switchToLogViewAction, QtCore.SIGNAL('triggered()'), self.changeMainWindowView) self.mainwindow.htoolBar.addSeparator() startIdleIcon = QtGui.QIcon() startIdleIcon.addPixmap(QtGui.QPixmap(returnResourcePath('images/start_idle.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.startIdleAction = self.mainwindow.htoolBar.addAction(startIdleIcon, 'Start idling') QtCore.QObject.connect(self.startIdleAction, QtCore.SIGNAL('triggered()'), curry(self.startUpAccounts, action='idle')) startIdleUnsandboxedIcon = QtGui.QIcon() startIdleUnsandboxedIcon.addPixmap(QtGui.QPixmap(returnResourcePath('images/start_idle_unsandboxed.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.startIdleUnsandboxedAction = self.mainwindow.htoolBar.addAction(startIdleUnsandboxedIcon, 'Idle unsandboxed') QtCore.QObject.connect(self.startIdleUnsandboxedAction, QtCore.SIGNAL('triggered()'), curry(self.startUpAccounts, action='idle_unsandboxed')) startTF2Icon = QtGui.QIcon() startTF2Icon.addPixmap(QtGui.QPixmap(returnResourcePath('images/start_tf2.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.startTF2Action = self.mainwindow.htoolBar.addAction(startTF2Icon, 'Start TF2') QtCore.QObject.connect(self.startTF2Action, QtCore.SIGNAL('triggered()'), curry(self.startUpAccounts, action='start_TF2')) startSteamIcon = QtGui.QIcon() startSteamIcon.addPixmap(QtGui.QPixmap(returnResourcePath('images/start_steam.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.startSteamAction = self.mainwindow.htoolBar.addAction(startSteamIcon, 'Start Steam') QtCore.QObject.connect(self.startSteamAction, QtCore.SIGNAL('triggered()'), curry(self.startUpAccounts, action='start_steam')) startProgramIcon = QtGui.QIcon() startProgramIcon.addPixmap(QtGui.QPixmap(returnResourcePath('images/start_program.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.startProgramAction = self.mainwindow.htoolBar.addAction(startProgramIcon, 'Start Program') QtCore.QObject.connect(self.startProgramAction, QtCore.SIGNAL('triggered()'), self.startProgram) self.mainwindow.htoolBar.addSeparator() terminateSandboxIcon = QtGui.QIcon() terminateSandboxIcon.addPixmap(QtGui.QPixmap(returnResourcePath('images/terminate.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.terminateSandboxAction = self.mainwindow.htoolBar.addAction(terminateSandboxIcon, 'Terminate sandbox') QtCore.QObject.connect(self.terminateSandboxAction, QtCore.SIGNAL('triggered()'), curry(self.modifySandboxes, action='/terminate')) emptySandboxIcon = QtGui.QIcon() emptySandboxIcon.addPixmap(QtGui.QPixmap(returnResourcePath('images/delete_sandbox.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.emptySandboxAction = self.mainwindow.htoolBar.addAction(emptySandboxIcon, 'Empty sandbox') QtCore.QObject.connect(self.emptySandboxAction, QtCore.SIGNAL('triggered()'), curry(self.modifySandboxes, action='delete_sandbox_silent')) self.mainwindow.htoolBar.addSeparator() updateGCFsIcon = QtGui.QIcon() if self.copyingGCFs: progressimage = returnResourcePath('images/updating_gcfs_%spercent.png' % self.percentage) updateGCFsIcon.addPixmap(QtGui.QPixmap(progressimage), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.updateGCFsAction = self.mainwindow.htoolBar.addAction(updateGCFsIcon, 'Updating GCFs') else: updateGCFsIcon.addPixmap(QtGui.QPixmap(returnResourcePath('images/update_gcfs.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.updateGCFsAction = self.mainwindow.htoolBar.addAction(updateGCFsIcon, 'Update GCFs') QtCore.QObject.connect(self.updateGCFsAction, QtCore.SIGNAL('triggered()'), self.updateGCFs) if construct: self.gridLayout = QtGui.QGridLayout(self) self.gridLayout.setMargin(0) self.verticalLayout = QtGui.QVBoxLayout() self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1) # Add keyboard shortcut to select all account boxes QtGui.QShortcut(QtGui.QKeySequence('Ctrl+A'), self.mainwindow, self.SelectAllAccounts) QtCore.QMetaObject.connectSlotsByName(self) self.updateAccountBoxes()
def __init__(self): QtGui.QMainWindow.__init__(self) self.settings = Config.settings self.toolBars = [] self.sandboxieINIIsModified = False self.view = 'accounts' self.setWindowTitle('TF2Idle') windowXSize, windowYSize = eval(self.settings.get_option('Settings', 'ui_window_size')) if (windowXSize, windowYSize) == (0, 0): self.setWindowState(QtCore.Qt.WindowMaximized) else: self.resize(windowXSize, windowYSize) self.setWindowIcon(QtGui.QIcon(returnResourcePath('images/tf2idle.png'))) self.createSystemTray() self.drawToolBars() # Add menu bar self.menuBar = QtGui.QMenuBar(self) self.menuBar.setObjectName('menubar') self.setMenuBar(self.menuBar) # Add File menu fileMenu = self.addMenu('File') self.addSubMenu(fileMenu, text='Settings', shortcut='Ctrl+S', action={'trigger':'triggered()', 'action':self.openSettings}, iconimage=returnResourcePath('images/settings_logo.png')) fileMenu.addSeparator() self.addSubMenu(fileMenu, text='Exit', shortcut='Ctrl+Q', action={'trigger':'triggered()', 'action':self.close}, iconimage=returnResourcePath('images/exit_logo.png')) # Add About menu helpMenu = self.addMenu('Help') self.addSubMenu(helpMenu, text='Readme / Source', action={'trigger':'triggered()', 'action':self.openGithub}, iconimage=returnResourcePath('images/readme_logo.png')) self.addSubMenu(helpMenu, text='Facepunch thread', action={'trigger':'triggered()', 'action':self.openFacepunch}, iconimage=returnResourcePath('images/facepunch_logo.png')) self.addSubMenu(helpMenu, text='Steam group', action={'trigger':'triggered()', 'action':self.openSteamGroup}, iconimage=returnResourcePath('images/steam_group_logo.png')) self.addSubMenu(helpMenu, text='Check for update', action={'trigger':'triggered()', 'action':self.checkForUpdate}, iconimage=returnResourcePath('images/update_logo.png')) self.addSubMenu(helpMenu, text='Bugs/Features/Feedback', action={'trigger':'triggered()', 'action':self.openFeedback}, iconimage=returnResourcePath('images/uservoice.png')) self.addSubMenu(helpMenu, text='About', action={'trigger':'triggered()', 'action':self.showAbout}, iconimage=returnResourcePath('images/tf2idle.png')) # Add Steam menu steamMenu = self.addMenu('Powered by Steam') self.addSubMenu(steamMenu, text='Steam website', action={'trigger':'triggered()', 'action':self.openSteamSite}, iconimage=returnResourcePath('images/steam_logo.png')) # Set starting view as accounts page self.accountsView = AccountsView(self) self.dropLogView = DropLogView(self, self.tray) self.stackedWidget = QtGui.QStackedWidget(self) self.stackedWidget.addWidget(self.accountsView) self.stackedWidget.addWidget(self.dropLogView) self.setCentralWidget(self.stackedWidget) # Connect signals used for passing account information between views QtCore.QObject.connect(self.accountsView, QtCore.SIGNAL('returnedSelectedAccounts(PyQt_PyObject)'), self.dropLogView.setSelectedAccounts) QtCore.QObject.connect(self.dropLogView, QtCore.SIGNAL('retrieveSelectedAccounts'), self.accountsView.returnSelectedAccounts) QtCore.QObject.connect(self.accountsView, QtCore.SIGNAL('startDropLog(PyQt_PyObject)'), self.dropLogView.addAccount) QtCore.QObject.connect(self.accountsView, QtCore.SIGNAL('stopDropLog(PyQt_PyObject)'), self.dropLogView.removeAccount) self.changeView() self.dropLogView.toggleItemValues()
def __init__(self): QtGui.QMainWindow.__init__(self) self.settings = Config.settings self.toolBars = [] self.sandboxieINIIsModified = False self.view = 'accounts' self.setWindowTitle('TF2Idle') windowXSize, windowYSize = eval( self.settings.get_option('Settings', 'ui_window_size')) if (windowXSize, windowYSize) == (0, 0): self.setWindowState(QtCore.Qt.WindowMaximized) else: self.resize(windowXSize, windowYSize) self.setWindowIcon( QtGui.QIcon(returnResourcePath('images/tf2idle.png'))) self.createSystemTray() self.drawToolBars() # Add menu bar self.menuBar = QtGui.QMenuBar(self) self.menuBar.setObjectName('menubar') self.setMenuBar(self.menuBar) # Add File menu fileMenu = self.addMenu('File') self.addSubMenu( fileMenu, text='Settings', shortcut='Ctrl+S', action={ 'trigger': 'triggered()', 'action': self.openSettings }, iconimage=returnResourcePath('images/settings_logo.png')) fileMenu.addSeparator() self.addSubMenu(fileMenu, text='Exit', shortcut='Ctrl+Q', action={ 'trigger': 'triggered()', 'action': self.close }, iconimage=returnResourcePath('images/exit_logo.png')) # Add About menu helpMenu = self.addMenu('Help') self.addSubMenu(helpMenu, text='Readme / Source', action={ 'trigger': 'triggered()', 'action': self.openGithub }, iconimage=returnResourcePath('images/readme_logo.png')) self.addSubMenu( helpMenu, text='Facepunch thread', action={ 'trigger': 'triggered()', 'action': self.openFacepunch }, iconimage=returnResourcePath('images/facepunch_logo.png')) self.addSubMenu( helpMenu, text='Steam group', action={ 'trigger': 'triggered()', 'action': self.openSteamGroup }, iconimage=returnResourcePath('images/steam_group_logo.png')) self.addSubMenu(helpMenu, text='Check for update', action={ 'trigger': 'triggered()', 'action': self.checkForUpdate }, iconimage=returnResourcePath('images/update_logo.png')) self.addSubMenu(helpMenu, text='Bugs/Features/Feedback', action={ 'trigger': 'triggered()', 'action': self.openFeedback }, iconimage=returnResourcePath('images/uservoice.png')) self.addSubMenu(helpMenu, text='About', action={ 'trigger': 'triggered()', 'action': self.showAbout }, iconimage=returnResourcePath('images/tf2idle.png')) # Add Steam menu steamMenu = self.addMenu('Powered by Steam') self.addSubMenu(steamMenu, text='Steam website', action={ 'trigger': 'triggered()', 'action': self.openSteamSite }, iconimage=returnResourcePath('images/steam_logo.png')) # Set starting view as accounts page self.accountsView = AccountsView(self) self.dropLogView = DropLogView(self, self.tray) self.stackedWidget = QtGui.QStackedWidget(self) self.stackedWidget.addWidget(self.accountsView) self.stackedWidget.addWidget(self.dropLogView) self.setCentralWidget(self.stackedWidget) # Connect signals used for passing account information between views QtCore.QObject.connect( self.accountsView, QtCore.SIGNAL('returnedSelectedAccounts(PyQt_PyObject)'), self.dropLogView.setSelectedAccounts) QtCore.QObject.connect(self.dropLogView, QtCore.SIGNAL('retrieveSelectedAccounts'), self.accountsView.returnSelectedAccounts) QtCore.QObject.connect(self.accountsView, QtCore.SIGNAL('startDropLog(PyQt_PyObject)'), self.dropLogView.addAccount) QtCore.QObject.connect(self.accountsView, QtCore.SIGNAL('stopDropLog(PyQt_PyObject)'), self.dropLogView.removeAccount) self.changeView() self.dropLogView.toggleItemValues()
self.close() def startup(): setDefaultSettings() myapp = MainWindow() myapp.show() app.exec_() Config.settings.flush_configuration() def my_excepthook(type, value, tback): logger.error('Uncaught Exception', exc_info=(type, value, tback)) # Call the default handler sys.__excepthook__(type, value, tback) if __name__ == "__main__": app = QtGui.QApplication(sys.argv) Config.init(optionsfile) sys.excepthook = my_excepthook if Config.settings.returnReadState(): startup() # config file is encrypted else: firstWindow = KeyDialog() firstWindow.exec_() if Config.settings.returnReadState(): startup() else: dialog = QtGui.QDialog() dialog.setWindowIcon(QtGui.QIcon(returnResourcePath('images/tf2idle.png'))) QtGui.QMessageBox.critical(dialog, 'Error', 'Could not decrypt the config file, your key is incorrect')
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.settings = Config.settings # Create dialog self.setWindowModality(QtCore.Qt.NonModal) self.resize(250, 450) self.setMinimumSize(QtCore.QSize(self.width(), self.height())) self.setWindowTitle('Select groups') self.setWindowIcon(QtGui.QIcon(returnResourcePath('images/select_group.png'))) self.gridLayout = QtGui.QVBoxLayout(self) self.scrollArea = QtGui.QScrollArea(self) self.scrollArea.setWidgetResizable(True) self.scrollArea.setFrameShape(QtGui.QFrame.NoFrame) self.gridLayout.addWidget(self.scrollArea) self.scrollAreaWidgetContents = QtGui.QWidget() self.scrollArea.setWidget(self.scrollAreaWidgetContents) self.widgetVerticalLayout = QtGui.QVBoxLayout(self.scrollAreaWidgetContents) self.verticalLayout = QtGui.QVBoxLayout() self.widgetVerticalLayout.addLayout(self.verticalLayout) # Generate groups dict self.groupsDict = {} for account in list(Set(self.settings.get_sections()) - Set(['Settings'])): groups = self.settings.get_option(account, 'groups') groups = groups.split(',') for group in groups: if group == '': pass else: if group in self.groupsDict: self.groupsDict[group].append(self.settings.get_option(account, 'steam_username')) else: self.groupsDict[group] = [] self.groupsDict[group].append(self.settings.get_option(account, 'steam_username')) # Add group checkboxes self.groupButtons = [] if len(self.groupsDict) == 0: self.Label = QtGui.QLabel() self.Label.setText('You have no groups set up. Try adding an account to a group first.') self.Label.setAlignment(QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter) self.Label.setWordWrap(True) self.verticalLayout.addWidget(self.Label) else: icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(returnResourcePath('images/unselected_button.png')), QtGui.QIcon.Selected, QtGui.QIcon.Off) icon.addPixmap(QtGui.QPixmap(returnResourcePath('images/selected_button.png')), QtGui.QIcon.Selected, QtGui.QIcon.On) for group in sorted(self.groupsDict, cmp = compare_keys): self.commandLinkButton = QtGui.QCommandLinkButton() self.commandLinkButton.setText(group) self.commandLinkButton.setIcon(icon) # Display members of group membersString = '' for member in sorted(self.groupsDict[group]): membersString += member + '\n' self.commandLinkButton.setDescription(membersString) self.commandLinkButton.setCheckable(True) self.verticalLayout.addWidget(self.commandLinkButton) self.groupButtons.append(self.commandLinkButton) # Add buttons self.buttonBox = QtGui.QDialogButtonBox() self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setCenterButtons(True) selectbutton = QtGui.QPushButton('Select', self) deselectbutton = QtGui.QPushButton('Deselect', self) cancelbutton = QtGui.QPushButton('Cancel', self) self.buttonBox.addButton(selectbutton, QtGui.QDialogButtonBox.ActionRole) self.buttonBox.addButton(deselectbutton, QtGui.QDialogButtonBox.ActionRole) self.buttonBox.addButton(cancelbutton, QtGui.QDialogButtonBox.RejectRole) self.gridLayout.addWidget(self.buttonBox) # Signal connections self.connect(selectbutton, QtCore.SIGNAL('clicked()'), self.select) self.connect(deselectbutton, QtCore.SIGNAL('clicked()'), self.deselect) self.connect(cancelbutton, QtCore.SIGNAL('clicked()'), self.reject) QtCore.QMetaObject.connectSlotsByName(self) self.accountsSelectList = [] self.accountsDeselectList = []
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.settings = Config.settings # Create dialog self.setWindowModality(QtCore.Qt.NonModal) self.setWindowTitle('TF2Idle Settings') self.setWindowIcon(QtGui.QIcon(returnResourcePath('images/settings.png'))) self.vBoxLayout = QtGui.QGridLayout(self) # Add tab widget and tabs self.tabWidget = QtGui.QTabWidget(self) self.vBoxLayout.addWidget(self.tabWidget) self.generalTab = QtGui.QWidget() self.tf2idleTab = QtGui.QWidget() self.droplogTab = QtGui.QWidget() self.tabWidget.addTab(self.generalTab, 'TF2') self.tabWidget.addTab(self.tf2idleTab, 'TF2Idle') self.tabWidget.addTab(self.droplogTab, 'Drop Log') # Add layouts for tabs self.generalVBoxLayout = QtGui.QVBoxLayout(self.generalTab) self.tf2idleVBoxLayout = QtGui.QGridLayout(self.tf2idleTab) self.droplogVBoxLayout = QtGui.QGridLayout(self.droplogTab) # Set fonts/styles self.greyoutstyle = 'background-color: rgb(225, 225, 225);' titleStyle = "QGroupBox {font-weight: bold;}" italicfont = QtGui.QFont() italicfont.setItalic(True) # TF2 settings tab # Locations section self.locationsGroupBox = QtGui.QGroupBox(self.generalTab) self.locationsGroupBox.setStyleSheet(titleStyle) self.locationsGroupBox.setTitle('Locations') self.generalVBoxLayout.addWidget(self.locationsGroupBox) self.locationsGroupBoxLayout = QtGui.QGridLayout(self.locationsGroupBox) self.steamLocationLabel = QtGui.QLabel(self.locationsGroupBox) self.steamLocationLabel.setToolTip('The path to your Steam installation. This folder should contain Steam.exe') self.steamLocationLabel.setText('Steam installation location:') self.locationsGroupBoxLayout.addWidget(self.steamLocationLabel, 0, 0, 1, 1) self.steamLocationLineEdit = QtGui.QLineEdit() self.steamLocationLineEdit.setToolTip('The path to your Steam installation. This folder should contain Steam.exe') self.steamLocationLineEdit.setPlaceholderText('Steam folder path') self.locationsGroupBoxLayout.addWidget(self.steamLocationLineEdit, 0, 1, 1, 1) self.steamLocationButton = QtGui.QPushButton() self.steamLocationButton.setText('..') self.steamLocationButton.setMaximumSize(QtCore.QSize(30, 20)) self.locationsGroupBoxLayout.addWidget(self.steamLocationButton, 0, 2, 1, 1) self.secondarySteamappsLocationLabel = QtGui.QLabel(self.locationsGroupBox) self.secondarySteamappsLocationLabel.setToolTip('The path to your backup copy of the steamapps folder. This folder should contain the TF2 GCFs. Optional, only if you wish to use sandboxes') self.secondarySteamappsLocationLabel.setText('Secondary Steamapps folder location:') self.locationsGroupBoxLayout.addWidget(self.secondarySteamappsLocationLabel, 1, 0, 1, 1) self.secondarySteamappsLocationLineEdit = QtGui.QLineEdit() self.secondarySteamappsLocationLineEdit.setToolTip('The path to your backup copy of the steamapps folder. This folder should contain the TF2 GCFs. Optional, only if you wish to use sandboxes') self.secondarySteamappsLocationLineEdit.setPlaceholderText('Steamapps folder path') self.locationsGroupBoxLayout.addWidget(self.secondarySteamappsLocationLineEdit, 1, 1, 1, 1) self.secondarySteamappsLocationButton = QtGui.QPushButton() self.secondarySteamappsLocationButton.setText('..') self.secondarySteamappsLocationButton.setMaximumSize(QtCore.QSize(30, 20)) self.locationsGroupBoxLayout.addWidget(self.secondarySteamappsLocationButton, 1, 2, 1, 1) self.sandboxieLocationLabel = QtGui.QLabel(self.locationsGroupBox) self.sandboxieLocationLabel.setToolTip('The path to your Sandboxie installation. This folder should contain sandboxie.exe. Optional, only if you wish to use sandboxes') self.sandboxieLocationLabel.setText('Sandboxie installation location:') self.locationsGroupBoxLayout.addWidget(self.sandboxieLocationLabel, 2, 0, 1, 1) self.sandboxieLocationLineEdit = QtGui.QLineEdit() self.sandboxieLocationLineEdit.setToolTip('The path to your Sandboxie installation. This folder should contain sandboxie.exe. Optional, only if you wish to use sandboxes') self.sandboxieLocationLineEdit.setPlaceholderText('Sandboxie folder path') self.locationsGroupBoxLayout.addWidget(self.sandboxieLocationLineEdit, 2, 1, 1, 1) self.sandboxieLocationButton = QtGui.QPushButton() self.sandboxieLocationButton.setText('..') self.sandboxieLocationButton.setMaximumSize(QtCore.QSize(30, 20)) self.locationsGroupBoxLayout.addWidget(self.sandboxieLocationButton, 2, 2, 1, 1) # Steam API section self.steamAPIGroupBox = QtGui.QGroupBox(self.generalTab) self.steamAPIGroupBox.setStyleSheet(titleStyle) self.steamAPIGroupBox.setTitle('Steam API Settings') self.generalVBoxLayout.addWidget(self.steamAPIGroupBox) self.SteamAPIGroupBoxLayout = QtGui.QGridLayout(self.steamAPIGroupBox) self.steamAPIKeyLabel = QtGui.QLabel(self.steamAPIGroupBox) self.steamAPIKeyLabel.setToolTip('Your Steam WebAPI key. Optional, only if you wish to use the drop log feature') self.steamAPIKeyLabel.setText('Steam API key:') self.SteamAPIGroupBoxLayout.addWidget(self.steamAPIKeyLabel, 0, 0, 1, 1) self.steamAPIKeyLineEdit = QtGui.QLineEdit() self.steamAPIKeyLineEdit.setToolTip('Your Steam WebAPI key. Optional, only if you wish to use the drop log feature') self.steamAPIKeyLineEdit.setPlaceholderText('Steam WebAPI key') self.SteamAPIGroupBoxLayout.addWidget(self.steamAPIKeyLineEdit, 0, 1, 1, 1) # Backpack viewer section self.backpackGroupBox = QtGui.QGroupBox(self.generalTab) self.backpackGroupBox.setStyleSheet(titleStyle) self.backpackGroupBox.setTitle('Backpack Viewer Settings') self.generalVBoxLayout.addWidget(self.backpackGroupBox) self.backpackGroupBoxLayout = QtGui.QGridLayout(self.backpackGroupBox) self.backpackViewerLabel = QtGui.QLabel(self.backpackGroupBox) self.backpackViewerLabel.setToolTip('Your choice of backpack viewer') self.backpackViewerLabel.setText('Backpack viewer:') self.backpackGroupBoxLayout.addWidget(self.backpackViewerLabel, 0, 0, 1, 1) self.backpackViewerComboBox = QtGui.QComboBox() self.backpackViewerComboBox.insertItem(1, 'Backpack.tf') self.backpackViewerComboBox.insertItem(2, 'OPTF2') self.backpackViewerComboBox.insertItem(3, 'Steam') self.backpackViewerComboBox.insertItem(4, 'TF2B') self.backpackViewerComboBox.insertItem(5, 'TF2Items') self.backpackGroupBoxLayout.addWidget(self.backpackViewerComboBox, 0, 1, 1, 1) # TF2 settings section self.TF2SettingsGroupBox = QtGui.QGroupBox(self.generalTab) self.TF2SettingsGroupBox.setStyleSheet(titleStyle) self.TF2SettingsGroupBox.setTitle('TF2 Settings') self.generalVBoxLayout.addWidget(self.TF2SettingsGroupBox) self.TF2SettingsGroupBoxLayout = QtGui.QGridLayout(self.TF2SettingsGroupBox) self.idleLaunchLabel = QtGui.QLabel(self.TF2SettingsGroupBox) self.idleLaunchLabel.setToolTip('Your TF2 launch options for idling') self.idleLaunchLabel.setText('Idle launch settings:') self.TF2SettingsGroupBoxLayout.addWidget(self.idleLaunchLabel, 0, 0, 1, 1) self.idleLaunchTextEdit = QTextEditWithPlaceholderText('TF2 launch options for idling') self.idleLaunchTextEdit.setTabChangesFocus(True) self.idleLaunchTextEdit.setToolTip('Your TF2 launch options for idling') self.TF2SettingsGroupBoxLayout.addWidget(self.idleLaunchTextEdit, 0, 1, 1, 2) self.idleLaunchTextButton = QtGui.QPushButton() self.idleLaunchTextButton.setText('Restore default launch settings') self.TF2SettingsGroupBoxLayout.addWidget(self.idleLaunchTextButton, 1, 1, 1, 2) self.delayTimerLabel = QtGui.QLabel(self.TF2SettingsGroupBox) self.delayTimerLabel.setToolTip('Choose the delay between launching accounts') self.delayTimerLabel.setText('Account launch delay (secs):') self.TF2SettingsGroupBoxLayout.addWidget(self.delayTimerLabel, 2, 0, 1, 1) self.delayTimerSlider = QtGui.QSlider(QtCore.Qt.Horizontal) self.delayTimerSlider.setToolTip('Choose the delay between launching accounts') self.delayTimerSlider.setTickInterval(10) self.delayTimerSlider.setMinimum(0) self.delayTimerSlider.setMaximum(600) self.delayTimerSlider.valueChanged[int].connect(curry(self.changeValue, spinbox='launch_delay_time')) self.TF2SettingsGroupBoxLayout.addWidget(self.delayTimerSlider, 2, 1, 1, 1) self.delayTimerSpinBox = QtGui.QSpinBox() self.delayTimerSpinBox.setToolTip('Choose the delay between launching accounts') self.delayTimerSpinBox.setSingleStep(10) self.delayTimerSpinBox.setMinimum(0) self.delayTimerSpinBox.setMaximum(600) self.delayTimerSpinBox.valueChanged[int].connect(curry(self.changeSlider, slider='launch_delay_time')) self.TF2SettingsGroupBoxLayout.addWidget(self.delayTimerSpinBox, 2, 2, 1, 1) # TF2Idle settings tab # Encryption section self.encryptionGroupBox = QtGui.QGroupBox(self.tf2idleTab) self.encryptionGroupBox.setStyleSheet(titleStyle) self.encryptionGroupBox.setTitle('Encryption') self.tf2idleVBoxLayout.addWidget(self.encryptionGroupBox) self.encryptionGroupBoxLayout = QtGui.QGridLayout(self.encryptionGroupBox) self.encryptionModeLabel = QtGui.QLabel(self.encryptionGroupBox) self.encryptionModeLabel.setToolTip('Choose whether to encrypt your config file') self.encryptionModeLabel.setText('Config file encryption:') self.encryptionGroupBoxLayout.addWidget(self.encryptionModeLabel, 0, 0, 1, 1) self.encryptionModeVLayout = QtGui.QVBoxLayout() self.encryptionModeVLayout.setMargin(0) self.encryptionGroupBoxLayout.addLayout(self.encryptionModeVLayout, 0, 1, 1, 1) self.encryptionOffRadioButton = QtGui.QRadioButton() self.encryptionOffRadioButton.setText('Encryption off') self.encryptionModeVLayout.addWidget(self.encryptionOffRadioButton) self.encryptionOnRadioButton = QtGui.QRadioButton() self.encryptionOnRadioButton.setText('Encryption on') self.encryptionModeVLayout.addWidget(self.encryptionOnRadioButton) self.encryptionModeDescriptionLabel = QtGui.QLabel(self.encryptionGroupBox) self.encryptionModeDescriptionLabel.setToolTip('Encryption mode description') self.encryptionModeDescriptionLabel.setFont(italicfont) self.encryptionModeDescriptionLabel.setAlignment(QtCore.Qt.AlignJustify|QtCore.Qt.AlignVCenter) self.encryptionGroupBoxLayout.addWidget(self.encryptionModeDescriptionLabel, 1, 1, 1, 1) self.encryptionKeyLabel = QtGui.QLabel(self.encryptionGroupBox) self.encryptionKeyLabel.setToolTip('Your encryption key') self.encryptionKeyLabel.setText('Encryption key:') self.encryptionGroupBoxLayout.addWidget(self.encryptionKeyLabel, 2, 0, 1, 1) self.encryptionKeyLineEdit = QtGui.QLineEdit(self.encryptionGroupBox) self.encryptionKeyLineEdit.setToolTip('Your encryption key') self.encryptionKeyLineEdit.setMaxLength(32) self.encryptionKeyLineEdit.setEchoMode(QtGui.QLineEdit.PasswordEchoOnEdit) self.encryptionGroupBoxLayout.addWidget(self.encryptionKeyLineEdit, 2, 1, 1, 1) # Sandboxie mode section self.sandboxesGroupBox = QtGui.QGroupBox(self.tf2idleTab) self.sandboxesGroupBox.setStyleSheet(titleStyle) self.sandboxesGroupBox.setTitle('Sandboxes') self.tf2idleVBoxLayout.addWidget(self.sandboxesGroupBox) self.sandboxesGroupBoxLayout = QtGui.QGridLayout(self.sandboxesGroupBox) self.sandboxModeLabel = QtGui.QLabel(self.sandboxesGroupBox) self.sandboxModeLabel.setToolTip('Choose a Sandboxie mode') self.sandboxModeLabel.setText('Sandboxie mode:') self.sandboxesGroupBoxLayout.addWidget(self.sandboxModeLabel, 0, 0, 1, 1) self.sandboxModeVLayout = QtGui.QVBoxLayout() self.sandboxModeVLayout.setMargin(0) self.sandboxesGroupBoxLayout.addLayout(self.sandboxModeVLayout, 0, 1, 1, 1) self.easySandboxModeRadioButton = QtGui.QRadioButton() self.easySandboxModeRadioButton.setText('Easy sandbox mode (experimental)') self.sandboxModeVLayout.addWidget(self.easySandboxModeRadioButton) self.advancedSandboxModeRadioButton = QtGui.QRadioButton() self.advancedSandboxModeRadioButton.setText('Advanced sandbox mode') self.sandboxModeVLayout.addWidget(self.advancedSandboxModeRadioButton) self.sandboxModeDescriptionLabel = QtGui.QLabel(self.sandboxesGroupBox) self.sandboxModeDescriptionLabel.setToolTip('Sandbox mode description') self.sandboxModeDescriptionLabel.setFont(italicfont) self.sandboxModeDescriptionLabel.setAlignment(QtCore.Qt.AlignJustify|QtCore.Qt.AlignVCenter) self.sandboxesGroupBoxLayout.addWidget(self.sandboxModeDescriptionLabel, 1, 1, 1, 1) # UI settings section self.userInterfaceSettingsGroupBox = QtGui.QGroupBox(self.tf2idleTab) self.userInterfaceSettingsGroupBox.setStyleSheet(titleStyle) self.userInterfaceSettingsGroupBox.setTitle('User Interface') self.tf2idleVBoxLayout.addWidget(self.userInterfaceSettingsGroupBox) self.userInterfaceSettingsGroupBoxLayout = QtGui.QGridLayout(self.userInterfaceSettingsGroupBox) self.closeBehaviourLabel = QtGui.QLabel() self.closeBehaviourLabel.setToolTip('Close the program to the tray') self.closeBehaviourLabel.setText('Close program to tray:') self.userInterfaceSettingsGroupBoxLayout.addWidget(self.closeBehaviourLabel, 0, 0, 1, 1) self.closeBehaviourCheckbox = QtGui.QCheckBox() self.userInterfaceSettingsGroupBoxLayout.addWidget(self.closeBehaviourCheckbox, 0, 1, 1, 1) self.noOfColumnsLabel = QtGui.QLabel() self.noOfColumnsLabel.setToolTip('The number of account boxes to display per row') self.noOfColumnsLabel.setText('No of account boxes per row:') self.userInterfaceSettingsGroupBoxLayout.addWidget(self.noOfColumnsLabel, 1, 0, 1, 1) self.noOfColumnsSlider = QtGui.QSlider(QtCore.Qt.Horizontal, ) self.noOfColumnsSlider.setToolTip('The number of account boxes to display per row') self.noOfColumnsSlider.setTickInterval(1) self.noOfColumnsSlider.setMinimum(1) self.noOfColumnsSlider.setMaximum(20) self.noOfColumnsSlider.valueChanged[int].connect(curry(self.changeValue, spinbox='no_of_columns')) self.userInterfaceSettingsGroupBoxLayout.addWidget(self.noOfColumnsSlider, 1, 1, 1, 1) self.noOfColumnsSpinBox = QtGui.QSpinBox() self.noOfColumnsSpinBox.setToolTip('The number of account boxes to display per row') self.noOfColumnsSpinBox.setMinimum(1) self.noOfColumnsSpinBox.setMaximum(20) self.noOfColumnsSpinBox.valueChanged[int].connect(curry(self.changeSlider, slider='no_of_columns')) self.userInterfaceSettingsGroupBoxLayout.addWidget(self.noOfColumnsSpinBox, 1, 2, 1, 1) self.accountFontSizeLabel = QtGui.QLabel() self.accountFontSizeLabel.setToolTip('The size of the font used in the account boxes') self.accountFontSizeLabel.setText('Account box font size:') self.userInterfaceSettingsGroupBoxLayout.addWidget(self.accountFontSizeLabel, 2, 0, 1, 1) self.accountFontSizeSlider = QtGui.QSlider(QtCore.Qt.Horizontal, ) self.accountFontSizeSlider.setToolTip('The size of the icon used in the account boxes') self.accountFontSizeSlider.setTickInterval(1) self.accountFontSizeSlider.setMinimum(1) self.accountFontSizeSlider.setMaximum(50) self.accountFontSizeSlider.valueChanged[int].connect(curry(self.changeValue, spinbox='account_font_size')) self.userInterfaceSettingsGroupBoxLayout.addWidget(self.accountFontSizeSlider, 2, 1, 1, 1) self.accountFontSizeSpinBox = QtGui.QSpinBox() self.accountFontSizeSpinBox.setToolTip('The size of the font used in the account boxes') self.accountFontSizeSpinBox.setMinimum(1) self.accountFontSizeSpinBox.setMaximum(50) self.accountFontSizeSpinBox.valueChanged[int].connect(curry(self.changeSlider, slider='account_font_size')) self.userInterfaceSettingsGroupBoxLayout.addWidget(self.accountFontSizeSpinBox, 2, 2, 1, 1) self.accountIconSizeLabel = QtGui.QLabel() self.accountIconSizeLabel.setToolTip('The size of the icon used in the account boxes') self.accountIconSizeLabel.setText('Account box icon size:') self.userInterfaceSettingsGroupBoxLayout.addWidget(self.accountIconSizeLabel, 3, 0, 1, 1) self.accountIconSizeSlider = QtGui.QSlider(QtCore.Qt.Horizontal, ) self.accountIconSizeSlider.setToolTip('The size of the icon used in the account boxes') self.accountIconSizeSlider.setTickInterval(1) self.accountIconSizeSlider.valueChanged[int].connect(curry(self.changeValue, spinbox='account_icon_size')) self.userInterfaceSettingsGroupBoxLayout.addWidget(self.accountIconSizeSlider, 3, 1, 1, 1) self.accountIconSizeSpinBox = QtGui.QSpinBox() self.accountIconSizeSpinBox.setToolTip('The size of the icon used in the account boxes') self.accountIconSizeSpinBox.setMinimum(0) self.accountIconSizeSpinBox.setMaximum(99) self.accountIconSizeSpinBox.valueChanged[int].connect(curry(self.changeSlider, slider='account_icon_size')) self.userInterfaceSettingsGroupBoxLayout.addWidget(self.accountIconSizeSpinBox, 3, 2, 1, 1) self.accountIconLabel = QtGui.QLabel() self.accountIconLabel.setToolTip('Choose an image to use as the account box icons') self.accountIconLabel.setText('Account box icon:') self.userInterfaceSettingsGroupBoxLayout.addWidget(self.accountIconLabel, 4, 0, 1, 1) self.accountIconLineEdit = QtGui.QLineEdit() self.accountIconLineEdit.setFrame(True) self.accountIconLineEdit.setToolTip('Choose an image to use as the account box icons') self.userInterfaceSettingsGroupBoxLayout.addWidget(self.accountIconLineEdit, 4, 1, 1, 1) self.accountIconButton = QtGui.QPushButton() self.accountIconButton.setText('..') self.accountIconButton.setMaximumSize(QtCore.QSize(30, 20)) self.userInterfaceSettingsGroupBoxLayout.addWidget(self.accountIconButton, 4, 2, 1, 1) self.accountIconRestoreButton = QtGui.QPushButton() self.accountIconRestoreButton.setText('Restore default icon') self.userInterfaceSettingsGroupBoxLayout.addWidget(self.accountIconRestoreButton, 5, 1, 1, 1) self.accountBoxPreviewLabel = QtGui.QLabel() self.accountBoxPreviewLabel.setToolTip('Account box preview') self.accountBoxPreviewLabel.setText('Account box preview:') self.userInterfaceSettingsGroupBoxLayout.addWidget(self.accountBoxPreviewLabel, 6, 0, 1, 1) ui_account_box_font_size = self.settings.get_option('Settings', 'ui_account_box_font_size') ui_account_box_icon_size = int(self.settings.get_option('Settings', 'ui_account_box_icon_size')) ui_account_box_icon = self.settings.get_option('Settings', 'ui_account_box_icon') self.commandLinkButton = QtGui.QCommandLinkButton() icon = QtGui.QIcon() if ui_account_box_icon != '': icon.addPixmap(QtGui.QPixmap(ui_account_box_icon)) else: icon.addPixmap(QtGui.QPixmap(returnResourcePath('images/unselected_button.png')), QtGui.QIcon.Selected, QtGui.QIcon.Off) icon.addPixmap(QtGui.QPixmap(returnResourcePath('images/selected_button.png')), QtGui.QIcon.Selected, QtGui.QIcon.On) self.commandLinkButton.setIcon(icon) self.commandLinkButton.setIconSize(QtCore.QSize(ui_account_box_icon_size, ui_account_box_icon_size)) self.commandLinkButton.setCheckable(True) self.commandLinkButton.setStyleSheet('font: %spt "TF2 Build";' % ui_account_box_font_size) self.commandLinkButton.setText('Idling account') self.userInterfaceSettingsGroupBoxLayout.addWidget(self.commandLinkButton, 6, 1, 1, 1) # Drop log settings tab # Poll time and file formatting section self.dropLogGroupBox = QtGui.QGroupBox(self.droplogTab) self.dropLogGroupBox.setStyleSheet(titleStyle) self.dropLogGroupBox.setTitle('Drop Log') self.droplogVBoxLayout.addWidget(self.dropLogGroupBox) self.dropLogGroupBoxLayout = QtGui.QGridLayout(self.dropLogGroupBox) self.pollTimeLabel = QtGui.QLabel(self.dropLogGroupBox) self.pollTimeLabel.setToolTip('Choose the amount of time between backpack polls') self.pollTimeLabel.setText('Backpack polling interval (mins):') self.dropLogGroupBoxLayout.addWidget(self.pollTimeLabel, 0, 0, 1, 1) self.pollTimeSlider = QtGui.QSlider(QtCore.Qt.Horizontal) self.pollTimeSlider.setToolTip('Choose the amount of time between backpack polls') self.pollTimeSlider.setTickInterval(1) self.pollTimeSlider.setMinimum(1) self.pollTimeSlider.setMaximum(30) self.pollTimeSlider.valueChanged[int].connect(curry(self.changeValue, spinbox='log_poll_time')) self.dropLogGroupBoxLayout.addWidget(self.pollTimeSlider, 0, 1, 1, 1) self.pollTimeSpinBox = QtGui.QSpinBox() self.pollTimeSpinBox.setToolTip('Choose the amount of time between backpack polls') self.pollTimeSpinBox.setMinimum(1) self.pollTimeSpinBox.setMaximum(30) self.pollTimeSpinBox.valueChanged[int].connect(curry(self.changeSlider, slider='log_poll_time')) self.dropLogGroupBoxLayout.addWidget(self.pollTimeSpinBox, 0, 2, 1, 1) self.fileFormattingLegendLabel = QtGui.QLabel() self.fileFormattingLegendLabel.setFont(italicfont) self.fileFormattingLegendLabel.setAlignment(QtCore.Qt.AlignJustify|QtCore.Qt.AlignVCenter) self.fileFormattingLegendLabel.setText('Keywords:\n\n{time}, {date}, {item}\n\n{itemtype}, {id}, {account}\n\n{accountnickname}, {nline}') self.dropLogGroupBoxLayout.addWidget(self.fileFormattingLegendLabel, 1, 1, 1, 2) self.fileFormattingLabel = QtGui.QLabel(self.dropLogGroupBox) self.fileFormattingLabel.setToolTip('The formatting of the log when you save to a text file') self.fileFormattingLabel.setText('Log file formatting:') self.dropLogGroupBoxLayout.addWidget(self.fileFormattingLabel, 2, 0, 1, 1) self.fileFormattingLineEdit = QtGui.QLineEdit() self.fileFormattingLineEdit.setToolTip('The formatting of the log when you save to a text file') self.fileFormattingLineEdit.setPlaceholderText('Log format string') self.dropLogGroupBoxLayout.addWidget(self.fileFormattingLineEdit, 2, 1, 1, 2) self.fileFormattingTextButton = QtGui.QPushButton() self.fileFormattingTextButton.setText('Restore default file formatting') self.dropLogGroupBoxLayout.addWidget(self.fileFormattingTextButton, 3, 1, 1, 2) self.webViewLabel = QtGui.QLabel(self.dropLogGroupBox) self.webViewLabel.setToolTip('Turn the web viewer on or off') self.webViewLabel.setText('Web viewer:') self.dropLogGroupBoxLayout.addWidget(self.webViewLabel, 4, 0, 1, 1) self.webViewVLayout = QtGui.QVBoxLayout() self.webViewVLayout.setMargin(0) self.dropLogGroupBoxLayout.addLayout(self.webViewVLayout, 4, 1, 1, 1) self.webViewOnRadioButton = QtGui.QRadioButton() self.webViewOnRadioButton.setText('On') self.webViewVLayout.addWidget(self.webViewOnRadioButton) self.webViewOffRadioButton = QtGui.QRadioButton() self.webViewOffRadioButton.setText('Off') self.webViewVLayout.addWidget(self.webViewOffRadioButton) self.webViewDescriptionLabel = QtGui.QLabel(self.dropLogGroupBox) self.webViewDescriptionLabel.setToolTip('Web view description') self.webViewDescriptionLabel.setFont(italicfont) self.webViewDescriptionLabel.setAlignment(QtCore.Qt.AlignJustify|QtCore.Qt.AlignVCenter) self.dropLogGroupBoxLayout.addWidget(self.webViewDescriptionLabel, 5, 1, 1, 1) self.webViewPortLabel = QtGui.QLabel(self.dropLogGroupBox) self.webViewPortLabel.setToolTip('Choose the port to use for the web viewer') self.webViewPortLabel.setText('Web viewer port:') self.dropLogGroupBoxLayout.addWidget(self.webViewPortLabel, 6, 0, 1, 1) self.webViewPortSpinBox = QtGui.QSpinBox() self.webViewPortSpinBox.setToolTip('Choose the port to use for the web viewer') self.webViewPortSpinBox.setMinimum(1024) self.webViewPortSpinBox.setMaximum(49151) self.dropLogGroupBoxLayout.addWidget(self.webViewPortSpinBox, 6, 1, 1, 1) self.trayNotificationsLabel = QtGui.QLabel(self.dropLogGroupBox) self.trayNotificationsLabel.setToolTip('Turn system tray notifications on or off') self.trayNotificationsLabel.setText('System tray notifications:') self.dropLogGroupBoxLayout.addWidget(self.trayNotificationsLabel, 7, 0, 1, 1) self.trayNotificationsHLayout = QtGui.QHBoxLayout() self.trayNotificationsHLayout.setMargin(0) self.dropLogGroupBoxLayout.addLayout(self.trayNotificationsHLayout, 7, 1, 1, 1) self.trayNotificationsHatsCheckbox = QtGui.QCheckBox() self.trayNotificationsHatsCheckbox.setText('Hats') self.trayNotificationsHLayout.addWidget(self.trayNotificationsHatsCheckbox) self.trayNotificationsWeaponsCheckbox = QtGui.QCheckBox() self.trayNotificationsWeaponsCheckbox.setText('Weapons') self.trayNotificationsHLayout.addWidget(self.trayNotificationsWeaponsCheckbox) self.trayNotificationsToolsCheckbox = QtGui.QCheckBox() self.trayNotificationsToolsCheckbox.setText('Tools') self.trayNotificationsHLayout.addWidget(self.trayNotificationsToolsCheckbox) self.trayNotificationsCratesCheckbox = QtGui.QCheckBox() self.trayNotificationsCratesCheckbox.setText('Crates') self.trayNotificationsHLayout.addWidget(self.trayNotificationsCratesCheckbox) self.dropViewValueLabel = QtGui.QLabel() self.dropViewValueLabel.setToolTip('Show item values on the drop log view') self.dropViewValueLabel.setText('Show item values:') self.dropLogGroupBoxLayout.addWidget(self.dropViewValueLabel, 8, 0, 1, 1) self.dropViewValueCheckbox = QtGui.QCheckBox() self.dropViewValueCheckbox.setFont(italicfont) self.dropViewValueCheckbox.setText('Uses the backpack.tf API to display dropped item values') self.dropLogGroupBoxLayout.addWidget(self.dropViewValueCheckbox, 8, 1, 1, 1) self.autoLogLabel = QtGui.QLabel() self.autoLogLabel.setToolTip('Automatically add accounts to the drop log when idled') self.autoLogLabel.setText('Auto log accounts:') self.dropLogGroupBoxLayout.addWidget(self.autoLogLabel, 9, 0, 1, 1) self.autoLogCheckbox = QtGui.QCheckBox() self.autoLogCheckbox.setFont(italicfont) self.autoLogCheckbox.setText('Automatically add accounts to the drop log when idled') self.dropLogGroupBoxLayout.addWidget(self.autoLogCheckbox, 9, 1, 1, 1) # Drop log UI section self.dropLogUIGroupBox = QtGui.QGroupBox(self.droplogTab) self.dropLogUIGroupBox.setStyleSheet(titleStyle) self.dropLogUIGroupBox.setTitle('User Interface') self.droplogVBoxLayout.addWidget(self.dropLogUIGroupBox) self.dropLogUIGroupBoxLayout = QtGui.QGridLayout(self.dropLogUIGroupBox) self.dropLogBackgroundColourLabel = QtGui.QLabel(self.dropLogUIGroupBox) self.dropLogBackgroundColourLabel.setToolTip('The background colour used in the log viewer') self.dropLogBackgroundColourLabel.setText('Drop log background colour:') self.dropLogUIGroupBoxLayout.addWidget(self.dropLogBackgroundColourLabel, 0, 0, 1, 1) self.dropLogBackgroundColourFrame = QtGui.QLineEdit() self.dropLogBackgroundColourFrame.setReadOnly(True) self.dropLogUIGroupBoxLayout.addWidget(self.dropLogBackgroundColourFrame, 0, 1, 1, 1) self.dropLogBackgroundColourButton = QtGui.QPushButton() self.dropLogBackgroundColourButton.setText('..') self.dropLogBackgroundColourButton.setMaximumSize(QtCore.QSize(30, 20)) self.dropLogUIGroupBoxLayout.addWidget(self.dropLogBackgroundColourButton, 0, 2, 1, 1) self.dropLogFontColourLabel = QtGui.QLabel(self.dropLogUIGroupBox) self.dropLogFontColourLabel.setToolTip('The font colour used in the log viewer') self.dropLogFontColourLabel.setText('Drop log font colour:') self.dropLogUIGroupBoxLayout.addWidget(self.dropLogFontColourLabel, 1, 0, 1, 1) self.dropLogFontColourFrame = QtGui.QLineEdit() self.dropLogFontColourFrame.setReadOnly(True) self.dropLogUIGroupBoxLayout.addWidget(self.dropLogFontColourFrame, 1, 1, 1, 1) self.dropLogFontColourButton = QtGui.QPushButton() self.dropLogFontColourButton.setText('..') self.dropLogFontColourButton.setMaximumSize(QtCore.QSize(30, 20)) self.dropLogUIGroupBoxLayout.addWidget(self.dropLogFontColourButton, 1, 2, 1, 1) self.dropLogFontLabel = QtGui.QLabel(self.dropLogUIGroupBox) self.dropLogFontLabel.setToolTip('The font used in the log viewer') self.dropLogFontLabel.setText('Drop log font:') self.dropLogUIGroupBoxLayout.addWidget(self.dropLogFontLabel, 2, 0, 1, 1) self.dropLogFontPreviewLabel = QtGui.QLabel() self.dropLogFontPreviewLabel.setText('You have found: Razorback!') self.dropLogUIGroupBoxLayout.addWidget(self.dropLogFontPreviewLabel, 2, 1, 1, 1) self.dropLogFontButton = QtGui.QPushButton() self.dropLogFontButton.setText('..') self.dropLogFontButton.setMaximumSize(QtCore.QSize(30, 20)) self.dropLogUIGroupBoxLayout.addWidget(self.dropLogFontButton, 2, 2, 1, 1) # Add buttons self.buttonBox = QtGui.QDialogButtonBox(self) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) self.buttonBox.setCenterButtons(False) self.vBoxLayout.addWidget(self.buttonBox) # Set mininmum label lengths on all groupboxes to align right hand side widgets self.setMinLabelLength(self.generalTab) self.setMinLabelLength(self.tf2idleTab) self.setMinLabelLength(self.droplogTab) # Signal connections QtCore.QObject.connect(self.steamLocationButton, QtCore.SIGNAL('clicked()'), curry(self.getDirectory, action='steam_location')) QtCore.QObject.connect(self.secondarySteamappsLocationButton, QtCore.SIGNAL('clicked()'), curry(self.getDirectory, action='secondary_steamapps_location')) QtCore.QObject.connect(self.sandboxieLocationButton, QtCore.SIGNAL('clicked()'), curry(self.getDirectory, action='sandboxie_location')) QtCore.QObject.connect(self.idleLaunchTextButton, QtCore.SIGNAL('clicked()'), curry(self.restoreDefault, action='idle_launch')) QtCore.QObject.connect(self.encryptionOnRadioButton, QtCore.SIGNAL('clicked()'), self.updateEncryptionModeDescription) QtCore.QObject.connect(self.encryptionOffRadioButton, QtCore.SIGNAL('clicked()'), self.updateEncryptionModeDescription) QtCore.QObject.connect(self.easySandboxModeRadioButton, QtCore.SIGNAL('clicked()'), self.updateSandboxModeDescription) QtCore.QObject.connect(self.advancedSandboxModeRadioButton, QtCore.SIGNAL('clicked()'), self.updateSandboxModeDescription) QtCore.QObject.connect(self.webViewOnRadioButton, QtCore.SIGNAL('clicked()'), self.updateWebViewDescription) QtCore.QObject.connect(self.webViewOffRadioButton, QtCore.SIGNAL('clicked()'), self.updateWebViewDescription) QtCore.QObject.connect(self.accountIconButton, QtCore.SIGNAL('clicked()'), self.getIconFile) QtCore.QObject.connect(self.accountIconRestoreButton, QtCore.SIGNAL('clicked()'), curry(self.restoreDefault, action='account_icon')) QtCore.QObject.connect(self.fileFormattingTextButton, QtCore.SIGNAL('clicked()'), curry(self.restoreDefault, action='file_formatting')) QtCore.QObject.connect(self.dropLogBackgroundColourButton, QtCore.SIGNAL('clicked()'), curry(self.getColour, component='background')) QtCore.QObject.connect(self.dropLogFontColourButton, QtCore.SIGNAL('clicked()'), curry(self.getColour, component='font')) QtCore.QObject.connect(self.dropLogFontButton, QtCore.SIGNAL('clicked()'), self.getFont) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL('accepted()'), self.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL('rejected()'), self.reject) self.populateDetails()
def updateAccountBoxes(self): # Get selected accounts and remove all account boxes checkedbuttons = [] for widget in self.accountButtons: if widget.isChecked(): checkedbuttons.append(str(widget.text())) widget.close() del widget self.accountButtons = [] row = 0 column = 0 numperrow = int( self.settings.get_option('Settings', 'ui_no_of_columns')) ui_account_box_font_size = self.settings.get_option( 'Settings', 'ui_account_box_font_size') ui_account_box_icon_size = int( self.settings.get_option('Settings', 'ui_account_box_icon_size')) ui_account_box_icon = self.settings.get_option('Settings', 'ui_account_box_icon') # Sort account boxes alphabetically sortedlist = [] for account in list( Set(self.settings.get_sections()) - Set(['Settings'])): if self.settings.get_option(account, 'account_nickname') != '': sortedlist.append( (self.settings.get_option(account, 'account_nickname'), account)) else: sortedlist.append( (self.settings.get_option(account, 'steam_username'), account)) for account in sorted(sortedlist): accountname = account[0] commandLinkButton = QtGui.QCommandLinkButton(self) commandLinkButton.setMinimumSize(QtCore.QSize(1, 1)) commandLinkButton.setObjectName( self.settings.get_option(account[1], 'steam_username')) icon = QtGui.QIcon() if ui_account_box_icon != '': icon.addPixmap(QtGui.QPixmap(ui_account_box_icon)) else: icon.addPixmap( QtGui.QPixmap( returnResourcePath('images/unselected_button.png')), QtGui.QIcon.Selected, QtGui.QIcon.Off) icon.addPixmap( QtGui.QPixmap( returnResourcePath('images/selected_button.png')), QtGui.QIcon.Selected, QtGui.QIcon.On) commandLinkButton.setIcon(icon) commandLinkButton.setIconSize( QtCore.QSize(ui_account_box_icon_size, ui_account_box_icon_size)) commandLinkButton.setCheckable(True) commandLinkButton.setChecked( (accountname in checkedbuttons or self.settings.get_option(account[1], 'steam_username') in self.chosenSelectGroupAccounts) and self.settings.get_option(account[1], 'steam_username') not in self.chosenDeselectGroupAccounts) commandLinkButton.setStyleSheet('font: %spt "TF2 Build";' % ui_account_box_font_size) commandLinkButton.setText(accountname) self.accountButtons.append(commandLinkButton) self.gridLayout.addWidget(commandLinkButton, row, column, 1, 1) column += 1 if column == numperrow: row += 1 column = 0
def updateWindow(self, construct=False): # Add horizontal toolbar actions switchToAccountsViewIcon = QtGui.QIcon() switchToAccountsViewIcon.addPixmap(QtGui.QPixmap(returnResourcePath('images/arrow_left.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.switchToAccountsViewAction = self.mainwindow.htoolBar.addAction(switchToAccountsViewIcon, 'Accounts view') QtCore.QObject.connect(self.switchToAccountsViewAction, QtCore.SIGNAL('triggered()'), self.changeMainWindowView) self.mainwindow.htoolBar.addSeparator() addAccountsIcon = QtGui.QIcon() addAccountsIcon.addPixmap(QtGui.QPixmap(returnResourcePath('images/add_account.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.addAccountsAction = self.mainwindow.htoolBar.addAction(addAccountsIcon, 'Add accounts') QtCore.QObject.connect(self.addAccountsAction, QtCore.SIGNAL('triggered()'), self.addAccounts) removeAccountsIcon = QtGui.QIcon() removeAccountsIcon.addPixmap(QtGui.QPixmap(returnResourcePath('images/remove_account.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.removeAccountsAction = self.mainwindow.htoolBar.addAction(removeAccountsIcon, 'Remove accounts') QtCore.QObject.connect(self.removeAccountsAction, QtCore.SIGNAL('triggered()'), self.removeAccounts) stopLoggingIcon = QtGui.QIcon() stopLoggingIcon.addPixmap(QtGui.QPixmap(returnResourcePath('images/terminate.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.stopLoggingAction = self.mainwindow.htoolBar.addAction(stopLoggingIcon, 'Stop logging') QtCore.QObject.connect(self.stopLoggingAction, QtCore.SIGNAL('triggered()'), self.stopLogging) self.mainwindow.htoolBar.addSeparator() toggleLogEntriesIcon = QtGui.QIcon() toggleLogEntriesIcon.addPixmap(QtGui.QPixmap(returnResourcePath('images/toggle_entries.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.toggleLogEntriesAction = self.mainwindow.htoolBar.addAction(toggleLogEntriesIcon, 'Toggle log entries') QtCore.QObject.connect(self.toggleLogEntriesAction, QtCore.SIGNAL('triggered()'), self.toggleEntries) saveToFileIcon = QtGui.QIcon() saveToFileIcon.addPixmap(QtGui.QPixmap(returnResourcePath('images/save_file.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.saveToFileAction = self.mainwindow.htoolBar.addAction(saveToFileIcon, 'Save to file') QtCore.QObject.connect(self.saveToFileAction, QtCore.SIGNAL('triggered()'), self.saveToFile) self.mainwindow.htoolBar.addSeparator() resetCountIcon = QtGui.QIcon() resetCountIcon.addPixmap(QtGui.QPixmap(returnResourcePath('images/reset_button.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.resetCountAction = self.mainwindow.htoolBar.addAction(resetCountIcon, 'Reset count') QtCore.QObject.connect(self.resetCountAction, QtCore.SIGNAL('triggered()'), self.resetCount) self.mainwindow.htoolBar.addSeparator() font = QtGui.QFont() font.setFamily('TF2 Build') font.setPointSize(23) self.hatCounterwidget = QtGui.QWidget() self.hatCounterLayout = QtGui.QVBoxLayout(self.hatCounterwidget) self.hatCounterLayout.setSpacing(0) self.hatCounterLayout.setContentsMargins(10, -1, 10, -1) self.hatCounter = QtGui.QLabel() self.hatCounter.setFont(font) self.hatCounter.setText(str(self.hatCount)) self.hatCounter.setAlignment(QtCore.Qt.AlignCenter) self.hatCounterLabel = QtGui.QLabel() self.hatCounterLabel.setText('Hats') self.hatCounterLabel.setAlignment(QtCore.Qt.AlignCenter) self.hatCounterLayout.addWidget(self.hatCounter) self.hatCounterLayout.addWidget(self.hatCounterLabel) self.mainwindow.htoolBar.addWidget(self.hatCounterwidget) self.weaponCounterwidget = QtGui.QWidget() self.weaponCounterLayout = QtGui.QVBoxLayout(self.weaponCounterwidget) self.weaponCounterLayout.setSpacing(0) self.weaponCounterLayout.setContentsMargins(10, -1, 10, -1) self.weaponCounter = QtGui.QLabel() self.weaponCounter.setFont(font) self.weaponCounter.setText(str(self.weaponCount)) self.weaponCounter.setAlignment(QtCore.Qt.AlignCenter) self.weaponCounterLabel = QtGui.QLabel() self.weaponCounterLabel.setText('Weapons') self.weaponCounterLabel.setAlignment(QtCore.Qt.AlignCenter) self.weaponCounterLayout.addWidget(self.weaponCounter) self.weaponCounterLayout.addWidget(self.weaponCounterLabel) self.mainwindow.htoolBar.addWidget(self.weaponCounterwidget) self.toolCounterwidget = QtGui.QWidget() self.toolCounterLayout = QtGui.QVBoxLayout(self.toolCounterwidget) self.toolCounterLayout.setSpacing(0) self.toolCounterLayout.setContentsMargins(10, -1, 10, -1) self.toolCounter = QtGui.QLabel() self.toolCounter.setFont(font) self.toolCounter.setText(str(self.toolCount)) self.toolCounter.setAlignment(QtCore.Qt.AlignCenter) self.toolCounterLabel = QtGui.QLabel() self.toolCounterLabel.setText('Tools') self.toolCounterLabel.setAlignment(QtCore.Qt.AlignCenter) self.toolCounterLayout.addWidget(self.toolCounter) self.toolCounterLayout.addWidget(self.toolCounterLabel) self.mainwindow.htoolBar.addWidget(self.toolCounterwidget) self.crateCounterwidget = QtGui.QWidget() self.crateCounterLayout = QtGui.QVBoxLayout(self.crateCounterwidget) self.crateCounterLayout.setSpacing(0) self.crateCounterLayout.setContentsMargins(10, -1, 10, -1) self.crateCounter = QtGui.QLabel() self.crateCounter.setFont(font) self.crateCounter.setText(str(self.crateCount)) self.crateCounter.setAlignment(QtCore.Qt.AlignCenter) self.crateCounterLabel = QtGui.QLabel() self.crateCounterLabel.setText('Crates') self.crateCounterLabel.setAlignment(QtCore.Qt.AlignCenter) self.crateCounterLayout.addWidget(self.crateCounter) self.crateCounterLayout.addWidget(self.crateCounterLabel) self.mainwindow.htoolBar.addWidget(self.crateCounterwidget) self.valueCounterwidget = QtGui.QWidget() self.valueCounterLayout = QtGui.QVBoxLayout(self.valueCounterwidget) self.valueCounterLayout.setSpacing(0) self.valueCounterLayout.setContentsMargins(10, -1, 10, -1) self.valueCounter = QtGui.QLabel() self.valueCounter.setFont(font) self.valueCounter.setText(str("%.2f" % float(self.valueCount))) self.valueCounter.setAlignment(QtCore.Qt.AlignCenter) self.valueCounterLabel = QtGui.QLabel() self.valueCounterLabel.setText('Value') self.valueCounterLabel.setAlignment(QtCore.Qt.AlignCenter) self.valueCounterLayout.addWidget(self.valueCounter) self.valueCounterLayout.addWidget(self.valueCounterLabel) if self.showItemValues: self.mainwindow.htoolBar.addWidget(self.valueCounterwidget) self.mainwindow.htoolBar.addSeparator() switchLogViewIcon = QtGui.QIcon() switchLogViewIcon.addPixmap(QtGui.QPixmap(returnResourcePath('images/switch_log_view.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.switchLogViewAction = self.mainwindow.htoolBar.addAction(switchLogViewIcon, 'Switch log view') QtCore.QObject.connect(self.switchLogViewAction, QtCore.SIGNAL('triggered()'), self.switchLogView) if construct: self.gridLayout = QtGui.QGridLayout(self) self.gridLayout.setMargin(0) self.verticalLayout = QtGui.QVBoxLayout() self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1) self.gridLayout.addWidget(self.logWindow) QtCore.QObject.connect(self.logWindow, QtCore.SIGNAL('anchorClicked(QUrl)'), self.openLink) QtCore.QMetaObject.connectSlotsByName(self) self.updateLogDisplay()
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.settings = Config.settings # Create dialog self.setWindowModality(QtCore.Qt.NonModal) self.resize(250, 450) self.setMinimumSize(QtCore.QSize(self.width(), self.height())) self.setWindowTitle('Select groups') self.setWindowIcon( QtGui.QIcon(returnResourcePath('images/select_group.png'))) self.gridLayout = QtGui.QVBoxLayout(self) self.scrollArea = QtGui.QScrollArea(self) self.scrollArea.setWidgetResizable(True) self.scrollArea.setFrameShape(QtGui.QFrame.NoFrame) self.gridLayout.addWidget(self.scrollArea) self.scrollAreaWidgetContents = QtGui.QWidget() self.scrollArea.setWidget(self.scrollAreaWidgetContents) self.widgetVerticalLayout = QtGui.QVBoxLayout( self.scrollAreaWidgetContents) self.verticalLayout = QtGui.QVBoxLayout() self.widgetVerticalLayout.addLayout(self.verticalLayout) # Generate groups dict self.groupsDict = {} for account in list( Set(self.settings.get_sections()) - Set(['Settings'])): groups = self.settings.get_option(account, 'groups') groups = groups.split(',') for group in groups: if group == '': pass else: if group in self.groupsDict: self.groupsDict[group].append( self.settings.get_option(account, 'steam_username')) else: self.groupsDict[group] = [] self.groupsDict[group].append( self.settings.get_option(account, 'steam_username')) # Add group checkboxes self.groupButtons = [] if len(self.groupsDict) == 0: self.Label = QtGui.QLabel() self.Label.setText( 'You have no groups set up. Try adding an account to a group first.' ) self.Label.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) self.Label.setWordWrap(True) self.verticalLayout.addWidget(self.Label) else: icon = QtGui.QIcon() icon.addPixmap( QtGui.QPixmap( returnResourcePath('images/unselected_button.png')), QtGui.QIcon.Selected, QtGui.QIcon.Off) icon.addPixmap( QtGui.QPixmap( returnResourcePath('images/selected_button.png')), QtGui.QIcon.Selected, QtGui.QIcon.On) for group in sorted(self.groupsDict, cmp=compare_keys): self.commandLinkButton = QtGui.QCommandLinkButton() self.commandLinkButton.setText(group) self.commandLinkButton.setIcon(icon) # Display members of group membersString = '' for member in sorted(self.groupsDict[group]): membersString += member + '\n' self.commandLinkButton.setDescription(membersString) self.commandLinkButton.setCheckable(True) self.verticalLayout.addWidget(self.commandLinkButton) self.groupButtons.append(self.commandLinkButton) # Add buttons self.buttonBox = QtGui.QDialogButtonBox() self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setCenterButtons(True) selectbutton = QtGui.QPushButton('Select', self) deselectbutton = QtGui.QPushButton('Deselect', self) cancelbutton = QtGui.QPushButton('Cancel', self) self.buttonBox.addButton(selectbutton, QtGui.QDialogButtonBox.ActionRole) self.buttonBox.addButton(deselectbutton, QtGui.QDialogButtonBox.ActionRole) self.buttonBox.addButton(cancelbutton, QtGui.QDialogButtonBox.RejectRole) self.gridLayout.addWidget(self.buttonBox) # Signal connections self.connect(selectbutton, QtCore.SIGNAL('clicked()'), self.select) self.connect(deselectbutton, QtCore.SIGNAL('clicked()'), self.deselect) self.connect(cancelbutton, QtCore.SIGNAL('clicked()'), self.reject) QtCore.QMetaObject.connectSlotsByName(self) self.accountsSelectList = [] self.accountsDeselectList = []
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.settings = Config.settings # Create dialog self.setWindowModality(QtCore.Qt.NonModal) self.setWindowTitle('Log entries') self.setWindowIcon( QtGui.QIcon(returnResourcePath('images/toggle_entries.png'))) self.vBoxLayout = QtGui.QVBoxLayout(self) # Add command link buttons self.systemCommandLinkButton = QtGui.QCommandLinkButton() self.systemCommandLinkButton.setText('System messages') icon = QtGui.QIcon( QtGui.QPixmap(returnResourcePath('images/settings.png'))) self.systemCommandLinkButton.setIcon(icon) self.systemCommandLinkButton.setIconSize(QtCore.QSize(40, 40)) self.systemCommandLinkButton.setCheckable(True) self.vBoxLayout.addWidget(self.systemCommandLinkButton) self.hatsCommandLinkButton = QtGui.QCommandLinkButton() self.hatsCommandLinkButton.setText('Hats') icon = QtGui.QIcon(QtGui.QPixmap(returnResourcePath('images/hat.png'))) self.hatsCommandLinkButton.setIcon(icon) self.hatsCommandLinkButton.setIconSize(QtCore.QSize(40, 40)) self.hatsCommandLinkButton.setCheckable(True) self.vBoxLayout.addWidget(self.hatsCommandLinkButton) self.weaponsCommandLinkButton = QtGui.QCommandLinkButton() self.weaponsCommandLinkButton.setText('Weapons') icon = QtGui.QIcon( QtGui.QPixmap(returnResourcePath('images/weapon.png'))) self.weaponsCommandLinkButton.setIcon(icon) self.weaponsCommandLinkButton.setIconSize(QtCore.QSize(40, 40)) self.weaponsCommandLinkButton.setCheckable(True) self.vBoxLayout.addWidget(self.weaponsCommandLinkButton) self.toolsCommandLinkButton = QtGui.QCommandLinkButton() self.toolsCommandLinkButton.setText('Tools') icon = QtGui.QIcon(QtGui.QPixmap( returnResourcePath('images/tool.png'))) self.toolsCommandLinkButton.setIcon(icon) self.toolsCommandLinkButton.setIconSize(QtCore.QSize(40, 40)) self.toolsCommandLinkButton.setCheckable(True) self.vBoxLayout.addWidget(self.toolsCommandLinkButton) self.cratesCommandLinkButton = QtGui.QCommandLinkButton() self.cratesCommandLinkButton.setText('Crates') icon = QtGui.QIcon( QtGui.QPixmap(returnResourcePath('images/crate.png'))) self.cratesCommandLinkButton.setIcon(icon) self.cratesCommandLinkButton.setIconSize(QtCore.QSize(40, 40)) self.cratesCommandLinkButton.setCheckable(True) self.vBoxLayout.addWidget(self.cratesCommandLinkButton) # Add buttons self.buttonBox = QtGui.QDialogButtonBox() self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setCenterButtons(False) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Ok) self.vBoxLayout.addWidget(self.buttonBox) # Signal connections QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL('accepted()'), self.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL('rejected()'), self.reject) QtCore.QMetaObject.connectSlotsByName(self) self.populateDetails()
def updateWindow(self, construct=False): self.mainwindow.htoolBar.clear() self.mainwindow.vtoolBar.clear() # Add vertical toolbar actions addAccountIcon = QtGui.QIcon() addAccountIcon.addPixmap( QtGui.QPixmap(returnResourcePath('images/add_account.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.addAccountAction = self.mainwindow.vtoolBar.addAction( addAccountIcon, 'Add account') QtCore.QObject.connect(self.addAccountAction, QtCore.SIGNAL('triggered()'), self.openAccountDialog) editAccountIcon = QtGui.QIcon() editAccountIcon.addPixmap( QtGui.QPixmap(returnResourcePath('images/edit_account.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.editAccountAction = self.mainwindow.vtoolBar.addAction( editAccountIcon, 'Edit account') QtCore.QObject.connect(self.editAccountAction, QtCore.SIGNAL('triggered()'), curry(self.openAccountDialog, editAccount=True)) removeAccountIcon = QtGui.QIcon() removeAccountIcon.addPixmap( QtGui.QPixmap(returnResourcePath('images/remove_account.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.deleteAccountsAction = self.mainwindow.vtoolBar.addAction( removeAccountIcon, 'Delete account') QtCore.QObject.connect(self.deleteAccountsAction, QtCore.SIGNAL('triggered()'), self.deleteAccounts) self.mainwindow.vtoolBar.addSeparator() selectGroupIcon = QtGui.QIcon() selectGroupIcon.addPixmap( QtGui.QPixmap(returnResourcePath('images/select_group.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.selectGroupsAction = self.mainwindow.vtoolBar.addAction( selectGroupIcon, 'Select Groups') QtCore.QObject.connect(self.selectGroupsAction, QtCore.SIGNAL('triggered()'), self.selectGroups) viewBackpackIcon = QtGui.QIcon() viewBackpackIcon.addPixmap( QtGui.QPixmap(returnResourcePath('images/backpack.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.viewBackpackAction = self.mainwindow.vtoolBar.addAction( viewBackpackIcon, 'View backpack') QtCore.QObject.connect(self.viewBackpackAction, QtCore.SIGNAL('triggered()'), self.openBackpack) # Add horizontal toolbar actions switchToLogViewIcon = QtGui.QIcon() switchToLogViewIcon.addPixmap( QtGui.QPixmap(returnResourcePath('images/arrow_right.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.switchToLogViewAction = self.mainwindow.htoolBar.addAction( switchToLogViewIcon, 'Drop log view') QtCore.QObject.connect(self.switchToLogViewAction, QtCore.SIGNAL('triggered()'), self.changeMainWindowView) self.mainwindow.htoolBar.addSeparator() startIdleIcon = QtGui.QIcon() startIdleIcon.addPixmap( QtGui.QPixmap(returnResourcePath('images/start_idle.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.startIdleAction = self.mainwindow.htoolBar.addAction( startIdleIcon, 'Start idling') QtCore.QObject.connect(self.startIdleAction, QtCore.SIGNAL('triggered()'), curry(self.startUpAccounts, action='idle')) startIdleUnsandboxedIcon = QtGui.QIcon() startIdleUnsandboxedIcon.addPixmap( QtGui.QPixmap( returnResourcePath('images/start_idle_unsandboxed.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.startIdleUnsandboxedAction = self.mainwindow.htoolBar.addAction( startIdleUnsandboxedIcon, 'Idle unsandboxed') QtCore.QObject.connect( self.startIdleUnsandboxedAction, QtCore.SIGNAL('triggered()'), curry(self.startUpAccounts, action='idle_unsandboxed')) startTF2Icon = QtGui.QIcon() startTF2Icon.addPixmap( QtGui.QPixmap(returnResourcePath('images/start_tf2.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.startTF2Action = self.mainwindow.htoolBar.addAction( startTF2Icon, 'Start TF2') QtCore.QObject.connect(self.startTF2Action, QtCore.SIGNAL('triggered()'), curry(self.startUpAccounts, action='start_TF2')) startSteamIcon = QtGui.QIcon() startSteamIcon.addPixmap( QtGui.QPixmap(returnResourcePath('images/start_steam.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.startSteamAction = self.mainwindow.htoolBar.addAction( startSteamIcon, 'Start Steam') QtCore.QObject.connect( self.startSteamAction, QtCore.SIGNAL('triggered()'), curry(self.startUpAccounts, action='start_steam')) startProgramIcon = QtGui.QIcon() startProgramIcon.addPixmap( QtGui.QPixmap(returnResourcePath('images/start_program.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.startProgramAction = self.mainwindow.htoolBar.addAction( startProgramIcon, 'Start Program') QtCore.QObject.connect(self.startProgramAction, QtCore.SIGNAL('triggered()'), self.startProgram) self.mainwindow.htoolBar.addSeparator() terminateSandboxIcon = QtGui.QIcon() terminateSandboxIcon.addPixmap( QtGui.QPixmap(returnResourcePath('images/terminate.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.terminateSandboxAction = self.mainwindow.htoolBar.addAction( terminateSandboxIcon, 'Terminate sandbox') QtCore.QObject.connect( self.terminateSandboxAction, QtCore.SIGNAL('triggered()'), curry(self.modifySandboxes, action='/terminate')) emptySandboxIcon = QtGui.QIcon() emptySandboxIcon.addPixmap( QtGui.QPixmap(returnResourcePath('images/delete_sandbox.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.emptySandboxAction = self.mainwindow.htoolBar.addAction( emptySandboxIcon, 'Empty sandbox') QtCore.QObject.connect( self.emptySandboxAction, QtCore.SIGNAL('triggered()'), curry(self.modifySandboxes, action='delete_sandbox_silent')) self.mainwindow.htoolBar.addSeparator() updateTF2Icon = QtGui.QIcon() if self.copyingTF2: progressimage = returnResourcePath('images/updating_tf2.png') updateTF2Icon.addPixmap(QtGui.QPixmap(progressimage), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.updateTF2Action = self.mainwindow.htoolBar.addAction( updateTF2Icon, 'Updating TF2 folder') else: updateTF2Icon.addPixmap( QtGui.QPixmap(returnResourcePath('images/update_tf2.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.updateTF2Action = self.mainwindow.htoolBar.addAction( updateTF2Icon, 'Update TF2 folder') QtCore.QObject.connect(self.updateTF2Action, QtCore.SIGNAL('triggered()'), self.updateTF2) if construct: self.gridLayout = QtGui.QGridLayout(self) self.gridLayout.setMargin(0) self.verticalLayout = QtGui.QVBoxLayout() self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1) # Add keyboard shortcut to select all account boxes QtGui.QShortcut(QtGui.QKeySequence('Ctrl+A'), self.mainwindow, self.SelectAllAccounts) QtCore.QMetaObject.connectSlotsByName(self) self.updateAccountBoxes()
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.settings = Config.settings # Create dialog self.setWindowModality(QtCore.Qt.NonModal) self.setWindowTitle('Log entries') self.setWindowIcon(QtGui.QIcon(returnResourcePath('images/toggle_entries.png'))) self.vBoxLayout = QtGui.QVBoxLayout(self) # Add command link buttons self.systemCommandLinkButton = QtGui.QCommandLinkButton() self.systemCommandLinkButton.setText('System messages') icon = QtGui.QIcon(QtGui.QPixmap(returnResourcePath('images/settings.png'))) self.systemCommandLinkButton.setIcon(icon) self.systemCommandLinkButton.setIconSize(QtCore.QSize(40,40)) self.systemCommandLinkButton.setCheckable(True) self.vBoxLayout.addWidget(self.systemCommandLinkButton) self.hatsCommandLinkButton = QtGui.QCommandLinkButton() self.hatsCommandLinkButton.setText('Hats') icon = QtGui.QIcon(QtGui.QPixmap(returnResourcePath('images/hat.png'))) self.hatsCommandLinkButton.setIcon(icon) self.hatsCommandLinkButton.setIconSize(QtCore.QSize(40,40)) self.hatsCommandLinkButton.setCheckable(True) self.vBoxLayout.addWidget(self.hatsCommandLinkButton) self.weaponsCommandLinkButton = QtGui.QCommandLinkButton() self.weaponsCommandLinkButton.setText('Weapons') icon = QtGui.QIcon(QtGui.QPixmap(returnResourcePath('images/weapon.png'))) self.weaponsCommandLinkButton.setIcon(icon) self.weaponsCommandLinkButton.setIconSize(QtCore.QSize(40,40)) self.weaponsCommandLinkButton.setCheckable(True) self.vBoxLayout.addWidget(self.weaponsCommandLinkButton) self.toolsCommandLinkButton = QtGui.QCommandLinkButton() self.toolsCommandLinkButton.setText('Tools') icon = QtGui.QIcon(QtGui.QPixmap(returnResourcePath('images/tool.png'))) self.toolsCommandLinkButton.setIcon(icon) self.toolsCommandLinkButton.setIconSize(QtCore.QSize(40,40)) self.toolsCommandLinkButton.setCheckable(True) self.vBoxLayout.addWidget(self.toolsCommandLinkButton) self.cratesCommandLinkButton = QtGui.QCommandLinkButton() self.cratesCommandLinkButton.setText('Crates') icon = QtGui.QIcon(QtGui.QPixmap(returnResourcePath('images/crate.png'))) self.cratesCommandLinkButton.setIcon(icon) self.cratesCommandLinkButton.setIconSize(QtCore.QSize(40,40)) self.cratesCommandLinkButton.setCheckable(True) self.vBoxLayout.addWidget(self.cratesCommandLinkButton) # Add buttons self.buttonBox = QtGui.QDialogButtonBox() self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setCenterButtons(False) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) self.vBoxLayout.addWidget(self.buttonBox) # Signal connections QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL('accepted()'), self.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL('rejected()'), self.reject) QtCore.QMetaObject.connectSlotsByName(self) self.populateDetails()
def __init__(self, accounts=[], parent=None): QtGui.QDialog.__init__(self, parent) self.settings = Config.settings self.accounts = accounts self.currentUsername = None self.easy_sandbox_mode = self.settings.get_option('Settings', 'easy_sandbox_mode') # Create dialog self.setWindowModality(QtCore.Qt.NonModal) self.resize(450, 500) self.setMinimumSize(QtCore.QSize(self.width(), self.height())) self.setWindowTitle('Account details') self.setWindowIcon(QtGui.QIcon(returnResourcePath('images/settings.png'))) self.vBoxLayout = QtGui.QVBoxLayout(self) # Set fonts/styles greyoutfont = QtGui.QFont() greyoutfont.setItalic(True) greyoutstyle = 'background-color: rgb(225, 225, 225);' self.italicfont = QtGui.QFont() self.italicfont.setItalic(True) titleStyle = "QGroupBox {font-weight: bold;}" # Steam account section self.steamAccountGroupBox = QtGui.QGroupBox(self) self.steamAccountGroupBox.setStyleSheet(titleStyle) self.steamAccountGroupBox.setTitle('Steam') self.vBoxLayout.addWidget(self.steamAccountGroupBox) self.steamAccountGroupBoxLayout = QtGui.QGridLayout(self.steamAccountGroupBox) self.steamUsernameLabel = QtGui.QLabel(self.steamAccountGroupBox) self.steamUsernameLabel.setToolTip('Your Steam username') self.steamUsernameLabel.setText('Steam username:'******'Your Steam username') self.steamUsernameLineEdit.setPlaceholderText('Steam username') if len(self.accounts) > 1: self.steamUsernameLineEdit.setReadOnly(True) self.steamUsernameLineEdit.setFont(greyoutfont) self.steamUsernameLineEdit.setStyleSheet(greyoutstyle) self.steamAccountGroupBoxLayout.addWidget(self.steamUsernameLineEdit, 0, 1, 1, 1) self.steamPasswordLabel = QtGui.QLabel(self.steamAccountGroupBox) self.steamPasswordLabel.setToolTip('Your Steam password') self.steamPasswordLabel.setText('Steam password:'******'Your Steam password') self.steamPasswordLineEdit.setPlaceholderText('Steam password') if len(self.accounts) > 1: self.steamPasswordLineEdit.setReadOnly(True) self.steamPasswordLineEdit.setFont(greyoutfont) self.steamPasswordLineEdit.setStyleSheet(greyoutstyle) self.steamAccountGroupBoxLayout.addWidget(self.steamPasswordLineEdit, 1, 1, 1, 1) self.steamVanityIDLabel = QtGui.QLabel(self.steamAccountGroupBox) self.steamVanityIDLabel.setToolTip('Your Steam vanity ID. eg. steamcommunity.com/id/<vanityID>. Optional, only if you wish to use the view backpack feature') self.steamVanityIDLabel.setText('Steam vanity ID:') self.steamAccountGroupBoxLayout.addWidget(self.steamVanityIDLabel, 2, 0, 1, 1) self.steamVanityIDLineEdit = QtGui.QLineEdit() self.steamVanityIDLineEdit.setToolTip('Your Steam vanity ID. eg. steamcommunity.com/id/<vanityID>. Optional, only if you wish to use the view backpack feature') self.steamVanityIDLineEdit.setPlaceholderText('Steam vanity ID. eg. steamcommunity.com/id/<vanityID>') if len(self.accounts) > 1: self.steamVanityIDLineEdit.setReadOnly(True) self.steamVanityIDLineEdit.setFont(greyoutfont) self.steamVanityIDLineEdit.setStyleSheet(greyoutstyle) self.steamAccountGroupBoxLayout.addWidget(self.steamVanityIDLineEdit, 2, 1, 1, 1) self.nicknameLabel = QtGui.QLabel(self.steamAccountGroupBox) self.nicknameLabel.setToolTip('Your account nickname to display within TF2Idle. Optional') self.nicknameLabel.setText('Account nickname:') self.steamAccountGroupBoxLayout.addWidget(self.nicknameLabel, 3, 0, 1, 1) self.nicknameLineEdit = QtGui.QLineEdit() self.nicknameLineEdit.setToolTip('Your account nickname to display within TF2Idle. Optional') self.nicknameLineEdit.setPlaceholderText('Account nickname') if len(self.accounts) > 1: self.nicknameLineEdit.setReadOnly(True) self.nicknameLineEdit.setFont(greyoutfont) self.nicknameLineEdit.setStyleSheet(greyoutstyle) self.steamAccountGroupBoxLayout.addWidget(self.nicknameLineEdit, 3, 1, 1, 1) # Sandboxie section self.sandboxieGroupBox = QtGui.QGroupBox(self) self.sandboxieGroupBox.setStyleSheet(titleStyle) self.sandboxieGroupBox.setTitle('Sandboxie') self.vBoxLayout.addWidget(self.sandboxieGroupBox) self.sandboxieGroupBoxLayout = QtGui.QGridLayout(self.sandboxieGroupBox) self.sandboxNameLabel = QtGui.QLabel(self.sandboxieGroupBox) self.sandboxNameLabel.setToolTip('The name of the Sandboxie sandbox to use with this account. Optional, only if you wish to use sandboxes') self.sandboxNameLabel.setText('Sandbox name:') self.sandboxieGroupBoxLayout.addWidget(self.sandboxNameLabel, 0, 0, 1, 1) self.sandboxNameLineEdit = QtGui.QLineEdit() self.sandboxNameLineEdit.setToolTip('The name of the Sandboxie sandbox to use with this account. Optional, only if you wish to use sandboxes') self.sandboxNameLineEdit.setPlaceholderText('Sandboxie sandbox name') if self.easy_sandbox_mode == 'yes': self.sandboxNameLineEdit.setReadOnly(True) self.sandboxNameLineEdit.setFont(greyoutfont) self.sandboxNameLineEdit.setText('Easy sandbox mode') self.sandboxNameLineEdit.setStyleSheet(greyoutstyle) self.sandboxieGroupBoxLayout.addWidget(self.sandboxNameLineEdit, 0, 1, 1, 1) self.sandboxPathLabel = QtGui.QLabel(self.sandboxieGroupBox) self.sandboxPathLabel.setToolTip('The path to Steam.exe for this sandbox. Optional, only if you wish to use sandboxes') self.sandboxPathLabel.setText('Sandbox path:') self.sandboxieGroupBoxLayout.addWidget(self.sandboxPathLabel, 1, 0, 1, 1) self.sandboxPathLineEdit = QtGui.QLineEdit() self.sandboxPathLineEdit.setToolTip('The path to Steam.exe for this sandbox. Optional, only if you wish to use sandboxes') self.sandboxPathLineEdit.setPlaceholderText('Sandboxie sandbox Steam.exe path') if self.easy_sandbox_mode == 'yes': self.sandboxPathLineEdit.setReadOnly(True) self.sandboxPathLineEdit.setFont(greyoutfont) self.sandboxPathLineEdit.setText('Easy sandbox mode') self.sandboxPathLineEdit.setStyleSheet(greyoutstyle) self.sandboxieGroupBoxLayout.addWidget(self.sandboxPathLineEdit, 1, 1, 1, 1) self.sandboxPathButton = QtGui.QPushButton() self.sandboxPathButton.setText('..') self.sandboxPathButton.setMaximumSize(QtCore.QSize(30, 20)) self.sandboxieGroupBoxLayout.addWidget(self.sandboxPathButton, 1, 2, 1, 1) # TF2 settings section self.TF2SettingsGroupBox = QtGui.QGroupBox(self) self.TF2SettingsGroupBox.setStyleSheet(titleStyle) self.TF2SettingsGroupBox.setTitle('TF2 Settings') self.vBoxLayout.addWidget(self.TF2SettingsGroupBox) self.TF2SettingsGroupBoxLayout = QtGui.QGridLayout(self.TF2SettingsGroupBox) self.idleLaunchLabel = QtGui.QLabel(self.TF2SettingsGroupBox) self.idleLaunchLabel.setToolTip('Account TF2 launch options for idling. Any launch options entered here will override the ones set in settings. Leave this box blank to use the main launch options') self.idleLaunchLabel.setText('Idle launch settings:') self.TF2SettingsGroupBoxLayout.addWidget(self.idleLaunchLabel, 0, 0, 1, 1) self.idleLaunchTextEdit = QTextEditWithPlaceholderText('Any launch options entered here will override the ones set in settings for this account. Leave this box blank to use the main launch options.') self.idleLaunchTextEdit.setTabChangesFocus(True) if len(self.accounts) > 1: self.idleLaunchTextEdit.setFont(self.italicfont) self.idleLaunchTextEdit.setToolTip('Account TF2 launch options for idling. Any launch options entered here will override the ones set in settings. Leave this box blank to use the main launch options') self.TF2SettingsGroupBoxLayout.addWidget(self.idleLaunchTextEdit, 0, 1, 1, 1) # Other section self.otherGroupBox = QtGui.QGroupBox(self) self.otherGroupBox.setStyleSheet(titleStyle) self.otherGroupBox.setTitle('Other') self.vBoxLayout.addWidget(self.otherGroupBox) self.otherGroupBoxLayout = QtGui.QGridLayout(self.otherGroupBox) self.groupsLabel = QtGui.QLabel(self.otherGroupBox) self.groupsLabel.setToolTip('Groups this account is a member of. Optional, only if you wish to use the groups feature') self.groupsLabel.setText('Groups:') self.otherGroupBoxLayout.addWidget(self.groupsLabel, 0, 0, 1, 1) self.groupsLineEdit = QtGui.QLineEdit() self.groupsLineEdit.setPlaceholderText('Groups (separated by commas)') self.groupsLineEdit.setToolTip('Groups this account is a member of. Optional, only if you wish to use the groups feature') self.otherGroupBoxLayout.addWidget(self.groupsLineEdit, 0, 1, 1, 1) if len(self.accounts) < 2: self.dropLogColourLabel = QtGui.QLabel(self.otherGroupBox) self.dropLogColourLabel.setToolTip('The account colour used in the drop log feature') self.dropLogColourLabel.setText('Drop log colour:') self.otherGroupBoxLayout.addWidget(self.dropLogColourLabel, 1, 0, 1, 1) self.dropLogColourFrame = QtGui.QLineEdit() self.dropLogColourFrame.setReadOnly(True) if len(self.accounts) == 0: self.dropLogColour = accountColourList[len(list(Set(self.settings.get_sections()) - Set(['Settings']))) % len(accountColourList)] self.dropLogColourFrame.setStyleSheet('background-color: #%s;' % self.dropLogColour) self.otherGroupBoxLayout.addWidget(self.dropLogColourFrame, 1, 1, 1, 1) self.dropLogColourButton = QtGui.QPushButton() self.dropLogColourButton.setText('..') self.dropLogColourButton.setMaximumSize(QtCore.QSize(30, 20)) self.otherGroupBoxLayout.addWidget(self.dropLogColourButton, 1, 2, 1, 1) # Add buttons self.buttonBox = QtGui.QDialogButtonBox(self) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) self.buttonBox.setCenterButtons(False) self.vBoxLayout.addWidget(self.buttonBox) # Set mininmum label lengths on all groupboxes to align right hand side widgets self.setMinLabelLength(self) # Signal connections if self.easy_sandbox_mode == 'no': QtCore.QObject.connect(self.sandboxPathButton, QtCore.SIGNAL('clicked()'), self.getDirectory) if len(self.accounts) < 2: QtCore.QObject.connect(self.dropLogColourButton, QtCore.SIGNAL('clicked()'), self.getColour) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL('accepted()'), self.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL('rejected()'), self.reject) QtCore.QMetaObject.connectSlotsByName(self) if len(self.accounts) != 0: self.populateDetails() else: self.idleLaunchTextEdit.setPlaceholderText()
myapp.show() app.exec_() Config.settings.flush_configuration() def my_excepthook(type, value, tback): logger.error('Uncaught Exception', exc_info=(type, value, tback)) # Call the default handler sys.__excepthook__(type, value, tback) if __name__ == "__main__": app = QtGui.QApplication(sys.argv) Config.init(optionsfile) sys.excepthook = my_excepthook if Config.settings.returnReadState(): startup() # config file is encrypted else: firstWindow = KeyDialog() firstWindow.exec_() if Config.settings.returnReadState(): startup() else: dialog = QtGui.QDialog() dialog.setWindowIcon( QtGui.QIcon(returnResourcePath('images/tf2idle.png'))) QtGui.QMessageBox.critical( dialog, 'Error', 'Could not decrypt the config file, your key is incorrect')