Example #1
0
class Ui_MainWindow(QMainWindow):

    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):

        self.transprot_mass =[]
        self.netprot_mass =[]
        self.filtering_is_on = 0

        grid = QGridLayout()
        self.setLayout(grid)

        self.IP_list = IP_list(self)
        self.TransProt_list = TransProt_list(self)
        self.NetProt_list = NetProt_list(self)
        self.setWindowTitle('Гамма')
        self.setWindowIcon(QIcon('допочки\Gamma_200x200.png'))
        self.resize(740, 830)
        self.to_center()
        self.centralwidget = QWidget(self)
        self.tabWidget = QTabWidget(self.centralwidget)
        self.tabWidget.setGeometry(QRect(20, 20, 700, 750))
        self.tab = QWidget()

        grid.addWidget(self.tab)

        self.cb_time = QCheckBox(self.tab)
        self.cb_time.setGeometry(QRect(360, 130, 120, 20))
        self.cb_time.setText("Фильтр по времени")
        self.cb_prot = QCheckBox(self.tab)
        self.cb_prot.setGeometry(QRect(20, 130, 140, 20))
        self.cb_prot.setText("Фильтр по протоколам")
        self.cb_addr = QCheckBox(self.tab)
        self.cb_addr.setGeometry(QRect(360, 290, 130, 20))
        self.cb_addr.setText("Фильтр по IP-адресам")

        self.dt_beg = QDateTimeEdit(self.tab)
        self.dt_beg.setGeometry(QRect(360, 210, 150, 20))
        self.dt_beg.setDateTime(QDateTime.currentDateTime())
        self.dt_beg.setDisplayFormat("dd.MM.yyyy H:mm:ss.zzz")
        self.dt_beg.setCalendarPopup(True)
        self.dt_beg.setToolTip('Выбрать начальное время (>=)')
        self.dt_beg.setEnabled(False)

        self.dt_end = QDateTimeEdit(self.tab)
        self.dt_end.setGeometry(QRect(520, 210, 150, 20))
        self.dt_end.setDateTime(QDateTime.currentDateTime())
        self.dt_end.setDisplayFormat("dd.MM.yyyy H:mm:ss.zzz")
        self.dt_end.setCalendarPopup(True)
        self.dt_end.setToolTip('Выбрать конечное время (<)')
        self.dt_end.setEnabled(False)

        self.dt_beg.dateChanged.connect(lambda dc: self.date_changed(1))
        self.dt_end.dateChanged.connect(lambda dc: self.date_changed(2))

        #self.l_input_dir = QLabel(self.tab)
        #self.l_input_dir.setGeometry(QRect(102, 50, 180, 15))
        #self.l_input_dir.setText("Выберите директорию с файлами")
        #self.l_or = QLabel(self.tab)
        #self.l_or.setGeometry(QRect(340, 50, 21, 16))
        #self.l_or.setText("ИЛИ")
        self.l_input_file = QLabel(self.tab)
        self.l_input_file.setGeometry(QRect(300, 50, 90, 15))
        self.l_input_file.setText("Выберите файлы")
        self.l_transpr = QLabel(self.tab)
        self.l_transpr.setGeometry(QRect(50, 190, 180, 16))
        self.l_transpr.setEnabled(False)
        self.l_transpr.setText("Протоколы Транспортного уровня")
        self.l_netpr = QLabel(self.tab)
        self.l_netpr.setGeometry(QRect(50, 290, 180, 16))
        self.l_netpr.setEnabled(False)
        self.l_netpr.setText("Протоколы Сетевого уровня")
        self.l_beg = QLabel(self.tab)
        self.l_beg.setGeometry(QRect(390, 190, 60, 16))
        self.l_beg.setEnabled(False)
        self.l_beg.setText("Начиная с..")
        self.l_end = QLabel(self.tab)
        self.l_end.setGeometry(QRect(560, 190, 80, 16))
        self.l_end.setEnabled(False)
        self.l_end.setText("Оканчивая до..")
        self.l_name = QLabel(self.tab)
        self.l_name.setGeometry(QRect(300, 450, 96, 16))
        self.l_name.setText("Как назвать файл?")
        self.l_filt = QLabel(self.tab)
        self.l_filt.setGeometry(QRect(300, 10, 91, 16))
        self.l_filt.setText("Выборка пакетов")

        self.line = QFrame(self.tab)
        self.line.setGeometry(QRect(0, 110, 690, 15))
        self.line.setFrameShape(QFrame.HLine)
        self.line.setFrameShadow(QFrame.Sunken)
        self.line_2 = QFrame(self.tab)
        self.line_2.setGeometry(QRect(340, 120, 15, 300))
        self.line_2.setFrameShape(QFrame.VLine)
        self.line_2.setFrameShadow(QFrame.Sunken)
        self.line_3 = QFrame(self.tab)
        self.line_3.setGeometry(QRect(0, 420, 690, 15))
        self.line_3.setFrameShape(QFrame.HLine)
        self.line_3.setFrameShadow(QFrame.Sunken)

        #self.le_dir = QLineEdit(self.tab)
        #self.le_dir.setGeometry(QRect(110, 80, 211, 20))
        #self.le_dir.setEnabled(False)
        #self.le_dir.setReadOnly(True)
        self.le_file = QLineEdit(self.tab)
        self.le_file.setGeometry(QRect(250, 80, 211, 20))
        #self.le_file.setEnabled(False)
        self.le_file.setReadOnly(True)
        self.le_name = QLineEdit(self.tab)
        self.le_name.setGeometry(QRect(250, 480, 231, 20))

        self.pt_transpr = QPlainTextEdit(self.tab)
        self.pt_transpr.setGeometry(QRect(50, 210, 271, 71))
        self.pt_transpr.setEnabled(False)
        self.pt_transpr.setReadOnly(True)
        self.pt_netpr = QPlainTextEdit(self.tab)
        self.pt_netpr.setGeometry(QRect(50, 320, 271, 71))
        self.pt_netpr.setEnabled(False)
        self.pt_netpr.setReadOnly(True)

        self.pt_addr = QPlainTextEdit(self.tab)
        self.pt_addr.setGeometry(QRect(390, 320, 271, 71))
        self.pt_addr.setEnabled(False)
        self.pt_log = QPlainTextEdit(self.tab)
        self.pt_log.setGeometry(QRect(20, 610, 651, 101))
        self.pt_log.setReadOnly(True)

        self.progressBar = QProgressBar(self.tab)
        self.progressBar.setGeometry(QRect(20, 580, 651, 20))
        self.progressBar.setFormat("%v" + "%")
        self.progressBar.setMaximum(100)
        self.progressBar.setValue(0)

        #self.pb_dir = QPushButton(self.tab)
        #self.pb_dir.setGeometry(QRect(80, 80, 21, 20))
        #self.pb_dir.setIcon(QIcon('допочки\_folder.png'))
        #self.pb_dir.clicked.connect(lambda gd: self.get_directory(1))
        self.pb_file = QPushButton(self.tab)
        self.pb_file.setGeometry(QRect(220, 80, 21, 20))
        self.pb_file.setIcon(QIcon('допочки\_folder.png'))
        self.pb_file.clicked.connect(lambda gf: self.get_files(1))
        self.pb_time = QPushButton(self.tab)
        self.pb_time.setGeometry(QRect(480, 240, 71, 20))
        self.pb_time.setToolTip('Добавить ещё временной отрезок')
        self.pb_time.setEnabled(False)
        self.pb_time.setText("Ещё!")

        self.pb_transpr = QPushButton(self.tab)
        self.pb_transpr.setGeometry(QRect(20, 210, 21, 20))
        self.pb_transpr.setToolTip('Выбрать протоколы Транспортного уровня')
        self.pb_transpr.setIcon(QIcon('допочки\_blank.png'))
        self.pb_transpr.setEnabled(False)
        self.pb_transpr.clicked.connect(self.TransProt_list.exec)

        self.pb_netpr = QPushButton(self.tab)
        self.pb_netpr.setGeometry(QRect(20, 320, 21, 20))
        self.pb_netpr.setToolTip('Выбрать протоколы Сетевого уровня')
        self.pb_netpr.setIcon(QIcon('допочки\_blank.png'))
        self.pb_netpr.setEnabled(False)
        self.pb_netpr.clicked.connect(self.NetProt_list.exec)
        self.pb_addr = QPushButton(self.tab)
        self.pb_addr.setGeometry(QRect(530, 290, 132, 20))
        self.pb_addr.setText('Редактировать список')
        self.pb_addr.setEnabled(False)
        self.pb_addr.clicked.connect(self.IP_list.exec)
        self.pb_name = QPushButton(self.tab)
        self.pb_name.setGeometry(QRect(220, 480, 21, 20))
        self.pb_name.setIcon(QIcon('допочки\_folder.png'))
        self.pb_name.clicked.connect(lambda ed: self.extract_to_directory(1))
        self.pb_start = QPushButton(self.tab)
        self.pb_start.setGeometry(QRect(220, 510, 261, 41))
        self.pb_start.setText("Начать выборку")
        self.pb_start.clicked.connect(self.do_it_motherFucker)

        #self.radiobutton = QRadioButton(self.tab)
        #self.radiobutton.setGeometry(QRect(84, 48, 20, 20))
        #self.radiobutton_2 = QRadioButton(self.tab)
        #self.radiobutton_2.setGeometry(QRect(424, 48, 20, 20))

        #self.radiobutton.raise_()
        #self.radiobutton_2.raise_()
        self.cb_time.raise_()
        self.cb_prot.raise_()
        self.cb_addr.raise_()
        self.dt_beg.raise_()
        self.dt_end.raise_()
        #self.l_input_dir.raise_()
        #self.l_or.raise_()
        self.l_input_file.raise_()
        self.l_transpr.raise_()
        self.l_netpr.raise_()
        self.l_beg.raise_()
        self.l_end.raise_()
        self.l_name.raise_()
        self.l_filt.raise_()
        self.line.raise_()
        self.line_2.raise_()
        self.line_3.raise_()
        #self.le_dir.raise_()
        self.le_file.raise_()
        self.le_name.raise_()
        self.pt_transpr.raise_()
        self.pt_netpr.raise_()
        self.pt_addr.raise_()
        self.pt_log.raise_()
        self.progressBar.raise_()
        #self.pb_dir.raise_()
        self.pb_file.raise_()
        self.pb_time.raise_()
        self.pb_transpr.raise_()
        self.pb_netpr.raise_()
        self.pb_addr.raise_()
        self.pb_name.raise_()
        self.pb_start.raise_()
        self.setCentralWidget(self.centralwidget)
        self.statusbar = QStatusBar(self)
        self.setStatusBar(self.statusbar)
        self.tabWidget.addTab(self.tab, "")

        self.cb_time.clicked['bool'].connect(self.dt_beg.setEnabled)
        self.cb_time.clicked['bool'].connect(self.dt_end.setEnabled)
        self.cb_time.clicked['bool'].connect(self.l_beg.setEnabled)
        self.cb_time.clicked['bool'].connect(self.l_end.setEnabled)
        self.cb_prot.clicked['bool'].connect(self.l_transpr.setEnabled)
        self.cb_prot.clicked['bool'].connect(self.l_netpr.setEnabled)
        self.cb_prot.clicked['bool'].connect(self.pt_transpr.setEnabled)
        self.cb_prot.clicked['bool'].connect(self.pt_netpr.setEnabled)
        self.cb_prot.clicked['bool'].connect(self.pb_transpr.setEnabled)
        self.cb_prot.clicked['bool'].connect(self.pb_netpr.setEnabled)
        self.cb_addr.clicked['bool'].connect(self.pt_addr.setEnabled)
        self.cb_addr.clicked['bool'].connect(self.pb_addr.setEnabled)



        #####------------------------------2_TAB



        self.tab_2 = QWidget()
        self.tabWidget.addTab(self.tab_2, "")
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), ("II работа с файлами"))

        self.l_merge = QLabel(self.tab_2)
        self.l_merge.setGeometry(QRect(300, 10, 180, 16))
        self.l_merge.setText("Объединение файлов")

        self.l_arch = QLabel(self.tab_2)
        self.l_arch.setGeometry(QRect(300, 250, 180, 16))
        self.l_arch.setText("Архивирование файлов")

        #self.radiobutton_3 = QRadioButton(self.tab_2)
        #self.radiobutton_3.setGeometry(QRect(84, 48, 20, 20))
        #self.radiobutton_4 = QRadioButton(self.tab_2)
        #self.radiobutton_4.setGeometry(QRect(424, 48, 20, 20))

        #self.l_input_dir2 = QLabel(self.tab_2)
        #self.l_input_dir2.setGeometry(QRect(102, 50, 180, 15))
        #self.l_input_dir2.setText("Выберите директорию с файлами")
        #self.l_or2 = QLabel(self.tab_2)
        #self.l_or2.setGeometry(QRect(340, 50, 21, 16))
        #self.l_or2.setText("ИЛИ")
        self.l_input_file2 = QLabel(self.tab_2)
        self.l_input_file2.setGeometry(QRect(102, 50, 180, 15))#442, 50, 90, 15))
        self.l_input_file2.setText("Выберите файлы")
        self.l_name2 = QLabel(self.tab_2)
        self.l_name2.setGeometry(QRect(442, 50, 180, 15))#280, 140, 180, 16))
        self.l_name2.setText("Куда сохранить результат?")
        self.l_ciph2 = QLabel(self.tab_2)
        self.l_ciph2.setGeometry(QRect(84, 298, 180, 15))
        self.l_ciph2.setText("Убрать шифрованный трафик")
        self.l_arch2 = QLabel(self.tab_2)
        self.l_arch2.setGeometry(QRect(424, 298, 180, 15))
        self.l_arch2.setText("Заархивировать файлы")


        #self.le_dir2 = QLineEdit(self.tab_2)
        #self.le_dir2.setGeometry(QRect(110, 80, 211, 20))
        #self.le_dir2.setEnabled(False)
        self.le_file2 = QLineEdit(self.tab_2)
        self.le_file2.setGeometry(QRect(110, 80, 211, 20))#450, 80, 211, 20))
        self.le_file2.setReadOnly(True)
        self.le_name2 = QLineEdit(self.tab_2)
        self.le_name2.setGeometry(QRect(450, 80, 211, 20))#260, 170, 180, 20))

        #self.pb_dir2 = QPushButton(self.tab_2)
        #self.pb_dir2.setGeometry(QRect(80, 80, 21, 20))
        #self.pb_dir2.setIcon(QIcon('допочки\_folder.png'))
        #self.pb_dir2.clicked.connect(lambda gd: self.get_directory(2))
        self.pb_file2 = QPushButton(self.tab_2)
        self.pb_file2.setGeometry(QRect(80, 80, 21, 20))#420, 80, 21, 20))
        self.pb_file2.setIcon(QIcon('допочки\_folder.png'))
        self.pb_file2.clicked.connect(lambda gf: self.get_files(2))
        self.pb_name2 = QPushButton(self.tab_2)
        self.pb_name2.setGeometry(QRect(420, 80, 21, 20))#230, 170, 21, 20))
        self.pb_name2.setIcon(QIcon('допочки\_folder.png'))
        self.pb_name2.clicked.connect(lambda ed: self.extract_to_directory(2))
        self.pb_merge = QPushButton(self.tab_2)
        self.pb_merge.setGeometry(QRect(270, 170, 160, 20))
        self.pb_merge.setText("Объединить")
        self.pb_merge.clicked.connect(self.merge_it_motherFucker)

        self.line_4 = QFrame(self.tab_2)
        self.line_4.setGeometry(QRect(0, 280, 690, 15))
        self.line_4.setFrameShape(QFrame.HLine)
        self.line_4.setFrameShadow(QFrame.Sunken)
        self.line_5 = QFrame(self.tab_2)
        self.line_5.setGeometry(QRect(0, 580, 690, 15))
        self.line_5.setFrameShape(QFrame.HLine)
        self.line_5.setFrameShadow(QFrame.Sunken)

        self.pt_log2 = QPlainTextEdit(self.tab_2)
        self.pt_log2.setGeometry(QRect(20, 610, 651, 101))
        self.pt_log2.setReadOnly(True)

        self.graphicsView = QGraphicsView(self.tab_2)
        self.graphicsView.setGeometry(QRect(0, 330, 714, 277))
        self.scene = QGraphicsScene()
        self.graphicsView.setScene(self.scene)
        self.scene.addPixmap(QPixmap('допочки\_in_working_3.png'))

        self.l_merge.raise_()
        self.l_arch.raise_()
        #self.l_input_dir2.raise_()
        #self.l_or2.raise_()
        self.l_input_file2.raise_()
        self.l_name2.raise_()
        #self.radiobutton_3.raise_()
        #self.radiobutton_4.raise_()
        #self.pb_dir2.raise_()
        self.pb_file2.raise_()
        self.pb_name2.raise_()
        #self.le_dir2.raise_()
        self.le_file2.raise_()
        self.le_name2.raise_()
        self.line_4.raise_()
        self.line_5.raise_()
        self.pt_log2.raise_()



        #####------------------------------2_TAB

        #####------------------------------3_TAB

        self.tab_3 = QWidget()
        self.tabWidget.addTab(self.tab_3, "")
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_3), ("III Проверка на аномальную активность"))
        self.tab_3.setEnabled(False)

        self.l_filt3 = QLabel(self.tab_3)
        self.l_filt3.setGeometry(QRect(300, 10, 91, 16))
        self.l_filt3.setText("Выборка пакетов")

        self.l_input_file3 = QLabel(self.tab_3)
        self.l_input_file3.setGeometry(QRect(300, 50, 90, 15))
        self.l_input_file3.setText("Выберите файлы")

        self.pb_file3 = QPushButton(self.tab_3)
        self.pb_file3.setGeometry(QRect(220, 80, 21, 20))
        self.pb_file3.setIcon(QIcon('допочки\_folder.png'))
        self.pb_file3.clicked.connect(lambda gf: self.get_files(3))

        self.le_file3 = QLineEdit(self.tab_3)
        self.le_file3.setGeometry(QRect(250, 80, 211, 20))
        self.le_file3.setReadOnly(True)

        self.pb_graphy = QPushButton(self.tab_3)
        self.pb_graphy.setGeometry(QRect(270, 170, 160, 20))
        self.pb_graphy.setText("Построить граф")
        #self.pb_graphy.clicked.connect(self.graph_it)

        #self.label_6 = QLabel(self.tab_3)
        #self.pixmap = QPixmap('допочки\_in_working_1.png')
        #self.label_6.setPixmap(self.pixmap)

        self.l_filt3.raise_()
        self.l_input_file3.raise_()
        self.pb_file3.raise_()
        self.le_file3.raise_()


        #####------------------------------3_TAB

        #####----------------------------IN_WORK



        self.tab_4 = QWidget()
        self.tabWidget.addTab(self.tab_4, "")
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_4), ("...IV visualization..."))
        self.tab_4.setEnabled(False)


        self.label_7 = QLabel(self.tab_4)
        self.pixmap_2 = QPixmap('допочки\_in_working_2.png')
        self.label_7.setPixmap(self.pixmap_2)

        #####----------------------------IN_WORK





        self.tabWidget.setCurrentIndex(0)
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), ("I выборка пакетов"))
        QMetaObject.connectSlotsByName(self)

        self.show()

    def closeEvent(self, event):
        reply = QMessageBox.question(self, 'Ща закроется всё', "Ты чо, реально хочешь выйти?",
                                     QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
        if reply == QMessageBox.Yes:
            event.accept()
        else:
            event.ignore()

    def to_center(self):
        qr = self.frameGeometry()
        qr.moveCenter(QDesktopWidget().availableGeometry().center())
        self.move(qr.topLeft())


    def get_directory(self, gd):
        if gd == 1:
            result = QFileDialog.getExistingDirectory()
            #self.le_dir.setText(result)
            self.le_file.setDisabled(True)
            #self.le_dir.setEnabled(True)
            #self.radiobutton_2.setChecked(False)
            #self.radiobutton.setChecked(True)
        else:
            result = QFileDialog.getExistingDirectory()
            #self.le_dir2.setText(result)
            self.le_file2.setDisabled(True)
            #self.le_dir2.setEnabled(True)
            #self.radiobutton_4.setChecked(False)
            #self.radiobutton_3.setChecked(True)

    def get_files(self, gf):
        if gf == 1:
            result, bullshit = QFileDialog.getOpenFileNames(self, "Выберите pcap-файлы", getcwd(), "files (*.pcap *.pcapng)")
            #self.le_dir.setDisabled(True)
            self.le_file.setEnabled(True)
            #self.radiobutton.setChecked(False)
            #self.radiobutton_2.setChecked(True)
            if len(result):
                self.le_file.setText(", ".join(result))
        elif gf == 3:
            result, bullshit = QFileDialog.getOpenFileNames(self, "Выберите pcap-файлы", getcwd(), "files (*.pcap *.pcapng)")
            #self.le_dir.setDisabled(True)
            self.le_file3.setEnabled(True)
            #self.radiobutton.setChecked(False)
            #self.radiobutton_2.setChecked(True)
            if len(result):
                self.le_file3.setText(", ".join(result))
        else:
            result, bullshit = QFileDialog.getOpenFileNames(self, "Выберите pcap-файлы", getcwd(), "files (*.pcap *.pcapng)")
            #self.le_dir2.setDisabled(True)
            self.le_file2.setEnabled(True)
            #self.radiobutton_3.setChecked(False)
            #self.radiobutton_4.setChecked(True)
            if len(result):
                self.le_file2.setText(", ".join(result))

    def date_changed(self, dc):
        if dc == 1:
            self.dt_end.setMinimumDateTime(QDateTime(self.dt_beg.dateTime()))
        else:
            self.dt_beg.setMaximumDateTime(QDateTime(self.dt_end.dateTime()))

    def extract_to_directory(self, ed):
        if ed == 1:
            result, bullshit =QFileDialog.getSaveFileName(self, "Сохранить файл", getcwd(), "files (*.pcap *.pcapng)")
            self.le_name.setText(result)
        else:
            result, bullshit =QFileDialog.getSaveFileName(self, "Сохранить файл", getcwd(), "files (*.pcap *.pcapng)")
            self.le_name2.setText(result)


    def do_it_motherFucker(self):
        if self.filtering_is_on == 0:
            #if ((not self.radiobutton.isChecked() and not self.radiobutton_2.isChecked())\
            #    or (self.radiobutton.isChecked() and self.le_dir.text() == '')\
            #        or (self.radiobutton_2.isChecked() and self.le_file.text() == ''))\
            #            and self.le_name.text() == '':
            if self.le_file.text() == '' and self.le_name.text() == '':
                self.pt_log.appendPlainText("  " + "Какие файлы обработать? Куда сохранить? Такая неопределённость..")
            #elif (not self.radiobutton.isChecked() and not self.radiobutton_2.isChecked()) or (self.radiobutton.isChecked() and self.le_dir.text() == '') or (self.radiobutton_2.isChecked() and self.le_file.text() == ''):
            elif self.le_file.text() == '':
                self.pt_log.appendPlainText("  " + "Какие файлы обработать?")
            elif self.le_name.text() == '':
                self.pt_log.appendPlainText("  " + "Куда сохранить?")
            else:
                self.filtering_is_on = 1  # эти пиздецы в идеале нужно заменить на что-нибудь адекватное
                self.count_for_pr_b = 0 # эти пиздецы в идеале нужно заменить на что-нибудь адекватное
                self.progressBar.setValue(0)
                self.pb_start.setText("Остановить выборку")

                #my_directory = self.le_dir.text()
                pcap_files_in = self.le_file.text()
                pcap_file_out = self.le_name.text()
                per_quest = 0
                per_beg = ''
                per_end = ''
                prot_quest = 0
                net_prot = 0
                trans_prot = 0
                appl_prot = 0 ##
                ip_quest = 0
                netprot_mass = []
                transprot_mass = []
                addr_mass = []

                if (pcap_file_out.endswith(".pcap") or pcap_file_out.endswith(".pcapng")) == False:
                    pcap_file_out = pcap_file_out + ".pcap"

                self.pt_log.appendPlainText("Сохранить в:")
                self.pt_log.appendPlainText("  " + pcap_file_out)

                #if self.radiobutton.isChecked():
                #    onlyfiles = [my_directory + '/' + f for f in listdir(my_directory) if
                #                 f.endswith(".pcap") or f.endswith(".pcapng") and isfile(join(my_directory, f))]
                #    self.for_pr_b = len(onlyfiles)
#
                #    self.pt_log.appendPlainText("Выбрана директория:")
                #    self.pt_log.appendPlainText("  " + self.le_dir.text())
                #    self.pt_log.appendPlainText("С pcap-файлами:")
                #    for file in onlyfiles:
                #        bullshit, fname = file.rsplit('/', 1)
                #        self.pt_log.appendPlainText("  " + fname)

                #elif self.radiobutton_2.isChecked():
                onlyfiles = pcap_files_in.split(', ')
                self.for_pr_b = len(onlyfiles)

                self.pt_log.appendPlainText("Выбраны pcap-файлы:")
                for file in onlyfiles:
                    self.pt_log.appendPlainText("  " + (file))

                if self.cb_addr.isChecked() and self.pt_addr.toPlainText() != '':
                    ip_quest = 1
                    addr_mass = self.pt_addr.toPlainText().splitlines()

                if self.cb_time.isChecked():
                    per_quest = 1
                    per_beg = self.dt_beg.dateTime()
                    per_end = self.dt_end.dateTime()

                if self.cb_prot.isChecked():
                    prot_quest = 1
                    transprot_mass = self.transprot_mass
                    netprot_mass = self.netprot_mass

                if self.pt_transpr.toPlainText() != '':
                    trans_prot = 1
                if self.pt_netpr.toPlainText() != '':
                    net_prot = 1

                #self.radiobutton.setDisabled(True)
                #self.radiobutton_2.setDisabled(True)
                #self.l_input_dir.setDisabled(True)
                #self.l_or.setDisabled(True)
                self.l_input_file.setDisabled(True)
                #self.pb_dir.setDisabled(True)
                self.pb_file.setDisabled(True)
                #self.le_dir.setDisabled(True)
                self.le_file.setDisabled(True)
                self.cb_time.setDisabled(True)
                self.cb_prot.setDisabled(True)
                self.cb_addr.setDisabled(True)
                self.l_transpr.setDisabled(True)
                self.l_netpr.setDisabled(True)
                self.l_beg.setDisabled(True)
                self.l_end.setDisabled(True)
                self.l_name.setDisabled(True)
                self.l_filt.setDisabled(True)
                self.le_name.setDisabled(True)
                self.dt_beg.setDisabled(True)
                self.dt_end.setDisabled(True)
                self.pt_transpr.setDisabled(True)
                self.pt_netpr.setDisabled(True)
                self.pt_addr.setDisabled(True)
                self.pb_time.setDisabled(True)
                self.pb_transpr.setDisabled(True)
                self.pb_netpr.setDisabled(True)
                self.pb_addr.setDisabled(True)
                self.pb_name.setDisabled(True)

                self.worker = WorkerThread(onlyfiles, pcap_file_out, per_quest, per_beg, per_end, prot_quest, net_prot,
                                           netprot_mass, trans_prot, transprot_mass, appl_prot, ip_quest, addr_mass)
                self.worker.callback_received.connect(self.append_to_log)
                self.worker.start()
                self.pt_log.appendPlainText("")
                self.pt_log.appendPlainText("В работе:")
        elif self.filtering_is_on == 1:
            self.worker.terminate()
            self.pt_log.appendPlainText("")
            self.pt_log.appendPlainText("Работа прервана")
            self.pt_log.appendPlainText("")
            self.pt_log.appendPlainText("")
            self.go_to_starting_set()

    def append_to_log(self, x):
        self.count_for_pr_b += 1
        self.pt_log.appendPlainText("")
        self.pt_log.appendPlainText(x)
        self.progressBar.setValue(self.count_for_pr_b * 100 / (self.for_pr_b + 1))

        if self.progressBar.value() == 100:
            self.pt_log.appendPlainText("")
            self.pt_log.appendPlainText("")
            self.go_to_starting_set()

    def go_to_starting_set(self):
        self.filtering_is_on = 0
        self.pb_start.setText("Начать выборку")

        #self.radiobutton.setDisabled(False)
        #self.radiobutton_2.setDisabled(False)
        #self.l_input_dir.setDisabled(False)
        #self.l_or.setDisabled(False)
        self.l_input_file.setDisabled(False)
        #self.pb_dir.setDisabled(False)
        self.pb_file.setDisabled(False)
        #self.le_dir.setDisabled(False)
        self.le_file.setDisabled(False)
        self.cb_time.setDisabled(False)
        self.cb_prot.setDisabled(False)
        self.cb_addr.setDisabled(False)
        self.l_name.setDisabled(False)
        self.l_filt.setDisabled(False)
        self.le_name.setDisabled(False)
        self.pb_name.setDisabled(False)

        if self.cb_time.isChecked():
            self.dt_beg.setEnabled(True)
            self.dt_end.setEnabled(True)
            self.l_beg.setEnabled(True)
            self.l_end.setEnabled(True)

        if self.cb_prot.isChecked():
            self.l_transpr.setEnabled(True)
            self.l_netpr.setEnabled(True)
            self.pt_transpr.setEnabled(True)
            self.pt_netpr.setEnabled(True)
            self.pb_transpr.setEnabled(True)
            self.pb_netpr.setEnabled(True)

        if self.cb_addr.isChecked():
            self.pt_addr.setEnabled(True)
            self.pb_addr.setEnabled(True)

    def merge_it_motherFucker(self):
        #if self.radiobutton_3.isChecked():
        #    self.pt_log2.appendPlainText("Выбрана директория с pcap-файлами:")
        #    self.pt_log2.appendPlainText("  " + self.le_dir2.text())
        #    self.pt_log2.appendPlainText('Просматриваем "{}"...'.format(self.le_dir2.text()))
        #    onlyfiles = [self.le_dir2.text() + '/' + f for f in listdir(self.le_dir2.text()) if
        #                 f.endswith(".pcap") or f.endswith(".pcapng") and isfile(join(self.le_dir2.text(), f))]
        #    self.pt_log2.appendPlainText(str(onlyfiles))

        #elif self.radiobutton_4.isChecked():
        self.pt_log2.appendPlainText("Выбраны pcap-файлы:")
        self.pt_log2.appendPlainText("  " + self.le_file2.text())
        onlyfiles = self.le_file2.text().split(', ')
        self.pt_log2.appendPlainText('Работаем с "{}"...'.format(onlyfiles))

        merge_file_out = self.le_name2.text()
        if (merge_file_out.endswith(".pcap") or merge_file_out.endswith(".pcapng")) == False:
            merge_file_out = merge_file_out + ".pcap"

        self.pt_log2.appendPlainText("Сохранить в:")
        self.pt_log2.appendPlainText("  " + merge_file_out)
        self.pt_log2.appendPlainText("")

        merge.mergecap(onlyfiles, merge_file_out)
Example #2
0
class Setting_Ui(QWidget):
    def __init__(self, persepolis_setting):
        super().__init__()
        icon = QIcon()

        self.persepolis_setting = persepolis_setting

        # add support for other languages
        locale = str(self.persepolis_setting.value('settings/locale'))
        QLocale.setDefault(QLocale(locale))
        self.translator = QTranslator()
        if self.translator.load(':/translations/locales/ui_' + locale, 'ts'):
            QCoreApplication.installTranslator(self.translator)

        self.setWindowIcon(
            QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg')))
        self.setWindowTitle(
            QCoreApplication.translate("setting_ui_tr", 'Preferences'))

        # set ui direction
        ui_direction = self.persepolis_setting.value('ui_direction')

        if ui_direction == 'rtl':
            self.setLayoutDirection(Qt.RightToLeft)

        elif ui_direction in 'ltr':
            self.setLayoutDirection(Qt.LeftToRight)

        global icons
        icons = ':/' + str(
            self.persepolis_setting.value('settings/icons')) + '/'

        # main layout
        window_verticalLayout = QVBoxLayout(self)

        # setting_tabWidget
        self.setting_tabWidget = QTabWidget(self)

        # download_options_tab
        self.download_options_tab = QWidget()
        download_options_tab_verticalLayout = QVBoxLayout(
            self.download_options_tab)
        download_options_tab_verticalLayout.setContentsMargins(21, 21, 0, 0)

        # tries
        tries_horizontalLayout = QHBoxLayout()

        self.tries_label = QLabel(self.download_options_tab)
        tries_horizontalLayout.addWidget(self.tries_label)

        self.tries_spinBox = QSpinBox(self.download_options_tab)
        self.tries_spinBox.setMinimum(1)

        tries_horizontalLayout.addWidget(self.tries_spinBox)
        download_options_tab_verticalLayout.addLayout(tries_horizontalLayout)

        #wait
        wait_horizontalLayout = QHBoxLayout()

        self.wait_label = QLabel(self.download_options_tab)
        wait_horizontalLayout.addWidget(self.wait_label)

        self.wait_spinBox = QSpinBox(self.download_options_tab)
        wait_horizontalLayout.addWidget(self.wait_spinBox)

        download_options_tab_verticalLayout.addLayout(wait_horizontalLayout)

        # time_out
        time_out_horizontalLayout = QHBoxLayout()

        self.time_out_label = QLabel(self.download_options_tab)
        time_out_horizontalLayout.addWidget(self.time_out_label)

        self.time_out_spinBox = QSpinBox(self.download_options_tab)
        time_out_horizontalLayout.addWidget(self.time_out_spinBox)

        download_options_tab_verticalLayout.addLayout(
            time_out_horizontalLayout)

        # connections
        connections_horizontalLayout = QHBoxLayout()

        self.connections_label = QLabel(self.download_options_tab)
        connections_horizontalLayout.addWidget(self.connections_label)

        self.connections_spinBox = QSpinBox(self.download_options_tab)
        self.connections_spinBox.setMinimum(1)
        self.connections_spinBox.setMaximum(16)
        connections_horizontalLayout.addWidget(self.connections_spinBox)

        download_options_tab_verticalLayout.addLayout(
            connections_horizontalLayout)

        # rpc_port
        self.rpc_port_label = QLabel(self.download_options_tab)
        self.rpc_horizontalLayout = QHBoxLayout()
        self.rpc_horizontalLayout.addWidget(self.rpc_port_label)

        self.rpc_port_spinbox = QSpinBox(self.download_options_tab)
        self.rpc_port_spinbox.setMinimum(1024)
        self.rpc_port_spinbox.setMaximum(65535)
        self.rpc_horizontalLayout.addWidget(self.rpc_port_spinbox)

        download_options_tab_verticalLayout.addLayout(
            self.rpc_horizontalLayout)

        # wait_queue
        wait_queue_horizontalLayout = QHBoxLayout()

        self.wait_queue_label = QLabel(self.download_options_tab)
        wait_queue_horizontalLayout.addWidget(self.wait_queue_label)

        self.wait_queue_time = QDateTimeEdit(self.download_options_tab)
        self.wait_queue_time.setDisplayFormat('H:mm')
        wait_queue_horizontalLayout.addWidget(self.wait_queue_time)

        download_options_tab_verticalLayout.addLayout(
            wait_queue_horizontalLayout)

        # change aria2 path
        aria2_path_verticalLayout = QVBoxLayout()

        self.aria2_path_checkBox = QCheckBox(self.download_options_tab)
        aria2_path_verticalLayout.addWidget(self.aria2_path_checkBox)

        aria2_path_horizontalLayout = QHBoxLayout()

        self.aria2_path_lineEdit = QLineEdit(self.download_options_tab)
        aria2_path_horizontalLayout.addWidget(self.aria2_path_lineEdit)

        self.aria2_path_pushButton = QPushButton(self.download_options_tab)
        aria2_path_horizontalLayout.addWidget(self.aria2_path_pushButton)

        aria2_path_verticalLayout.addLayout(aria2_path_horizontalLayout)

        download_options_tab_verticalLayout.addLayout(
            aria2_path_verticalLayout)

        download_options_tab_verticalLayout.addStretch(1)

        self.setting_tabWidget.addTab(self.download_options_tab, "")

        # save_as_tab
        self.save_as_tab = QWidget()

        save_as_tab_verticalLayout = QVBoxLayout(self.save_as_tab)
        save_as_tab_verticalLayout.setContentsMargins(20, 30, 0, 0)

        # download_folder
        self.download_folder_horizontalLayout = QHBoxLayout()

        self.download_folder_label = QLabel(self.save_as_tab)
        self.download_folder_horizontalLayout.addWidget(
            self.download_folder_label)

        self.download_folder_lineEdit = QLineEdit(self.save_as_tab)
        self.download_folder_horizontalLayout.addWidget(
            self.download_folder_lineEdit)

        self.download_folder_pushButton = QPushButton(self.save_as_tab)
        self.download_folder_horizontalLayout.addWidget(
            self.download_folder_pushButton)

        save_as_tab_verticalLayout.addLayout(
            self.download_folder_horizontalLayout)

        # temp_download_folder
        self.temp_horizontalLayout = QHBoxLayout()

        self.temp_download_label = QLabel(self.save_as_tab)
        self.temp_horizontalLayout.addWidget(self.temp_download_label)

        self.temp_download_lineEdit = QLineEdit(self.save_as_tab)
        self.temp_horizontalLayout.addWidget(self.temp_download_lineEdit)

        self.temp_download_pushButton = QPushButton(self.save_as_tab)
        self.temp_horizontalLayout.addWidget(self.temp_download_pushButton)

        save_as_tab_verticalLayout.addLayout(self.temp_horizontalLayout)

        # create subfolder
        self.subfolder_checkBox = QCheckBox(self.save_as_tab)
        save_as_tab_verticalLayout.addWidget(self.subfolder_checkBox)

        save_as_tab_verticalLayout.addStretch(1)

        self.setting_tabWidget.addTab(self.save_as_tab, "")

        # notifications_tab
        self.notifications_tab = QWidget()
        notification_tab_verticalLayout = QVBoxLayout(self.notifications_tab)
        notification_tab_verticalLayout.setContentsMargins(21, 21, 0, 0)

        self.enable_notifications_checkBox = QCheckBox(self.notifications_tab)
        notification_tab_verticalLayout.addWidget(
            self.enable_notifications_checkBox)

        self.sound_frame = QFrame(self.notifications_tab)
        self.sound_frame.setFrameShape(QFrame.StyledPanel)
        self.sound_frame.setFrameShadow(QFrame.Raised)

        verticalLayout = QVBoxLayout(self.sound_frame)

        self.volume_label = QLabel(self.sound_frame)
        verticalLayout.addWidget(self.volume_label)

        self.volume_dial = QDial(self.sound_frame)
        self.volume_dial.setProperty("value", 100)
        verticalLayout.addWidget(self.volume_dial)

        notification_tab_verticalLayout.addWidget(self.sound_frame)

        # message_notification
        message_notification_horizontalLayout = QHBoxLayout()
        self.notification_label = QLabel(self.notifications_tab)
        message_notification_horizontalLayout.addWidget(
            self.notification_label)

        self.notification_comboBox = QComboBox(self.notifications_tab)
        message_notification_horizontalLayout.addWidget(
            self.notification_comboBox)
        notification_tab_verticalLayout.addLayout(
            message_notification_horizontalLayout)

        notification_tab_verticalLayout.addStretch(1)

        self.setting_tabWidget.addTab(self.notifications_tab, "")

        # style_tab
        self.style_tab = QWidget()
        style_tab_verticalLayout = QVBoxLayout(self.style_tab)
        style_tab_verticalLayout.setContentsMargins(21, 21, 0, 0)

        # style
        style_horizontalLayout = QHBoxLayout()

        self.style_label = QLabel(self.style_tab)
        style_horizontalLayout.addWidget(self.style_label)

        self.style_comboBox = QComboBox(self.style_tab)
        style_horizontalLayout.addWidget(self.style_comboBox)

        style_tab_verticalLayout.addLayout(style_horizontalLayout)

        # language
        language_horizontalLayout = QHBoxLayout()

        self.lang_label = QLabel(self.style_tab)
        language_horizontalLayout.addWidget(self.lang_label)
        self.lang_comboBox = QComboBox(self.style_tab)
        language_horizontalLayout.addWidget(self.lang_comboBox)

        style_tab_verticalLayout.addLayout(language_horizontalLayout)
        language_horizontalLayout = QHBoxLayout()
        self.lang_label.setText(
            QCoreApplication.translate("setting_ui_tr", "Language:"))

        # color scheme
        self.color_label = QLabel(self.style_tab)
        language_horizontalLayout.addWidget(self.color_label)

        self.color_comboBox = QComboBox(self.style_tab)
        language_horizontalLayout.addWidget(self.color_comboBox)

        style_tab_verticalLayout.addLayout(language_horizontalLayout)

        # icons
        icons_horizontalLayout = QHBoxLayout()
        self.icon_label = QLabel(self.style_tab)
        icons_horizontalLayout.addWidget(self.icon_label)

        self.icon_comboBox = QComboBox(self.style_tab)
        icons_horizontalLayout.addWidget(self.icon_comboBox)

        style_tab_verticalLayout.addLayout(icons_horizontalLayout)

        self.icons_size_horizontalLayout = QHBoxLayout()
        self.icons_size_label = QLabel(self.style_tab)
        self.icons_size_horizontalLayout.addWidget(self.icons_size_label)

        self.icons_size_comboBox = QComboBox(self.style_tab)
        self.icons_size_horizontalLayout.addWidget(self.icons_size_comboBox)

        style_tab_verticalLayout.addLayout(self.icons_size_horizontalLayout)

        # font
        font_horizontalLayout = QHBoxLayout()
        self.font_checkBox = QCheckBox(self.style_tab)
        font_horizontalLayout.addWidget(self.font_checkBox)

        self.fontComboBox = QFontComboBox(self.style_tab)
        font_horizontalLayout.addWidget(self.fontComboBox)

        self.font_size_label = QLabel(self.style_tab)
        font_horizontalLayout.addWidget(self.font_size_label)

        self.font_size_spinBox = QSpinBox(self.style_tab)
        self.font_size_spinBox.setMinimum(1)
        font_horizontalLayout.addWidget(self.font_size_spinBox)

        style_tab_verticalLayout.addLayout(font_horizontalLayout)
        self.setting_tabWidget.addTab(self.style_tab, "")
        window_verticalLayout.addWidget(self.setting_tabWidget)

        # start persepolis in system tray if browser executed
        self.start_persepolis_if_browser_executed_checkBox = QCheckBox(
            self.style_tab)
        style_tab_verticalLayout.addWidget(
            self.start_persepolis_if_browser_executed_checkBox)

        # hide window if close button clicked
        self.hide_window_checkBox = QCheckBox(self.style_tab)
        style_tab_verticalLayout.addWidget(self.hide_window_checkBox)

        # Enable system tray icon
        self.enable_system_tray_checkBox = QCheckBox(self.style_tab)
        style_tab_verticalLayout.addWidget(self.enable_system_tray_checkBox)

        # after_download dialog
        self.after_download_checkBox = QCheckBox()
        style_tab_verticalLayout.addWidget(self.after_download_checkBox)

        # show_menubar_checkbox
        self.show_menubar_checkbox = QCheckBox()
        style_tab_verticalLayout.addWidget(self.show_menubar_checkbox)

        # show_sidepanel_checkbox
        self.show_sidepanel_checkbox = QCheckBox()
        style_tab_verticalLayout.addWidget(self.show_sidepanel_checkbox)

        # hide progress window
        self.show_progress_window_checkbox = QCheckBox()
        style_tab_verticalLayout.addWidget(self.show_progress_window_checkbox)

        # add persepolis to startup
        self.startup_checkbox = QCheckBox()
        style_tab_verticalLayout.addWidget(self.startup_checkbox)

        # keep system awake
        self.keep_awake_checkBox = QCheckBox()
        style_tab_verticalLayout.addWidget(self.keep_awake_checkBox)

        style_tab_verticalLayout.addStretch(1)

        # columns_tab
        self.columns_tab = QWidget()

        columns_tab_verticalLayout = QVBoxLayout(self.columns_tab)
        columns_tab_verticalLayout.setContentsMargins(21, 21, 0, 0)

        # creating checkBox for columns
        self.show_column_label = QLabel()
        self.column0_checkBox = QCheckBox()
        self.column1_checkBox = QCheckBox()
        self.column2_checkBox = QCheckBox()
        self.column3_checkBox = QCheckBox()
        self.column4_checkBox = QCheckBox()
        self.column5_checkBox = QCheckBox()
        self.column6_checkBox = QCheckBox()
        self.column7_checkBox = QCheckBox()
        self.column10_checkBox = QCheckBox()
        self.column11_checkBox = QCheckBox()
        self.column12_checkBox = QCheckBox()

        columns_tab_verticalLayout.addWidget(self.show_column_label)
        columns_tab_verticalLayout.addWidget(self.column0_checkBox)
        columns_tab_verticalLayout.addWidget(self.column1_checkBox)
        columns_tab_verticalLayout.addWidget(self.column2_checkBox)
        columns_tab_verticalLayout.addWidget(self.column3_checkBox)
        columns_tab_verticalLayout.addWidget(self.column4_checkBox)
        columns_tab_verticalLayout.addWidget(self.column5_checkBox)
        columns_tab_verticalLayout.addWidget(self.column6_checkBox)
        columns_tab_verticalLayout.addWidget(self.column7_checkBox)
        columns_tab_verticalLayout.addWidget(self.column10_checkBox)
        columns_tab_verticalLayout.addWidget(self.column11_checkBox)
        columns_tab_verticalLayout.addWidget(self.column12_checkBox)

        columns_tab_verticalLayout.addStretch(1)

        self.setting_tabWidget.addTab(self.columns_tab, '')

        # video_finder_tab
        self.video_finder_tab = QWidget()

        video_finder_layout = QVBoxLayout(self.video_finder_tab)
        video_finder_layout.setContentsMargins(21, 21, 0, 0)

        video_finder_tab_verticalLayout = QVBoxLayout()

        max_links_horizontalLayout = QHBoxLayout()

        # max_links_label
        self.max_links_label = QLabel(self.video_finder_tab)

        max_links_horizontalLayout.addWidget(self.max_links_label)

        # max_links_spinBox
        self.max_links_spinBox = QSpinBox(self.video_finder_tab)
        self.max_links_spinBox.setMinimum(1)
        self.max_links_spinBox.setMaximum(16)
        max_links_horizontalLayout.addWidget(self.max_links_spinBox)
        video_finder_tab_verticalLayout.addLayout(max_links_horizontalLayout)

        self.video_finder_dl_path_horizontalLayout = QHBoxLayout()

        self.video_finder_frame = QFrame(self.video_finder_tab)
        self.video_finder_frame.setLayout(video_finder_tab_verticalLayout)

        video_finder_tab_verticalLayout.addStretch(1)

        video_finder_layout.addWidget(self.video_finder_frame)

        self.setting_tabWidget.addTab(self.video_finder_tab, "")

        # shortcut tab
        self.shortcut_tab = QWidget()
        shortcut_tab_verticalLayout = QVBoxLayout(self.shortcut_tab)
        shortcut_tab_verticalLayout.setContentsMargins(21, 21, 0, 0)

        # shortcut_table
        self.shortcut_table = QTableWidget(self)
        self.shortcut_table.setColumnCount(2)
        self.shortcut_table.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.shortcut_table.setSelectionMode(QAbstractItemView.SingleSelection)
        self.shortcut_table.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.shortcut_table.verticalHeader().hide()

        shortcut_table_header = [
            QCoreApplication.translate("setting_ui_tr", 'Action'),
            QCoreApplication.translate("setting_ui_tr", 'Shortcut')
        ]

        self.shortcut_table.setHorizontalHeaderLabels(shortcut_table_header)

        shortcut_tab_verticalLayout.addWidget(self.shortcut_table)

        self.setting_tabWidget.addTab(
            self.shortcut_tab,
            QCoreApplication.translate("setting_ui_tr", "Shortcuts"))

        # Actions
        actions_list = [
            QCoreApplication.translate('setting_ui_tr', 'Quit'),
            QCoreApplication.translate(
                'setting_ui_tr', 'Minimize main window to the tray icon'),
            QCoreApplication.translate('setting_ui_tr',
                                       'Remove download items'),
            QCoreApplication.translate('setting_ui_tr',
                                       'Delete download items'),
            QCoreApplication.translate('setting_ui_tr',
                                       'Move up selected items'),
            QCoreApplication.translate('setting_ui_tr',
                                       'Move down selected items'),
            QCoreApplication.translate('setting_ui_tr',
                                       'Add new download link'),
            QCoreApplication.translate('setting_ui_tr', 'Add new Video link'),
            QCoreApplication.translate('setting_ui_tr',
                                       'Import links from text file')
        ]

        # add actions to the shortcut_table
        j = 0
        for action in actions_list:
            item = QTableWidgetItem(str(action))

            # align center
            item.setTextAlignment(0x0004 | 0x0080)

            # insert item in shortcut_table
            self.shortcut_table.insertRow(j)
            self.shortcut_table.setItem(j, 0, item)

            j = j + 1

        self.shortcut_table.resizeColumnsToContents()

        # window buttons
        buttons_horizontalLayout = QHBoxLayout()
        buttons_horizontalLayout.addStretch(1)

        self.defaults_pushButton = QPushButton(self)
        buttons_horizontalLayout.addWidget(self.defaults_pushButton)

        self.cancel_pushButton = QPushButton(self)
        self.cancel_pushButton.setIcon(QIcon(icons + 'remove'))
        buttons_horizontalLayout.addWidget(self.cancel_pushButton)

        self.ok_pushButton = QPushButton(self)
        self.ok_pushButton.setIcon(QIcon(icons + 'ok'))
        buttons_horizontalLayout.addWidget(self.ok_pushButton)

        window_verticalLayout.addLayout(buttons_horizontalLayout)

        # set style_tab for default
        self.setting_tabWidget.setCurrentIndex(3)

        # labels and translations
        self.setWindowTitle(
            QCoreApplication.translate("setting_ui_tr", "Preferences"))

        self.tries_label.setToolTip(
            QCoreApplication.translate(
                "setting_ui_tr",
                "<html><head/><body><p>Set number of tries if download failed.</p></body></html>"
            ))
        self.tries_label.setText(
            QCoreApplication.translate("setting_ui_tr", "Number of tries: "))
        self.tries_spinBox.setToolTip(
            QCoreApplication.translate(
                "setting_ui_tr",
                "<html><head/><body><p>Set number of tries if download failed.</p></body></html>"
            ))

        self.wait_label.setToolTip(
            QCoreApplication.translate(
                "setting_ui_tr",
                "<html><head/><body><p>Set the seconds to wait between retries. Download manager will  retry  downloads  when  the  HTTP  server  returns  a  503 response.</p></body></html>"
            ))
        self.wait_label.setText(
            QCoreApplication.translate("setting_ui_tr",
                                       "Wait between retries (seconds): "))
        self.wait_spinBox.setToolTip(
            QCoreApplication.translate(
                "setting_ui_tr",
                "<html><head/><body><p>Set the seconds to wait between retries. Download manager will  retry  downloads  when  the  HTTP  server  returns  a  503 response.</p></body></html>"
            ))

        self.time_out_label.setToolTip(
            QCoreApplication.translate(
                "setting_ui_tr",
                "<html><head/><body><p>Set timeout in seconds. </p></body></html>"
            ))
        self.time_out_label.setText(
            QCoreApplication.translate("setting_ui_tr", "Timeout (seconds): "))
        self.time_out_spinBox.setToolTip(
            QCoreApplication.translate(
                "setting_ui_tr",
                "<html><head/><body><p>Set timeout in seconds. </p></body></html>"
            ))

        self.connections_label.setToolTip(
            QCoreApplication.translate(
                "setting_ui_tr",
                "<html><head/><body><p>Using multiple connections can help speed up your download.</p></body></html>"
            ))
        self.connections_label.setText(
            QCoreApplication.translate("setting_ui_tr",
                                       "Number of connections: "))
        self.connections_spinBox.setToolTip(
            QCoreApplication.translate(
                "setting_ui_tr",
                "<html><head/><body><p>Using multiple connections can help speed up your download.</p></body></html>"
            ))

        self.rpc_port_label.setText(
            QCoreApplication.translate("setting_ui_tr", "RPC port number: "))
        self.rpc_port_spinbox.setToolTip(
            QCoreApplication.translate(
                "setting_ui_tr",
                "<html><head/><body><p> Specify a port number for JSON-RPC/XML-RPC server to listen to. Possible Values: 1024 - 65535 Default: 6801 </p></body></html>"
            ))

        self.wait_queue_label.setText(
            QCoreApplication.translate(
                "setting_ui_tr", 'Wait between every downloads in queue:'))

        self.aria2_path_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr",
                                       'Change Aria2 default path'))
        self.aria2_path_pushButton.setText(
            QCoreApplication.translate("setting_ui_tr", 'Change'))
        aria2_path_tooltip = QCoreApplication.translate(
            "setting_ui_tr",
            "<html><head/><body><p>Attention: Wrong path may have caused problem! Do it carefully or don't change default setting!</p></body></html>"
        )
        self.aria2_path_checkBox.setToolTip(aria2_path_tooltip)
        self.aria2_path_lineEdit.setToolTip(aria2_path_tooltip)
        self.aria2_path_pushButton.setToolTip(aria2_path_tooltip)

        self.setting_tabWidget.setTabText(
            self.setting_tabWidget.indexOf(self.download_options_tab),
            QCoreApplication.translate("setting_ui_tr", "Download Options"))

        self.download_folder_label.setText(
            QCoreApplication.translate("setting_ui_tr", "Download Folder: "))
        self.download_folder_pushButton.setText(
            QCoreApplication.translate("setting_ui_tr", "Change"))

        self.temp_download_label.setText(
            QCoreApplication.translate("setting_ui_tr",
                                       "Temporary Download Folder: "))
        self.temp_download_pushButton.setText(
            QCoreApplication.translate("setting_ui_tr", "Change"))

        self.subfolder_checkBox.setText(
            QCoreApplication.translate(
                "setting_ui_tr",
                "Create subfolders for Music,Videos,... in default download folder"
            ))

        self.setting_tabWidget.setTabText(
            self.setting_tabWidget.indexOf(self.save_as_tab),
            QCoreApplication.translate("setting_ui_tr", "Save as"))

        self.enable_notifications_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr",
                                       "Enable notification sounds"))

        self.volume_label.setText(
            QCoreApplication.translate("setting_ui_tr", "Volume: "))

        self.setting_tabWidget.setTabText(
            self.setting_tabWidget.indexOf(self.notifications_tab),
            QCoreApplication.translate("setting_ui_tr", "Notifications"))

        self.style_label.setText(
            QCoreApplication.translate("setting_ui_tr", "Style: "))
        self.color_label.setText(
            QCoreApplication.translate("setting_ui_tr", "Color scheme: "))
        self.icon_label.setText(
            QCoreApplication.translate("setting_ui_tr", "Icons: "))

        self.icons_size_label.setText(
            QCoreApplication.translate("setting_ui_tr",
                                       "Toolbar's icons size: "))

        self.notification_label.setText(
            QCoreApplication.translate("setting_ui_tr", "Notification type: "))

        self.font_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", "Font: "))
        self.font_size_label.setText(
            QCoreApplication.translate("setting_ui_tr", "Size: "))

        self.hide_window_checkBox.setText(
            QCoreApplication.translate(
                "setting_ui_tr", "Hide main window if close button clicked."))
        self.hide_window_checkBox.setToolTip(
            QCoreApplication.translate(
                "setting_ui_tr",
                "<html><head/><body><p>This feature may not work in your operating system.</p></body></html>"
            ))

        self.start_persepolis_if_browser_executed_checkBox.setText(
            QCoreApplication.translate(
                'setting_ui_tr',
                'Start Persepolis in system tray, If browser is executed.'))

        self.enable_system_tray_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr",
                                       "Enable system tray icon."))

        self.after_download_checkBox.setText(
            QCoreApplication.translate(
                "setting_ui_tr",
                "Show download complete dialog when download has finished."))

        self.show_menubar_checkbox.setText(
            QCoreApplication.translate("setting_ui_tr", "Show menubar."))
        self.show_sidepanel_checkbox.setText(
            QCoreApplication.translate("setting_ui_tr", "Show side panel."))
        self.show_progress_window_checkbox.setText(
            QCoreApplication.translate("setting_ui_tr",
                                       "Show download's progress window"))

        self.startup_checkbox.setText(
            QCoreApplication.translate("setting_ui_tr",
                                       "Run Persepolis at startup"))

        self.keep_awake_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", "Keep system awake!"))
        self.keep_awake_checkBox.setToolTip(
            QCoreApplication.translate(
                "setting_ui_tr",
                "<html><head/><body><p>This option is preventing system from going to sleep.\
            This is necessary if your power manager is suspending system automatically. </p></body></html>"
            ))

        self.wait_queue_time.setToolTip(
            QCoreApplication.translate(
                "setting_ui_tr",
                "<html><head/><body><p>Format HH:MM</p></body></html>"))

        self.setting_tabWidget.setTabText(
            self.setting_tabWidget.indexOf(self.style_tab),
            QCoreApplication.translate("setting_ui_tr", "Preferences"))

        # columns_tab
        self.show_column_label.setText(
            QCoreApplication.translate("setting_ui_tr", 'Show this columns:'))
        self.column0_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", 'File Name'))
        self.column1_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", 'Status'))
        self.column2_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", 'Size'))
        self.column3_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", 'Downloaded'))
        self.column4_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", 'Percentage'))
        self.column5_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", 'Connections'))
        self.column6_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", 'Transfer rate'))
        self.column7_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", 'Estimated time left'))
        self.column10_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", 'First try date'))
        self.column11_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", 'Last try date'))
        self.column12_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", 'Category'))

        self.setting_tabWidget.setTabText(
            self.setting_tabWidget.indexOf(self.columns_tab),
            QCoreApplication.translate("setting_ui_tr",
                                       "Columns customization"))

        # Video Finder options tab
        self.setting_tabWidget.setTabText(
            self.setting_tabWidget.indexOf(self.video_finder_tab),
            QCoreApplication.translate("setting_ui_tr",
                                       "Video Finder Options"))

        self.max_links_label.setText(
            QCoreApplication.translate(
                "setting_ui_tr", 'Maximum number of links to capture:<br/>'
                '<small>(If browser sends multiple video links at a time)</small>'
            ))

        # window buttons
        self.defaults_pushButton.setText(
            QCoreApplication.translate("setting_ui_tr", "Defaults"))
        self.cancel_pushButton.setText(
            QCoreApplication.translate("setting_ui_tr", "Cancel"))
        self.ok_pushButton.setText(
            QCoreApplication.translate("setting_ui_tr", "OK"))
