#coding=utf-8

from view.setting.teriminalset import Ui_Form
from PyQt4.Qt import QString, QDialog
from PyQt4.QtCore import Qt,SIGNAL

import controller.terminaltool.usblist
import controller.terminaltool.netservice
from common.globalfun import moveWidgetToScreenCenter

class TerminalTools(QDialog,Ui_Form):
    def __init__(self):
        super(TerminalTools,self).__init__()
        self.setupUi(self)
        flags = Qt.FramelessWindowHint
        self.setWindowFlags(flags)
        self.frame.setStyleSheet(QString("QWidget#frame{border-image: url(../images/terminaltool.png);}"))
        self.frame.setAttribute(Qt.WA_TransparentForMouseEvents)
        
        _usbList=controller.terminaltool.usblist.UsbList()
        _netService=controller.terminaltool.netservice.NetService()
        
        self.tabWidget.addTab(_netService, QString.fromUtf8("网络诊断"))
        self.tabWidget.addTab(_usbList, QString.fromUtf8("USB硬件列表"))
        self.mousePressed = False
        self.connect(self.pushButtonQuit, SIGNAL("clicked()"),self.close)
        
        _netService.runButton.setFocus()
        moveWidgetToScreenCenter(self)
        
        
    def mouseMoveEvent(self,event):
        if self.mousePressed:
            self.move(self.pos() + event.pos() - self.currentPos)   
        self.default = QString()
    def mousePressEvent(self,event):
        if event.buttons() == Qt.LeftButton:
            self.currentPos = event.pos()
            self.mousePressed = True
    def mouseReleaseEvent(self,event):
        if event.buttons() == Qt.LeftButton:
            self.mousePressed = False
        