Skip to content

Commit

Permalink
Optimized Duplicated-Selection UI
Browse files Browse the repository at this point in the history
- Optimized Duplicated-Selection UI
- Renamed FF_Help_UI.py to FF_About_UI.py.py
- Added Tutorial button to Help in the menubar
- Improved Tutorial Popups
- Removed typo in README.md
- Removed unused code
  • Loading branch information
Pixel-Master committed Apr 7, 2024
1 parent 2b625ae commit 2f12bcd
Show file tree
Hide file tree
Showing 8 changed files with 313 additions and 185 deletions.
175 changes: 175 additions & 0 deletions FF_About_UI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# This source file is a part of File Find made by Pixel-Master
#
# Copyright 2022-2024 Pixel-Master
#
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
# which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html

# This file contains the code for the about-window

# Imports
import logging
import os
from sys import platform
from subprocess import run

# PySide6 Gui Imports
from PySide6.QtGui import QFont, QPixmap, QAction
from PySide6.QtWidgets import QMainWindow, QLabel, QPushButton, QWidget, QGridLayout

import FF_Additional_UI
# Projects Libraries
import FF_Files
import FF_Settings


# The class for the about-window
class AboutWindow:
def __init__(self, parent):
# Debug
logging.debug("Called Help UI")

# Test if window was already build
global about_window_global
if about_window_global is None:
logging.debug("About UI wasn't build already")
about_window_global = self.setup(parent)
about_window_global.show()
else:
logging.debug("About UI was build already")
logging.debug("Displaying About Window...")
about_window_global.show()

@staticmethod
def setup(parent):
# Debug
logging.info("Building About UI...")

# The Base Window with Labels
about_window = QMainWindow(parent)
about_window.setWindowTitle("About File Find")

# Main Layout
# Create a central widget
central_widget = QWidget(about_window)
about_window.setCentralWidget(central_widget)
# Create the main Layout
about_layout = QGridLayout(central_widget)
about_layout.setContentsMargins(30, 30, 30, 30)
about_layout.setVerticalSpacing(10)

# File Find for macOS Label
ff_info = QLabel(about_window)
# Change Font and Text
ff_info.setText("File Find")
ff_info.setFont(QFont("Futura", 30))
# Display the Label
about_layout.addWidget(ff_info, 3, 1)

# File Find Logo
ff_logo = QLabel(about_window)
# Set the Icon
ff_logo_img = QPixmap(os.path.join(FF_Files.ASSETS_FOLDER, "FFlogo_small.png"))
ff_logo.setPixmap(ff_logo_img)
# Display the Icon
about_layout.addWidget(ff_logo, 0, 1, 2, 1)

# The Version Label
version_label = QLabel(about_window)
# Font and Text
version_label.setText(f"v. {FF_Files.VERSION_SHORT} ({FF_Files.VERSION})")
version_label.setFont(QFont("Arial", 15))
# The command and tooltip
version_label.setToolTip(f"Version: {FF_Files.VERSION_SHORT} Extended Version: {FF_Files.VERSION}")
# Display the Label
about_layout.addWidget(version_label, 4, 1)

# The Author Label
author_label = QLabel(about_window)
# Font and Text
author_label.setText(
"Created by Pixel Master, Copyright © 2022–2024 Pixel Master.\nLicensed under the GNU GPLv3")
author_label.setFont(QFont("Arial", 15))
# The command and tooltip
author_label.setToolTip(f"Version: {FF_Files.VERSION_SHORT} Extended Version: {FF_Files.VERSION}")
# Display the Label
author_label.setFixedHeight(50)
about_layout.addWidget(author_label, 8, 0, 8, 3)

# Links using QPushButton
def generate_link_button(displayed_text, domain, color):
link = QPushButton(about_window)
# Font and Text
link.setText(displayed_text)
link.setFont(QFont("Arial", 20))
# The command and tooltip
link.setToolTip(domain)
# Depends on the os

if platform == "darwin":
link.clicked.connect(lambda: run(["open", domain]))
elif platform == "win32" or platform == "cygwin":
link.clicked.connect(lambda: run(["start", domain], shell=True))
elif platform == "linux":
link.clicked.connect(lambda: run(["xdg-open", domain]))

