#!/usr/bin/python3

import os
import sys
from pathlib import Path
from PySide6.QtWidgets import (
    QApplication,
    QLabel,
    QDialog,
    QPushButton,
)
from PySide6.QtUiTools import QUiLoader
from PySide6.QtCore import QFile

SCRIPT_PATH = Path(os.path.dirname(os.path.realpath(__file__)))
UI_PATH = SCRIPT_PATH / 'about.ui'


class PelinkAboutDialog:
    def __init__(self):
        loader = QUiLoader()
        ui_file = QFile(str(UI_PATH))
        ui_file.open(QFile.ReadOnly)
        self.dialog = loader.load(ui_file)
        ui_file.close()
        self.dialog.setWindowTitle("About Pelink")

        self.but_close = self.dialog.findChild(QPushButton, "but_close")
        self.but_close.clicked.connect(self.close)

    def launch(self):
        return self.dialog.exec()

    # def show(self):
    #     self.dialog.show()

    def close(self):
        self.dialog.close()
