def get_icon(conn_type, state = False): state = ("dialog-ok", "ok") if state else None CONN_TYPES = {"802-11-wireless": QIconLoader.loadOverlayed("network-wireless", state, 32, position = QIconLoader.TopLeft), "802-3-ethernet" : QIconLoader.loadOverlayed("network-wired", state, 32, position = QIconLoader.TopLeft)} return CONN_TYPES.get(conn_type, QIconLoader.loadOverlayed("network-wired", state, 32, position = QIconLoader.TopLeft))
def setupUi(self, Test): Test.setObjectName("Test") Test.resize(460, 300) self.gridLayout = QtWidgets.QGridLayout(Test) self.gridLayout.setObjectName("gridLayout") self.name = QtWidgets.QComboBox(Test) self.name.setObjectName("name") self.name.setEditable(True) self.gridLayout.addWidget(self.name, 0, 0, 1, 1) self.size = QtWidgets.QComboBox(Test) self.size.setObjectName("size") self.size.setMaximumSize(QtCore.QSize(100, 16777215)) self.size.addItem("128") self.size.addItem("64") self.size.addItem("48") self.size.addItem("32") self.size.addItem("22") self.size.addItem("16") self.gridLayout.addWidget(self.size, 0, 1, 1, 1) self.getButton = QtWidgets.QPushButton(Test) self.getButton.setText("Get Icon") self.getButton.setMaximumSize(QtCore.QSize(100, 16777215)) self.gridLayout.addWidget(self.getButton, 0, 2, 1, 1) self.label = QtWidgets.QLabel(Test) self.label.setObjectName("label") self.gridLayout.addWidget(self.label, 1, 0, 1, 3) self.getButton.clicked.connect(self.showIcon) QtCore.QMetaObject.connectSlotsByName(Test) Pds = pds.Pds(debug=True) # Force to use Default Session for testing # Pds.session = pds.DefaultDe self.loader = QIconLoader(Pds, debug=True) completer = QtWidgets.QCompleter(self.loader._available_icons) self.name.setCompleter(completer) self.getButton.setShortcut("Return") print "Desktop Session :", self.loader.pds.session.Name print "Desktop Version :", self.loader.pds.session.Version print "Icon Paths :", self.loader.iconDirs print "Theme :", self.loader.themeName
class Ui_Test(object): def setupUi(self, Test): Test.setObjectName("Test") Test.resize(460, 300) self.gridLayout = QtGui.QGridLayout(Test) self.gridLayout.setObjectName("gridLayout") self.name = QtGui.QComboBox(Test) self.name.setObjectName("name") self.name.setEditable(True) self.gridLayout.addWidget(self.name, 0, 0, 1, 1) self.size = QtGui.QComboBox(Test) self.size.setObjectName("size") self.size.setMaximumSize(QtCore.QSize(100, 16777215)) self.size.addItem("128") self.size.addItem("64") self.size.addItem("48") self.size.addItem("32") self.size.addItem("22") self.size.addItem("16") self.gridLayout.addWidget(self.size, 0, 1, 1, 1) self.getButton = QtGui.QPushButton(Test) self.getButton.setText("Get Icon") self.getButton.setMaximumSize(QtCore.QSize(100, 16777215)) self.gridLayout.addWidget(self.getButton, 0, 2, 1, 1) self.label = QtGui.QLabel(Test) self.label.setObjectName("label") self.gridLayout.addWidget(self.label, 1, 0, 1, 3) self.getButton.clicked.connect(self.showIcon) QtCore.QMetaObject.connectSlotsByName(Test) Pds = pds.Pds(debug = True) # Force to use Default Session for testing # Pds.session = pds.DefaultDe self.loader = QIconLoader(Pds, debug = True) completer = QtGui.QCompleter(self.loader._available_icons) self.name.setCompleter(completer) self.getButton.setShortcut("Return") print "Desktop Session :", self.loader.pds.session.Name print "Desktop Version :", self.loader.pds.session.Version print "Icon Paths :", self.loader.iconDirs print "Theme :", self.loader.themeName def showIcon(self): a = time() print "Clicked !" icons = unicode(self.name.currentText()) self.label.setPixmap(self.loader.load(icons.split(','), self.size.currentText())) print 'It took : ', time() - a
from PyQt5.QtGui import QPixmap from PyQt5.QtWidgets import QMessageBox from PyQt5.QtWidgets import QApplication from PyQt5.QtNetwork import QNetworkProxy import pds from pds.qiconloader import QIconLoader Pds = pds.Pds('package-manager', debug=False) # Force to use Default Session for testing # Pds.session = pds.DefaultDe # print 'Current session is : %s %s' % (Pds.session.Name, Pds.session.Version) i18n = Pds.session.i18n KIconLoader = QIconLoader(Pds) KIcon = KIconLoader.icon class PM: def __init__(): pass def connectOperationSignals(self): # Basic connections self.operation.exception[str].connect(self.exceptionCaught) self.operation.finished[str].connect(self.actionFinished) self.operation.started[str].connect(self.actionStarted) self.operation.operationCancelled.connect(self.actionCancelled) # ProgressDialog connections
# # Please read the COPYING file. # import pds import traceback from time import time from pds.qiconloader import QIconLoader Pds = pds.Pds('boot-manager', debug=False) # Force to use Default Session for testing #Pds.session = pds.DefaultDe #print 'Current session is : %s %s' % (Pds.session.Name, Pds.session.Version) i18n = Pds.i18n KIconLoader = QIconLoader(Pds, forceCache=True) KIcon = KIconLoader.icon time_counter = 0 start_time = time() last_time = time() def _time(): global last_time, time_counter trace = list(traceback.extract_stack()) diff = time() - start_time print('%s ::: %s:%s' % (time_counter, trace[-2][0].split('/')[-1], trace[-2][1])), diff, diff - last_time last_time = diff time_counter += 1
import dbus from dbus.mainloop.qt import DBusQtMainLoop # Qt Libraries from PyQt5 import QtGui from PyQt5.QtCore import * # UI from pds.ui.ui_connectionitem import Ui_ConnectionItem # Pds from pds.gui import * from pds.qiconloader import QIconLoader from pds.qprogressindicator import QProgressIndicator QIconLoader = QIconLoader() # NetworkManager from networkmanager import State from networkmanager import NetworkManager from networkmanager import ActiveConnectionState NM_BUS_NAME = 'org.freedesktop.NetworkManager' NM_OBJECT_PATH = '/org/freedesktop/NetworkManager' NM_SETTINGS_OBJECT_PATH = '/org/freedesktop/NetworkManagerSettings' NM_SETTINGS = 'org.freedesktop.NetworkManagerSettings' NM_INTERFACE = 'org.freedesktop.NetworkManager' NM_SETTINGS_CONNECTION = 'org.freedesktop.NetworkManagerSettings.Connection'