Ejemplo n.º 1
0
        def get_screen_shot(self, antialias=False, rect=None):
            WIDTH, HEIGHT = self.get_screen_size()
            if rect:
                x, y, w, h = rect
                img = QPixmap.grabWindow(QApplication.desktop().winId(), x, y,
                                         w, h).toImage()
                WIDTH = w
                HEIGHT = h
            else:
                img = QPixmap.grabWindow(
                    QApplication.desktop().winId()).toImage()  # returns 32bits

            if self.HALFSIZE:
                length = (WIDTH / 2) * (HEIGHT / 2) * BPP
                ## note Qt.SmoothTransform only works on 32bit images
                if antialias:
                    img = img.scaled(QSize(WIDTH / 2, HEIGHT / 2),
                                     transformMode=Qt.SmoothTransformation)
                else:
                    img = img.scaled(QSize(WIDTH / 2, HEIGHT / 2))
                #img = img.convertToFormat( img.Format_RGB888 )	# WRONG!
                return ctypes.string_at(int(img.bits()), length)
            else:
                length = WIDTH * HEIGHT * BPP
                return ctypes.string_at(int(img.bits()), length)
Ejemplo n.º 2
0
 def on_btn_beautify_clicked(self):
     try:
         try:
             from css_html_prettify import css_prettify
         except:
             _t = QMessageBox.question(self, "Can't beautify", "Python package \"css_html_prettify\" could not be loaded.\nDo you want to try installing it now?", QMessageBox.Yes, QMessageBox.No)
             if _t == QMessageBox.Yes:
               from devtools import PluginInstaller
               PluginInstaller().installPackages(['css_html_prettify'])
               self.on_btn_beautify_clicked()
             return
             #import traceback; QMessageBox.Critical("Can't minify", traceback.format_exc()).exec_()
         index = self.tabWidget.currentIndex
         _old = ""
         if index == 0:
             _old = self.qssEditor.toPlainText()
         elif index == 1: _old = self.chatEditor.toPlainText()
         _beautified = css_prettify(_old)
         if index == 0:
             QApplication.instance().styleSheet = _beautified
             self.qssEditor.setPlainText(_beautified)
         elif index == 1: self.chatEditor.setPlainText(_beautified);return
         if QMessageBox(QMessageBox.Warning, "Use minified QSS?", "Your minified QSS code has been applied.\n\nIf you encounter any issues with the minified code you should click on cancel.", QMessageBox.Ok | QMessageBox.Cancel).exec_() == QMessageBox.Cancel:
             QApplication.instance().styleSheet = _old
             self.qssEditor.setPlainText(_old)
     except:
         try:
             from traceback import format_exc
             QMessageBox(QMessageBox.Critical, "Can't beautify", format_exc()).exec_()
         except:
             print(format_exc())
Ejemplo n.º 3
0
    def on_copyAction_triggered(self):
        cur = self.listmodel.fileByIndex(self.currentItem())

        if not cur:
            return

        err, host, port, _ = ts3lib.getServerConnectInfo(self.schid)

        if err == ERROR_ok:
            url = ("[URL=ts3file://{address}?port={port}&channel={cid}&"
                   "path={path}&filename={fname}&isDir={isdir}&"
                   "size={size}&fileDateTime={date}]{fname}[/URL]").format(
                       address=host,
                       port=port,
                       cid=self.cid,
                       path=QUrl.toPercentEncoding(cur.path),
                       fname=cur.name,
                       isdir=1 if cur.isDirectory else 0,
                       size=cur.size,
                       date=int(cur.datetime.timestamp()))

            QApplication.clipboard().setText(url)
        else:
            self.showError(self._tr("Error getting server connection info"),
                           err)
Ejemplo n.º 4
0
 def index(self, row, column, parent):
     if not parent.isValid():
         if len(QApplication.topLevelWidgets()) <= row:
             return QModelIndex()
         else:
             return self.createIndex(row, column, QApplication.topLevelWidgets()[row])
     else:
         if len(parent.internalPointer().children()) <= row:
             return QModelIndex()
         else:
             return self.createIndex(row, column, parent.internalPointer().children()[row])
