def setupWidgets(self): self.catalog = TTabWidget(standart_page_widget=TTreeWidget) dock = QtGui.QDockWidget("Dir Tree", self) dock.setWidget(self.catalog) dock.setFeatures(QtGui.QDockWidget.AllDockWidgetFeatures) self.addDockWidget(Qt.Qt.LeftDockWidgetArea, dock) self.video_prev = VideoPreview() dock = QtGui.QDockWidget("Preview", self) dock.setWidget(self.video_prev) dock.setFeatures(QtGui.QDockWidget.AllDockWidgetFeatures) self.addDockWidget(Qt.Qt.LeftDockWidgetArea, dock) self.items_list = TTableWidget() self.setCentralWidget(self.items_list) self.filter_lineedit = QtGui.QLineEdit() self.filter_lineedit.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) self.combo_box = QtGui.QComboBox() self.combo_box.addItem("Filename") self.combo_box.addItem("Format") self.combo_box.addItem("Codec") self.combo_box.addItem("Duration") self.combo_box.addItem("Resolution") self.combo_box.addItem("Tags") self.combo_box.setCurrentIndex(0) self.createActions() self.createToolbar() self.configureSignals()
class MainWindow(QtGui.QMainWindow): sql = TSQL() def __init__(self): super(self.__class__, self).__init__() self.sql.connect("DB.dbf") self.sql.initTables() self.setupWidgets() # self.mi = MediaInfo.media_info() self.run() def setupWidgets(self): self.catalog = TTabWidget(standart_page_widget=TTreeWidget) dock = QtGui.QDockWidget("Dir Tree", self) dock.setWidget(self.catalog) dock.setFeatures(QtGui.QDockWidget.AllDockWidgetFeatures) self.addDockWidget(Qt.Qt.LeftDockWidgetArea, dock) self.video_prev = VideoPreview() dock = QtGui.QDockWidget("Preview", self) dock.setWidget(self.video_prev) dock.setFeatures(QtGui.QDockWidget.AllDockWidgetFeatures) self.addDockWidget(Qt.Qt.LeftDockWidgetArea, dock) self.items_list = TTableWidget() self.setCentralWidget(self.items_list) self.filter_lineedit = QtGui.QLineEdit() self.filter_lineedit.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) self.combo_box = QtGui.QComboBox() self.combo_box.addItem("Filename") self.combo_box.addItem("Format") self.combo_box.addItem("Codec") self.combo_box.addItem("Duration") self.combo_box.addItem("Resolution") self.combo_box.addItem("Tags") self.combo_box.setCurrentIndex(0) self.createActions() self.createToolbar() self.configureSignals() def createActions(self): self.newAct = QtGui.QAction(QtGui.QIcon(r"icons\new.png"), "&New", self, shortcut="Ctrl+N", statusTip="New collection", triggered=self.fileNewClicked) self.openAct = QtGui.QAction(QtGui.QIcon(r"icons\open.png"), "&Open", self, shortcut="Ctrl+O", statusTip="Open collection", triggered=self.fileOpenClicked) self.saveAct = QtGui.QAction(QtGui.QIcon(r"icons\save.png"), "&Save", self, shortcut="Ctrl+S", statusTip="Apply changes", triggered=self.fileSaveClicked) self.exitAct = QtGui.QAction(QtGui.QIcon(r"icons\exit.png"), "&Quit", self, shortcut="Ctrl+Q", statusTip="Close application", triggered=self.fileExitClicked) self.addAct = QtGui.QAction(QtGui.QIcon(r"icons\add.png"), "&Add Category", self, shortcut="Ctrl+Ins", statusTip="Add files", triggered=self.editAddClicked) self.addChildAct = QtGui.QAction(QtGui.QIcon(r"icons\add_node.png"), "&Add Subcztegory", self, shortcut="Ctrl+Shift+Ins", statusTip="Add Subcategory", triggered=self.editAddChild) self.reloadAct = QtGui.QAction(QtGui.QIcon(r"icons\reload.png"), "&Add Category", self, shortcut="Ctrl+R", statusTip="Reload", triggered=self.reloadClicked) self.deleteAct = QtGui.QAction(QtGui.QIcon(r"icons\del.png"), "&Delete", self, shortcut="Del", statusTip="Delete", triggered=self.editDeleteClicked) self.undoAct = QtGui.QAction(QtGui.QIcon(r"icons\undo.png"), "&Undo", self, shortcut="Ctrl+Z", statusTip="Undo the last action", triggered=self.editUndoClicked) self.redoAct = QtGui.QAction(QtGui.QIcon(r"icons\redo.png"), "&Redo", self, shortcut="Ctrl+U", statusTip="Redo the last action", triggered=self.editRedoClicked) def createToolbar(self): fileToolbar = self.addToolBar("&File") fileToolbar.setIconSize(QtCore.QSize(24,24)) fileToolbar.addAction(self.newAct) fileToolbar.addAction(self.openAct) fileToolbar.addAction(self.saveAct) fileToolbar.addAction(self.exitAct) editToolbar = self.addToolBar("&Edit") editToolbar.setIconSize(QtCore.QSize(24,24)) editToolbar.addAction(self.addAct) # editToolbar.addAction(self.addChildAct) editToolbar.addAction(self.deleteAct) editToolbar.addAction(self.reloadAct) # editToolbar.addAction(self.undoAct) # editToolbar.addAction(self.redoAct) filterToolbar = self.addToolBar("&Filter") filterToolbar.addWidget(QtGui.QLabel("Filter: ")) filterToolbar.addWidget(self.filter_lineedit) filterToolbar.addWidget(QtGui.QLabel(" by: ")) filterToolbar.addWidget(self.combo_box) def configureSignals(self): self.filter_lineedit.textChanged.connect(self.filterValChange) self.combo_box.currentIndexChanged.connect(self.filterValChange) self.catalog.widgetSelectionChanged.connect(self.items_list.updateTableByID) self.catalog.filesUrlsDropped.connect(self.items_list.updateDataByFilesId) self.items_list.currentItemChanged.connect(self.video_prev.setSourse) # self.catalog.readyToSave.connect(self.sql.saveData) def fileNewClicked(self): pass def fileOpenClicked(self): pass def fileSaveClicked(self): save_data = self.catalog.prepareDataToSave() self.sql.saveData((("pages", save_data[0]), ("nodes", save_data[1]))) def fileExitClicked(self): self.close() def editAddClicked(self): self.focusWidget().addAct.emit() def editAddChild(self): pass def reloadClicked(self): pass def editDeleteClicked(self): self.focusWidget().delAct.emit() def editUndoClicked(self): pass def editRedoClicked(self): pass def filterValChange(self): pass def run(self): self.catalog.loadWidgetsData((self.sql.getTableData("pages"), self.sql.getTableData("nodes")))