Skip to content

Commit

Permalink
working on settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
quintenvandamme committed May 1, 2024
1 parent 1942bc3 commit d2e34a3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 21 deletions.
12 changes: 10 additions & 2 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ def _createDir(directory):
if not os.path.exists(directory):
os.makedirs(directory)

def _get_7z():
_run_command("winget install -e --id 7zip.7zip --accept-source-agreements --accept-package-agreements")
print("=> Installed 7z")

def _get_ffmpeg():
FFMPEG_ARCH = ""

Expand All @@ -28,9 +32,13 @@ def _get_ffmpeg():
_run_command("tar -xf ffmpeg.tar.xz")
_run_command(f"mv ./ffmpeg-git-*-{FFMPEG_ARCH}-static/ffmpeg ./out/ffmpeg")
_run_command(f"rm -rf ffmpeg.tar.xz ffmpeg-git-*-{FFMPEG_ARCH}-static")

elif OS == "win32":
pass
_get_7z()
_run_command(f'Invoke-WebRequest -OutFile ffmpeg.7z -Uri https://www.gyan.dev/ffmpeg/builds/ffmpeg-git-essentials.7z')
_run_command(f'7z.exe x ffmpeg.7z -oout/ffmpeg.exe bin/ffmpeg.exe -r')
_run_command(f'del ffmpeg.7z')

print("=> Downloaded ffmpeg")

def install_dependencies():
print("=> Installing dependencies...")
Expand Down
42 changes: 23 additions & 19 deletions gui/main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from PyQt6.QtWidgets import *
from PyQt6.QtGui import *
#from constants import *
#from util import *
import sys
import os
import requests
import threading

from get_videos import get_videos
from settings import Settings
Expand Down Expand Up @@ -71,7 +70,7 @@ def __init__(self, video, list_widget):

# Create button to download the video
if video.exists():
download_button = QPushButton('Downloaded')
download_button = QPushButton('gedownload')
download_button.setEnabled(False)
date_layout.addWidget(download_button)
else:
Expand Down Expand Up @@ -147,6 +146,7 @@ def _create_widgets(self):
main_layout.addWidget(self.search_results)

self.window.setLayout(main_layout)
self.event = threading.Event()

def _handle_search(self):
# This function will be called when the search button is clicked
Expand All @@ -159,42 +159,47 @@ def run(self):
self.app.exec()

class SettingsApplication:
def __init__(self, parent):
def __init__(self, window):
# Create a new dialog window
self.window = QDialog(parent)
self.window = QDialog(window)
self.window.setWindowTitle('Instellingen')
self.window.setWindowIcon(QIcon(resource_path('data/logo/logo-256x256.png')))
self.window.setMinimumSize(400, 300)
self._create_widgets()
self.window.setMinimumSize(600, 300)
self.window.show()

self._create_widgets()

def _create_widgets(self):
layout = QVBoxLayout()
download_layout = QHBoxLayout()
save_layout = QHBoxLayout()

# Create a label for the download path
download_path_label = QLabel('Download locatie:')
download_layout.addWidget(download_path_label)
download_layout.addWidget(download_path_label, stretch=1000)

# Create a line edit for the download path
self.download_path_input = QLineEdit()
self.download_path_input = QLabel()
self.download_path_input.setText(settings.get('Settings', 'download_path'))
download_layout.addWidget(self.download_path_input)

layout.addLayout(download_layout)
# create a button and use a slot to connect it to the function
save_button = QPushButton('Open')
# add the standard folder icon to the button
save_button.setIcon(QIcon.fromTheme('folder'))

save_button.clicked.connect(lambda: self._save_settings())
download_layout.addWidget(save_button)

# Create a button to save the settings
save_button = QPushButton('Opslaan')
save_button.clicked.connect(self._save_settings)
layout.addWidget(save_button)
layout.addLayout(download_layout)
layout.addLayout(save_layout)

self.window.setLayout(layout)

def _save_settings(self):
download_path = self.download_path_input.text()
settings.set('Settings', 'download_path', download_path)
self.window.close()
download_path = QFileDialog.getExistingDirectory(self.window, 'Selecteer een download locatie')
if download_path:
self.download_path_input.setText(download_path)
settings.set('Settings', 'download_path', download_path)

class AboutApplication:
def __init__(self, parent):
Expand Down Expand Up @@ -229,7 +234,6 @@ def __init__(self, parent):

self.window.show()


if __name__ == '__main__':
app = MainApplication()
app.run()
Expand Down

0 comments on commit d2e34a3

Please sign in to comment.