Ejemplo n.º 5
0
 def mouseReleaseEvent(self, e):
     QPlainTextEdit.mouseReleaseEvent(self, e)
     if e.button() == Qt.LeftButton:
         self.textCursor().setCharFormat(self.selformat)
         self.seltext = self.textCursor().selectedText()
         self.setTextCursor(self.selcursor)
     elif e.button() == Qt.RightButton:
         if self.seltext == "":
             self.textCursor().insertText(QApplication.clipboard().text())
         else:
             self.textCursor().insertText(self.seltext)
             QApplication.clipboard().setText(self.seltext)
Ejemplo n.º 6
0
 def on_btn_beautify_clicked(self):
     try:
         try:
             from bs4 import BeautifulSoup
         except Exception:
             from traceback import format_exc
             print("Error: {0}".format(format_exc()))
             _t = QMessageBox.question(
                 self, "Can't beautify",
                 "Python package \"beautifulsoup4\" could not be loaded.\nDo you want to try installing it now?",
                 QMessageBox.Yes, QMessageBox.No)
             if _t == QMessageBox.Yes:
                 from devtools import PluginInstaller
                 PluginInstaller().installPackages(['beautifulsoup4'])
                 self.on_btn_beautify_clicked()
             return
             #import traceback; QMessageBox.Critical("Can't minify", traceback.format_exc()).exec_()
         index = self.tabWidget.currentIndex
         _old = ""
         if index == 0: _old = self.qssEditor.toPlainText()
         elif index == 1: _old = self.chatEditor.toPlainText()
         elif index == 2: _old = self.tplEditor.toPlainText()
         elif index == 3: _old = self.chatEditor_html.toPlainText()
         _beautified = BeautifulSoup(_old)
         _beautified = _beautified.prettify()
         if index == 0:
             QApplication.instance().styleSheet = _beautified
             self.qssEditor.setPlainText(_beautified)
         elif index == 1:
             self.chatEditor.setPlainText(_beautified)
             return
         elif index == 2:
             self.tplEditor.setPlainText(_beautified)
             return
         elif index == 3:
             self.chatEditor_html.setPlainText(_beautified)
             return
         if QMessageBox(
                 QMessageBox.Warning, "Use beautified code?",
                 "Your beautified code has been applied.\n\nIf you encounter any issues with the beautified code you should click on cancel.",
                 QMessageBox.Ok
                 | QMessageBox.Cancel).exec_() == QMessageBox.Cancel:
             QApplication.instance().styleSheet = _old
             self.qssEditor.setPlainText(_old)
     except:
         try:
             from traceback import format_exc
             QMessageBox(QMessageBox.Critical, "Can't beautify",
                         format_exc()).exec_()
         except:
             print(format_exc())
Ejemplo n.º 7
0
    def _paintSpacer(self, painter, option, index):
        st = index.data(ServerViewRoles.spacertype)

        if st != Qt.CustomDashLine:
            painter.setPen(st)
            painter.drawLine(option.rect.x(),
                             option.rect.y() + option.rect.height() / 2,
                             option.rect.x() + option.rect.width(),
                             option.rect.y() + option.rect.height() / 2)
        else:
            align = index.data(ServerViewRoles.spaceralignment)
            ctext = index.data(ServerViewRoles.spacercustomtext)

            if align != Qt.AlignJustify:
                painter.drawText(option.rect.x(), option.rect.y(),
                                 option.rect.width(), option.rect.height(),
                                 align, ctext)
            else:
                fm = QFontMetrics(QApplication.font())
                w = l = fm.width(ctext)
                txt = ctext
                while l < option.rect.width():
                    txt += ctext
                    l += w

                painter.drawText(option.rect.x(), option.rect.y(),
                                 option.rect.width(), option.rect.height(),
                                 Qt.AlignLeft, txt)
