# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'ctls.ui'
#
# Created by: PyQt5 UI code generator 5.15.0
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.

from re import findall
from PyQt5 import QtCore, QtGui, QtWidgets
class textEdit(QtWidgets.QPlainTextEdit):
    def __int__(self):
        super().__init__()
        self.setAcceptDrops(True) #允许接收拖曳过来的内容

    def dragEnterEvent(self, e):
        if e.mimeData().hasText():
            e.accept()
        else:
            e.ignore()

    def dropEvent(self, e):
        if self.toPlainText():
            if '\n正在处理：'in self.toPlainText():
                self.setPlainText('')
            self.setPlainText(self.toPlainText()+'\n'+e.mimeData().text().replace('file:///', ''))
        else:
            self.setPlainText(e.mimeData().text().replace('file:///', ''))

class Ui_mainWindow(object):
    def setupUi(self, mainWindow):
        mainWindow.setObjectName("mainWindow")
        mainWindow.resize(425, 265)
        self.centralwidget = QtWidgets.QWidget(mainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName("gridLayout")
        self.text = textEdit()
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.text.sizePolicy().hasHeightForWidth())
        self.text.setSizePolicy(sizePolicy)
        self.text.setObjectName("text")
        self.gridLayout.addWidget(self.text, 0, 0, 1, 1)
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.open = QtWidgets.QPushButton(self.centralwidget)
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.open.setFont(font)
        self.open.setObjectName("open")
        self.verticalLayout.addWidget(self.open)
        self.gridLayout.addLayout(self.verticalLayout, 0, 1, 1, 1)
        self.start = QtWidgets.QPushButton(self.centralwidget)
        self.start.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.start.setObjectName("start")
        self.gridLayout.addWidget(self.start, 1, 0, 1, 2)
        mainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(mainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 425, 22))
        self.menubar.setObjectName("menubar")
        mainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(mainWindow)
        self.statusbar.setObjectName("statusbar")
        mainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(mainWindow)
        QtCore.QMetaObject.connectSlotsByName(mainWindow)

    def retranslateUi(self, mainWindow):
        _translate = QtCore.QCoreApplication.translate
        mainWindow.setWindowTitle(_translate("mainWindow", "epub转mobi"))
        self.text.setPlaceholderText(_translate("mainWindow", "可批量拖入或点击右侧打开epub文件"))
        self.open.setText(_translate("mainWindow", "..."))
        self.start.setText(_translate("mainWindow", "开始处理"))
