Example #1
0
    def __init__(self, parent):
        NewConn.__init__(self, parent)

        self.links.header().hide()
        self.fillLabels()

        self.connect(self.links, SIGNAL("doubleClicked(QListViewItem *, const QPoint &, int)"), self.slotDouble)
        self.connect(self.links, SIGNAL("selectionChanged()"), self.slotSelection)
        self.connect(self.links, SIGNAL("collapsed(QListViewItem *)"), self.slotCollapse)

        links = comlink.links.values()
        links.sort(key=lambda x: x.name)

        comlink.device_hook.append(self.slotDevices)

        for link in links:
            item = QListViewItem(self.links)
            item.setSelectable(False)
            item.setPixmap(0, icons.get_state(link.type, "up"))
            item.setText(1, unicode(link.name))
            item.setText(2, link.script)
            item.setOpen(True)
            comlink.queryDevices(link.script)

        self.connect(self.createBut, SIGNAL("clicked()"), self.accept)
        self.connect(self.cancelBut, SIGNAL("clicked()"), self.reject)

        self.show()
Example #2
0
 def updateState(self):
     self.ignore_signal = True
     self.check.setChecked(self.conn.state in ("up", "connecting", "inaccessible"))
     self.ignore_signal = False
     self.mypix = icons.get_state(comlink.links[self.conn.script].type, self.conn.state)
     if self.conn.state in ("inaccessible", "unavailable"):
         self.mypix = KIconEffect().apply(self.mypix, KIconEffect.ToGray, 1, QColor(), False)
     self.update()
Example #3
0
 def updateState(self):
     self.ignore_signal = True
     self.check.setChecked(self.conn.state in ("up", "connecting", "inaccessible"))
     self.ignore_signal = False
     self.mypix = icons.get_state(comlink.links[self.conn.script].type, self.conn.state)
     if self.conn.state in ("inaccessible", "unavailable"):
         self.mypix = KIconEffect().apply(self.mypix, KIconEffect.ToGray, 1, QColor(), False)
     self.update()
Example #4
0
    def __init__(self, parent):
        QDialog.__init__(self, parent)
        self.setMinimumSize(340, 340)
        self.resize(340, 340)
        self.setCaption(i18n("Create a new connection"))
        vb = QVBoxLayout(self)
        vb.setSpacing(6)
        vb.setMargin(12)

        lab = QLabel(i18n("Select device:"), self)
        vb.addWidget(lab)

        self.links = QListView(self)
        self.connect(
            self.links,
            SIGNAL("doubleClicked(QListViewItem *, const QPoint &, int)"),
            self.slotDouble)
        self.connect(self.links, SIGNAL("selectionChanged()"),
                     self.slotSelection)
        self.connect(self.links, SIGNAL("collapsed(QListViewItem *)"),
                     self.slotCollapse)
        self.links.setAllColumnsShowFocus(True)
        vb.addWidget(self.links)
        self.links.addColumn("")
        self.links.addColumn("")
        self.links.header().hide()
        links = comlink.links.values()
        links.sort(key=lambda x: x.name)

        comlink.device_hook.append(self.slotDevices)
        for link in links:
            item = QListViewItem(self.links)
            item.setSelectable(False)
            item.setPixmap(0, icons.get_state(link.type, "up"))
            item.setText(1, unicode(link.name))
            item.setText(2, link.script)
            item.setOpen(True)
            comlink.queryDevices(link.script)

        hb = QHBox(self)
        hb.setSpacing(6)
        but = QPushButton(getIconSet("add", KIcon.Small), i18n("Create"), hb)
        but.setEnabled(False)
        self.connect(but, SIGNAL("clicked()"), self.accept)
        but.setDefault(True)
        self.but = but

        but = QPushButton(
            getIconSet("cancel", KIcon.Small), i18n("Cancel"), hb)
        self.connect(but, SIGNAL("clicked()"), self.reject)

        vb.addWidget(hb)
        self.show()
Example #5
0
 def paint(self, painter):
     if self.online == "up":
         text = unicode(i18n("Online")) + ", "
     else:
         text = unicode(i18n("Offline")) + ", "
     fm = QFontMetrics(self.f1)
     fm2 = QFontMetrics(self.f2)
     painter.setPen(Qt.black)
     painter.setFont(self.f1)
     painter.drawText(48 + 9, 3 + fm.ascent(), unicode(self.name))
     painter.setFont(self.f2)
     painter.drawText(48 + 9, 3 + fm.height() + 3 + fm2.ascent(),
         "%s" % (self.device_name))
     painter.drawText(48 + 9, 3 + fm.height() + 3 + fm2.height() + 3 + fm2.ascent()
         , text + self.address)
     painter.drawPixmap(3, 3, icons.get_state(links.get_info(self.link_name).type, self.online))
Example #6
0
    def __init__(self, view, conn):
        self.is_odd = 0
        dev = view.devices.get(conn.devid, None)
        if not dev:
            dev = Device(view, conn.devname, conn.devid)
            dev.show()
        QWidget.__init__(self, dev)
        self.tipper = ConnectionTipper(self)
        self.tipper.parent = self
        dev.connections.append(self)

        self.view = view
        self.conn = conn

        self.edit = None

        self.mypix = icons.get_state(comlink.links[conn.script].type,
                                     conn.state)
        if self.conn.state in ("inaccessible", "unavailable"):
            self.mypix = KIconEffect().apply(self.mypix, KIconEffect.ToGray, 1,
                                             QColor(), False)
        self.check = QCheckBox(self)
        self.check.setChecked(self.conn.state in ("up", "connecting",
                                                  "inaccessible"))
        QToolTip.add(self.check, i18n("Turn on/off connection"))
        self.check.setGeometry(6, 3, 16, 16)
        self.connect(self.check, SIGNAL("toggled(bool)"), self.slotToggle)
        self.check.setAutoMask(True)

        w = self.check.width()
        self.pix_start = 6 + w + 3
        w = self.mypix.width()
        self.text_start = self.pix_start + w + 6

        view.connections[conn.hash] = self

        self.edit_but = IconButton("configure", self)
        QToolTip.add(self.edit_but, i18n("Configure connection"))
        self.connect(self.edit_but, SIGNAL("clicked()"), self.slotEdit)
        self.del_but = IconButton("cancel", self)
        QToolTip.add(self.del_but, i18n("Delete connection"))
        self.connect(self.del_but, SIGNAL("clicked()"), self.slotDelete)

        self.show()

        self.ignore_signal = False