Ejemplo n.º 8
0
    def _paintSpacer(self, painter, option, index):
        st = index.data(ServerViewRoles.spacertype)

        if st != Qt.CustomDashLine:
            painter.setPen(st)
            painter.drawLine(option.rect.x(),
                             option.rect.y() + option.rect.height() / 2,
                             option.rect.x() + option.rect.width(),
                             option.rect.y() + option.rect.height() / 2)
        else:
            align = index.data(ServerViewRoles.spaceralignment)
            ctext = index.data(ServerViewRoles.spacercustomtext)

            if align != Qt.AlignJustify:
                painter.drawText(option.rect.x(), option.rect.y(),
                                 option.rect.width(), option.rect.height(),
                                 align, ctext)
            else:
                fm = QFontMetrics(QApplication.font())
                w = l = fm.width(ctext)
                txt = ctext
                while l < option.rect.width():
                    txt += ctext
                    l += w

                painter.drawText(option.rect.x(), option.rect.y(),
                                 option.rect.width(), option.rect.height(),
                                 Qt.AlignLeft, txt)
Ejemplo n.º 9
0
 def on_btn_apply_clicked(self):
     i = self.tabWidget.currentIndex
     if i == 0:
         QApplication.instance().styleSheet = self.qssEditor.toPlainText()
     elif i == 1:
         QApp = QApplication.instance()
         widgets = QApp.topLevelWidgets() + QApp.allWidgets()
         for x in widgets:
             if x.objectName == "ChatTab":
                 x.findChild(QTextDocument).defaultStyleSheet = self.chatEditor.toPlainText()
     elif i == 2:
         _i = self.getWidgetByObjectName("InfoFrame")
         _o = _i.styleSheet
         _i.styleSheet = "background:red;"
         _i.html = self.html
         _i.styleSheet = _o
Ejemplo n.º 10
0
 def on_btn_reset_clicked(self):
     if QMessageBox(
             QMessageBox.Warning, "Reset QSS?",
             "This will reset your changes to the initial Stylesheet! Continue?",
             QMessageBox.Ok
             | QMessageBox.Cancel).exec_() == QMessageBox.Ok:
         QApplication.instance().styleSheet = self.stylesheet
         self.qssEditor.setPlainText(self.stylesheet)
Ejemplo n.º 11
0
    def paint(self, painter, option, idx):
        if idx.column() != 1:
            QStyledItemDelegate.paint(self, painter, option, idx)
            return

        progress = idx.data()

        pgoptions = QStyleOptionProgressBar()
        pgoptions.rect = option.rect
        pgoptions.minimum = 0
        pgoptions.maximum = 100
        pgoptions.progress = progress
        pgoptions.text = "%s%%" % progress
        pgoptions.textVisible = True

        QApplication.style().drawControl(QStyle.CE_ProgressBar, pgoptions,
                                         painter)
Ejemplo n.º 12
0
    def paint(self, painter, option, idx):
        if idx.column() != 1:
            QStyledItemDelegate.paint(self, painter, option, idx)
            return

        progress = idx.data()

        pgoptions = QStyleOptionProgressBar()
        pgoptions.rect = option.rect
        pgoptions.minimum = 0
        pgoptions.maximum = 100
        pgoptions.progress = progress
        pgoptions.text = "%s%%" % progress
        pgoptions.textVisible = True

        QApplication.style().drawControl(QStyle.CE_ProgressBar, pgoptions,
                                         painter)
Ejemplo n.º 13
0
Archivo: pyvnc.py Proyecto: A-K/naali
		def get_screen_shot( self, antialias=False, rect=None ):
			WIDTH,HEIGHT = self.get_screen_size()
			if rect:
				x,y,w,h = rect
				img = QPixmap.grabWindow(QApplication.desktop().winId(), x,y,w,h).toImage()
				WIDTH = w; HEIGHT = h
			else:
				img = QPixmap.grabWindow(QApplication.desktop().winId()).toImage()	# returns 32bits

			if self.HALFSIZE:
				length = (WIDTH/2)*(HEIGHT/2)*BPP
				## note Qt.SmoothTransform only works on 32bit images
				if antialias: img = img.scaled( QSize(WIDTH/2, HEIGHT/2), transformMode=Qt.SmoothTransformation )
				else: img = img.scaled( QSize(WIDTH/2, HEIGHT/2) )
				#img = img.convertToFormat( img.Format_RGB888 )	# WRONG!
				return ctypes.string_at( int(img.bits()), length )
			else:
				length = WIDTH*HEIGHT*BPP
				return ctypes.string_at( int(img.bits()), length )
