def setupUI(self): rc = RcModel() self.hook = HookModel() self.setStyleSheet(rc.getCssString()) self.setWindowTitle(const.UI_MAIN_WINDOW_TITLE) # self.showMaximized() self.resize(1024, 768) self.centralWidget = Gui.QWidget(self) self.setCentralWidget(self.centralWidget) self.process_list = Gui.QComboBox() self.process_list.setParent(self.centralWidget) self.process_list.resize(300, 25) self.process_list.move(5, 5) self.btn_refresh = Gui.QPushButton() self.btn_refresh.setText('refresh') self.btn_refresh.setParent(self.centralWidget) self.btn_refresh.move(310, 5) self.btn_detach = Gui.QPushButton() self.btn_detach.setText('detach') self.btn_detach.setParent(self.centralWidget) self.btn_detach.move(self.btn_refresh.x()+100, 5) self.edit_proto = Gui.QLineEdit() self.edit_proto.setParent(self.centralWidget) self.edit_proto.move(5, 35)
def __init__(self, parent, title): super(EntityNode, self).__init__(QtGui.QWidget, parent, const.CSS_WIDGET_ENTITY) self.label = QtGui.QLabel() self.label.setObjectName(const.CSS_LABEL_TAG_NODE) self.label.move(4, 4) self.addWidget(self.label) if title: self.setTitle(title) #todo 功能栏 :音频预览 打开文件位置 设置为封面 #todo audio preview #todo open in explorer #todo set cover #todo func icon ''' ''' self.func_widget = QtGui.QWidget() self.func_widget.setObjectName(const.CSS_WIDGET_TAG_NODE_FUNC) self.addWidget(self.func_widget) self.func_widget.move(300, 4) self.func_widget.resize(150, 30) self.func_list = list() # self.preview_button = self.add_func_button('A', self.preview_audio) # self.dir_button = self.add_func_button('F', self.open_dir) # self.set_cover_button = self.add_func_button('C', self.set_cover) self.set_cover_button.mouseMoveEvent = self.mouseMoveEvent self.res = RcModel() self.override()
def __init__(self, parent): super(EntityTree, self).__init__(QtGui.QWidget, parent, const.CSS_WIDGET_DIR_TREE) self.resize(800, 800) self.override() # self.add_listener() self.tag_list_widget = QtGui.QWidget(self.base) self.tag_list_widget.setObjectName(const.CSS_WIDGET_DIR_TREE) self.tag_list_widget.resize(self.base.width(), self.base.height() - 30) self.tag_list_widget.move(0, 35) self.vScroll_bar = QtGui.QScrollBar(self.base) self.vScroll_bar.setOrientation(QtCore.Qt.Vertical) self.vScroll_bar.resize(15, self.tag_list_widget.height()) self.vScroll_bar.move(self.width() - self.vScroll_bar.width() - 5, self.tag_list_widget.y()) self.base.connect(self.vScroll_bar, QtCore.SIGNAL(const.VALUE_CHANGED), self.on_vScroll_changed) self.scroll_y = 0 rc = RcModel() self.icon = rc.getCopy(1, 0)
def setupUI(self): rc = RcModel() self.setStyleSheet(rc.getCssString()) self.setWindowTitle(const.UI_MAIN_WINDOW_TITLE) self.showMaximized() self.centralWidget = Gui.QWidget(self) self.setCentralWidget(self.centralWidget) ''' 菜单 ''' self.menu_bar = MenuBar(self) self.setMenuBar(self.menu_bar) ''' 目录 ''' self.dir_tree = DirTree(self.centralWidget) self.dir_tree.move(10, 5) self.entity = EntityTree(self.centralWidget) self.entity.move(400, 5)
class EntityNode(CssQBase): func_list = None press = False def __init__(self, parent, title): super(EntityNode, self).__init__(QtGui.QWidget, parent, const.CSS_WIDGET_ENTITY) self.label = QtGui.QLabel() self.label.setObjectName(const.CSS_LABEL_TAG_NODE) self.label.move(4, 4) self.addWidget(self.label) if title: self.setTitle(title) #todo 功能栏 :音频预览 打开文件位置 设置为封面 #todo audio preview #todo open in explorer #todo set cover #todo func icon ''' ''' self.func_widget = QtGui.QWidget() self.func_widget.setObjectName(const.CSS_WIDGET_TAG_NODE_FUNC) self.addWidget(self.func_widget) self.func_widget.move(300, 4) self.func_widget.resize(150, 30) self.func_list = list() # self.preview_button = self.add_func_button('A', self.preview_audio) # self.dir_button = self.add_func_button('F', self.open_dir) # self.set_cover_button = self.add_func_button('C', self.set_cover) self.set_cover_button.mouseMoveEvent = self.mouseMoveEvent self.res = RcModel() self.override() def override(self): self.base.dragEnterEvent = self.dragEnterEvent self.base.dropEvent = self.dropEvent self.base.setAcceptDrops(True) def update(self, filename): self.setTitle(filename) self.show() def mouseMoveEvent(self, e): if not self.press: return mimeData = QtCore.QMimeData() drag = QtGui.QDrag(self.base) drag.setMimeData(mimeData) drag.setPixmap(self.res.getCopy(4, 0)) dropAction = drag.start(QtCore.Qt.MoveAction) print("....") def dropEvent(self, e): print('dropEvent') def dragEnterEvent(self, e): e.accept() # if e.mimeDate().hasFormat('text/plain'): # e.accept() # else: # e.ignore() def add_func_button(self, text, func=None): button = QtGui.QPushButton("Toggle Button", self.func_widget) button.setText(text) button.move(len(self.func_list) * 28 + 2, 2) button.resize(26, 26) button.mousePressEvent = func self.func_list.append(button) return button def preview_audio(self, *args): p = Preview() print self, p t = Thread() if p.playing: # if t.isAlive(): p.stop() print __name__, ">>stop..." else: self.play() # try: # # t.setDaemon(True) # t.run = self.play # t.start() # except Exception, e: # print e print 'preview audio file', args def play(self): p = Preview() p.open(model.get_file_url(self.getTitle())) p.play() def open_dir(self, *args): p = Preview() p.stop() print 'open file in explorer', args def set_cover(self, *args): self.press = True # QtGui.QPushButton.mousePressEvent(self.set_cover_button, *args) print 'set cover', args def setTitle(self, title): self.label.setText(title) def getTitle(self): return str(self.label.text()) def free(self): self.hide() # self.icon = QtGui.QPixmap(self) # self.icon.load('tmp/icon.png')