Example #7
0
 def __init__(self, view, conn):
     self.is_odd = 0
     dev = view.devices.get(conn.devid, None)
     if not dev:
         dev = Device(view, conn.devname, conn.devid)
         dev.show()
     QWidget.__init__(self, dev)
     self.tipper = ConnectionTipper(self)
     self.tipper.parent = self
     dev.connections.append(self)
     
     self.view = view
     self.conn = conn
     
     self.edit = None
     
     self.mypix = icons.get_state(comlink.links[conn.script].type, conn.state)
     if self.conn.state in ("inaccessible", "unavailable"):
         self.mypix = KIconEffect().apply(self.mypix, KIconEffect.ToGray, 1, QColor(), False)
     self.check = QCheckBox(self)
     self.check.setChecked(self.conn.state in ("up", "connecting", "inaccessible"))
     QToolTip.add(self.check, i18n("Turn on/off connection"))
     self.check.setGeometry(6, 3, 16, 16)
     self.connect(self.check, SIGNAL("toggled(bool)"), self.slotToggle)
     self.check.setAutoMask(True)
     
     w = self.check.width()
     self.pix_start = 6 + w + 3
     w = self.mypix.width()
     self.text_start = self.pix_start + w + 6
     
     view.connections[conn.hash] = self
     
     self.edit_but = IconButton("configure", self)
     QToolTip.add(self.edit_but, i18n("Configure connection"))
     self.connect(self.edit_but, SIGNAL("clicked()"), self.slotEdit)
     self.del_but = IconButton("cancel", self)
     QToolTip.add(self.del_but, i18n("Delete connection"))
     self.connect(self.del_but, SIGNAL("clicked()"), self.slotDelete)
     
     self.show()
     
     self.ignore_signal = False
Example #8
0
 def updateState(self, state):
     msg = ""
     if "\n" in state:
         state, msg = state.split("\n", 1)
     if state == "on":
         self.active = True
     elif state == "off":
         self.active = False
     elif state in ("up", "connecting", "down"):
         self.state = state
     
     if state == "down":
         self.got_address = None
     
     self.ignore_signal = True
     self.check.setChecked(self.active)
     self.ignore_signal = False
     self.mypix = icons.get_state(links.get_info(self.script).type, self.state)
     
     self.update()
Example #9
0
 def paint(self, painter):
     tc = self.listBox().colorGroup().text()
     i = self.listBox().index(self)
     if i / 2 * 2 != i and not self.isSelected():
         bc = self.listBox().colorGroup().light()
         bc2 = QColor(bc.red() - 15, bc.green() - 15, bc.blue())
         painter.fillRect(painter.window(), QBrush(bc2))
     
     if self.state == "up":
         text = unicode(i18n("Active")) + ", "
     else:
         text = unicode(i18n("Inactive")) + ", "
     fm = QFontMetrics(self.f1)
     fm2 = QFontMetrics(self.f2)
     painter.setPen(tc)
     painter.setFont(self.f1)
     painter.drawText(48 + 9, 3 + fm.ascent(), unicode(self.name))
     painter.setFont(self.f2)
     painter.drawText(48 + 9, 3 + fm.height() + 3 + fm2.ascent(),
         "%s" % (self.device_name))
     painter.drawText(48 + 9, 3 + fm.height() + 3 + fm2.height() + 3 + fm2.ascent()
         , text + self.address)
     painter.drawPixmap(3, 3, icons.get_state(links.get_info(self.link_name).type, self.online))
Example #10
0
 def __init__(self, view, script, data):
     name, devid, devname = unicode(data).split("\n")
     dev = view.devices.get(devid, None)
     if not dev:
         dev = Device(view, devname, devid)
         dev.show()
     QWidget.__init__(self, dev)
     dev.connections.append(self)
     
     self.name = name
     self.script = script
     self.devid = devid
     self.active = False
     self.state = "down"
     self.address = ""
     self.got_address = None
     
     fm = self.fontMetrics()
     self.myBase = fm.ascent()
     self.myHeight = fm.height()
     self.mypix = icons.get_state("net", self.state)
     self.check = QCheckBox(self)
     self.connect(self.check, SIGNAL("toggled(bool)"), self.slotToggle)
     self.check.setAutoMask(True)
     self.edit_but = MinButton(i18n("Edit"), self)
     self.connect(self.edit_but, SIGNAL("clicked()"), self.slotEdit)
     self.del_but = MinButton(i18n("Delete"), self)
     self.connect(self.del_but, SIGNAL("clicked()"), self.slotDelete)
     view.connections[connHash(script, name)] = self
     self.show()
     
     self.view = view
     view.comlink.call_package("Net.Link.getAddress", script, [ "name", name ], id=3)
     view.comlink.call_package("Net.Link.getState", script, [ "name", name ], id=4)
     
     self.ignore_signal = False