Ejemplo n.º 14
0
    def retrieveWidgets(self):
        process = False

        if not hasattr(self, "main"):
            qapp = QApplication.instance()

            for w in qapp.topLevelWidgets():
                if "MainWindow" in str(type(w)):
                    self.main = w
                    process = True
        else:
            process = True

        if process and not hasattr(self, "splitter"):
            for c in self.main.children():
                if type(c) is QSplitter:
                    self.splitter = c
                    break

            if not hasattr(self, "splitter"):
                process = False

        if process and (not hasattr(self, "chat")
                        or not hasattr(self, "tabwidget")):
            for c in self.splitter.children():
                if c.objectName == "MainWindowChatWidget":
                    self.chat = c
                elif c.objectName == "MainWindowServerTabsWidget":
                    self.tabwidget = c

            if not hasattr(self, "chat") or not hasattr(self, "tabwidget"):
                process = False

        if process and not hasattr(self, "tab"):
            for c in self.tabwidget.children():
                if "ServerViewManager" in str(type(c)):
                    self.tab = c
                    break

            if not hasattr(self, "tab"):
                process = False

        if process and not hasattr(self, "svparent"):
            for c in self.tab.children():
                if type(c) is QStackedWidget:
                    self.svparent = c
                    break

        if not process:
            #it's possible that this plugin is started before the client's UI is loaded
            QTimer.singleShot(300, self.retrieveWidgets)
        else:
            self.tab.connect("currentChanged(int)", self.onTabIndexChanged)

            self.startDocking()
Ejemplo n.º 15
0
    def __init__(self, schid, parent=None):
        self.lay = QHBoxLayout(parent)
        self.tree = DragDropServerview(schid, parent)
        self.lay.addWidget(self.tree)
        self.lay.setContentsMargins(0,0,0,0)
        parent.setLayout(self.lay)

        self.tree.connect("clicked(QModelIndex)", self.tree.onItemClicked)
        self.tree.connect("customContextMenuRequested(QPoint)", self.tree.onContextMenu)

        self.searchFrame = [item for item in QApplication.instance().allWidgets() if type(item).__name__ == "SearchFrame"][0]
        self.searchFrame.connect("find(QString,QTextDocument::FindFlags,bool,bool,bool&)", self.tree.onSearch)
Ejemplo n.º 16
0
    def on_copyAction_triggered(self):
        cur = self.listmodel.fileByIndex(self.currentItem())

        if not cur:
            return

        err, host, port, _ = ts3lib.getServerConnectInfo(self.schid)

        if err == ERROR_ok:
            url = ("[URL=ts3file://{address}?port={port}&channel={cid}&"
                   "path={path}&filename={fname}&isDir={isdir}&"
                   "size={size}&fileDateTime={date}]{fname}[/URL]").format(
                   address=host, port=port, cid=self.cid,
                   path=QUrl.toPercentEncoding(cur.path), fname=cur.name,
                   isdir=1 if cur.isDirectory else 0, size=cur.size,
                   date=int(cur.datetime.timestamp()))

            QApplication.clipboard().setText(url)
        else:
            self.showError(self._tr("Error getting server connection info"),
                           err)
Ejemplo n.º 17
0
 def parent(self, index):
     if not index.isValid():
         return QModelIndex()
        
     obj = index.internalPointer()
     tlw = QApplication.topLevelWidgets()
     
     if obj in tlw:
         return QModelIndex()
     else:
         if obj.parent() in tlw:
             return self.createIndex(tlw.index(obj.parent()), 0, obj.parent())
         else:
             return self.createIndex(obj.parent().children().index(obj), 0, obj.parent()) 