Example #3
0
class Setting_Ui(QWidget):
    def __init__(self, persepolis_setting):
        super().__init__()
        icon = QtGui.QIcon()
        self.setWindowIcon(
            QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg')))
        self.setWindowTitle('Preferences')

        global icons
        icons = ':/' + str(persepolis_setting.value('settings/icons')) + '/'

        self.verticalLayout_2 = QVBoxLayout(self)
        self.setting_tabWidget = QTabWidget(self)
        # download_options_tab
        self.download_options_tab = QWidget()
        self.layoutWidget = QWidget(self.download_options_tab)
        self.download_options_verticalLayout = QVBoxLayout(self.layoutWidget)
        self.download_options_verticalLayout.setContentsMargins(21, 21, 0, 0)
        self.download_options_verticalLayout.setObjectName(
            "download_options_verticalLayout")
        self.horizontalLayout_5 = QHBoxLayout()
        # tries_label
        self.tries_label = QLabel(self.layoutWidget)
        self.horizontalLayout_5.addWidget(self.tries_label)
        # tries_spinBox
        self.tries_spinBox = QSpinBox(self.layoutWidget)
        self.tries_spinBox.setMinimum(1)

        self.horizontalLayout_5.addWidget(self.tries_spinBox)
        self.download_options_verticalLayout.addLayout(self.horizontalLayout_5)
        self.horizontalLayout_4 = QHBoxLayout()
        # wait_label
        self.wait_label = QLabel(self.layoutWidget)
        self.horizontalLayout_4.addWidget(self.wait_label)
        # wait_spinBox
        self.wait_spinBox = QSpinBox(self.layoutWidget)
        self.horizontalLayout_4.addWidget(self.wait_spinBox)

        self.download_options_verticalLayout.addLayout(self.horizontalLayout_4)
        self.horizontalLayout_3 = QHBoxLayout()
        # time_out_label
        self.time_out_label = QLabel(self.layoutWidget)
        self.horizontalLayout_3.addWidget(self.time_out_label)
        # time_out_spinBox
        self.time_out_spinBox = QSpinBox(self.layoutWidget)
        self.horizontalLayout_3.addWidget(self.time_out_spinBox)

        self.download_options_verticalLayout.addLayout(self.horizontalLayout_3)
        self.horizontalLayout_2 = QHBoxLayout()
        # connections_label
        self.connections_label = QLabel(self.layoutWidget)
        self.horizontalLayout_2.addWidget(self.connections_label)
        # connections_spinBox
        self.connections_spinBox = QSpinBox(self.layoutWidget)
        self.connections_spinBox.setMinimum(1)
        self.connections_spinBox.setMaximum(16)
        self.horizontalLayout_2.addWidget(self.connections_spinBox)

        self.download_options_verticalLayout.addLayout(self.horizontalLayout_2)
        # rpc_port_label
        self.rpc_port_label = QLabel(self.layoutWidget)
        self.rpc_horizontalLayout = QHBoxLayout()
        self.rpc_horizontalLayout.addWidget(self.rpc_port_label)
        # rpc_port_spinbox
        self.rpc_port_spinbox = QSpinBox(self.layoutWidget)
        self.rpc_port_spinbox.setMinimum(1024)
        self.rpc_port_spinbox.setMaximum(65535)
        self.rpc_horizontalLayout.addWidget(self.rpc_port_spinbox)

        self.download_options_verticalLayout.addLayout(
            self.rpc_horizontalLayout)

        # wait_queue
        wait_queue_horizontalLayout = QHBoxLayout()

        self.wait_queue_label = QLabel(self.layoutWidget)
        wait_queue_horizontalLayout.addWidget(self.wait_queue_label)

        self.wait_queue_time = QDateTimeEdit(self.layoutWidget)
        self.wait_queue_time.setDisplayFormat('H:mm')
        wait_queue_horizontalLayout.addWidget(self.wait_queue_time)

        self.download_options_verticalLayout.addLayout(
            wait_queue_horizontalLayout)

        self.setting_tabWidget.addTab(self.download_options_tab, "")
        # save_as_tab
        self.save_as_tab = QWidget()

        self.layoutWidget1 = QWidget(self.save_as_tab)

        self.save_as_verticalLayout = QVBoxLayout(self.layoutWidget1)
        self.save_as_verticalLayout.setContentsMargins(20, 30, 0, 0)

        self.download_folder_horizontalLayout = QHBoxLayout()
        # download_folder_label
        self.download_folder_label = QLabel(self.layoutWidget1)
        self.download_folder_horizontalLayout.addWidget(
            self.download_folder_label)
        # download_folder_lineEdit
        self.download_folder_lineEdit = QLineEdit(self.layoutWidget1)
        self.download_folder_horizontalLayout.addWidget(
            self.download_folder_lineEdit)
        # download_folder_pushButton
        self.download_folder_pushButton = QPushButton(self.layoutWidget1)
        self.download_folder_horizontalLayout.addWidget(
            self.download_folder_pushButton)

        self.save_as_verticalLayout.addLayout(
            self.download_folder_horizontalLayout)
        self.temp_horizontalLayout = QHBoxLayout()
        # temp_download_label
        self.temp_download_label = QLabel(self.layoutWidget1)
        self.temp_horizontalLayout.addWidget(self.temp_download_label)
        # temp_download_lineEdit
        self.temp_download_lineEdit = QLineEdit(self.layoutWidget1)
        self.temp_horizontalLayout.addWidget(self.temp_download_lineEdit)
        # temp_download_pushButton
        self.temp_download_pushButton = QPushButton(self.layoutWidget1)
        self.temp_horizontalLayout.addWidget(self.temp_download_pushButton)

        self.save_as_verticalLayout.addLayout(self.temp_horizontalLayout)

        # create subfolder checkBox
        self.subfolder_checkBox = QCheckBox(self.layoutWidget1)
        self.save_as_verticalLayout.addWidget(self.subfolder_checkBox)

        self.setting_tabWidget.addTab(self.save_as_tab, "")
        # notifications_tab
        self.notifications_tab = QWidget()
        self.layoutWidget2 = QWidget(self.notifications_tab)
        self.verticalLayout_4 = QVBoxLayout(self.layoutWidget2)
        self.verticalLayout_4.setContentsMargins(21, 21, 0, 0)
        # enable_notifications_checkBox
        self.enable_notifications_checkBox = QCheckBox(self.layoutWidget2)
        self.verticalLayout_4.addWidget(self.enable_notifications_checkBox)
        # sound_frame
        self.sound_frame = QFrame(self.layoutWidget2)
        self.sound_frame.setFrameShape(QFrame.StyledPanel)
        self.sound_frame.setFrameShadow(QFrame.Raised)

        self.verticalLayout = QVBoxLayout(self.sound_frame)
        # volume_label
        self.volume_label = QLabel(self.sound_frame)
        self.verticalLayout.addWidget(self.volume_label)
        # volume_dial
        self.volume_dial = QDial(self.sound_frame)
        self.volume_dial.setProperty("value", 100)
        self.verticalLayout.addWidget(self.volume_dial)

        self.verticalLayout_4.addWidget(self.sound_frame)
        self.setting_tabWidget.addTab(self.notifications_tab, "")
        # style_tab
        self.style_tab = QWidget()
        self.layoutWidget3 = QWidget(self.style_tab)
        self.verticalLayout_3 = QVBoxLayout(self.layoutWidget3)
        self.verticalLayout_3.setContentsMargins(21, 21, 0, 0)
        self.horizontalLayout_8 = QHBoxLayout()
        # style_label
        self.style_label = QLabel(self.layoutWidget3)
        self.horizontalLayout_8.addWidget(self.style_label)
        # style_comboBox
        self.style_comboBox = QComboBox(self.layoutWidget3)
        self.horizontalLayout_8.addWidget(self.style_comboBox)

        self.verticalLayout_3.addLayout(self.horizontalLayout_8)
        self.horizontalLayout_7 = QHBoxLayout()
        # color_label
        self.color_label = QLabel(self.layoutWidget3)
        self.horizontalLayout_7.addWidget(self.color_label)
        # color_comboBox
        self.color_comboBox = QComboBox(self.layoutWidget3)
        self.horizontalLayout_7.addWidget(self.color_comboBox)

        self.verticalLayout_3.addLayout(self.horizontalLayout_7)
        # icon_label
        self.horizontalLayout_12 = QHBoxLayout()
        self.icon_label = QLabel(self.layoutWidget3)
        self.horizontalLayout_12.addWidget(self.icon_label)
        # icon_comboBox
        self.icon_comboBox = QComboBox(self.layoutWidget3)
        self.horizontalLayout_12.addWidget(self.icon_comboBox)

        self.verticalLayout_3.addLayout(self.horizontalLayout_12)
        self.horizontalLayout_6 = QHBoxLayout()
        # notification_label
        self.horizontalLayout_13 = QHBoxLayout()
        self.notification_label = QLabel(self.layoutWidget3)
        self.horizontalLayout_13.addWidget(self.notification_label)
        # notification_comboBox
        self.notification_comboBox = QComboBox(self.layoutWidget3)
        self.horizontalLayout_13.addWidget(self.notification_comboBox)
        self.verticalLayout_3.addLayout(self.horizontalLayout_13)
        # font_checkBox
        self.font_checkBox = QCheckBox(self.layoutWidget3)
        self.horizontalLayout_6.addWidget(self.font_checkBox)
        # fontComboBox
        self.fontComboBox = QFontComboBox(self.layoutWidget3)
        self.horizontalLayout_6.addWidget(self.fontComboBox)
        # font_size_label
        self.font_size_label = QLabel(self.layoutWidget3)
        self.horizontalLayout_6.addWidget(self.font_size_label)
        # font_size_spinBox
        self.font_size_spinBox = QSpinBox(self.layoutWidget3)
        self.font_size_spinBox.setMinimum(1)
        self.horizontalLayout_6.addWidget(self.font_size_spinBox)

        self.verticalLayout_3.addLayout(self.horizontalLayout_6)
        self.setting_tabWidget.addTab(self.style_tab, "")
        self.verticalLayout_2.addWidget(self.setting_tabWidget)
        self.horizontalLayout = QHBoxLayout()
        spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                 QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        # Enable system tray icon
        self.enable_system_tray_checkBox = QCheckBox(self.layoutWidget3)
        self.verticalLayout_3.addWidget(self.enable_system_tray_checkBox)
        # after_download dialog
        self.after_download_checkBox = QCheckBox()
        self.verticalLayout_3.addWidget(self.after_download_checkBox)

        # show_menubar_checkbox
        self.show_menubar_checkbox = QCheckBox()
        self.verticalLayout_3.addWidget(self.show_menubar_checkbox)

        # show_sidepanel_checkbox
        self.show_sidepanel_checkbox = QCheckBox()
        self.verticalLayout_3.addWidget(self.show_sidepanel_checkbox)

        # hide progress window
        self.show_progress_window_checkbox = QCheckBox()
        self.verticalLayout_3.addWidget(self.show_progress_window_checkbox)

        # add persepolis to startup
        self.startup_checkbox = QCheckBox()
        self.verticalLayout_3.addWidget(self.startup_checkbox)

        # keep system awake
        self.keep_awake_checkBox = QCheckBox()
        self.verticalLayout_3.addWidget(self.keep_awake_checkBox)

        # columns_tab
        self.columns_tab = QWidget()
        layoutWidget4 = QWidget(self.columns_tab)

        column_verticalLayout = QVBoxLayout(layoutWidget4)
        column_verticalLayout.setContentsMargins(21, 21, 0, 0)

        # creating checkBox for columns
        self.show_column_label = QLabel()
        self.column0_checkBox = QCheckBox()
        self.column1_checkBox = QCheckBox()
        self.column2_checkBox = QCheckBox()
        self.column3_checkBox = QCheckBox()
        self.column4_checkBox = QCheckBox()
        self.column5_checkBox = QCheckBox()
        self.column6_checkBox = QCheckBox()
        self.column7_checkBox = QCheckBox()
        self.column10_checkBox = QCheckBox()
        self.column11_checkBox = QCheckBox()
        self.column12_checkBox = QCheckBox()

        column_verticalLayout.addWidget(self.show_column_label)
        column_verticalLayout.addWidget(self.column0_checkBox)
        column_verticalLayout.addWidget(self.column1_checkBox)
        column_verticalLayout.addWidget(self.column2_checkBox)
        column_verticalLayout.addWidget(self.column3_checkBox)
        column_verticalLayout.addWidget(self.column4_checkBox)
        column_verticalLayout.addWidget(self.column5_checkBox)
        column_verticalLayout.addWidget(self.column6_checkBox)
        column_verticalLayout.addWidget(self.column7_checkBox)
        column_verticalLayout.addWidget(self.column10_checkBox)
        column_verticalLayout.addWidget(self.column11_checkBox)
        column_verticalLayout.addWidget(self.column12_checkBox)

        self.setting_tabWidget.addTab(self.columns_tab, '')
        # defaults_pushButton
        self.defaults_pushButton = QPushButton(self)
        self.horizontalLayout.addWidget(self.defaults_pushButton)
        # cancel_pushButton
        self.cancel_pushButton = QPushButton(self)
        self.cancel_pushButton.setIcon(QIcon(icons + 'remove'))
        self.horizontalLayout.addWidget(self.cancel_pushButton)
        # ok_pushButton
        self.ok_pushButton = QPushButton(self)
        self.ok_pushButton.setIcon(QIcon(icons + 'ok'))
        self.horizontalLayout.addWidget(self.ok_pushButton)

        self.verticalLayout_2.addLayout(self.horizontalLayout)
        self.setting_tabWidget.setCurrentIndex(3)

        self.setWindowTitle("Preferences")

        self.tries_label.setToolTip(
            "<html><head/><body><p>Set number of tries if download failed.</p></body></html>"
        )
        self.tries_label.setText("Number of tries : ")
        self.tries_spinBox.setToolTip(
            "<html><head/><body><p>Set number of tries if download failed.</p></body></html>"
        )

        self.wait_label.setToolTip(
            "<html><head/><body><p>Set the seconds to wait between retries. Download manager will  retry  downloads  when  the  HTTP  server  returns  a  503 response.</p></body></html>"
        )
        self.wait_label.setText("Wait between retries (seconds) : ")
        self.wait_spinBox.setToolTip(
            "<html><head/><body><p>Set the seconds to wait between retries. Download manager will  retry  downloads  when  the  HTTP  server  returns  a  503 response.</p></body></html>"
        )

        self.time_out_label.setToolTip(
            "<html><head/><body><p>Set timeout in seconds. </p></body></html>")
        self.time_out_label.setText("Time out (seconds) : ")
        self.time_out_spinBox.setToolTip(
            "<html><head/><body><p>Set timeout in seconds. </p></body></html>")

        self.connections_label.setToolTip(
            "<html><head/><body><p>Using multiple connections can help speed up your download.</p></body></html>"
        )
        self.connections_label.setText("Number of connections : ")
        self.connections_spinBox.setToolTip(
            "<html><head/><body><p>Using multiple connections can help speed up your download.</p></body></html>"
        )

        self.rpc_port_label.setText("RPC port number : ")
        self.rpc_port_spinbox.setToolTip(
            "<html><head/><body><p> Specify a port number for JSON-RPC/XML-RPC server to listen to. Possible Values: 1024 - 65535 Default: 6801 </p></body></html>"
        )

        self.wait_queue_label.setText('Wait between every downloads in queue:')

        self.setting_tabWidget.setTabText(
            self.setting_tabWidget.indexOf(self.download_options_tab),
            "Download Options")

        self.download_folder_label.setText("Download Folder : ")
        self.download_folder_pushButton.setText("Change")

        self.temp_download_label.setText("Temporary Download Folder : ")
        self.temp_download_pushButton.setText("Change")

        self.subfolder_checkBox.setText(
            "Create subfolders for Music,Videos,... in default download folder"
        )

        self.setting_tabWidget.setTabText(
            self.setting_tabWidget.indexOf(self.save_as_tab), "Save as")

        self.enable_notifications_checkBox.setText(
            "Enable notification sounds")

        self.volume_label.setText("Volume : ")

        self.setting_tabWidget.setTabText(
            self.setting_tabWidget.indexOf(self.notifications_tab),
            "Notifications")

        self.style_label.setText("Style : ")
        self.color_label.setText("Color scheme : ")
        self.icon_label.setText("Icons : ")

        self.notification_label.setText("Notification type : ")

        self.font_checkBox.setText("Font : ")
        self.font_size_label.setText("Size : ")

        self.enable_system_tray_checkBox.setText("Enable system tray icon.")
        self.after_download_checkBox.setText(
            "Show download complete dialog,when download has finished.")

        self.show_menubar_checkbox.setText("Show menubar.")
        self.show_sidepanel_checkbox.setText("Show side panel.")
        self.show_progress_window_checkbox.setText(
            "Show download's progress window")

        self.startup_checkbox.setText("Run Persepolis at startup")

        self.keep_awake_checkBox.setText("Keep system awake!")
        self.keep_awake_checkBox.setToolTip(
            "<html><head/><body><p>This option is preventing system from going to sleep.\
            This is necessary if your power manager is suspending system automatically. </p></body></html>"
        )

        self.wait_queue_time.setToolTip(
            "<html><head/><body><p>Format HH:MM</p></body></html>")

        self.setting_tabWidget.setTabText(
            self.setting_tabWidget.indexOf(self.style_tab), "Preferences")

        # columns_tab
        self.show_column_label.setText('Show this columns:')
        self.column0_checkBox.setText('File Name')
        self.column1_checkBox.setText('Status')
        self.column2_checkBox.setText('Size')
        self.column3_checkBox.setText('Downloaded')
        self.column4_checkBox.setText('Percentage')
        self.column5_checkBox.setText('Connections')
        self.column6_checkBox.setText('Transfer rate')
        self.column7_checkBox.setText('Estimate time left')
        self.column10_checkBox.setText('First try date')
        self.column11_checkBox.setText('Last try date')
        self.column12_checkBox.setText('Category')

        self.setting_tabWidget.setTabText(
            self.setting_tabWidget.indexOf(self.columns_tab),
            "Columns customization")

        # window buttons
        self.defaults_pushButton.setText("Defaults")
        self.cancel_pushButton.setText("Cancel")
        self.ok_pushButton.setText("OK")
Example #4
0
    def initUI(self):
        btn_gen = QPushButton('Generate', self)
        btn_gen.setToolTip("Generate meal suggestions")
        btn_gen.setStyleSheet(
            'QPushButton {background-color : rgb(255,0,0); color : black}')

        btn_edit = QPushButton('Edit List', self)
        btn_edit.setToolTip("Edit Meals")

        sld = QSlider(Qt.Horizontal, self)
        sld.setToolTip(
            "The ratio of vegetarian dishes in the next list of suggestions")
        sld.setMinimum(0)
        sld.setMaximum(100)
        sld.setValue(70)

        sld_lab = QLabel("Veg Dishes " + str(sld.value()) + "%", self)

        def onChanged():
            text = "Veg Dishes " + str(sld.value()) + "%"
            sld_lab.setText(text)

        sld.valueChanged.connect(onChanged)

        start_cal = QDateTimeEdit(self)
        start_cal.setCalendarPopup(True)
        start_cal.setMinimumDate(QDate.currentDate())
        start_cal.setDisplayFormat("ddd dd.MM")
        start_cal.setToolTip("Select a starting date")
        start_cal_lab = QLabel("Start:", self)

        end_cal = QDateTimeEdit(self)
        end_cal.setCalendarPopup(True)
        end_cal.setDate(QDate.currentDate().addDays(5))
        end_cal.setMinimumDate(QDate.currentDate().addDays(0))
        end_cal.setDisplayFormat("ddd dd.MM")
        end_cal.setToolTip("Select an end date")
        end_cal_lab = QLabel("End:", self)

        def startrange():
            if end_cal.date() < start_cal.date():
                start_cal.setDate(end_cal.date())

        end_cal.dateChanged.connect(startrange)

        self.setFixedSize(300, 150)
        self.center()
        self.setWindowTitle('suggestible')
        self.setWindowIcon(QIcon('icon.png'))

        def createGridLayout(self):
            self.horizontalGroupBox = QWidget()
            layout = QGridLayout()
            layout.setColumnStretch(0, 5)
            layout.setColumnStretch(1, 5)
            layout.setRowStretch(5, 1)
            layout.setVerticalSpacing(8)

            layout.addWidget(start_cal_lab, 0, 0)
            layout.addWidget(end_cal_lab, 0, 1)
            layout.addWidget(start_cal, 1, 0)
            layout.addWidget(end_cal, 1, 1)
            layout.addWidget(btn_edit, 2, 0)
            layout.addWidget(sld, 2, 1)
            layout.addWidget(sld_lab, 2, 1, 3, 1, alignment=Qt.AlignCenter)
            layout.addWidget(btn_gen, 4, 0, 2, 2)
            layout.setRowMinimumHeight(4, 15)
            layout.setRowMinimumHeight(5, 15)

            self.horizontalGroupBox.setLayout(layout)

        createGridLayout(self)

        windowLayout = QVBoxLayout()
        windowLayout.addWidget(self.horizontalGroupBox)
        self.setLayout(windowLayout)

        self.show()

        def dates(starting, ending):
            end = ending.date()
            start = starting.date()
            en = end.toString("yyyy-MM-dd")
            en = parse(en)
            st = start.toString("yyyy.MM.dd")
            st = parse(st)

            def daterange(st, en):
                for n in range(int((en - st).days) + 1):
                    yield st + timedelta(n)

            fin_dates = []
            for dt in daterange(st, en):
                fin_dates.append(dt.strftime("%A %d.%m"))

            return fin_dates

        def dates_header(starting, ending):
            end = ending.date()
            start = starting.date()
            en = end.toString("dd.MM")
            st = start.toString("dd.MM")
            return st + "-" + en

        def html_creator(starting, ending, ratio0):
            templateLoader = jinja2.FileSystemLoader(searchpath="")
            templateEnv = jinja2.Environment(loader=templateLoader)
            TEMPLATE_FILE = "template_suggestions.html"
            template = templateEnv.get_template(TEMPLATE_FILE)

            outputText = template.render(range=dates_header(starting, ending),
                                         table=main(dates(starting, ending),
                                                    ratio0))
            html_file = open("suggestions" + '.html', 'w')
            html_file.write(outputText)
            html_file.close()

        def generate():
            html_creator(start_cal, end_cal, sld.value() / 100)
            webbrowser.open("suggestions.html", new=1)

        def popupwindow():
            self.editor = tablegui.App()

        btn_gen.clicked.connect(generate)
        btn_edit.clicked.connect(popupwindow)
Example #5
0
class Setting_Ui(QWidget):
    def __init__(self, persepolis_setting):
        super().__init__()
        icon = QtGui.QIcon()

        self.persepolis_setting = persepolis_setting

        # add support for other languages
        locale = str(self.persepolis_setting.value('settings/locale'))
        QLocale.setDefault(QLocale(locale))
        self.translator = QTranslator()
        if self.translator.load(':/translations/locales/ui_' + locale, 'ts'):
            QCoreApplication.installTranslator(self.translator)

        self.setWindowIcon(
            QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg')))
        self.setWindowTitle(
            QCoreApplication.translate("setting_ui_tr", 'Preferences'))

        # set ui direction
        ui_direction = self.persepolis_setting.value('ui_direction')

        if ui_direction == 'rtl':
            self.setLayoutDirection(Qt.RightToLeft)

        elif ui_direction in 'ltr':
            self.setLayoutDirection(Qt.LeftToRight)

        global icons
        icons = ':/' + str(
            self.persepolis_setting.value('settings/icons')) + '/'

        self.verticalLayout_2 = QVBoxLayout(self)
        self.setting_tabWidget = QTabWidget(self)
        # download_options_tab
        self.download_options_tab = QWidget()
        self.layoutWidget = QWidget(self.download_options_tab)
        self.download_options_verticalLayout = QVBoxLayout(self.layoutWidget)
        self.download_options_verticalLayout.setContentsMargins(21, 21, 0, 0)
        self.download_options_verticalLayout.setObjectName(
            "download_options_verticalLayout")
        self.horizontalLayout_5 = QHBoxLayout()
        # tries_label
        self.tries_label = QLabel(self.layoutWidget)
        self.horizontalLayout_5.addWidget(self.tries_label)
        # tries_spinBox
        self.tries_spinBox = QSpinBox(self.layoutWidget)
        self.tries_spinBox.setMinimum(1)

        self.horizontalLayout_5.addWidget(self.tries_spinBox)
        self.download_options_verticalLayout.addLayout(self.horizontalLayout_5)
        self.horizontalLayout_4 = QHBoxLayout()
        # wait_label
        self.wait_label = QLabel(self.layoutWidget)
        self.horizontalLayout_4.addWidget(self.wait_label)
        # wait_spinBox
        self.wait_spinBox = QSpinBox(self.layoutWidget)
        self.horizontalLayout_4.addWidget(self.wait_spinBox)

        self.download_options_verticalLayout.addLayout(self.horizontalLayout_4)
        self.horizontalLayout_3 = QHBoxLayout()
        # time_out_label
        self.time_out_label = QLabel(self.layoutWidget)
        self.horizontalLayout_3.addWidget(self.time_out_label)
        # time_out_spinBox
        self.time_out_spinBox = QSpinBox(self.layoutWidget)
        self.horizontalLayout_3.addWidget(self.time_out_spinBox)

        self.download_options_verticalLayout.addLayout(self.horizontalLayout_3)
        self.horizontalLayout_2 = QHBoxLayout()
        # connections_label
        self.connections_label = QLabel(self.layoutWidget)
        self.horizontalLayout_2.addWidget(self.connections_label)
        # connections_spinBox
        self.connections_spinBox = QSpinBox(self.layoutWidget)
        self.connections_spinBox.setMinimum(1)
        self.connections_spinBox.setMaximum(16)
        self.horizontalLayout_2.addWidget(self.connections_spinBox)

        self.download_options_verticalLayout.addLayout(self.horizontalLayout_2)
        # rpc_port_label
        self.rpc_port_label = QLabel(self.layoutWidget)
        self.rpc_horizontalLayout = QHBoxLayout()
        self.rpc_horizontalLayout.addWidget(self.rpc_port_label)
        # rpc_port_spinbox
        self.rpc_port_spinbox = QSpinBox(self.layoutWidget)
        self.rpc_port_spinbox.setMinimum(1024)
        self.rpc_port_spinbox.setMaximum(65535)
        self.rpc_horizontalLayout.addWidget(self.rpc_port_spinbox)

        self.download_options_verticalLayout.addLayout(
            self.rpc_horizontalLayout)

        # wait_queue
        wait_queue_horizontalLayout = QHBoxLayout()

        self.wait_queue_label = QLabel(self.layoutWidget)
        wait_queue_horizontalLayout.addWidget(self.wait_queue_label)

        self.wait_queue_time = QDateTimeEdit(self.layoutWidget)
        self.wait_queue_time.setDisplayFormat('H:mm')
        wait_queue_horizontalLayout.addWidget(self.wait_queue_time)

        self.download_options_verticalLayout.addLayout(
            wait_queue_horizontalLayout)

        # change aria2 path
        aria2_path_verticalLayout = QVBoxLayout()

        self.aria2_path_checkBox = QCheckBox(self.layoutWidget)
        aria2_path_verticalLayout.addWidget(self.aria2_path_checkBox)

        aria2_path_horizontalLayout = QHBoxLayout()

        self.aria2_path_lineEdit = QLineEdit(self.layoutWidget)
        aria2_path_horizontalLayout.addWidget(self.aria2_path_lineEdit)

        self.aria2_path_pushButton = QPushButton(self.layoutWidget)
        aria2_path_horizontalLayout.addWidget(self.aria2_path_pushButton)

        aria2_path_verticalLayout.addLayout(aria2_path_horizontalLayout)

        self.download_options_verticalLayout.addLayout(
            aria2_path_verticalLayout)

        self.setting_tabWidget.addTab(self.download_options_tab, "")
        # save_as_tab
        self.save_as_tab = QWidget()

        self.layoutWidget1 = QWidget(self.save_as_tab)

        self.save_as_verticalLayout = QVBoxLayout(self.layoutWidget1)
        self.save_as_verticalLayout.setContentsMargins(20, 30, 0, 0)

        self.download_folder_horizontalLayout = QHBoxLayout()
        # download_folder_label
        self.download_folder_label = QLabel(self.layoutWidget1)
        self.download_folder_horizontalLayout.addWidget(
            self.download_folder_label)
        # download_folder_lineEdit
        self.download_folder_lineEdit = QLineEdit(self.layoutWidget1)
        self.download_folder_horizontalLayout.addWidget(
            self.download_folder_lineEdit)
        # download_folder_pushButton
        self.download_folder_pushButton = QPushButton(self.layoutWidget1)
        self.download_folder_horizontalLayout.addWidget(
            self.download_folder_pushButton)

        self.save_as_verticalLayout.addLayout(
            self.download_folder_horizontalLayout)
        self.temp_horizontalLayout = QHBoxLayout()
        # temp_download_label
        self.temp_download_label = QLabel(self.layoutWidget1)
        self.temp_horizontalLayout.addWidget(self.temp_download_label)
        # temp_download_lineEdit
        self.temp_download_lineEdit = QLineEdit(self.layoutWidget1)
        self.temp_horizontalLayout.addWidget(self.temp_download_lineEdit)
        # temp_download_pushButton
        self.temp_download_pushButton = QPushButton(self.layoutWidget1)
        self.temp_horizontalLayout.addWidget(self.temp_download_pushButton)

        self.save_as_verticalLayout.addLayout(self.temp_horizontalLayout)

        # create subfolder checkBox
        self.subfolder_checkBox = QCheckBox(self.layoutWidget1)
        self.save_as_verticalLayout.addWidget(self.subfolder_checkBox)

        self.setting_tabWidget.addTab(self.save_as_tab, "")
        # notifications_tab
        self.notifications_tab = QWidget()
        self.layoutWidget2 = QWidget(self.notifications_tab)
        self.verticalLayout_4 = QVBoxLayout(self.layoutWidget2)
        self.verticalLayout_4.setContentsMargins(21, 21, 0, 0)
        # enable_notifications_checkBox
        self.enable_notifications_checkBox = QCheckBox(self.layoutWidget2)
        self.verticalLayout_4.addWidget(self.enable_notifications_checkBox)
        # sound_frame
        self.sound_frame = QFrame(self.layoutWidget2)
        self.sound_frame.setFrameShape(QFrame.StyledPanel)
        self.sound_frame.setFrameShadow(QFrame.Raised)

        self.verticalLayout = QVBoxLayout(self.sound_frame)
        # volume_label
        self.volume_label = QLabel(self.sound_frame)
        self.verticalLayout.addWidget(self.volume_label)
        # volume_dial
        self.volume_dial = QDial(self.sound_frame)
        self.volume_dial.setProperty("value", 100)
        self.verticalLayout.addWidget(self.volume_dial)

        self.verticalLayout_4.addWidget(self.sound_frame)
        self.setting_tabWidget.addTab(self.notifications_tab, "")
        # style_tab
        self.style_tab = QWidget()
        self.layoutWidget3 = QWidget(self.style_tab)
        self.verticalLayout_3 = QVBoxLayout(self.layoutWidget3)
        self.verticalLayout_3.setContentsMargins(21, 21, 0, 0)
        self.horizontalLayout_8 = QHBoxLayout()
        # style_label
        self.style_label = QLabel(self.layoutWidget3)
        self.horizontalLayout_8.addWidget(self.style_label)
        # style_comboBox
        self.style_comboBox = QComboBox(self.layoutWidget3)
        self.horizontalLayout_8.addWidget(self.style_comboBox)

        self.verticalLayout_3.addLayout(self.horizontalLayout_8)
        self.horizontalLayout_7 = QHBoxLayout()
        # language_combox
        self.lang_label = QLabel(self.layoutWidget3)
        self.horizontalLayout_7.addWidget(self.lang_label)
        self.lang_comboBox = QComboBox(self.layoutWidget3)
        self.horizontalLayout_7.addWidget(self.lang_comboBox)

        # language_label
        self.verticalLayout_3.addLayout(self.horizontalLayout_7)
        self.horizontalLayout_7 = QHBoxLayout()
        self.lang_label.setText(
            QCoreApplication.translate("setting_ui_tr", "Language:"))
        # color_label
        self.color_label = QLabel(self.layoutWidget3)
        self.horizontalLayout_7.addWidget(self.color_label)
        # color_comboBox
        self.color_comboBox = QComboBox(self.layoutWidget3)
        self.horizontalLayout_7.addWidget(self.color_comboBox)

        self.verticalLayout_3.addLayout(self.horizontalLayout_7)
        # icon_label
        self.horizontalLayout_12 = QHBoxLayout()
        self.icon_label = QLabel(self.layoutWidget3)
        self.horizontalLayout_12.addWidget(self.icon_label)

        # icon_comboBox
        self.icon_comboBox = QComboBox(self.layoutWidget3)
        self.horizontalLayout_12.addWidget(self.icon_comboBox)

        self.verticalLayout_3.addLayout(self.horizontalLayout_12)

        # icons_size_comboBox
        self.icons_size_horizontalLayout = QHBoxLayout()
        self.icons_size_label = QLabel(self.layoutWidget3)
        self.icons_size_horizontalLayout.addWidget(self.icons_size_label)

        self.icons_size_comboBox = QComboBox(self.layoutWidget3)
        self.icons_size_horizontalLayout.addWidget(self.icons_size_comboBox)

        self.verticalLayout_3.addLayout(self.icons_size_horizontalLayout)

        self.horizontalLayout_6 = QHBoxLayout()
        # notification_label
        self.horizontalLayout_13 = QHBoxLayout()
        self.notification_label = QLabel(self.layoutWidget3)
        self.horizontalLayout_13.addWidget(self.notification_label)
        # notification_comboBox
        self.notification_comboBox = QComboBox(self.layoutWidget3)
        self.horizontalLayout_13.addWidget(self.notification_comboBox)
        self.verticalLayout_3.addLayout(self.horizontalLayout_13)
        # font_checkBox
        self.font_checkBox = QCheckBox(self.layoutWidget3)
        self.horizontalLayout_6.addWidget(self.font_checkBox)
        # fontComboBox
        self.fontComboBox = QFontComboBox(self.layoutWidget3)
        self.horizontalLayout_6.addWidget(self.fontComboBox)
        # font_size_label
        self.font_size_label = QLabel(self.layoutWidget3)
        self.horizontalLayout_6.addWidget(self.font_size_label)
        # font_size_spinBox
        self.font_size_spinBox = QSpinBox(self.layoutWidget3)
        self.font_size_spinBox.setMinimum(1)
        self.horizontalLayout_6.addWidget(self.font_size_spinBox)

        self.verticalLayout_3.addLayout(self.horizontalLayout_6)
        self.setting_tabWidget.addTab(self.style_tab, "")
        self.verticalLayout_2.addWidget(self.setting_tabWidget)
        self.horizontalLayout = QHBoxLayout()
        spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                 QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        # Enable system tray icon
        self.enable_system_tray_checkBox = QCheckBox(self.layoutWidget3)
        self.verticalLayout_3.addWidget(self.enable_system_tray_checkBox)
        # after_download dialog
        self.after_download_checkBox = QCheckBox()
        self.verticalLayout_3.addWidget(self.after_download_checkBox)

        # show_menubar_checkbox
        self.show_menubar_checkbox = QCheckBox()
        self.verticalLayout_3.addWidget(self.show_menubar_checkbox)

        # show_sidepanel_checkbox
        self.show_sidepanel_checkbox = QCheckBox()
        self.verticalLayout_3.addWidget(self.show_sidepanel_checkbox)

        # hide progress window
        self.show_progress_window_checkbox = QCheckBox()
        self.verticalLayout_3.addWidget(self.show_progress_window_checkbox)

        # add persepolis to startup
        self.startup_checkbox = QCheckBox()
        self.verticalLayout_3.addWidget(self.startup_checkbox)

        # keep system awake
        self.keep_awake_checkBox = QCheckBox()
        self.verticalLayout_3.addWidget(self.keep_awake_checkBox)

        # columns_tab
        self.columns_tab = QWidget()
        layoutWidget4 = QWidget(self.columns_tab)

        column_verticalLayout = QVBoxLayout(layoutWidget4)
        column_verticalLayout.setContentsMargins(21, 21, 0, 0)

        # creating checkBox for columns
        self.show_column_label = QLabel()
        self.column0_checkBox = QCheckBox()
        self.column1_checkBox = QCheckBox()
        self.column2_checkBox = QCheckBox()
        self.column3_checkBox = QCheckBox()
        self.column4_checkBox = QCheckBox()
        self.column5_checkBox = QCheckBox()
        self.column6_checkBox = QCheckBox()
        self.column7_checkBox = QCheckBox()
        self.column10_checkBox = QCheckBox()
        self.column11_checkBox = QCheckBox()
        self.column12_checkBox = QCheckBox()

        column_verticalLayout.addWidget(self.show_column_label)
        column_verticalLayout.addWidget(self.column0_checkBox)
        column_verticalLayout.addWidget(self.column1_checkBox)
        column_verticalLayout.addWidget(self.column2_checkBox)
        column_verticalLayout.addWidget(self.column3_checkBox)
        column_verticalLayout.addWidget(self.column4_checkBox)
        column_verticalLayout.addWidget(self.column5_checkBox)
        column_verticalLayout.addWidget(self.column6_checkBox)
        column_verticalLayout.addWidget(self.column7_checkBox)
        column_verticalLayout.addWidget(self.column10_checkBox)
        column_verticalLayout.addWidget(self.column11_checkBox)
        column_verticalLayout.addWidget(self.column12_checkBox)

        self.setting_tabWidget.addTab(self.columns_tab, '')

        # video_finder_tab
        self.video_finder_tab = QWidget()
        self.layoutWidgetYTD = QWidget(self.video_finder_tab)
        self.video_finder_layout = QVBoxLayout(self.layoutWidgetYTD)
        self.video_finder_layout.setContentsMargins(20, 30, 0, 0)

        self.video_finder_verticalLayout = QVBoxLayout()

        # Whether to enable video link capturing.
        self.enable_video_finder_checkbox = QCheckBox(self.layoutWidgetYTD)
        self.video_finder_layout.addWidget(self.enable_video_finder_checkbox)

        # If we should hide videos with no audio
        self.hide_no_audio_checkbox = QCheckBox(self.layoutWidgetYTD)
        self.video_finder_verticalLayout.addWidget(self.hide_no_audio_checkbox)

        # If we should hide audios without video
        self.hide_no_video_checkbox = QCheckBox(self.layoutWidgetYTD)
        self.video_finder_verticalLayout.addWidget(self.hide_no_video_checkbox)

        self.max_links_horizontalLayout = QHBoxLayout()

        # max_links_label
        self.max_links_label = QLabel(self.layoutWidgetYTD)

        self.max_links_horizontalLayout.addWidget(self.max_links_label)
        # max_links_spinBox
        self.max_links_spinBox = QSpinBox(self.layoutWidgetYTD)
        self.max_links_spinBox.setMinimum(1)
        self.max_links_spinBox.setMaximum(16)
        self.max_links_horizontalLayout.addWidget(self.max_links_spinBox)
        self.video_finder_verticalLayout.addLayout(
            self.max_links_horizontalLayout)

        self.video_finder_dl_path_horizontalLayout = QHBoxLayout()

        self.video_finder_frame = QFrame(self.video_finder_tab)
        self.video_finder_frame.setLayout(self.video_finder_verticalLayout)

        self.video_finder_layout.addWidget(self.video_finder_frame)

        self.setting_tabWidget.addTab(self.video_finder_tab, "")

        # defaults_pushButton
        self.defaults_pushButton = QPushButton(self)
        self.horizontalLayout.addWidget(self.defaults_pushButton)
        # cancel_pushButton
        self.cancel_pushButton = QPushButton(self)
        self.cancel_pushButton.setIcon(QIcon(icons + 'remove'))
        self.horizontalLayout.addWidget(self.cancel_pushButton)
        # ok_pushButton
        self.ok_pushButton = QPushButton(self)
        self.ok_pushButton.setIcon(QIcon(icons + 'ok'))
        self.horizontalLayout.addWidget(self.ok_pushButton)

        self.verticalLayout_2.addLayout(self.horizontalLayout)
        self.setting_tabWidget.setCurrentIndex(3)

        self.setWindowTitle(
            QCoreApplication.translate("setting_ui_tr", "Preferences"))

        self.tries_label.setToolTip(
            QCoreApplication.translate(
                "setting_ui_tr",
                "<html><head/><body><p>Set number of tries if download failed.</p></body></html>"
            ))
        self.tries_label.setText(
            QCoreApplication.translate("setting_ui_tr", "Number of tries: "))
        self.tries_spinBox.setToolTip(
            QCoreApplication.translate(
                "setting_ui_tr",
                "<html><head/><body><p>Set number of tries if download failed.</p></body></html>"
            ))

        self.wait_label.setToolTip(
            QCoreApplication.translate(
                "setting_ui_tr",
                "<html><head/><body><p>Set the seconds to wait between retries. Download manager will  retry  downloads  when  the  HTTP  server  returns  a  503 response.</p></body></html>"
            ))
        self.wait_label.setText(
            QCoreApplication.translate("setting_ui_tr",
                                       "Wait between retries (seconds): "))
        self.wait_spinBox.setToolTip(
            QCoreApplication.translate(
                "setting_ui_tr",
                "<html><head/><body><p>Set the seconds to wait between retries. Download manager will  retry  downloads  when  the  HTTP  server  returns  a  503 response.</p></body></html>"
            ))

        self.time_out_label.setToolTip(
            QCoreApplication.translate(
                "setting_ui_tr",
                "<html><head/><body><p>Set timeout in seconds. </p></body></html>"
            ))
        self.time_out_label.setText(
            QCoreApplication.translate("setting_ui_tr", "Timeout (seconds): "))
        self.time_out_spinBox.setToolTip(
            QCoreApplication.translate(
                "setting_ui_tr",
                "<html><head/><body><p>Set timeout in seconds. </p></body></html>"
            ))

        self.connections_label.setToolTip(
            QCoreApplication.translate(
                "setting_ui_tr",
                "<html><head/><body><p>Using multiple connections can help speed up your download.</p></body></html>"
            ))
        self.connections_label.setText(
            QCoreApplication.translate("setting_ui_tr",
                                       "Number of connections: "))
        self.connections_spinBox.setToolTip(
            QCoreApplication.translate(
                "setting_ui_tr",
                "<html><head/><body><p>Using multiple connections can help speed up your download.</p></body></html>"
            ))

        self.rpc_port_label.setText(
            QCoreApplication.translate("setting_ui_tr", "RPC port number: "))
        self.rpc_port_spinbox.setToolTip(
            QCoreApplication.translate(
                "setting_ui_tr",
                "<html><head/><body><p> Specify a port number for JSON-RPC/XML-RPC server to listen to. Possible Values: 1024 - 65535 Default: 6801 </p></body></html>"
            ))

        self.wait_queue_label.setText(
            QCoreApplication.translate(
                "setting_ui_tr", 'Wait between every downloads in queue:'))

        self.aria2_path_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr",
                                       'Change Aria2 default path'))
        self.aria2_path_pushButton.setText(
            QCoreApplication.translate("setting_ui_tr", 'Change'))
        aria2_path_tooltip = QCoreApplication.translate(
            "setting_ui_tr",
            "<html><head/><body><p>Attention: Wrong path may have caused problem! Do it carefully or don't change default setting!</p></body></html>"
        )
        self.aria2_path_checkBox.setToolTip(aria2_path_tooltip)
        self.aria2_path_lineEdit.setToolTip(aria2_path_tooltip)
        self.aria2_path_pushButton.setToolTip(aria2_path_tooltip)

        self.setting_tabWidget.setTabText(
            self.setting_tabWidget.indexOf(self.download_options_tab),
            QCoreApplication.translate("setting_ui_tr", "Download Options"))

        self.download_folder_label.setText(
            QCoreApplication.translate("setting_ui_tr", "Download Folder: "))
        self.download_folder_pushButton.setText(
            QCoreApplication.translate("setting_ui_tr", "Change"))

        self.temp_download_label.setText(
            QCoreApplication.translate("setting_ui_tr",
                                       "Temporary Download Folder: "))
        self.temp_download_pushButton.setText(
            QCoreApplication.translate("setting_ui_tr", "Change"))

        self.subfolder_checkBox.setText(
            QCoreApplication.translate(
                "setting_ui_tr",
                "Create subfolders for Music,Videos,... in default download folder"
            ))

        self.setting_tabWidget.setTabText(
            self.setting_tabWidget.indexOf(self.save_as_tab),
            QCoreApplication.translate("setting_ui_tr", "Save as"))

        self.enable_notifications_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr",
                                       "Enable notification sounds"))

        self.volume_label.setText(
            QCoreApplication.translate("setting_ui_tr", "Volume: "))

        self.setting_tabWidget.setTabText(
            self.setting_tabWidget.indexOf(self.notifications_tab),
            QCoreApplication.translate("setting_ui_tr", "Notifications"))

        self.style_label.setText(
            QCoreApplication.translate("setting_ui_tr", "Style: "))
        self.color_label.setText(
            QCoreApplication.translate("setting_ui_tr", "Color scheme: "))
        self.icon_label.setText(
            QCoreApplication.translate("setting_ui_tr", "Icons: "))

        self.icons_size_label.setText(
            QCoreApplication.translate("setting_ui_tr",
                                       "Toolbar's icons size: "))

        self.notification_label.setText(
            QCoreApplication.translate("setting_ui_tr", "Notification type: "))

        self.font_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", "Font: "))
        self.font_size_label.setText(
            QCoreApplication.translate("setting_ui_tr", "Size: "))

        self.enable_system_tray_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr",
                                       "Enable system tray icon."))
        self.after_download_checkBox.setText(
            QCoreApplication.translate(
                "setting_ui_tr",
                "Show download complete dialog when download has finished."))

        self.show_menubar_checkbox.setText(
            QCoreApplication.translate("setting_ui_tr", "Show menubar."))
        self.show_sidepanel_checkbox.setText(
            QCoreApplication.translate("setting_ui_tr", "Show side panel."))
        self.show_progress_window_checkbox.setText(
            QCoreApplication.translate("setting_ui_tr",
                                       "Show download's progress window"))

        self.startup_checkbox.setText(
            QCoreApplication.translate("setting_ui_tr",
                                       "Run Persepolis at startup"))

        self.keep_awake_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", "Keep system awake!"))
        self.keep_awake_checkBox.setToolTip(
            QCoreApplication.translate(
                "setting_ui_tr",
                "<html><head/><body><p>This option is preventing system from going to sleep.\
            This is necessary if your power manager is suspending system automatically. </p></body></html>"
            ))

        self.wait_queue_time.setToolTip(
            QCoreApplication.translate(
                "setting_ui_tr",
                "<html><head/><body><p>Format HH:MM</p></body></html>"))

        self.setting_tabWidget.setTabText(
            self.setting_tabWidget.indexOf(self.style_tab),
            QCoreApplication.translate("setting_ui_tr", "Preferences"))

        # columns_tab
        self.show_column_label.setText(
            QCoreApplication.translate("setting_ui_tr", 'Show this columns:'))
        self.column0_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", 'File Name'))
        self.column1_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", 'Status'))
        self.column2_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", 'Size'))
        self.column3_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", 'Downloaded'))
        self.column4_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", 'Percentage'))
        self.column5_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", 'Connections'))
        self.column6_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", 'Transfer rate'))
        self.column7_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", 'Estimated time left'))
        self.column10_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", 'First try date'))
        self.column11_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", 'Last try date'))
        self.column12_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", 'Category'))

        self.setting_tabWidget.setTabText(
            self.setting_tabWidget.indexOf(self.columns_tab),
            QCoreApplication.translate("setting_ui_tr",
                                       "Columns customization"))

        # Video Finder options tab
        self.setting_tabWidget.setTabText(
            self.setting_tabWidget.indexOf(self.video_finder_tab),
            QCoreApplication.translate("setting_ui_tr",
                                       "Video Finder Options"))

        self.enable_video_finder_checkbox.setText(
            QCoreApplication.translate("setting_ui_tr", 'Enable Video Finder'))

        self.hide_no_audio_checkbox.setText(
            QCoreApplication.translate("setting_ui_tr",
                                       'Hide videos with no audio'))

        self.hide_no_video_checkbox.setText(
            QCoreApplication.translate("setting_ui_tr",
                                       'Hide audios with no video'))
        self.max_links_label.setText(
            QCoreApplication.translate(
                "setting_ui_tr", 'Maximum number of links to capture:<br/>'
                '<small>(If browser sends multiple video links at a time)</small>'
            ))

        # window buttons
        self.defaults_pushButton.setText(
            QCoreApplication.translate("setting_ui_tr", "Defaults"))
        self.cancel_pushButton.setText(
            QCoreApplication.translate("setting_ui_tr", "Cancel"))
        self.ok_pushButton.setText(
            QCoreApplication.translate("setting_ui_tr", "OK"))
