예제 #1
0
    def setupUi(self):
        self.Title = QtGui.QLineEdit()
        self.Writers = ListWidget()
        self.Writers.setFixedHeight(120)
        self.Publisher = QtGui.QLineEdit()
        self.Categories = ListWidget()
        self.Categories.setFixedHeight(120)
        self.SerieName = QtGui.QLineEdit()
        self.SerieNo = QtGui.QLineEdit()
        self.Language = QtGui.QLineEdit()
        self.Pages = QtGui.QLineEdit()
        self.IsRead = QtGui.QCheckBox(self.tr("Read"))
        self.Excerpt = QtGui.QTextEdit()
        self.Cover = Cover()

        SerieLayout = QtGui.QHBoxLayout()
        SerieLayout.addWidget(self.SerieName)
        SerieLayout.addWidget(self.SerieNo)
        SerieLayout.setStretch(0,5)
        SerieLayout.setStretch(1,1)
        SerieLayout.setSpacing(20)
        self.SerieName.setPlaceholderText(self.tr("Name"))
        self.SerieNo.setPlaceholderText(self.tr("No"))

        OtherLayout = QtGui.QHBoxLayout()
        OtherLayout.addWidget(self.Language)
        OtherLayout.addWidget(self.Pages)
        OtherLayout.setStretch(0,5)
        OtherLayout.setStretch(1,1)
        OtherLayout.setSpacing(20)
        self.Language.setPlaceholderText(self.tr("Language"))
        self.Pages.setPlaceholderText(self.tr("Pages"))
        
        FormLayout = QtGui.QFormLayout()
        FormLayout.setRowWrapPolicy(FormLayout.WrapLongRows)
        FormLayout.setSpacing(10)
        FormLayout.addRow(self.tr("Title"), self.Title)
        FormLayout.addRow(self.tr("Writers"), self.Writers)
        FormLayout.addRow(self.tr("Publisher"), self.Publisher)
        FormLayout.addRow(self.tr("Categories"), self.Categories)
        FormLayout.addRow(self.tr("Serie"), SerieLayout)
        FormLayout.addRow(self.tr("Other"), OtherLayout)

        Tab = QtGui.QTabWidget()
        Tab.addTab(self.Excerpt,self.tr("Excerpt"))

        Layout = QtGui.QGridLayout()
        Layout.addLayout(FormLayout,0,0,2,1)
        Layout.addWidget(self.Cover,0,1)
        Layout.addWidget(self.IsRead,1,1,QtCore.Qt.AlignHCenter)
        Layout.addWidget(Tab,2,0,1,2)
        Layout.setSpacing(30)

        self.setLayout(Layout)
