def closeEvent(self, event): """ Persisting things to the cache before closing the window """ # Known playernames if self.knownPlayerNames: value = ",".join(self.knownPlayerNames) self.cache.putIntoCache("known_player_names", value, 60 * 60 * 24 * 30) # Program state to cache (to read it on next startup) settings = ((None, "restoreGeometry", str(self.saveGeometry())), (None, "restoreState", str(self.saveState())), ("splitter", "restoreGeometry", str(self.splitter.saveGeometry())), ("splitter", "restoreState", str(self.splitter.saveState())), ("mapView", "setZoomFactor", self.mapView.zoomFactor()), (None, "changeChatFontSize", ChatEntryWidget.TEXT_SIZE), (None, "changeOpacity", self.opacityGroup.checkedAction().opacity), (None, "changeAlwaysOnTop", self.alwaysOnTopAction.isChecked()), (None, "changeShowAvatars", self.showChatAvatarsAction.isChecked()), (None, "changeAlarmDistance", self.alarmDistance), (None, "changeSound", self.activateSoundAction.isChecked()), (None, "changeChatVisibility", self.showChatAction.isChecked()), (None, "loadInitialMapPositions", self.mapPositionsDict), (None, "setSoundVolume", SoundManager().soundVolume), (None, "changeFrameless", self.framelessWindowAction.isChecked()), (None, "changeUseSpokenNotifications", self.useSpokenNotificationsAction.isChecked()), (None, "changeKosCheckClipboard", self.kosClipboardActiveAction.isChecked()), (None, "changeAutoScanIntel", self.scanIntelForKosRequestsEnabled)) self.cache.putIntoCache("settings", str(settings), 60 * 60 * 24 * 30) # Stop the threads try: SoundManager().quit() self.avatarFindThread.quit() self.avatarFindThread.wait() self.filewatcherThread.quit() self.filewatcherThread.wait() self.versionCheckThread.quit() self.versionCheckThread.wait() self.statisticsThread.quit() self.statisticsThread.wait() except Exception: pass self.trayIcon.hide() event.accept()
def showNotification(self, message, system, char, distance): if message is None: return room = message.room title = None text = None icon = None text = "" if (message.status == states.ALARM and self.showAlarm and self.lastNotifications.get(states.ALARM, 0) < time.time() - self.MIN_WAIT_NOTIFICATION): title = "ALARM!" icon = 2 speechText = (u"{0} alarmed in {1}, {2} jumps from {3}".format( system, room, distance, char)) text = speechText + (u"\nText: %s" % text) SoundManager().playSound("alarm", text, speechText) self.lastNotifications[states.ALARM] = time.time() elif (message.status == states.REQUEST and self.showRequest and self.lastNotifications.get(states.REQUEST, 0) < time.time() - self.MIN_WAIT_NOTIFICATION): title = "Status request" icon = 1 text = (u"Someone is requesting status of {0} in {1}.".format( system, room)) self.lastNotifications[states.REQUEST] = time.time() SoundManager().playSound("request", text) if not (title is None or text is None or icon): text = text.format(**locals()) self.showMessage(title, text, icon)
def showSoundSetup(self): dialog = QtGui.QDialog(self) uic.loadUi(resourcePath("vi/ui/SoundSetup.ui"), dialog) dialog.volumeSlider.setValue(SoundManager().soundVolume) dialog.connect(dialog.volumeSlider, SIGNAL("valueChanged(int)"), SoundManager().setSoundVolume) dialog.connect(dialog.testSoundButton, SIGNAL("clicked()"), SoundManager().playSound) dialog.connect(dialog.closeButton, SIGNAL("clicked()"), dialog.accept) dialog.show()
def showSoundSetup(self): dialog = QtWidgets.QDialog(self) uic.loadUi(resource_stream(__name__, "SoundSetup.ui"), dialog) dialog.volumeSlider.setValue(SoundManager().soundVolume) dialog.volumeSlider.valueChanged.connect(SoundManager().setSoundVolume) dialog.testSoundButton.clicked.connect(SoundManager().playSound) dialog.closeButton.clicked.connect(dialog.accept) dialog.show()
def changeUseSpokenNotifications(self, newValue=None): if SoundManager().platformSupportsSpeech(): if newValue is None: newValue = self.useSpokenNotificationsAction.isChecked() self.useSpokenNotificationsAction.setChecked(newValue) SoundManager().setUseSpokenNotifications(newValue) else: self.useSpokenNotificationsAction.setChecked(False) self.useSpokenNotificationsAction.setEnabled(False)
def changeSound(self, newValue=None, disable=False): if disable: self.activateSoundAction.setChecked(False) self.activateSoundAction.setEnabled(False) self.soundSetupAction.setEnabled(False) # self.soundButton.setEnabled(False) QMessageBox.warning(None, "Sound disabled", "The lib 'pyglet' which is used to play sounds cannot be found, ""so the soundsystem is disabled.\nIf you want sound, please install the 'pyglet' library. This warning will not be shown again.", "OK") else: if newValue is None: newValue = self.activateSoundAction.isChecked() self.activateSoundAction.setChecked(newValue) SoundManager().soundActive = newValue
def showKosResult(self, state, text, requestType, hasKos): if not self.scanIntelForKosRequestsEnabled: return try: if hasKos: SoundManager().playSound("kos", text) if state == "ok": if requestType == "xxx": # An xxx request out of the chat self.trayIcon.showMessage("Player KOS-Check", text, 1) elif requestType == "clipboard": # request from clipboard-change if len(text) <= 0: text = "None KOS" self.trayIcon.showMessage("Your KOS-Check", text, 1) text = text.replace("\n\n", "<br>") message = chatparser.chatparser.Message("Spyglass KOS-Check", text, evegate.currentEveTime(), "Spyglass", [], states.NOT_CHANGE, text.upper(), text) self.addMessageToIntelChat(message) elif state == "error": self.trayIcon.showMessage("KOS Failure", text, 3) except Exception: pass self.trayIcon.setIcon(self.taskbarIconQuiescent)
def setSoundVolume(self, value): SoundManager().setSoundVolume(value)
def __init__(self, pathToLogs, trayIcon, backGroundColor): QtGui.QMainWindow.__init__(self) self.cache = Cache() if backGroundColor: self.setStyleSheet("QWidget { background-color: %s; }" % backGroundColor) uic.loadUi(resourcePath('vi/ui/MainWindow.ui'), self) self.setWindowTitle( "Spyglass " + vi.version.VERSION + "{dev}".format(dev="-SNAPSHOT" if vi.version.SNAPSHOT else "")) self.taskbarIconQuiescent = QtGui.QIcon(resourcePath("vi/ui/res/logo_small.png")) self.taskbarIconWorking = QtGui.QIcon(resourcePath("vi/ui/res/logo_small_green.png")) self.setWindowIcon(self.taskbarIconQuiescent) self.setFocusPolicy(QtCore.Qt.StrongFocus) self.pathToLogs = pathToLogs self.mapTimer = QtCore.QTimer(self) self.connect(self.mapTimer, SIGNAL("timeout()"), self.updateMapView) self.clipboardTimer = QtCore.QTimer(self) self.oldClipboardContent = "" self.trayIcon = trayIcon self.trayIcon.activated.connect(self.systemTrayActivated) self.clipboard = QtGui.QApplication.clipboard() self.clipboard.clear(mode=self.clipboard.Clipboard) self.alarmDistance = 0 self.lastStatisticsUpdate = 0 self.chatEntries = [] self.frameButton.setVisible(False) self.scanIntelForKosRequestsEnabled = True self.initialMapPosition = None self.mapPositionsDict = {} self.autoRescanIntelEnabled = self.cache.getFromCache("changeAutoRescanIntel") # Load user's toon names self.knownPlayerNames = self.cache.getFromCache("known_player_names") if self.knownPlayerNames: self.knownPlayerNames = set(self.knownPlayerNames.split(",")) else: self.knownPlayerNames = set() diagText = "Spyglass scans EVE system logs and remembers your characters as they change systems.\n\nSome features (clipboard KOS checking, alarms, etc.) may not work until your character(s) have been registered. Change systems, with each character you want to monitor, while Spyglass is running to remedy this." QMessageBox.warning(None, "Known Characters not Found", diagText, "Ok") # Set up user's intel rooms roomnames = self.cache.getFromCache("room_names") if roomnames: roomnames = roomnames.split(",") else: roomnames = (u"TheCitadel", u"North Provi Intel", u"4THINTEL") self.cache.putIntoCache("room_names", u",".join(roomnames), 60 * 60 * 24 * 365 * 5) self.roomnames = roomnames # Disable the sound UI if sound is not available if not SoundManager().soundAvailable: self.changeSound(disable=True) else: self.changeSound() # Set up Transparency menu - fill in opacity values and make connections self.opacityGroup = QActionGroup(self.menu) for i in (100, 80, 60, 40, 20): action = QAction("Opacity {0}%".format(i), None, checkable=True) if i == 100: action.setChecked(True) action.opacity = i / 100.0 self.connect(action, SIGNAL("triggered()"), self.changeOpacity) self.opacityGroup.addAction(action) self.menuTransparency.addAction(action) # Set up Theme menu - fill in list of themes and add connections self.themeGroup = QActionGroup(self.menu) styles = Styles() for theme in styles.getStyles(): action = QAction(theme, None, checkable=True) action.theme = theme if action.theme == "default": action.setChecked(True) logging.info("Adding theme {}".format(theme)) self.connect(action, SIGNAL("triggered()"), self.changeTheme) self.themeGroup.addAction(action) self.menuTheme.addAction(action) styles = None # # Platform specific UI resizing - we size items in the resource files to look correct on the mac, # then resize other platforms as needed # if sys.platform.startswith("win32") or sys.platform.startswith("cygwin"): font = self.statisticsButton.font() font.setPointSize(8) self.statisticsButton.setFont(font) self.jumpbridgesButton.setFont(font) elif sys.platform.startswith("linux"): pass self.wireUpUIConnections() self.recallCachedSettings() self.setupThreads() self.setupMap(True) initialTheme = self.cache.getFromCache("theme") if initialTheme: self.changeTheme(initialTheme)