Ejemplo n.º 18
0
    def retrieveWidgets(self):
        if not self.main:
            for w in QApplication.instance().topLevelWidgets():
                if "MainWindow" in str(type(w)):
                    self.main = w
                    break

        if self.main and not self.svmanagerstack:
            self.svmanagerstack = findChildWidget(self.main, lambda x: x.objectName == "qt_tabwidget_stackedwidget" and "ServerViewManager" in str(type(x.parent())), True)

        if self.svmanagerstack:
            self.svmanagerstack.installEventFilter(self.svobserver)
            for tree in findAllChildWidgets(self.svmanagerstack, lambda x: "TreeView" in str(type(x)), True):
                #TODO: maybe create a new servertreeview here?
                tree.installEventFilter(self.treekeyobserver)
        else:
            QTimer.singleShot(300, self.retrieveWidgets)
Ejemplo n.º 19
0
    def paint(self, painter, option, index):
        if option.state & QStyle.State_Selected:
            painter.fillRect(option.rect, option.palette.highlight())

        if not index.isValid():
            super().paint(painter, option, index)
            return

        if index.data(ServerViewRoles.isspacer):
            painter.save()
            self._paintSpacer(painter, option, index)
            painter.restore()
            return

        icon = index.data(Qt.DecorationRole)
        statusicons = index.data(ServerViewRoles.statusicons)
        font = index.data(Qt.FontRole) or QApplication.font()
        brush = index.data(Qt.ForegroundRole) or Qt.black

        if icon:
            iconsize = icon.actualSize(option.decorationSize)
            icon.paint(painter, option.rect, Qt.AlignLeft)
        else:
            iconsize = option.decorationSize

        headerRect = option.rect
        headerRect.setLeft(headerRect.left() + iconsize.width() + 5)

        painter.save()

        pen = painter.pen()
        pen.setBrush(brush)
        painter.setPen(pen)
        painter.setFont(font)

        painter.drawText(headerRect, Qt.AlignLeft, index.data())

        nextx = 18
        if statusicons:
            for ico in reversed(statusicons):
                ico.paint(painter,
                          option.rect.right() - nextx, option.rect.y(),
                          iconsize.width(), iconsize.height())
                nextx += 18

        painter.restore()
Ejemplo n.º 20
0
 def setWidget(self, widg):
     self.widget = widg
     
     tlw = QApplication.topLevelWidgets()
     
     if widg in tlw:
         index = self.treemodel.createIndex(tlw.index(widg), 0, widg)
     else:
         index = self.treemodel.createIndex(widg.parent().children().index(widg), 0, widg)
         
     self.tree.selectionModel().select(index, QItemSelectionModel.ClearAndSelect)
     self.tree.scrollTo(index)
     
     while index.isValid():
         self.tree.expand(index)
         index = index.parent()
     
     self.tablemodel.setWidget(widg)
Ejemplo n.º 21
0
def tr(context, sourcetext, *, disambiguation="", n=-1):
    """
    Returns the current translation for a string. This function calls can be
    extracted by pyTSon's pylupdate.py.
    @param context: context of the string literal, must be a raw string, not
    the return value of another function, an attribute or such
    @type context: str
    @param sourcetext: translatable string, must be a raw string, not the
    return value of another function, an attribute or such
    @type sourcetext: str
    @param disambiguation: used to distinguish between two equal sourcetexts
    int the same context, or as comment, optional, defaults to an empty string,
    must be a raw string, not the return value of another function, an
    attribute or such
    @type disambiguation: str
    @param n: used for strings containing plurals, optional, defaults to -1
    @type n: int
    """
    return QApplication.translate(context, sourcetext, disambiguation, n)
Ejemplo n.º 22
0
def tr(context, sourcetext, *, disambiguation="", n=-1):
    """
    Returns the current translation for a string. This function calls can be
    extracted by pyTSon's pylupdate.py.
    @param context: context of the string literal, must be a raw string, not
    the return value of another function, an attribute or such
    @type context: str
    @param sourcetext: translatable string, must be a raw string, not the
    return value of another function, an attribute or such
    @type sourcetext: str
    @param disambiguation: used to distinguish between two equal sourcetexts
    int the same context, or as comment, optional, defaults to an empty string,
    must be a raw string, not the return value of another function, an
    attribute or such
    @type disambiguation: str
    @param n: used for strings containing plurals, optional, defaults to -1
    @type n: int
    """
    return QApplication.translate(context, sourcetext, disambiguation, n)
