コード例 #1
0
ファイル: connection.py プロジェクト: Tayyib/uludag
 def __init__(self, parent, name, link_name, is_new=0):
     QMainWindow.__init__(self, parent)
     self.name = name
     self.link_name = link_name
     
     self.setCaption(i18n("Configure network connection"))
     self.setMinimumSize(580, 380)
     
     vb = QVBox(self)
     vb.setMargin(6)
     vb.setSpacing(6)
     self.setCentralWidget(vb)
     
     tab = QTabWidget(vb)
     self.tab = tab
     
     self.basic = BasicTab(tab)
     tab.addTab(self.basic, i18n("Basic"))
     
     hb = QHBox(vb)
     hb.setSpacing(12)
     but = QPushButton(i18n("Connect"), hb)
     self.connect(but, SIGNAL("clicked()"), self.slotConnect)
     but = QPushButton(i18n("Accept"), hb)
     self.connect(but, SIGNAL("clicked()"), self.slotAccept)
     but = QPushButton(i18n("Cancel"), hb)
     self.connect(but, SIGNAL("clicked()"), self.slotCancel)
     
     self.w_name = self.basic.name.edit
     self.w_device = self.basic.device.device
     self.w_address = self.basic.address.address.edit
     self.w_gateway = self.basic.address.gateway.edit
     self.w_remote = self.basic.device.remote
     self.w_remote_label = self.basic.device.remote_label
     self.w_remote_scan = self.basic.device.remote_scan
     self.device_list = {}
     
     self.connect(self.w_remote_scan, SIGNAL("clicked()"), self.slotScan)
     
     lname = links.get_info(self.link_name).remote_name
     # what a hack! :)
     if lname == "Phone number":
         lname = i18n("Phone number")
     self.w_remote_label.setText(lname)
     self.show()
     
     self.w_name.setText(unicode(name))
     
     self.comar = comar.Link()
     self.comar.call_package("Net.Link.modes", link_name, id=3)
     if is_new:
         self.device = i18n("No device")
         self.comar.call_package("Net.Link.deviceList", link_name, id=1)
     else:
         self.comar.call_package("Net.Link.getAddress", link_name, [ "name", name ], id=2)
         self.comar.call_package("Net.Link.connectionInfo", link_name, [ "name", name ], id=4)
     
     self.notifier = QSocketNotifier(self.comar.sock.fileno(), QSocketNotifier.Read)
     self.connect(self.notifier, SIGNAL("activated(int)"), self.slotComar)
コード例 #2
0
ファイル: mainwin.py プロジェクト: Tayyib/uludag
 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))
コード例 #3
0
ファイル: mainwin.py プロジェクト: Tayyib/uludag
 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()
コード例 #4
0
ファイル: mainwin.py プロジェクト: Tayyib/uludag
 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))