Dialog for metadata editing

This commit is contained in:
BasioMeusPuga
2018-03-02 00:11:48 +05:30
parent a9d6cf73c7
commit 98541a5ca3
4 changed files with 211 additions and 2 deletions

View File

@@ -32,6 +32,8 @@ from library import Library
from settings import Settings
from settingsdialog import SettingsUI
from metadatadialog import MetadataUI
class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
def __init__(self):
@@ -68,6 +70,9 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
# Initialize settings dialog
self.settings_dialog = SettingsUI(self)
# Initialize metadata dialog
self.metadata_dialog = MetadataUI(self)
# Statusbar widgets
self.statusMessage.setObjectName('statusMessage')
self.statusBar.addPermanentWidget(self.statusMessage)
@@ -239,8 +244,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
def open_books_at_startup(self):
# Last open books and command line books aren't being opened together
# so that command line books are processed last and therefore retain
# focus
# so that command line books are processed last and therefore retain focus
# Open last... open books.
# Then set the value to None for the next run
@@ -360,6 +364,8 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
def test_function(self):
print('Caesar si viveret, ad remum dareris')
self.metadata_dialog.show()
def resizeEvent(self, event=None):
if event:

32
metadatadialog.py Normal file
View File

@@ -0,0 +1,32 @@
#!/usr/bin/env python3
# This file is a part of Lector, a Qt based ebook reader
# Copyright (C) 2017 BasioMeusPuga
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from PyQt5 import QtWidgets, QtCore
from resources import metadata
class MetadataUI(QtWidgets.QDialog, metadata.Ui_Dialog):
def __init__(self, parent):
super(MetadataUI, self).__init__()
self.setupUi(self)
self.parent = parent
self.setWindowFlags(
QtCore.Qt.Window |
QtCore.Qt.WindowMinimizeButtonHint |
QtCore.Qt.WindowCloseButtonHint)
self.setFixedSize(self.width(), self.height())

65
resources/metadata.py Normal file
View File

@@ -0,0 +1,65 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'raw/metadata.ui'
#
# Created by: PyQt5 UI code generator 5.10
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(640, 212)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(Dialog.sizePolicy().hasHeightForWidth())
Dialog.setSizePolicy(sizePolicy)
Dialog.setMaximumSize(QtCore.QSize(700, 212))
Dialog.setModal(True)
self.gridLayout = QtWidgets.QGridLayout(Dialog)
self.gridLayout.setObjectName("gridLayout")
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.coverView = QtWidgets.QGraphicsView(Dialog)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.coverView.sizePolicy().hasHeightForWidth())
self.coverView.setSizePolicy(sizePolicy)
self.coverView.setMinimumSize(QtCore.QSize(140, 200))
self.coverView.setMaximumSize(QtCore.QSize(140, 200))
self.coverView.setBaseSize(QtCore.QSize(140, 200))
self.coverView.setObjectName("coverView")
self.horizontalLayout.addWidget(self.coverView)
self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout")
self.titleLine = QtWidgets.QLineEdit(Dialog)
self.titleLine.setObjectName("titleLine")
self.verticalLayout.addWidget(self.titleLine)
self.authorLine = QtWidgets.QLineEdit(Dialog)
self.authorLine.setObjectName("authorLine")
self.verticalLayout.addWidget(self.authorLine)
self.yearLine = QtWidgets.QLineEdit(Dialog)
self.yearLine.setObjectName("yearLine")
self.verticalLayout.addWidget(self.yearLine)
self.tagsLine = QtWidgets.QLineEdit(Dialog)
self.tagsLine.setMinimumSize(QtCore.QSize(0, 0))
self.tagsLine.setObjectName("tagsLine")
self.verticalLayout.addWidget(self.tagsLine)
self.horizontalLayout.addLayout(self.verticalLayout)
self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1)
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Edit metadata"))
self.titleLine.setPlaceholderText(_translate("Dialog", "Title"))
self.authorLine.setPlaceholderText(_translate("Dialog", "Author"))
self.yearLine.setPlaceholderText(_translate("Dialog", "Year"))
self.tagsLine.setPlaceholderText(_translate("Dialog", "Tags"))

106
resources/raw/metadata.ui Normal file
View File

@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>212</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>700</width>
<height>212</height>
</size>
</property>
<property name="windowTitle">
<string>Edit metadata</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGraphicsView" name="coverView">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>200</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>140</width>
<height>200</height>
</size>
</property>
<property name="baseSize">
<size>
<width>140</width>
<height>200</height>
</size>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLineEdit" name="titleLine">
<property name="placeholderText">
<string>Title</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="authorLine">
<property name="placeholderText">
<string>Author</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="yearLine">
<property name="placeholderText">
<string>Year</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="tagsLine">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="placeholderText">
<string>Tags</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>