# Path: persepolis/scripts/useful_tools.py
# def determineConfigFolder():
#     if os_type in OS.UNIX_LIKE:
#         config_folder = os.path.join(
#             home_address, ".config/persepolis_download_manager")
#     elif os_type == OS.OSX:
#         config_folder = os.path.join(
#             home_address, "Library/Application Support/persepolis_download_manager")
#     elif os_type == OS.WINDOWS:
#         config_folder = os.path.join(
#             home_address, 'AppData', 'Local', 'persepolis_download_manager')
# 
#     return config_folder
# 
# Path: persepolis/gui/log_window_ui.py
# class LogWindow_Ui(QWidget):
#     def __init__(self, persepolis_setting):
#         super().__init__()
# 
#         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)
# 
#         # 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)
# 
#         icons = ':/' + \
#             str(self.persepolis_setting.value('settings/icons')) + '/'
# 
#         # finding windows_size
#         self.setMinimumSize(QtCore.QSize(620, 300))
#         self.setWindowIcon(QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg')))
# 
#         verticalLayout = QVBoxLayout(self)
#         horizontalLayout = QHBoxLayout()
#         horizontalLayout.addStretch(1)
# 
# # text_edit
#         self.text_edit = QTextEdit(self)
#         self.text_edit.setReadOnly(True)
# 
#         verticalLayout.addWidget(self.text_edit)
# 
# # clear_log_pushButton
#         self.clear_log_pushButton = QPushButton(self)
#         horizontalLayout.addWidget(self.clear_log_pushButton)
# 
# # refresh_log_pushButton
#         self.refresh_log_pushButton = QPushButton(self)
#         self.refresh_log_pushButton.setIcon(QIcon(icons + 'refresh'))
#         horizontalLayout.addWidget(self.refresh_log_pushButton)
# 
# # report_pushButton
#         self.report_pushButton = QPushButton(self)
#         self.report_pushButton.setIcon(QIcon(icons + 'about'))
#         horizontalLayout.addWidget(self.report_pushButton)
# 
#         self.copy_log_pushButton = QPushButton(self)
# 
# # copy_log_pushButton
#         self.copy_log_pushButton.setIcon(QIcon(icons + 'clipboard'))
#         horizontalLayout.addWidget(self.copy_log_pushButton)
# 
# # close_pushButton
#         self.close_pushButton = QPushButton(self)
#         self.close_pushButton.setIcon(QIcon(icons + 'remove'))
#         horizontalLayout.addWidget(self.close_pushButton)
# 
#         verticalLayout.addLayout(horizontalLayout)
# 
# # set labels
# 
#         self.setWindowTitle(QCoreApplication.translate("log_window_ui_tr", 'Persepolis Log'))
#         self.close_pushButton.setText(QCoreApplication.translate("log_window_ui_tr", 'Close'))
#         self.copy_log_pushButton.setText(QCoreApplication.translate("log_window_ui_tr", 'Copy Selected to Clipboard'))
#         self.report_pushButton.setText(QCoreApplication.translate("log_window_ui_tr", "Report Issue"))
#         self.refresh_log_pushButton.setText(QCoreApplication.translate("log_window_ui_tr", 'Refresh Log Messages'))
#         self.clear_log_pushButton.setText(QCoreApplication.translate("log_window_ui_tr", 'Clear Log Messages'))
# 
# Path: persepolis/scripts/osCommands.py
# def findFileManager():
# def touch(file_path):
# def xdgOpen(file_path, f_type='file', path='file'):
# def remove(file_path): 
# def removeDir(folder_path):
# def makeDirs(folder_path, hidden=False):
# def findMountPoint(path):
# def makeTempDownloadDir(path):
# def moveFile(old_file_path, new_path, new_path_type='folder'):
#         CREATE_NO_WINDOW = 0x08000000
#             CREATE_NO_WINDOW = 0x08000000


from persepolis.scripts.useful_tools import determineConfigFolder
from persepolis.gui.log_window_ui import LogWindow_Ui
from persepolis.scripts import osCommands
    from PySide6.QtCore import Qt, QPoint, QSize
    from PySide6.QtGui import QIcon
    from PySide6 import QtWidgets
    from PyQt5.QtCore import Qt, QPoint, QSize
    from PyQt5.QtGui import QIcon
    from PyQt5 import QtWidgets
import os
            self.copy_log_pushButton.setEnabled(True)
        else:
            self.copy_log_pushButton.setEnabled(False)

    def copyPushButtonPressed(self, button):
        #         clipboard = QApplication.clipboard()
        #         clipboard.setText(self.text)
        self.text_edit.copy()

# this method is refresh log messages in text_edit
    def refreshLogPushButtonPressed(self, button):
        f = open(self.log_file, 'r')
        f_lines = f.readlines()
        f.close()

        self.text = 'Log File:\n'
        for line in f_lines:
            self.text = self.text + str(line) + '\n'

        self.text_edit.clear()
        self.text_edit.insertPlainText(self.text)

    # close window with ESC key
    def keyPressEvent(self, event):
        if event.key() == Qt.Key_Escape:
            self.close()


    def closeEvent(self, event):
        self.layout().setSizeConstraint(QtWidgets.QLayout.SetDefaultConstraint)