예제 #2
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(720, 517)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.centralwidget)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.groupBox = QtWidgets.QGroupBox(self.centralwidget)
        self.groupBox.setTitle("")
        self.groupBox.setObjectName("groupBox")
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.groupBox)
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.tabWidget = QtWidgets.QTabWidget(self.groupBox)
        self.tabWidget.setObjectName("tabWidget")
        self.tab_new_task = QtWidgets.QWidget()
        self.tab_new_task.setObjectName("tab_new_task")
        self.gridLayout = QtWidgets.QGridLayout(self.tab_new_task)
        self.gridLayout.setObjectName("gridLayout")
        self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_4.setObjectName("horizontalLayout_4")
        self.label = QtWidgets.QLabel(self.tab_new_task)
        self.label.setObjectName("label")
        self.horizontalLayout_4.addWidget(self.label)
        self.lb_current_site = QtWidgets.QPushButton(self.tab_new_task)
        self.lb_current_site.setMinimumSize(QtCore.QSize(75, 23))
        font = QtGui.QFont()
        font.setUnderline(True)
        self.lb_current_site.setFont(font)
        self.lb_current_site.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.lb_current_site.setCheckable(False)
        self.lb_current_site.setFlat(True)
        self.lb_current_site.setObjectName("lb_current_site")
        self.horizontalLayout_4.addWidget(self.lb_current_site)
        self.gridLayout.addLayout(self.horizontalLayout_4, 0, 0, 1, 1)
        self.horizontalLayout_5 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_5.setObjectName("horizontalLayout_5")
        self.lb_task_name = QtWidgets.QLabel(self.tab_new_task)
        self.lb_task_name.setMaximumSize(QtCore.QSize(48, 16777215))
        self.lb_task_name.setObjectName("lb_task_name")
        self.horizontalLayout_5.addWidget(self.lb_task_name)
        self.le_task_name = QtWidgets.QLineEdit(self.tab_new_task)
        self.le_task_name.setMaximumSize(QtCore.QSize(316, 16777215))
        self.le_task_name.setObjectName("le_task_name")
        self.horizontalLayout_5.addWidget(self.le_task_name)
        self.gridLayout.addLayout(self.horizontalLayout_5, 0, 1, 1, 1)
        self.horizontalLayout_6 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_6.setObjectName("horizontalLayout_6")
        self.lb_search_conditions = QtWidgets.QLabel(self.tab_new_task)
        self.lb_search_conditions.setMaximumSize(QtCore.QSize(66, 16777215))
        self.lb_search_conditions.setObjectName("lb_search_conditions")
        self.horizontalLayout_6.addWidget(self.lb_search_conditions)
        self.le_search_keywords = QtWidgets.QLineEdit(self.tab_new_task)
        self.le_search_keywords.setMaximumSize(QtCore.QSize(420, 16777215))
        self.le_search_keywords.setObjectName("le_search_keywords")
        self.horizontalLayout_6.addWidget(self.le_search_keywords)
        self.gridLayout.addLayout(self.horizontalLayout_6, 1, 0, 1, 2)
        self.horizontalLayout_7 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_7.setObjectName("horizontalLayout_7")
        self.pb_Ok = QtWidgets.QPushButton(self.tab_new_task)
        self.pb_Ok.setObjectName("pb_Ok")
        self.horizontalLayout_7.addWidget(self.pb_Ok)
        self.pb_Cancel = QtWidgets.QPushButton(self.tab_new_task)
        self.pb_Cancel.setObjectName("pb_Cancel")
        self.horizontalLayout_7.addWidget(self.pb_Cancel)
        self.gridLayout.addLayout(self.horizontalLayout_7, 2, 2, 1, 1)
        self.tabWidget.addTab(self.tab_new_task, "")
        self.tab_running_tasks = QtWidgets.QWidget()
        self.tab_running_tasks.setObjectName("tab_running_tasks")
        self.horizontalLayout_8 = QtWidgets.QHBoxLayout(self.tab_running_tasks)
        self.horizontalLayout_8.setObjectName("horizontalLayout_8")
        self.groupBox_2 = QtWidgets.QGroupBox(self.tab_running_tasks)
        self.groupBox_2.setMaximumSize(QtCore.QSize(280, 16777215))
        self.groupBox_2.setObjectName("groupBox_2")
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.groupBox_2)
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        self.lw_processing_tasks = TaskRunningTable(self.groupBox_2)
        self.lw_processing_tasks.setMinimumSize(QtCore.QSize(100, 0))
        self.lw_processing_tasks.setMaximumSize(QtCore.QSize(300, 16777215))
        self.lw_processing_tasks.setObjectName("lw_processing_tasks")
        self.lw_processing_tasks.setColumnCount(2)
        self.lw_processing_tasks.setRowCount(0)
        item = QtWidgets.QTableWidgetItem()
        self.lw_processing_tasks.setHorizontalHeaderItem(0, item)
        item = QtWidgets.QTableWidgetItem()
        self.lw_processing_tasks.setHorizontalHeaderItem(1, item)
        self.horizontalLayout_3.addWidget(self.lw_processing_tasks)
        self.horizontalLayout_8.addWidget(self.groupBox_2)
        self.groupBox_4 = QtWidgets.QGroupBox(self.tab_running_tasks)
        self.groupBox_4.setObjectName("groupBox_4")
        self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.groupBox_4)
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        self.tw_processing_task_details = QtWidgets.QTableWidget(self.groupBox_4)
        self.tw_processing_task_details.setObjectName("tw_processing_task_details")
        self.tw_processing_task_details.setColumnCount(0)
        self.tw_processing_task_details.setRowCount(0)
        self.verticalLayout_3.addWidget(self.tw_processing_task_details)
        self.horizontalLayout_8.addWidget(self.groupBox_4)
        self.tabWidget.addTab(self.tab_running_tasks, "")
        self.tab_completed_tasks = QtWidgets.QWidget()
        self.tab_completed_tasks.setObjectName("tab_completed_tasks")
        self.horizontalLayout = QtWidgets.QHBoxLayout(self.tab_completed_tasks)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.groupBox_3 = QtWidgets.QGroupBox(self.tab_completed_tasks)
        self.groupBox_3.setMaximumSize(QtCore.QSize(191, 16777215))
        self.groupBox_3.setObjectName("groupBox_3")
        self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.groupBox_3)
        self.verticalLayout_5.setObjectName("verticalLayout_5")
        self.lw_finished_tasks = ListWidget(self.groupBox_3)
        self.lw_finished_tasks.setMaximumSize(QtCore.QSize(171, 16777215))
        self.lw_finished_tasks.setObjectName("lw_finished_tasks")
        self.verticalLayout_5.addWidget(self.lw_finished_tasks)
        self.horizontalLayout.addWidget(self.groupBox_3)
        self.groupBox_5 = QtWidgets.QGroupBox(self.tab_completed_tasks)
        self.groupBox_5.setObjectName("groupBox_5")
        self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.groupBox_5)
        self.verticalLayout_4.setObjectName("verticalLayout_4")
        self.tw_finished_task_details = QtWidgets.QTableWidget(self.groupBox_5)
        self.tw_finished_task_details.setObjectName("tw_finished_task_details")
        self.tw_finished_task_details.setColumnCount(0)
        self.tw_finished_task_details.setRowCount(0)
        self.verticalLayout_4.addWidget(self.tw_finished_task_details)
        self.horizontalLayout.addWidget(self.groupBox_5)
        self.tabWidget.addTab(self.tab_completed_tasks, "")
        self.tab_history = QtWidgets.QWidget()
        self.tab_history.setObjectName("tab_history")
        self.tabWidget.addTab(self.tab_history, "")
        self.tab_search = QtWidgets.QWidget()
        self.tab_search.setObjectName("tab_search")
        self.tabWidget.addTab(self.tab_search, "")
        self.horizontalLayout_2.addWidget(self.tabWidget)
        self.verticalLayout_2.addWidget(self.groupBox)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 720, 21))
        self.menubar.setObjectName("menubar")
        self.menuFile = QtWidgets.QMenu(self.menubar)
        self.menuFile.setObjectName("menuFile")
        self.menu = QtWidgets.QMenu(self.menubar)
        self.menu.setObjectName("menu")
        self.menu_2 = QtWidgets.QMenu(self.menubar)
        self.menu_2.setObjectName("menu_2")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.toolBar = QtWidgets.QToolBar(MainWindow)
        self.toolBar.setObjectName("toolBar")
        MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)
        self.actionOpen = QtWidgets.QAction(MainWindow)
        self.actionOpen.setObjectName("actionOpen")
        self.actionDebug = QtWidgets.QAction(MainWindow)
        self.actionDebug.setObjectName("actionDebug")
        self.actionAbout = QtWidgets.QAction(MainWindow)
        self.actionAbout.setObjectName("actionAbout")
        self.actionDelete = QtWidgets.QAction(MainWindow)
        self.actionDelete.setObjectName("actionDelete")
        self.actionDeleteFromDisk = QtWidgets.QAction(MainWindow)
        self.actionDeleteFromDisk.setObjectName("actionDeleteFromDisk")
        self.menuFile.addAction(self.actionOpen)
        self.menu.addAction(self.actionDelete)
        self.menu.addAction(self.actionDeleteFromDisk)
        self.menu_2.addAction(self.actionDebug)
        self.menu_2.addSeparator()
        self.menu_2.addAction(self.actionAbout)
        self.menubar.addAction(self.menuFile.menuAction())
        self.menubar.addAction(self.menu.menuAction())
        self.menubar.addAction(self.menu_2.menuAction())
        self.toolBar.addSeparator()

        self.retranslateUi(MainWindow)
        self.tabWidget.setCurrentIndex(0)
        self.lw_finished_tasks.itemClicked['QListWidgetItem*'].connect(MainWindow.onFinishedTasksItemClicked)
        self.pb_Ok.clicked.connect(MainWindow.onNewTask)
        self.lw_processing_tasks.cellContextClicked['QTableWidgetItem*'].connect(MainWindow.onProcessTasksRClicked)
        self.lw_finished_tasks.cellContextClicked['QListWidgetItem*'].connect(MainWindow.onFinishedTasksRClicked)
        self.tabWidget.tabBarClicked['int'].connect(MainWindow.onTabBarClicked)
        self.lb_current_site.clicked.connect(MainWindow.onSelectSite)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
        MainWindow.setTabOrder(self.lw_processing_tasks, self.tw_processing_task_details)
        MainWindow.setTabOrder(self.tw_processing_task_details, self.lw_finished_tasks)
        MainWindow.setTabOrder(self.lw_finished_tasks, self.tabWidget)
        MainWindow.setTabOrder(self.tabWidget, self.tw_finished_task_details)