# Set the color to blue
link.setStyleSheet(f"color: {color};")
# Display the Label
link.adjustSize()
link.show()
# Return the Label to move it
return link

sourcecode = generate_link_button("Website", "https://pixel-master.github.io/File-Find/", "blue")
about_layout.addWidget(sourcecode, 7, 0)

update = generate_link_button("Update", "https://github.com/Pixel-Master/File-Find/releases", "green")
about_layout.addWidget(update, 7, 1)

faq_link = generate_link_button("FaQ", "https://pixel-master.github.io/File-Find/#faq", "red")
about_layout.addWidget(faq_link, 7, 2)

# Menu bar
menu_bar = about_window.menuBar()

# Menus
window_menu = menu_bar.addMenu("&Window")
help_menu = menu_bar.addMenu("&Help")

# Close Window
close_action = QAction("&Close Window", about_window)
close_action.triggered.connect(about_window.hide)
close_action.setShortcut("Ctrl+W")
window_menu.addAction(close_action)

# About File Find
about_action = QAction("&About File Find", about_window)
about_action.triggered.connect(about_window.show)
help_menu.addAction(about_action)

# Settings
settings_action = QAction("&Settings", about_window)
settings_action.triggered.connect(lambda: FF_Settings.SettingsWindow(about_window))
settings_action.setShortcut("Ctrl+,")
help_menu.addAction(settings_action)

# Help
help_action = QAction("&About File Find", about_window)
help_action.triggered.connect(about_window.show)
help_menu.addAction(help_action)

# Tutorial
tutorial_action = QAction("&Tutorial", about_window)
tutorial_action.triggered.connect(lambda: FF_Additional_UI.welcome_popups(parent, force_popups=True))
help_menu.addAction(tutorial_action)

# Debug
logging.info("Finished Setting up About UI\n")

# Sets the Window
return about_window


about_window_global = None
23 changes: 17 additions & 6 deletions FF_Additional_UI.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def show_delete_question(parent, file):


# Displaying Welcome Popups
def welcome_popups(parent):
def welcome_popups(parent, force_popups=False):
# Debug
logging.debug("Testing for PopUps...")

Expand All @@ -315,12 +315,13 @@ def welcome_popups(parent):
settings = load(settings_file)
popup_dict = settings["popup"]

if popup_dict["FF_welcome"]:
if popup_dict["FF_welcome"] or force_popups:
# Debug
logging.info("Showing Welcomes PopUp...")

# Asking if tutorial is necessary
question_popup = QMessageBox(text="Would you like to have a short tutorial?", parent=parent)
question_popup = QMessageBox(text="Would you like to have a short tutorial?\n\n"
"By going to Help > Tutorial, you can get it later.", parent=parent)

question_popup.setStandardButtons(QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No)
# Entering the mainloop
Expand All @@ -336,18 +337,28 @@ def welcome_popups(parent):
text="Welcome to File Find!\n\nThanks for downloading File Find!\n"
"File Find is an open-source macOS utility,"
" that makes it easy to search and find files.\n\n"
"To search fill in the filters you need and leave those"
"To search, fill in the filters you need and leave those"
" you don't need empty.\n\n\n"
"File Find version: "
f"{FF_Files.VERSION_SHORT}[{FF_Files.VERSION}]",
parent=parent)
PopUps.show_info_messagebox(
title="Welcome to File Find",
text="Welcome to File Find!\n\nSearch with the Find button.\n\n"
"You can find all info's and settings in the Settings section!\n\n"
"You can find all and settings in the settings menu.\n"
"(find it by going to File Find > Setting in the menubar)\n\n"
"If you press on the File Find icon in the menu bar and go to \"Searches:\","
" you can see the state of all your searches",
" you can see the state of all your active searches.",
parent=parent)
PopUps.show_info_messagebox(
title="Welcome to File Find",
text="Welcome to File Find!\n\nSave a search or a filter preset \n"
"by pressing CMD/Ctrl + S in the result or main window.\n\n"
"After you opened a search, you can find duplicated files\n"
"or compare the opened search to an search saved on the disk,\n"
"by pressing the corresponding buttons in the top right.",
parent=parent)

PopUps.show_info_messagebox(
title="Welcome to File Find",
text="Welcome to File Find!\n\n"
Expand Down
Loading

0 comments on commit 2f12bcd

Please sign in to comment.