Example #6
0
class Setting_Ui(QWidget):
    def __init__(self, persepolis_setting):
        super().__init__()
        icon = QtGui.QIcon()

        self.persepolis_setting = persepolis_setting

        # add support for other languages
        locale = str(self.persepolis_setting.value('settings/locale'))
        QLocale.setDefault(QLocale(locale))
        self.translator = QTranslator()
        if self.translator.load(':/translations/locales/ui_' + locale, 'ts'):
            QCoreApplication.installTranslator(self.translator)

        self.setWindowIcon(QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg')))
        self.setWindowTitle(QCoreApplication.translate("setting_ui_tr", 'Preferences'))

        # set ui direction
        ui_direction = self.persepolis_setting.value('ui_direction')

        if ui_direction == 'rtl':
            self.setLayoutDirection(Qt.RightToLeft)
        
        elif ui_direction in 'ltr':
            self.setLayoutDirection(Qt.LeftToRight)


        global icons
        icons = ':/' + str(self.persepolis_setting.value('settings/icons')) + '/'


        # main layout 
        window_verticalLayout = QVBoxLayout(self)

        # setting_tabWidget
        self.setting_tabWidget = QTabWidget(self)

        # download_options_tab
        self.download_options_tab = QWidget()
        download_options_tab_verticalLayout = QVBoxLayout(self.download_options_tab)
        download_options_tab_verticalLayout.setContentsMargins(21, 21, 0, 0)

        # tries
        tries_horizontalLayout = QHBoxLayout()

        self.tries_label = QLabel(self.download_options_tab)
        tries_horizontalLayout.addWidget(self.tries_label)

        self.tries_spinBox = QSpinBox(self.download_options_tab)
        self.tries_spinBox.setMinimum(1)

        tries_horizontalLayout.addWidget(self.tries_spinBox)
        download_options_tab_verticalLayout.addLayout(tries_horizontalLayout)

        #wait
        wait_horizontalLayout = QHBoxLayout()

        self.wait_label = QLabel(self.download_options_tab)
        wait_horizontalLayout.addWidget(self.wait_label)

        self.wait_spinBox = QSpinBox(self.download_options_tab)
        wait_horizontalLayout.addWidget(self.wait_spinBox)

        download_options_tab_verticalLayout.addLayout(wait_horizontalLayout)

        # time_out
        time_out_horizontalLayout = QHBoxLayout()

        self.time_out_label = QLabel(self.download_options_tab)
        time_out_horizontalLayout.addWidget(self.time_out_label)

        self.time_out_spinBox = QSpinBox(self.download_options_tab)
        time_out_horizontalLayout.addWidget(self.time_out_spinBox)

        download_options_tab_verticalLayout.addLayout(time_out_horizontalLayout)

        # connections
        connections_horizontalLayout = QHBoxLayout()

        self.connections_label = QLabel(self.download_options_tab)
        connections_horizontalLayout.addWidget(self.connections_label)

        self.connections_spinBox = QSpinBox(self.download_options_tab)
        self.connections_spinBox.setMinimum(1)
        self.connections_spinBox.setMaximum(16)
        connections_horizontalLayout.addWidget(self.connections_spinBox)

        download_options_tab_verticalLayout.addLayout(connections_horizontalLayout)

        # rpc_port
        self.rpc_port_label = QLabel(self.download_options_tab)
        self.rpc_horizontalLayout = QHBoxLayout()
        self.rpc_horizontalLayout.addWidget(self.rpc_port_label)

        self.rpc_port_spinbox = QSpinBox(self.download_options_tab)
        self.rpc_port_spinbox.setMinimum(1024)
        self.rpc_port_spinbox.setMaximum(65535)
        self.rpc_horizontalLayout.addWidget(self.rpc_port_spinbox)

        download_options_tab_verticalLayout.addLayout(
            self.rpc_horizontalLayout)

        # wait_queue
        wait_queue_horizontalLayout = QHBoxLayout() 

        self.wait_queue_label = QLabel(self.download_options_tab)
        wait_queue_horizontalLayout.addWidget(self.wait_queue_label)

        self.wait_queue_time = QDateTimeEdit(self.download_options_tab)
        self.wait_queue_time.setDisplayFormat('H:mm')
        wait_queue_horizontalLayout.addWidget(self.wait_queue_time)
        
        download_options_tab_verticalLayout.addLayout(
            wait_queue_horizontalLayout) 

        # change aria2 path
        aria2_path_verticalLayout = QVBoxLayout()

        self.aria2_path_checkBox = QCheckBox(self.download_options_tab)
        aria2_path_verticalLayout.addWidget(self.aria2_path_checkBox)

        aria2_path_horizontalLayout = QHBoxLayout()

        self.aria2_path_lineEdit = QLineEdit(self.download_options_tab)
        aria2_path_horizontalLayout.addWidget(self.aria2_path_lineEdit)

        self.aria2_path_pushButton = QPushButton(self.download_options_tab)
        aria2_path_horizontalLayout.addWidget(self.aria2_path_pushButton)

        aria2_path_verticalLayout.addLayout(aria2_path_horizontalLayout)

        download_options_tab_verticalLayout.addLayout(aria2_path_verticalLayout)

        download_options_tab_verticalLayout.addStretch(1)

        self.setting_tabWidget.addTab(self.download_options_tab, "")


        # save_as_tab
        self.save_as_tab = QWidget()

        save_as_tab_verticalLayout = QVBoxLayout(self.save_as_tab)
        save_as_tab_verticalLayout.setContentsMargins(20, 30, 0, 0)

        # download_folder
        self.download_folder_horizontalLayout = QHBoxLayout()

        self.download_folder_label = QLabel(self.save_as_tab)
        self.download_folder_horizontalLayout.addWidget(
            self.download_folder_label)

        self.download_folder_lineEdit = QLineEdit(self.save_as_tab)
        self.download_folder_horizontalLayout.addWidget(self.download_folder_lineEdit)

        self.download_folder_pushButton = QPushButton(self.save_as_tab)
        self.download_folder_horizontalLayout.addWidget(self.download_folder_pushButton)

        save_as_tab_verticalLayout.addLayout(self.download_folder_horizontalLayout)

        # temp_download_folder
        self.temp_horizontalLayout = QHBoxLayout()

        self.temp_download_label = QLabel(self.save_as_tab)
        self.temp_horizontalLayout.addWidget(self.temp_download_label)

        self.temp_download_lineEdit = QLineEdit(self.save_as_tab)
        self.temp_horizontalLayout.addWidget(self.temp_download_lineEdit)

        self.temp_download_pushButton = QPushButton(self.save_as_tab)
        self.temp_horizontalLayout.addWidget(self.temp_download_pushButton)

        save_as_tab_verticalLayout.addLayout(self.temp_horizontalLayout)

        # create subfolder
        self.subfolder_checkBox = QCheckBox(self.save_as_tab)
        save_as_tab_verticalLayout.addWidget(self.subfolder_checkBox)

        save_as_tab_verticalLayout.addStretch(1)
        
        self.setting_tabWidget.addTab(self.save_as_tab, "")

        # notifications_tab
        self.notifications_tab = QWidget()
        notification_tab_verticalLayout = QVBoxLayout(self.notifications_tab)
        notification_tab_verticalLayout.setContentsMargins(21, 21, 0, 0)

        self.enable_notifications_checkBox = QCheckBox(self.notifications_tab)
        notification_tab_verticalLayout.addWidget(self.enable_notifications_checkBox)

        self.sound_frame = QFrame(self.notifications_tab)
        self.sound_frame.setFrameShape(QFrame.StyledPanel)
        self.sound_frame.setFrameShadow(QFrame.Raised)

        verticalLayout = QVBoxLayout(self.sound_frame)

        self.volume_label = QLabel(self.sound_frame)
        verticalLayout.addWidget(self.volume_label)

        self.volume_dial = QDial(self.sound_frame)
        self.volume_dial.setProperty("value", 100)
        verticalLayout.addWidget(self.volume_dial)

        notification_tab_verticalLayout.addWidget(self.sound_frame)

        # message_notification
        message_notification_horizontalLayout = QHBoxLayout()
        self.notification_label = QLabel(self.notifications_tab)
        message_notification_horizontalLayout.addWidget(self.notification_label)

        self.notification_comboBox = QComboBox(self.notifications_tab)
        message_notification_horizontalLayout.addWidget(self.notification_comboBox)
        notification_tab_verticalLayout.addLayout(message_notification_horizontalLayout)

        notification_tab_verticalLayout.addStretch(1)

        self.setting_tabWidget.addTab(self.notifications_tab, "")

        # style_tab
        self.style_tab = QWidget()
        style_tab_verticalLayout = QVBoxLayout(self.style_tab)
        style_tab_verticalLayout.setContentsMargins(21, 21, 0, 0)

        # style
        style_horizontalLayout = QHBoxLayout()

        self.style_label = QLabel(self.style_tab)
        style_horizontalLayout.addWidget(self.style_label)

        self.style_comboBox = QComboBox(self.style_tab)
        style_horizontalLayout.addWidget(self.style_comboBox)

        style_tab_verticalLayout.addLayout(style_horizontalLayout)

        # language
        language_horizontalLayout = QHBoxLayout()        

        self.lang_label = QLabel(self.style_tab)
        language_horizontalLayout.addWidget(self.lang_label)
        self.lang_comboBox = QComboBox(self.style_tab)
        language_horizontalLayout.addWidget(self.lang_comboBox)

        style_tab_verticalLayout.addLayout(language_horizontalLayout)
        language_horizontalLayout = QHBoxLayout()
        self.lang_label.setText(QCoreApplication.translate("setting_ui_tr", "Language:"))

        # color scheme
        self.color_label = QLabel(self.style_tab)
        language_horizontalLayout.addWidget(self.color_label)

        self.color_comboBox = QComboBox(self.style_tab)
        language_horizontalLayout.addWidget(self.color_comboBox)

        style_tab_verticalLayout.addLayout(language_horizontalLayout)

        # icons
        icons_horizontalLayout = QHBoxLayout()
        self.icon_label = QLabel(self.style_tab)
        icons_horizontalLayout.addWidget(self.icon_label)

        self.icon_comboBox = QComboBox(self.style_tab)
        icons_horizontalLayout.addWidget(self.icon_comboBox)

        style_tab_verticalLayout.addLayout(icons_horizontalLayout)

        self.icons_size_horizontalLayout = QHBoxLayout()
        self.icons_size_label = QLabel(self.style_tab)
        self.icons_size_horizontalLayout.addWidget(self.icons_size_label)

        self.icons_size_comboBox = QComboBox(self.style_tab)
        self.icons_size_horizontalLayout.addWidget(self.icons_size_comboBox)

        style_tab_verticalLayout.addLayout(self.icons_size_horizontalLayout)

        # font
        font_horizontalLayout = QHBoxLayout()
        self.font_checkBox = QCheckBox(self.style_tab)
        font_horizontalLayout.addWidget(self.font_checkBox)

        self.fontComboBox = QFontComboBox(self.style_tab)
        font_horizontalLayout.addWidget(self.fontComboBox)

        self.font_size_label = QLabel(self.style_tab)
        font_horizontalLayout.addWidget(self.font_size_label)

        self.font_size_spinBox = QSpinBox(self.style_tab)
        self.font_size_spinBox.setMinimum(1)
        font_horizontalLayout.addWidget(self.font_size_spinBox)

        style_tab_verticalLayout.addLayout(font_horizontalLayout)
        self.setting_tabWidget.addTab(self.style_tab, "")
        window_verticalLayout.addWidget(self.setting_tabWidget)

        # Enable system tray icon
        self.enable_system_tray_checkBox = QCheckBox(self.style_tab)
        style_tab_verticalLayout.addWidget(self.enable_system_tray_checkBox)

        # after_download dialog
        self.after_download_checkBox = QCheckBox()
        style_tab_verticalLayout.addWidget(self.after_download_checkBox)

        # show_menubar_checkbox
        self.show_menubar_checkbox = QCheckBox()
        style_tab_verticalLayout.addWidget(self.show_menubar_checkbox)

        # show_sidepanel_checkbox
        self.show_sidepanel_checkbox = QCheckBox()
        style_tab_verticalLayout.addWidget(self.show_sidepanel_checkbox)

        # hide progress window
        self.show_progress_window_checkbox = QCheckBox()
        style_tab_verticalLayout.addWidget(self.show_progress_window_checkbox)

        # add persepolis to startup
        self.startup_checkbox = QCheckBox()
        style_tab_verticalLayout.addWidget(self.startup_checkbox)

        # keep system awake
        self.keep_awake_checkBox = QCheckBox()
        style_tab_verticalLayout.addWidget(self.keep_awake_checkBox)

        style_tab_verticalLayout.addStretch(1)

        # columns_tab
        self.columns_tab = QWidget()

        columns_tab_verticalLayout = QVBoxLayout(self.columns_tab)
        columns_tab_verticalLayout.setContentsMargins(21, 21, 0, 0)

        # creating checkBox for columns
        self.show_column_label = QLabel()
        self.column0_checkBox = QCheckBox()
        self.column1_checkBox = QCheckBox()
        self.column2_checkBox = QCheckBox()
        self.column3_checkBox = QCheckBox()
        self.column4_checkBox = QCheckBox()
        self.column5_checkBox = QCheckBox()
        self.column6_checkBox = QCheckBox()
        self.column7_checkBox = QCheckBox()
        self.column10_checkBox = QCheckBox()
        self.column11_checkBox = QCheckBox()
        self.column12_checkBox = QCheckBox()

        columns_tab_verticalLayout.addWidget(self.show_column_label) 
        columns_tab_verticalLayout.addWidget(self.column0_checkBox) 
        columns_tab_verticalLayout.addWidget(self.column1_checkBox) 
        columns_tab_verticalLayout.addWidget(self.column2_checkBox) 
        columns_tab_verticalLayout.addWidget(self.column3_checkBox) 
        columns_tab_verticalLayout.addWidget(self.column4_checkBox) 
        columns_tab_verticalLayout.addWidget(self.column5_checkBox) 
        columns_tab_verticalLayout.addWidget(self.column6_checkBox) 
        columns_tab_verticalLayout.addWidget(self.column7_checkBox) 
        columns_tab_verticalLayout.addWidget(self.column10_checkBox) 
        columns_tab_verticalLayout.addWidget(self.column11_checkBox) 
        columns_tab_verticalLayout.addWidget(self.column12_checkBox) 

        columns_tab_verticalLayout.addStretch(1)

        self.setting_tabWidget.addTab(self.columns_tab, '')

        # video_finder_tab
        self.video_finder_tab = QWidget()

        video_finder_layout = QVBoxLayout(self.video_finder_tab)
        video_finder_layout.setContentsMargins(21, 21, 0, 0)

        video_finder_tab_verticalLayout = QVBoxLayout()

        # Whether to enable video link capturing.
        self.enable_video_finder_checkbox = QCheckBox(self.video_finder_tab)
        video_finder_layout.addWidget(self.enable_video_finder_checkbox)

        # If we should hide videos with no audio
        self.hide_no_audio_checkbox = QCheckBox(self.video_finder_tab)
        video_finder_tab_verticalLayout.addWidget(self.hide_no_audio_checkbox)

        # If we should hide audios without video
        self.hide_no_video_checkbox = QCheckBox(self.video_finder_tab)
        video_finder_tab_verticalLayout.addWidget(self.hide_no_video_checkbox)

        max_links_horizontalLayout = QHBoxLayout()

        # max_links_label
        self.max_links_label = QLabel(self.video_finder_tab)

        max_links_horizontalLayout.addWidget(self.max_links_label)
        # max_links_spinBox
        self.max_links_spinBox = QSpinBox(self.video_finder_tab)
        self.max_links_spinBox.setMinimum(1)
        self.max_links_spinBox.setMaximum(16)
        max_links_horizontalLayout.addWidget(self.max_links_spinBox)
        video_finder_tab_verticalLayout.addLayout(max_links_horizontalLayout)

        self.video_finder_dl_path_horizontalLayout = QHBoxLayout()

        self.video_finder_frame = QFrame(self.video_finder_tab)
        self.video_finder_frame.setLayout(video_finder_tab_verticalLayout)

        video_finder_tab_verticalLayout.addStretch(1)

        video_finder_layout.addWidget(self.video_finder_frame)

        self.setting_tabWidget.addTab(self.video_finder_tab, "")

        # window buttons
        buttons_horizontalLayout = QHBoxLayout()
        buttons_horizontalLayout.addStretch(1)

        self.defaults_pushButton = QPushButton(self)
        buttons_horizontalLayout.addWidget(self.defaults_pushButton)

        self.cancel_pushButton = QPushButton(self)
        self.cancel_pushButton.setIcon(QIcon(icons + 'remove'))
        buttons_horizontalLayout.addWidget(self.cancel_pushButton)

        self.ok_pushButton = QPushButton(self)
        self.ok_pushButton.setIcon(QIcon(icons + 'ok'))
        buttons_horizontalLayout.addWidget(self.ok_pushButton)

        window_verticalLayout.addLayout(buttons_horizontalLayout)

        # set style_tab for default
        self.setting_tabWidget.setCurrentIndex(3)

        # labels and translations
        self.setWindowTitle(QCoreApplication.translate("setting_ui_tr", "Preferences"))

        self.tries_label.setToolTip(
            QCoreApplication.translate("setting_ui_tr", "<html><head/><body><p>Set number of tries if download failed.</p></body></html>"))
        self.tries_label.setText(QCoreApplication.translate("setting_ui_tr", "Number of tries: "))
        self.tries_spinBox.setToolTip(
            QCoreApplication.translate("setting_ui_tr", "<html><head/><body><p>Set number of tries if download failed.</p></body></html>"))

        self.wait_label.setToolTip(
            QCoreApplication.translate("setting_ui_tr", "<html><head/><body><p>Set the seconds to wait between retries. Download manager will  retry  downloads  when  the  HTTP  server  returns  a  503 response.</p></body></html>"))
        self.wait_label.setText(QCoreApplication.translate("setting_ui_tr", "Wait between retries (seconds): "))
        self.wait_spinBox.setToolTip(
            QCoreApplication.translate("setting_ui_tr", "<html><head/><body><p>Set the seconds to wait between retries. Download manager will  retry  downloads  when  the  HTTP  server  returns  a  503 response.</p></body></html>"))

        self.time_out_label.setToolTip(
            QCoreApplication.translate("setting_ui_tr", "<html><head/><body><p>Set timeout in seconds. </p></body></html>"))
        self.time_out_label.setText(QCoreApplication.translate("setting_ui_tr", "Timeout (seconds): "))
        self.time_out_spinBox.setToolTip(
            QCoreApplication.translate("setting_ui_tr", "<html><head/><body><p>Set timeout in seconds. </p></body></html>"))

        self.connections_label.setToolTip(
            QCoreApplication.translate("setting_ui_tr", "<html><head/><body><p>Using multiple connections can help speed up your download.</p></body></html>"))
        self.connections_label.setText(QCoreApplication.translate("setting_ui_tr", "Number of connections: "))
        self.connections_spinBox.setToolTip(
            QCoreApplication.translate("setting_ui_tr", "<html><head/><body><p>Using multiple connections can help speed up your download.</p></body></html>"))

        self.rpc_port_label.setText(QCoreApplication.translate("setting_ui_tr", "RPC port number: "))
        self.rpc_port_spinbox.setToolTip(
            QCoreApplication.translate("setting_ui_tr", "<html><head/><body><p> Specify a port number for JSON-RPC/XML-RPC server to listen to. Possible Values: 1024 - 65535 Default: 6801 </p></body></html>"))

        self.wait_queue_label.setText(QCoreApplication.translate("setting_ui_tr", 'Wait between every downloads in queue:'))

        self.aria2_path_checkBox.setText(QCoreApplication.translate("setting_ui_tr", 'Change Aria2 default path'))
        self.aria2_path_pushButton.setText(QCoreApplication.translate("setting_ui_tr", 'Change'))
        aria2_path_tooltip =QCoreApplication.translate("setting_ui_tr", "<html><head/><body><p>Attention: Wrong path may have caused problem! Do it carefully or don't change default setting!</p></body></html>" )
        self.aria2_path_checkBox.setToolTip(aria2_path_tooltip)
        self.aria2_path_lineEdit.setToolTip(aria2_path_tooltip)
        self.aria2_path_pushButton.setToolTip(aria2_path_tooltip)

        self.setting_tabWidget.setTabText(self.setting_tabWidget.indexOf(
            self.download_options_tab),  QCoreApplication.translate("setting_ui_tr", "Download Options"))

        self.download_folder_label.setText(QCoreApplication.translate("setting_ui_tr", "Download Folder: "))
        self.download_folder_pushButton.setText(QCoreApplication.translate("setting_ui_tr", "Change"))

        self.temp_download_label.setText(QCoreApplication.translate("setting_ui_tr", "Temporary Download Folder: "))
        self.temp_download_pushButton.setText(QCoreApplication.translate("setting_ui_tr", "Change"))

        self.subfolder_checkBox.setText(QCoreApplication.translate("setting_ui_tr", "Create subfolders for Music,Videos,... in default download folder"))

        self.setting_tabWidget.setTabText(
            self.setting_tabWidget.indexOf(self.save_as_tab),  QCoreApplication.translate("setting_ui_tr", "Save as"))

        self.enable_notifications_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", "Enable notification sounds"))

        self.volume_label.setText(QCoreApplication.translate("setting_ui_tr", "Volume: "))

        self.setting_tabWidget.setTabText(self.setting_tabWidget.indexOf(
            self.notifications_tab),  QCoreApplication.translate("setting_ui_tr", "Notifications"))

        self.style_label.setText(QCoreApplication.translate("setting_ui_tr", "Style: "))
        self.color_label.setText(QCoreApplication.translate("setting_ui_tr", "Color scheme: "))
        self.icon_label.setText(QCoreApplication.translate("setting_ui_tr", "Icons: "))

        self.icons_size_label.setText(QCoreApplication.translate("setting_ui_tr", "Toolbar's icons size: "))

        self.notification_label.setText(QCoreApplication.translate("setting_ui_tr", "Notification type: "))

        self.font_checkBox.setText(QCoreApplication.translate("setting_ui_tr", "Font: "))
        self.font_size_label.setText(QCoreApplication.translate("setting_ui_tr", "Size: "))

        self.enable_system_tray_checkBox.setText(QCoreApplication.translate("setting_ui_tr", "Enable system tray icon."))
        self.after_download_checkBox.setText(
            QCoreApplication.translate("setting_ui_tr", "Show download complete dialog when download has finished."))

        self.show_menubar_checkbox.setText(QCoreApplication.translate("setting_ui_tr", "Show menubar."))
        self.show_sidepanel_checkbox.setText(QCoreApplication.translate("setting_ui_tr", "Show side panel."))
        self.show_progress_window_checkbox.setText(
            QCoreApplication.translate("setting_ui_tr", "Show download's progress window"))

        self.startup_checkbox.setText(QCoreApplication.translate("setting_ui_tr", "Run Persepolis at startup"))

        self.keep_awake_checkBox.setText(QCoreApplication.translate("setting_ui_tr", "Keep system awake!"))
        self.keep_awake_checkBox.setToolTip(
            QCoreApplication.translate("setting_ui_tr", "<html><head/><body><p>This option is preventing system from going to sleep.\
            This is necessary if your power manager is suspending system automatically. </p></body></html>"))
 
        self.wait_queue_time.setToolTip(
                QCoreApplication.translate("setting_ui_tr", "<html><head/><body><p>Format HH:MM</p></body></html>"))
 
        self.setting_tabWidget.setTabText(
            self.setting_tabWidget.indexOf(self.style_tab),  QCoreApplication.translate("setting_ui_tr", "Preferences"))

# columns_tab
        self.show_column_label.setText(QCoreApplication.translate("setting_ui_tr", 'Show this columns:'))
        self.column0_checkBox.setText(QCoreApplication.translate("setting_ui_tr", 'File Name'))
        self.column1_checkBox.setText(QCoreApplication.translate("setting_ui_tr", 'Status'))
        self.column2_checkBox.setText(QCoreApplication.translate("setting_ui_tr", 'Size'))
        self.column3_checkBox.setText(QCoreApplication.translate("setting_ui_tr", 'Downloaded'))
        self.column4_checkBox.setText(QCoreApplication.translate("setting_ui_tr", 'Percentage'))
        self.column5_checkBox.setText(QCoreApplication.translate("setting_ui_tr", 'Connections'))
        self.column6_checkBox.setText(QCoreApplication.translate("setting_ui_tr", 'Transfer rate'))
        self.column7_checkBox.setText(QCoreApplication.translate("setting_ui_tr", 'Estimated time left'))
        self.column10_checkBox.setText(QCoreApplication.translate("setting_ui_tr", 'First try date'))
        self.column11_checkBox.setText(QCoreApplication.translate("setting_ui_tr", 'Last try date'))
        self.column12_checkBox.setText(QCoreApplication.translate("setting_ui_tr", 'Category'))


        self.setting_tabWidget.setTabText(
            self.setting_tabWidget.indexOf(self.columns_tab), QCoreApplication.translate("setting_ui_tr", "Columns customization"))

# Video Finder options tab
        self.setting_tabWidget.setTabText(self.setting_tabWidget.indexOf(
            self.video_finder_tab), QCoreApplication.translate("setting_ui_tr",  "Video Finder Options"))

        self.enable_video_finder_checkbox.setText(QCoreApplication.translate("setting_ui_tr", 'Enable Video Finder'))

        self.hide_no_audio_checkbox.setText(QCoreApplication.translate("setting_ui_tr", 'Hide videos with no audio'))

        self.hide_no_video_checkbox.setText(QCoreApplication.translate("setting_ui_tr", 'Hide audios with no video'))
        self.max_links_label.setText(QCoreApplication.translate("setting_ui_tr", 'Maximum number of links to capture:<br/>'
                                     '<small>(If browser sends multiple video links at a time)</small>'))

# window buttons
        self.defaults_pushButton.setText(QCoreApplication.translate("setting_ui_tr", "Defaults"))
        self.cancel_pushButton.setText(QCoreApplication.translate("setting_ui_tr", "Cancel"))
        self.ok_pushButton.setText(QCoreApplication.translate("setting_ui_tr", "OK"))