def __init__(self,name,interval=1000): if self not in self.indicators: self.indicators += [self] self.name = name self.interval = interval self.initSystray() self.splash = None QApplication.desktop().resized.connect( self.screenSizeChanged)
def display(self): """ Display the image in the ImageViewer, making sure it isn't larger than the desktop size. """ if QApplication.desktop().width() > self.image.width() + 10 and \ QApplication.desktop().height() > self.image.height() + 30: self.show() else: self.showMaximized() # No scrollbars provided with showMaximized. The image is clipped if it is larger than the screen. # Probably need to use a QScrollView for large images. Mark 060701. return
def show_pos_label(self): self.pos_label.setVisible(True) self.pos_label.setStyleSheet(self.info_label_style%( 'rgba(0, 0, 0, 0)', self.view.document.colors()[1])) sw = QApplication.desktop().screenGeometry(self.view) self.pos_label.move(15, sw.height() - self.pos_label.height()-10) self.update_pos_label()
def loadConfig(cls): Config = cls.Config for name in ("window", "shell"): Config["%swidth" % name] = QVariant( QApplication.desktop().availableGeometry().width() / 2).toInt()[0] Config["%sheight" % name] = QVariant( QApplication.desktop().availableGeometry().height() / 2).toInt()[0] Config["%sy" % name] = QVariant(0).toInt()[0] Config["toolbars"] = QByteArray(b'') Config["splitter"] = QByteArray(b'') Config["shellx"] = QVariant(0).toInt()[0] Config["windowx"] = QVariant( QApplication.desktop().availableGeometry().width() / 2).toInt()[0] Config["remembergeometry"] = QVariant(True).toBool() Config["startwithshell"] = QVariant(True).toBool() Config["showwindowinfo"] = QVariant(True).toBool() Config["backupsuffix"] = QVariant(".bak").toString() Config["cwd"] = QVariant(".").toString() Config["tooltipsize"] = QVariant(150).toInt()[0] Config["maxlinestoscan"] = QVariant(5000).toInt()[0] Config["pythondocpath"] = QVariant("http://docs.python.org").toString() Config["autohidefinddialog"] = QVariant(True).toBool() Config["findcasesensitive"] = QVariant(False).toBool() Config["findwholewords"] = QVariant(False).toBool() Config["tabwidth"] = QVariant(4).toInt()[0] Config["fontfamily"] = QVariant("monospace").toString() Config["fontsize"] = QVariant(10).toInt()[0] for name, color, bold, italic in (("normal", "#000000", False, False), ("keyword", "#000080", True, False), ("builtin", "#0000A0", False, False), ("constant", "#0000C0", False, False), ("decorator", "#0000E0", False, False), ("comment", "#007F00", False, True), ("string", "#808000", False, False), ("number", "#924900", False, False), ("error", "#FF0000", False, False), ("pyqt", "#50621A", False, False)): Config["%sfontcolor" % name] = QVariant(color).toString() Config["%sfontbold" % name] = QVariant(bold).toBool() Config["%sfontitalic" % name] = QVariant(italic).toBool()
def show_clock(self): self.clock_label.setVisible(True) self.clock_label.setText('99:99 AA') self.clock_timer.start(1000) self.clock_label.setStyleSheet(self.clock_label_style% tuple(self.view.document.colors())) self.clock_label.resize(self.clock_label.sizeHint()) sw = QApplication.desktop().screenGeometry(self.view) self.clock_label.move(sw.width() - self.vertical_scrollbar.width() - 15 - self.clock_label.width(), sw.height() - self.clock_label.height()-10) self.update_clock()
def loadConfig(cls): Config = cls.Config for name in ("window", "shell"): Config["%swidth" % name] = QVariant(QApplication.desktop().availableGeometry().width() / 2).toInt()[0] Config["%sheight" % name] = QVariant(QApplication.desktop().availableGeometry().height() / 2).toInt()[0] Config["%sy" % name] = QVariant(0).toInt()[0] Config["toolbars"] = QByteArray(b"") Config["splitter"] = QByteArray(b"") Config["shellx"] = QVariant(0).toInt()[0] Config["windowx"] = QVariant(QApplication.desktop().availableGeometry().width() / 2).toInt()[0] Config["remembergeometry"] = QVariant(True).toBool() Config["startwithshell"] = QVariant(True).toBool() Config["showwindowinfo"] = QVariant(True).toBool() Config["backupsuffix"] = QVariant(".bak").toString() Config["cwd"] = QVariant(".").toString() Config["tooltipsize"] = QVariant(150).toInt()[0] Config["maxlinestoscan"] = QVariant(5000).toInt()[0] Config["pythondocpath"] = QVariant("http://docs.python.org").toString() Config["autohidefinddialog"] = QVariant(True).toBool() Config["findcasesensitive"] = QVariant(False).toBool() Config["findwholewords"] = QVariant(False).toBool() Config["tabwidth"] = QVariant(4).toInt()[0] Config["fontfamily"] = QVariant("monospace").toString() Config["fontsize"] = QVariant(10).toInt()[0] for name, color, bold, italic in ( ("normal", "#000000", False, False), ("keyword", "#000080", True, False), ("builtin", "#0000A0", False, False), ("constant", "#0000C0", False, False), ("decorator", "#0000E0", False, False), ("comment", "#007F00", False, True), ("string", "#808000", False, False), ("number", "#924900", False, False), ("error", "#FF0000", False, False), ("pyqt", "#50621A", False, False), ): Config["%sfontcolor" % name] = QVariant(color).toString() Config["%sfontbold" % name] = QVariant(bold).toBool() Config["%sfontitalic" % name] = QVariant(italic).toBool()
def show_clock(self): self.clock_label.setVisible(True) self.clock_label.setText('99:99 AA') self.clock_timer.start(1000) self.clock_label.setStyleSheet(self.clock_label_style % tuple(self.view.document.colors())) self.clock_label.resize(self.clock_label.sizeHint()) sw = QApplication.desktop().screenGeometry(self.view) self.clock_label.move( sw.width() - self.vertical_scrollbar.width() - 15 - self.clock_label.width(), sw.height() - self.clock_label.height() - 10) self.update_clock()
def popup(self, select_first=True): if self.disable_popup: return p = self m = p.model() widget = self.completer_widget() if widget is None: return screen = QApplication.desktop().availableGeometry(widget) h = (p.sizeHintForRow(0) * min(self.max_visible_items, m.rowCount()) + 3) + 3 hsb = p.horizontalScrollBar() if hsb and hsb.isVisible(): h += hsb.sizeHint().height() rh = widget.height() pos = widget.mapToGlobal(QPoint(0, widget.height() - 2)) w = min(widget.width(), screen.width()) if (pos.x() + w) > (screen.x() + screen.width()): pos.setX(screen.x() + screen.width() - w) if pos.x() < screen.x(): pos.setX(screen.x()) top = pos.y() - rh - screen.top() + 2 bottom = screen.bottom() - pos.y() h = max(h, p.minimumHeight()) if h > bottom: h = min(max(top, bottom), h) if top > bottom: pos.setY(pos.y() - h - rh + 2) p.setGeometry(pos.x(), pos.y(), w, h) if (tweaks['preselect_first_completion'] and select_first and not self.currentIndex().isValid() and self.model().rowCount() > 0): self.setCurrentIndex(self.model().index(0)) if not p.isVisible(): if isosx and get_osx_version() >= (10, 9, 0): # On mavericks the popup menu seems to use a font smaller than # the widgets font, see for example: # https://bugs.launchpad.net/bugs/1243761 fp = QFontInfo(widget.font()) f = QFont() f.setPixelSize(fp.pixelSize()) self.setFont(f) p.show()
def updateSplashGeometry(self, hide=False): syslog.syslog( syslog.LOG_DEBUG, "DEBUG indicator updateSplashGeometry") if not self.splash: return if hide: self.hideAllSplashes() r = self.s.geometry() sr = QApplication.desktop().availableGeometry() left = sr.width() - self.splash.width - r.left() if left > 0: left = 0 top = r.height()+3 r.translate( left, top) syslog.syslog( syslog.LOG_DEBUG, "DEBUG topLeft: %d, %d" % (r.left(), r.top())) self.splash.move(r.topLeft())
def misc_config(self): opts = config().parse() self.hyphenate = opts.hyphenate self.hyphenate_default_lang = opts.hyphenate_default_lang self.do_fit_images = opts.fit_images self.page_flip_duration = opts.page_flip_duration self.enable_page_flip = self.page_flip_duration > 0.1 self.font_magnification_step = opts.font_magnification_step self.wheel_flips_pages = opts.wheel_flips_pages self.line_scrolling_stops_on_pagebreaks = opts.line_scrolling_stops_on_pagebreaks screen_width = QApplication.desktop().screenGeometry().width() # Leave some space for the scrollbar and some border self.max_fs_width = min(opts.max_fs_width, screen_width-50) self.fullscreen_clock = opts.fullscreen_clock
def misc_config(self): opts = config().parse() self.hyphenate = opts.hyphenate self.hyphenate_default_lang = opts.hyphenate_default_lang self.do_fit_images = opts.fit_images self.page_flip_duration = opts.page_flip_duration self.enable_page_flip = self.page_flip_duration > 0.1 self.font_magnification_step = opts.font_magnification_step self.wheel_flips_pages = opts.wheel_flips_pages self.line_scrolling_stops_on_pagebreaks = opts.line_scrolling_stops_on_pagebreaks screen_width = QApplication.desktop().screenGeometry().width() # Leave some space for the scrollbar and some border self.max_fs_width = min(opts.max_fs_width, screen_width - 50) self.fullscreen_clock = opts.fullscreen_clock
def show_clock(self): self.clock_label.setVisible(True) self.clock_label.setText(QTime(22, 33, 33).toString(Qt.SystemLocaleShortDate)) self.clock_timer.start(1000) self.clock_label.setStyleSheet(self.info_label_style%( 'rgba(0, 0, 0, 0)', self.view.document.colors()[1])) self.clock_label.resize(self.clock_label.sizeHint()) sw = QApplication.desktop().screenGeometry(self.view) vswidth = (self.vertical_scrollbar.width() if self.vertical_scrollbar.isVisible() else 0) self.clock_label.move(sw.width() - vswidth - 15 - self.clock_label.width(), sw.height() - self.clock_label.height()-10) self.update_clock()
def misc_config(self, opts): self.hyphenate = opts.hyphenate self.hyphenate_default_lang = opts.hyphenate_default_lang self.do_fit_images = opts.fit_images self.page_flip_duration = opts.page_flip_duration self.enable_page_flip = self.page_flip_duration > 0.1 self.font_magnification_step = opts.font_magnification_step self.wheel_flips_pages = opts.wheel_flips_pages self.line_scrolling_stops_on_pagebreaks = opts.line_scrolling_stops_on_pagebreaks screen_width = QApplication.desktop().screenGeometry().width() # Leave some space for the scrollbar and some border self.max_fs_width = min(opts.max_fs_width, screen_width-50) self.fullscreen_clock = opts.fullscreen_clock self.fullscreen_scrollbar = opts.fullscreen_scrollbar self.fullscreen_pos = opts.fullscreen_pos self.use_book_margins = opts.use_book_margins self.cols_per_screen = opts.cols_per_screen self.side_margin = opts.side_margin self.top_margin, self.bottom_margin = opts.top_margin, opts.bottom_margin
def popup(self, select_first=True): p = self m = p.model() widget = self.completer_widget() if widget is None: return screen = QApplication.desktop().availableGeometry(widget) h = (p.sizeHintForRow(0) * min(self.max_visible_items, m.rowCount()) + 3) + 3 hsb = p.horizontalScrollBar() if hsb and hsb.isVisible(): h += hsb.sizeHint().height() rh = widget.height() pos = widget.mapToGlobal(QPoint(0, widget.height() - 2)) w = min(widget.width(), screen.width()) if (pos.x() + w) > (screen.x() + screen.width()): pos.setX(screen.x() + screen.width() - w) if pos.x() < screen.x(): pos.setX(screen.x()) top = pos.y() - rh - screen.top() + 2 bottom = screen.bottom() - pos.y() h = max(h, p.minimumHeight()) if h > bottom: h = min(max(top, bottom), h) if top > bottom: pos.setY(pos.y() - h - rh + 2) p.setGeometry(pos.x(), pos.y(), w, h) if (tweaks['preselect_first_completion'] and select_first and not self.currentIndex().isValid() and self.model().rowCount() > 0): self.setCurrentIndex(self.model().index(0)) if not p.isVisible(): p.show()
def misc_config(self, opts): self.hyphenate = opts.hyphenate self.hyphenate_default_lang = opts.hyphenate_default_lang self.do_fit_images = opts.fit_images self.page_flip_duration = opts.page_flip_duration self.enable_page_flip = self.page_flip_duration > 0.1 self.font_magnification_step = opts.font_magnification_step self.wheel_flips_pages = opts.wheel_flips_pages self.line_scrolling_stops_on_pagebreaks = opts.line_scrolling_stops_on_pagebreaks screen_width = QApplication.desktop().screenGeometry().width() # Leave some space for the scrollbar and some border self.max_fs_width = min(opts.max_fs_width, screen_width-50) self.fullscreen_clock = opts.fullscreen_clock self.fullscreen_scrollbar = opts.fullscreen_scrollbar self.fullscreen_pos = opts.fullscreen_pos self.start_in_fullscreen = opts.start_in_fullscreen self.show_fullscreen_help = opts.show_fullscreen_help self.use_book_margins = opts.use_book_margins self.cols_per_screen = opts.cols_per_screen self.side_margin = opts.side_margin self.top_margin, self.bottom_margin = opts.top_margin, opts.bottom_margin self.show_controls = opts.show_controls
def get_screen_dpi(): d = QApplication.desktop() return (d.logicalDpiX(), d.logicalDpiY())
def set_geometry(self): geometry = QApplication.desktop().screenGeometry() width = int(0.7*geometry.width()) height = int(0.7*geometry.height()) self.setGeometry(50, 50, width, height)