Ejemplo n.º 23
0
 def __init__(self, arg, parent=None):
     super(QDialog, self).__init__(parent)
     setupUi(self, os.path.join(ts3.getPluginPath(), "pyTSon", "scripts", "devTools", "editor.ui"))
     self.resize(1000, 900)
     self.setWindowTitle('Teamspeak Stylesheet Editor : : Developer Tools')
     self.stylesheet = QApplication.instance().styleSheet
     self.chatsheet = self.getWidgetByObjectName("ChatTab").findChild(QTextDocument).defaultStyleSheet
     self.html = self.getWidgetByObjectName("InfoFrame").html
     self.qssEditor.setPlainText(self.stylesheet)
     self.chatEditor.setPlainText(self.chatsheet)
     self.tplEditor.setPlainText(self.html)
     self.chatEditor.setReadOnly(True);self.tplEditor.setReadOnly(True)
     index = self.tabWidget.currentIndex
     if index == 0:
         self.btn_apply.setEnabled(True);self.btn_minify.setEnabled(True);self.btn_insert.setEnabled(True);self.btn_reset.setEnabled(True);self.chk_live.setEnabled(True)
     elif index == 1:
         self.btn_apply.setEnabled(False);self.btn_minify.setEnabled(True);self.btn_insert.setEnabled(False);self.btn_reset.setEnabled(False);self.chk_live.setEnabled(False)
     else:
         self.btn_apply.setEnabled(False);self.btn_minify.setEnabled(False);self.btn_insert.setEnabled(False);self.btn_reset.setEnabled(False);self.chk_live.setEnabled(False)
     self.lastSave = None
Ejemplo n.º 24
0
 def get_screen_size(self):
     _size = QApplication.desktop().size()
     WIDTH = _size.width()
     HEIGHT = _size.height()
     return WIDTH, HEIGHT
Ejemplo n.º 25
0
    #import rexviewer	# deprecated
    import naali
    import circuits
    import circuits.Component
    import PythonQt
    from PythonQt import QtGui, QtCore
    from PythonQt.QtCore import Qt, QSize
    from PythonQt.QtGui import QPixmap, QApplication
    PyQt4 = PythonQt
except:
    try:
        import PyQt4
        from PyQt4 import QtGui, QtCore
        from PyQt4.QtCore import Qt, QSize
        from PyQt4.QtGui import QPixmap, QApplication
        app = QApplication(sys.argv)
    except:
        try:
            import PythonQt
        except:
            import gtk
            import gtk.gdk, numpy

if naali:
    #if os.path.split( os.path.abspath('.') )[-1] != 'pymodules':
    #	sys.path.append( os.path.abspath('pymodules') )
    #	sys.path.append( os.path.abspath('pymodules/lib') )
    #	sys.path.append( os.path.abspath('pymodules/DLLs') )
    #	os.chdir('pymodules')

    class NaaliServerHandler(circuits.Component):
Ejemplo n.º 26
0
 def onQSSChanged(self):
     QApplication.instance().styleSheet = self.qssEditor.toPlainText()
Ejemplo n.º 27
0
Archivo: pyvnc.py Proyecto: A-K/naali
		def get_screen_size(self):
			_size = QApplication.desktop().size()
			WIDTH = _size.width()
			HEIGHT = _size.height()
			return WIDTH, HEIGHT
Ejemplo n.º 28
0
 def getWidgetByClassName(self, name):
     QApp = QApplication.instance()
     widgets = QApp.topLevelWidgets()
     widgets = widgets + QApp.allWidgets()
     for x in widgets:
         if str(x.__class__) == name: return x