예제 #3
0
class Book(QtGui.QWidget):
    def __init__(self, parent=None):
        super(Book, self).__init__(parent)

        self.setupUi()

    def setupUi(self):
        self.Title = QtGui.QLineEdit()
        self.Writers = ListWidget()
        self.Writers.setFixedHeight(120)
        self.Publisher = QtGui.QLineEdit()
        self.Categories = ListWidget()
        self.Categories.setFixedHeight(120)
        self.SerieName = QtGui.QLineEdit()
        self.SerieNo = QtGui.QLineEdit()
        self.Language = QtGui.QLineEdit()
        self.Pages = QtGui.QLineEdit()
        self.IsRead = QtGui.QCheckBox(self.tr("Read"))
        self.Excerpt = QtGui.QTextEdit()
        self.Cover = Cover()

        SerieLayout = QtGui.QHBoxLayout()
        SerieLayout.addWidget(self.SerieName)
        SerieLayout.addWidget(self.SerieNo)
        SerieLayout.setStretch(0,5)
        SerieLayout.setStretch(1,1)
        SerieLayout.setSpacing(20)
        self.SerieName.setPlaceholderText(self.tr("Name"))
        self.SerieNo.setPlaceholderText(self.tr("No"))

        OtherLayout = QtGui.QHBoxLayout()
        OtherLayout.addWidget(self.Language)
        OtherLayout.addWidget(self.Pages)
        OtherLayout.setStretch(0,5)
        OtherLayout.setStretch(1,1)
        OtherLayout.setSpacing(20)
        self.Language.setPlaceholderText(self.tr("Language"))
        self.Pages.setPlaceholderText(self.tr("Pages"))
        
        FormLayout = QtGui.QFormLayout()
        FormLayout.setRowWrapPolicy(FormLayout.WrapLongRows)
        FormLayout.setSpacing(10)
        FormLayout.addRow(self.tr("Title"), self.Title)
        FormLayout.addRow(self.tr("Writers"), self.Writers)
        FormLayout.addRow(self.tr("Publisher"), self.Publisher)
        FormLayout.addRow(self.tr("Categories"), self.Categories)
        FormLayout.addRow(self.tr("Serie"), SerieLayout)
        FormLayout.addRow(self.tr("Other"), OtherLayout)

        Tab = QtGui.QTabWidget()
        Tab.addTab(self.Excerpt,self.tr("Excerpt"))

        Layout = QtGui.QGridLayout()
        Layout.addLayout(FormLayout,0,0,2,1)
        Layout.addWidget(self.Cover,0,1)
        Layout.addWidget(self.IsRead,1,1,QtCore.Qt.AlignHCenter)
        Layout.addWidget(Tab,2,0,1,2)
        Layout.setSpacing(30)

        self.setLayout(Layout)

    def fromDict(self, book):
        self.Title.setText(book.get("title",""))
        self.Writers.addItems(book.get("writers",[]))
        self.Publisher.setText(book.get("publisher",""))
        self.Categories.addItems(book.get("categories",[]))
        self.SerieName.setText(book.get("serie_name",""))
        self.SerieNo.setText(book.get("serie_no",""))
        self.Language.setText(book.get("language",""))
        self.Pages.setText(book.get("pages",""))
        self.IsRead.setChecked(book.get("is_read",False))
        self.Excerpt.setText(book.get("excerpt",""))
        if book.get("cover_path",""):
            self.Cover.fromFile(book["cover_path"])
        elif book.get("cover_url",""):
            self.Cover.fromUrl(book["cover_url"])
        else:
            self.Cover._remove()

    def toDict(self):
        return {"title": self.Title.text(),
                "writers": self.Writers.getItems(),
                "publisher": self.Publisher.text(),
                "categories": self.Categories.getItems(),
                "serie_name": self.SerieName.text(),
                "serie_no": self.SerieNo.text(),
                "language": self.Language.text(),
                "pages": self.Pages.text(),
                "is_read": int(self.IsRead.isChecked()),
                "excerpt": self.Excerpt.toPlainText(),
                "cover": self.Cover.toByteArray()}