# Path: persepolis/scripts/useful_tools.py
# def determineConfigFolder():
#     if os_type in OS.UNIX_LIKE:
#         config_folder = os.path.join(
#             home_address, ".config/persepolis_download_manager")
#     elif os_type == OS.OSX:
#         config_folder = os.path.join(
#             home_address, "Library/Application Support/persepolis_download_manager")
#     elif os_type == OS.WINDOWS:
#         config_folder = os.path.join(
#             home_address, 'AppData', 'Local', 'persepolis_download_manager')
# 
#     return config_folder
# 
# Path: persepolis/gui/log_window_ui.py
# class LogWindow_Ui(QWidget):
#     def __init__(self, persepolis_setting):
#         super().__init__()
# 
#         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)
# 
#         # 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)
# 
#         icons = ':/' + \
#             str(self.persepolis_setting.value('settings/icons')) + '/'
# 
#         # finding windows_size
#         self.setMinimumSize(QtCore.QSize(620, 300))
#         self.setWindowIcon(QIcon.fromTheme('persepolis', QIcon(':/persepolis.svg')))
# 
#         verticalLayout = QVBoxLayout(self)
#         horizontalLayout = QHBoxLayout()
#         horizontalLayout.addStretch(1)
# 
# # text_edit
#         self.text_edit = QTextEdit(self)
#         self.text_edit.setReadOnly(True)
# 
#         verticalLayout.addWidget(self.text_edit)
# 
# # clear_log_pushButton
#         self.clear_log_pushButton = QPushButton(self)
#         horizontalLayout.addWidget(self.clear_log_pushButton)
# 
# # refresh_log_pushButton
#         self.refresh_log_pushButton = QPushButton(self)
#         self.refresh_log_pushButton.setIcon(QIcon(icons + 'refresh'))
#         horizontalLayout.addWidget(self.refresh_log_pushButton)
# 
# # report_pushButton
#         self.report_pushButton = QPushButton(self)
#         self.report_pushButton.setIcon(QIcon(icons + 'about'))
#         horizontalLayout.addWidget(self.report_pushButton)
# 
#         self.copy_log_pushButton = QPushButton(self)
# 
# # copy_log_pushButton
#         self.copy_log_pushButton.setIcon(QIcon(icons + 'clipboard'))
#         horizontalLayout.addWidget(self.copy_log_pushButton)
# 
# # close_pushButton
#         self.close_pushButton = QPushButton(self)
#         self.close_pushButton.setIcon(QIcon(icons + 'remove'))
#         horizontalLayout.addWidget(self.close_pushButton)
# 
#         verticalLayout.addLayout(horizontalLayout)
# 
# # set labels
# 
#         self.setWindowTitle(QCoreApplication.translate("log_window_ui_tr", 'Persepolis Log'))
#         self.close_pushButton.setText(QCoreApplication.translate("log_window_ui_tr", 'Close'))
#         self.copy_log_pushButton.setText(QCoreApplication.translate("log_window_ui_tr", 'Copy Selected to Clipboard'))
#         self.report_pushButton.setText(QCoreApplication.translate("log_window_ui_tr", "Report Issue"))
#         self.refresh_log_pushButton.setText(QCoreApplication.translate("log_window_ui_tr", 'Refresh Log Messages'))
#         self.clear_log_pushButton.setText(QCoreApplication.translate("log_window_ui_tr", 'Clear Log Messages'))
# 
# Path: persepolis/scripts/osCommands.py
# def findFileManager():
# def touch(file_path):
# def xdgOpen(file_path, f_type='file', path='file'):
# def remove(file_path): 
# def removeDir(folder_path):
# def makeDirs(folder_path, hidden=False):
# def findMountPoint(path):
# def makeTempDownloadDir(path):
# def moveFile(old_file_path, new_path, new_path_type='folder'):
#         CREATE_NO_WINDOW = 0x08000000
#             CREATE_NO_WINDOW = 0x08000000


# Path: persepolis/scripts/log_window.py
from persepolis.scripts.useful_tools import determineConfigFolder
from persepolis.gui.log_window_ui import LogWindow_Ui
from persepolis.scripts import osCommands
    from PySide6.QtCore import Qt, QPoint, QSize
    from PySide6.QtGui import QIcon
    from PySide6 import QtWidgets
    from PyQt5.QtCore import Qt, QPoint, QSize
    from PyQt5.QtGui import QIcon
    from PyQt5 import QtWidgets
import os

            self.copy_log_pushButton.setEnabled(True)
        else:
            self.copy_log_pushButton.setEnabled(False)

    def copyPushButtonPressed(self, button):
        #         clipboard = QApplication.clipboard()
        #         clipboard.setText(self.text)
        self.text_edit.copy()

# this method is refresh log messages in text_edit
    def refreshLogPushButtonPressed(self, button):
        f = open(self.log_file, 'r')
        f_lines = f.readlines()
        f.close()

        self.text = 'Log File:\n'
        for line in f_lines:
            self.text = self.text + str(line) + '\n'

        self.text_edit.clear()
        self.text_edit.insertPlainText(self.text)

    # close window with ESC key
    def keyPressEvent(self, event):
        if event.key() == Qt.Key_Escape:
            self.close()


    def closeEvent(self, event):
        self.layout().setSizeConstraint(QtWidgets.QLayout.SetDefaultConstraint)

        self.setMinimumSize(QSize(self.width(), self.minimum_height))