Ejemplo n.º 29
0
    def data(self, index, role):
        obj = self._indexObject(index)

        if role == Qt.DisplayRole:
            if type(obj) is Client:
                if obj.isRecording:
                    return "*** %s *** [RECORDING]" % obj.displayName
                else:
                    return obj.displayName

            return obj.name
        elif role == ServerViewRoles.isspacer:
            return type(obj) is Channel and obj.isSpacer
        elif type(obj) is Channel and role == ServerViewRoles.spacertype:
            return obj.spacerType
        elif type(obj) is Channel and role == ServerViewRoles.spacercustomtext:
            return obj.spacerCustomtext
        elif type(obj) is Channel and role == ServerViewRoles.spaceralignment:
            return obj.spacerAlignment
        elif role == Qt.DecorationRole:
            if not (type(obj) is Channel and obj.isSpacer):
                return QIcon(self.iconpack.icon(obj.iconVariable()))
        elif role == ServerViewRoles.statusicons:
            ret = []
            if type(obj) is Channel:
                if obj.isDefault:
                    ret.append(QIcon(self.iconpack.icon("DEFAULT")))
                if obj.codec == ts3defines.CodecType.CODEC_OPUS_MUSIC:
                    ret.append(QIcon(self.iconpack.icon("MUSIC")))
                if obj.neededTalkPower > 0:
                    ret.append(QIcon(self.iconpack.icon("MODERATED")))
                if obj.iconID != 0:
                    ret.append(QIcon(self.icons.icon(obj.iconID)))
            elif type(obj) is Client:
                # badges
                # priority speaker
                if obj.isPrioritySpeaker:
                    ret.append(QIcon(self.iconpack.icon("CAPTURE")))
                # istalker
                if obj.isTalker:
                    ret.append(QIcon(self.iconpack.icon("IS_TALKER")))
                elif obj.talkPower < obj.parentNode.neededTalkPower:
                    ret.append(QIcon(self.iconpack.icon("INPUT_MUTED")))
                # channelgroup
                if obj.channelGroup in self.cgicons:
                    ret.append(QIcon(self.icons.icon(
                        self.cgicons[obj.channelGroup])))
                # servergroups
                for sg in obj.serverGroups:
                    if sg in self.sgicons:
                        ret.append(QIcon(self.icons.icon(self.sgicons[sg])))
                # clienticon
                if obj.iconID != 0:
                    ret.append(QIcon(self.icons.icon(obj.iconID)))
                # talkrequest
                if obj.isRequestingTalkPower:
                    ret.append(QIcon(self.iconpack.icon("REQUEST_TALK_POWER")))
                # flag
                if obj.country != "":
                    ret.append(QIcon(self.countries.flag(obj.country)))
            else:
                assert type(obj) is Server
                if obj.iconID != 0:
                    ret.append(QIcon(self.icons.icon(obj.iconID)))

            return ret
        elif role == Qt.FontRole:
            if type(obj) is Client and obj.isme:
                font = QApplication.font()
                font.setBold(True)
                return font
        elif role == Qt.ForegroundRole:
            if type(obj) is Client and obj.isRecording:
                return QColor(Qt.darkRed)

        return None
Ejemplo n.º 30
0
 def onHotkeyEvent(self, keyword):
     if keyword == "info":
         self.showInfo(QApplication.instance().widgetAt(QCursor.pos()))
Ejemplo n.º 31
0
    def data(self, index, role):
        obj = self._indexObject(index)

        if role == Qt.DisplayRole:
            if type(obj) is Client:
                if obj.isRecording:
                    return "*** %s *** [RECORDING]" % obj.displayName
                else:
                    return obj.displayName

            return obj.name
        elif role == ServerViewRoles.isspacer:
            return type(obj) is Channel and obj.isSpacer
        elif type(obj) is Channel and role == ServerViewRoles.spacertype:
            return obj.spacerType
        elif type(obj) is Channel and role == ServerViewRoles.spacercustomtext:
            return obj.spacerCustomtext
        elif type(obj) is Channel and role == ServerViewRoles.spaceralignment:
            return obj.spacerAlignment
        elif role == Qt.DecorationRole:
            if not (type(obj) is Channel and obj.isSpacer):
                return QIcon(self.iconpack.icon(obj.iconVariable()))
        elif role == ServerViewRoles.statusicons:
            ret = []
            if type(obj) is Channel:
                if obj.isDefault:
                    ret.append(QIcon(self.iconpack.icon("DEFAULT")))
                if obj.codec == ts3defines.CodecType.CODEC_OPUS_MUSIC:
                    ret.append(QIcon(self.iconpack.icon("MUSIC")))
                if obj.neededTalkPower > 0:
                    ret.append(QIcon(self.iconpack.icon("MODERATED")))
                if obj.iconID != 0:
                    ret.append(QIcon(self.icons.icon(obj.iconID)))
            elif type(obj) is Client:
                # badges
                # priority speaker
                if obj.isPrioritySpeaker:
                    ret.append(QIcon(self.iconpack.icon("CAPTURE")))
                # istalker
                if obj.isTalker:
                    ret.append(QIcon(self.iconpack.icon("IS_TALKER")))
                elif obj.talkPower < obj.parentNode.neededTalkPower:
                    ret.append(QIcon(self.iconpack.icon("INPUT_MUTED")))
                # channelgroup
                if obj.channelGroup in self.cgicons:
                    ret.append(
                        QIcon(self.icons.icon(self.cgicons[obj.channelGroup])))
                # servergroups
                for sg in obj.serverGroups:
                    if sg in self.sgicons:
                        ret.append(QIcon(self.icons.icon(self.sgicons[sg])))
                # clienticon
                if obj.iconID != 0:
                    ret.append(QIcon(self.icons.icon(obj.iconID)))
                # talkrequest
                if obj.isRequestingTalkPower:
                    ret.append(QIcon(self.iconpack.icon("REQUEST_TALK_POWER")))
                # flag
                if obj.country != "":
                    ret.append(QIcon(self.countries.flag(obj.country)))
            else:
                assert type(obj) is Server
                if obj.iconID != 0:
                    ret.append(QIcon(self.icons.icon(obj.iconID)))

            return ret
        elif role == Qt.FontRole:
            if type(obj) is Client and obj.isme:
                font = QApplication.font()
                font.setBold(True)
                return font
        elif role == Qt.ForegroundRole:
            if type(obj) is Client and obj.isRecording:
                return QColor(Qt.darkRed)

        return None
Ejemplo n.º 32
0
 def getWidgetByObjectName(self, name):
     QApp = QApplication.instance()
     widgets = QApp.topLevelWidgets()
     widgets = widgets + QApp.allWidgets()
     for x in widgets:
         if str(x.objectName) == name: return x
Ejemplo n.º 33
0
 def __init__(self):
   self.clipboard = QApplication.clipboard()
   self.action = QAction("Copy to clipboard", None)
   clementine.ui.AddAction("song_menu", self.action)
   self.action.connect("activated()", self.CopyToClipboard)
Ejemplo n.º 34
0
Archivo: pyvnc.py Proyecto: A-K/naali
	#import rexviewer	# deprecated
	import naali
	import circuits
	import circuits.Component
	import PythonQt
	from PythonQt import QtGui, QtCore
	from PythonQt.QtCore import Qt, QSize
	from PythonQt.QtGui import QPixmap, QApplication
	PyQt4 = PythonQt
except:
	try:
		import PyQt4
		from PyQt4 import QtGui, QtCore
		from PyQt4.QtCore import Qt, QSize
		from PyQt4.QtGui import QPixmap, QApplication
		app = QApplication(sys.argv)
	except:
		try: import PythonQt
		except:
			import gtk
			import gtk.gdk, numpy


if naali:
	#if os.path.split( os.path.abspath('.') )[-1] != 'pymodules':
	#	sys.path.append( os.path.abspath('pymodules') )
	#	sys.path.append( os.path.abspath('pymodules/lib') )
	#	sys.path.append( os.path.abspath('pymodules/DLLs') )
	#	os.chdir('pymodules')

	class NaaliServerHandler(circuits.Component):
Ejemplo n.º 35
0
 def rowCount(self, parent):
     if not parent.isValid():
         return len(QApplication.topLevelWidgets())
     else:
         return len(parent.internalPointer().children())