diff --git a/assets/css/sidenav.css b/assets/css/sidenav.css
index 2f0bd26..66f0f6c 100644
--- a/assets/css/sidenav.css
+++ b/assets/css/sidenav.css
@@ -39,8 +39,7 @@
}
.sidenav a:hover {
- color: #c5af86;
- text-shadow: 0 0 5px #c5af86;
+ color: #1a5dad;
margin-left: 20px;
}
diff --git a/assets/css/style.css b/assets/css/style.css
index 6a176fb..1dfae49 100644
--- a/assets/css/style.css
+++ b/assets/css/style.css
@@ -97,16 +97,7 @@ a {
}
a:hover, a:focus {
- text-shadow: 0 0 4px #cccccc;
-}
-
-footer a {
- color: #F2F2F2;
- text-decoration: underline;
-}
-
-em, cite {
- font-style: italic;
+ text-shadow: 0 0 4px #1a5dad;
}
strong {
@@ -205,7 +196,16 @@ Full-Width Styles
#menu_title {
border-bottom: none;
- margin-left: 30px;
+ line-height: 40px;
+ height: 40px;
+ margin: 5px;
+}
+
+#menu_icon {
+ width: 40px;
+ height: 40px;
+ padding: 0;
+ margin: 5px;
}
#title {
diff --git a/assets/images/coms/logo.png b/assets/images/coms/logo.png
deleted file mode 100644
index 6e076bd..0000000
Binary files a/assets/images/coms/logo.png and /dev/null differ
diff --git a/assets/images/logo-site-accueil.svg b/assets/images/logo-site-accueil.svg
new file mode 100644
index 0000000..9583617
--- /dev/null
+++ b/assets/images/logo-site-accueil.svg
@@ -0,0 +1,523 @@
+
+
+
+
diff --git a/assets/scripts/sidenavScript.js b/assets/scripts/sidenavScript.js
index 2010a03..5ddd655 100644
--- a/assets/scripts/sidenavScript.js
+++ b/assets/scripts/sidenavScript.js
@@ -70,12 +70,12 @@ manager.on('swipe', function(e) {
// Animate hamburger on hover
hamburger.hover(function(){
- $("#bar1").css("background-color", "#c5af86");
- $("#bar2-1").css("background-color", "#73b795");
- $("#bar2-2").css("background-color", "#73b795");
+ $("#bar1").css("background-color", "#1a5dad");
+ $("#bar2-1").css("background-color", "#ee293d");
+ $("#bar2-2").css("background-color", "#ee293d");
$("#bar2-1").css("left", "-5px");
$("#bar2-2").css("right", "-5px");
- $("#bar3").css("background-color", "#c5af86");
+ $("#bar3").css("background-color", "#1a5dad");
}, function(){
$("#bar1").css("background-color", "white");
$("#bar2-1").css("background-color", "white");
diff --git a/favicon.ico b/favicon.ico
index 78bb04f..1f3eb38 100644
Binary files a/favicon.ico and b/favicon.ico differ
diff --git a/includes/top_bar.html b/includes/top_bar.html
index 1120d92..ec8592a 100644
--- a/includes/top_bar.html
+++ b/includes/top_bar.html
@@ -5,5 +5,6 @@
-
+
+
\ No newline at end of file
diff --git a/photos.php b/photos.php
index 0aa849c..eab87b5 100644
--- a/photos.php
+++ b/photos.php
@@ -181,7 +181,7 @@ function getTotalPhotoCount($path)
function isValidImage($imagePath)
{
$ext = pathinfo($imagePath, PATHINFO_EXTENSION);
- return !is_dir($imagePath) && ($ext == "jpg" || $ext == "jpeg" || $ext == "png");
+ return !is_dir($imagePath) && ($ext == "jpg" || $ext == "JPG" || $ext == "jpeg" || $ext == "JPEG" || $ext == "png" || $ext == "PNG");
}
/**
diff --git a/photos/compress_photos.py b/photos/compress_photos.py
index 2ff4a90..8568e90 100644
--- a/photos/compress_photos.py
+++ b/photos/compress_photos.py
@@ -1,156 +1,416 @@
-#!/usr/bin/python
-
+#!/usr/bin/python3
import os
import sys
-from zipfile import ZipFile, ZIP_DEFLATED
-from PIL import Image
+
+from PyQt5.QtCore import QThreadPool, Qt, pyqtSlot
+from PyQt5.QtGui import QIcon
+from PyQt5.QtWidgets import QMainWindow, QAction, QDesktopWidget, QWidget, QFrame, QLineEdit, QListWidget, QVBoxLayout, \
+ QLabel, QPushButton, QGridLayout, QMessageBox, QFileDialog, QDialog, QTabWidget, QApplication, QCheckBox, \
+ QProgressBar
+
+from compresser import Compresser
+from scanner import Scanner
+from utils import create_file_dialog
-def get_images(path):
- """
- get images in the folder specified and all its sub folders (hidden and empty folders are ignored)
+class MainWindow(QMainWindow):
- :param path: directory to get images in
- :return: images list
- """
- file_list = []
- for root, dirs, files in os.walk(path):
- if is_directory_valid(root, files):
- for fn in files:
- if is_file_valid_image(fn):
- file_list.append(os.path.join(root, fn))
- return file_list
+ def __init__(self, parent=None):
+ super(MainWindow, self).__init__(parent)
+ self.resize(1000, 600)
+ self.center()
+ self.main_widget = MainWidgets()
+ self.setCentralWidget(self.main_widget)
+ self.create_menu_bar()
+ self.setWindowTitle('Compression de Photos')
+ self.setWindowIcon(QIcon('icon.png'))
+
+ def create_menu_bar(self):
+ main_menu = self.menuBar()
+ file_menu = main_menu.addMenu("Fichier")
+ help_menu = main_menu.addMenu("Aide")
+
+ exit_button = QAction('Quitter', self)
+ exit_button.setShortcut('Ctrl+Q')
+ exit_button.setStatusTip('Quitter le logiciel')
+ exit_button.triggered.connect(self.close)
+ file_menu.addAction(exit_button)
+
+ about_button = QAction('À Propos', self)
+ about_button.setShortcut('Ctrl+H')
+ about_button.setStatusTip('Voir les informations du logiciel')
+ about_button.triggered.connect(self.display_help_dialog)
+ help_menu.addAction(about_button)
+
+ def center(self):
+ rectangle = self.frameGeometry()
+ center_point = QDesktopWidget().availableGeometry().center()
+ rectangle.moveCenter(center_point)
+ self.move(rectangle.topLeft())
+
+ def display_help_dialog(self):
+ dialog = HelpDialog(self)
+ dialog.exec_()
+ dialog.deleteLater()
-def compress_images(images):
- """
- Compress images to a 140x105 format, cropping in the middle if needed
- :param images: list o images paths to compress
- :return:
- """
- size = 140, 105 # 4/3 format
- print("Creating thumbnails", end="")
- for current_img in images:
- print(".", end="")
- # If height is higher we resize vertically, if not we resize horizontally
- img = Image.open(current_img)
- # Get current and desired ratio for the images
- img_ratio = img.size[0] / float(img.size[1])
- ratio = size[0] / float(size[1])
- # The image is scaled/cropped vertically or horizontally depending on the ratio
- if ratio > img_ratio:
- img = img.resize((size[0], round(size[0] * img.size[1] / img.size[0])), Image.BILINEAR)
- # Crop in the middle
- box = (0, round((img.size[1] - size[1]) / 2), img.size[0], round((img.size[1] + size[1]) / 2))
- img = img.crop(box)
- elif ratio < img_ratio:
- img = img.resize((round(size[1] * img.size[0] / img.size[1]), size[1]), Image.BILINEAR)
- # Crop in the middle
- box = (round((img.size[0] - size[0]) / 2), 0, round((img.size[0] + size[0]) / 2), img.size[1])
- img = img.crop(box)
+class MainWidgets(QWidget):
+
+ def __init__(self):
+ super().__init__()
+ self.dir_select_group = QFrame()
+ self.dir_path_line_edit = QLineEdit(os.path.dirname(__file__))
+ self.dir_selection_button = QPushButton("Selectionner")
+ self.dir_thumb_path_line_edit = QLineEdit(os.path.dirname(__file__) + "_thumb")
+ self.dir_thumb_selection_button = QPushButton("Selectionner")
+ self.scan_progress_bar = QProgressBar()
+ self.scan_progress_text = QLabel("Scan")
+ self.dir_list_group = QFrame()
+ self.directories_list = QListWidget()
+ self.scan_button = QPushButton("Scanner")
+ self.stop_scan_button = QPushButton("Stop")
+ self.compress_button = QPushButton("Compresser")
+ self.stop_compress_button = QPushButton("Stop")
+ self.list_title = QLabel("0 images dans 0 dossiers :")
+ self.delete_button = QPushButton("Enlever sélectionné")
+ self.enable_zip_radio_button = QCheckBox("Créer .zip")
+ self.enable_thumb_radio_button = QCheckBox("Créer miniatures")
+ self.enable_compress_radio_button = QCheckBox("Compresser photos")
+ self.compress_progress_bar = QProgressBar()
+ self.compress_progress_text = QLabel("Compression")
+ self.zip_progress_bar = QProgressBar()
+ self.zip_progress_text = QLabel("Création de .zip")
+ self.thumb_progress_bar = QProgressBar()
+ self.thumb_progress_text = QLabel("Création de miniatures")
+ self.image_list = []
+ self.main_layout = QGridLayout()
+ self.scanner = Scanner("")
+ self.compresser = Compresser([], [], "", "", True, True, True)
+ self.thread_pool = QThreadPool()
+ self.init_ui()
+
+ def init_ui(self):
+ self.setLayout(self.main_layout)
+
+ subtitle = QLabel("Cet utilitaire permet de créer un fichier compressé des images du dossier sélectionné (et "
+ "tout ses sous dossiers)\nainsi que la miniatures de images présentes")
+ subtitle.setAlignment(Qt.AlignCenter)
+
+ y = 0
+ self.main_layout.addWidget(subtitle, y, 0, 1, 20)
+ y += 1
+ self.main_layout.addWidget(QLabel("Dossier parent :"), y, 0, 1, 1)
+ self.dir_path_line_edit.textChanged.connect(self.directories_list.clear)
+ self.main_layout.addWidget(self.dir_path_line_edit, y, 1, 1, 18)
+ self.dir_selection_button.clicked.connect(self.open_dir)
+ self.main_layout.addWidget(self.dir_selection_button, y, 19, 1, 1)
+
+ y += 1
+ self.main_layout.addWidget(QLabel("Dossier miniatures :"), y, 0, 1, 1)
+ self.dir_thumb_path_line_edit.textChanged.connect(self.directories_list.clear)
+ self.main_layout.addWidget(self.dir_thumb_path_line_edit, y, 1, 1, 18)
+ self.dir_thumb_selection_button.clicked.connect(self.open_thumb_dir)
+ self.main_layout.addWidget(self.dir_thumb_selection_button, y, 19, 1, 1)
+
+ y += 1
+ self.scan_button.clicked.connect(self.scan_click)
+ self.main_layout.addWidget(self.scan_button, y, 5, 1, 10)
+ self.stop_scan_button.clicked.connect(self.stop_scan)
+ self.stop_scan_button.setEnabled(False)
+ self.main_layout.addWidget(self.stop_scan_button, y, 15, 1, 1)
+
+ y += 1
+ self.main_layout.addWidget(self.scan_progress_text, y, 0, 1, 20)
+ self.scan_progress_bar.setTextVisible(False)
+
+ y += 1
+ self.main_layout.addWidget(self.scan_progress_bar, y, 0, 1, 20)
+
+ y += 1
+ self.main_layout.addWidget(self.list_title, y, 0, 1, 20)
+
+ y += 1
+ self.main_layout.addWidget(self.directories_list, y, 0, 10, 19)
+ self.delete_button.clicked.connect(self.dir_list_delete_selected)
+ self.main_layout.addWidget(self.delete_button, y, 19, 1, 1)
+
+ y += 1
+ self.enable_compress_radio_button.toggled.connect(self.set_compress_enabled)
+ self.enable_compress_radio_button.setChecked(True)
+ self.main_layout.addWidget(self.enable_compress_radio_button, y, 19, 1, 1)
+
+ y += 1
+ self.enable_zip_radio_button.toggled.connect(self.set_zip_enabled)
+ self.enable_zip_radio_button.setChecked(True)
+ self.main_layout.addWidget(self.enable_zip_radio_button, y, 19, 1, 1)
+
+ y += 1
+ self.enable_thumb_radio_button.toggled.connect(self.set_thumb_enabled)
+ self.enable_thumb_radio_button.setChecked(True)
+ self.main_layout.addWidget(self.enable_thumb_radio_button, y, 19, 1, 1)
+
+ y += 7
+ self.compress_button.clicked.connect(self.compress_click)
+ self.main_layout.addWidget(self.compress_button, y, 5, 1, 10)
+ self.stop_compress_button.clicked.connect(self.stop_compress)
+ self.stop_compress_button.setEnabled(False)
+ self.main_layout.addWidget(self.stop_compress_button, y, 15, 1, 1)
+
+ y += 1
+ self.main_layout.addWidget(self.compress_progress_text, y, 0, 1, 20)
+
+ y += 1
+ self.compress_progress_bar.setTextVisible(False)
+ self.main_layout.addWidget(self.compress_progress_bar, y, 0, 1, 20)
+
+ y += 1
+ self.main_layout.addWidget(self.zip_progress_text, y, 0, 1, 20)
+
+ y += 1
+ self.zip_progress_bar.setTextVisible(False)
+ self.main_layout.addWidget(self.zip_progress_bar, y, 0, 1, 20)
+
+ y += 1
+ self.main_layout.addWidget(self.thumb_progress_text, y, 0, 1, 20)
+
+ y += 1
+ self.thumb_progress_bar.setTextVisible(False)
+ self.main_layout.addWidget(self.thumb_progress_bar, y, 0, 1, 20)
+
+ def dir_list_delete_selected(self):
+ for selected_item in self.directories_list.selectedItems():
+ self.directories_list.takeItem(self.directories_list.row(selected_item))
+
+ def get_dir_list(self):
+ items = []
+ for index in range(self.directories_list.count()):
+ items.append(self.directories_list.item(index).text())
+ return items
+
+ def set_compress_enabled(self, enabled):
+ self.compress_progress_bar.setHidden(not enabled)
+ self.compress_progress_text.setEnabled(enabled)
+
+ def set_zip_enabled(self, enabled):
+ self.zip_progress_bar.setHidden(not enabled)
+ self.zip_progress_text.setEnabled(enabled)
+
+ def set_thumb_enabled(self, enabled):
+ self.thumb_progress_bar.setHidden(not enabled)
+ self.thumb_progress_text.setEnabled(enabled)
+
+ def set_ui_enabled(self, enabled, is_scan):
+ self.dir_path_line_edit.setEnabled(enabled)
+ self.dir_thumb_path_line_edit.setEnabled(enabled)
+ self.stop_compress_button.setEnabled(enabled)
+ self.stop_scan_button.setEnabled(enabled)
+ self.compress_button.setEnabled(enabled)
+ self.scan_button.setEnabled(enabled)
+ self.delete_button.setEnabled(enabled)
+ self.enable_zip_radio_button.setEnabled(enabled)
+ self.enable_compress_radio_button.setEnabled(enabled)
+ self.enable_thumb_radio_button.setEnabled(enabled)
+ self.dir_selection_button.setEnabled(enabled)
+ self.dir_thumb_selection_button.setEnabled(enabled)
+ self.stop_scan_button.setEnabled((not enabled) and is_scan)
+ self.stop_compress_button.setEnabled((not enabled) and (not is_scan))
+
+ def scan_click(self):
+ self.directories_list.clear()
+ # Start scan thread
+ self.set_ui_enabled(False, True)
+ self.scanner = Scanner(self.dir_path_line_edit.text())
+ self.scanner.signals.scanned_dir_signal.connect(self.add_dir_to_list)
+ self.scanner.signals.scan_finished_signal.connect(self.scan_finished)
+ self.scanner.signals.scanned_dir_finished.connect(self.reset_progress_scan)
+ self.scanner.signals.scanned_images_signal.connect(self.add_progress_scan)
+ self.scanner.signals.new_scan_task_started.connect(self.scan_progress_text.setText)
+ self.thread_pool.start(self.scanner)
+
+ def stop_scan(self):
+ self.scanner.stop()
+
+ def add_dir_to_list(self, directory):
+ self.directories_list.addItem(directory)
+
+ def scan_finished(self, dir_list, image_list):
+ self.set_ui_enabled(True, True)
+ self.image_list = image_list
+ self.list_title.setText(
+ str(len(self.image_list)) + " images dans " + str(len(self.get_dir_list())) + " dossiers :")
+ self.reset_progress_compress()
+ self.reset_progress_zip()
+ self.reset_progress_thumb()
+ if self.scanner.is_aborted():
+ QMessageBox.warning(self, "Scan Annulé", "Scan des dossiers stoppé\n" + str(len(dir_list)) + " dossier et "
+ + str(len(self.image_list)) + " images trouvés")
else:
- img = img.resize((size[0], size[1]), Image.BILINEAR)
- # If the scale is the same, we do not need to crop
- filename = get_new_path(current_img)
- if not os.path.exists(os.path.dirname(filename)):
- try:
- os.makedirs(os.path.dirname(filename))
- except OSError:
- sys.exit("Fatal : Directory '" + os.path.dirname(filename) + "' does not exist and cannot be created")
+ QMessageBox.information(self, "Scan Terminé",
+ "Scan des dossiers terminé\n" + str(len(dir_list)) + " dossier et "
+ + str(len(self.image_list)) + " images trouvés")
- img.save(filename, "JPEG")
- print("done")
- print("Thumbnails saved in 'photos_thumb' directory")
+ def compress_click(self):
+ if self.directories_list.count() == 0:
+ QMessageBox.warning(self, "Erreur", "Aucun dossier trouvé\nVeuillez vérifier le dossier parent")
+ elif (not self.enable_compress_radio_button.checkState()) and (not self.enable_zip_radio_button.checkState()) \
+ and (not self.enable_thumb_radio_button.checkState()):
+ QMessageBox.warning(self, "Erreur", "Aucune action sélectionnée")
+ else:
+ self.show_confirmation_dialog()
+
+ def show_confirmation_dialog(self):
+ msg = str(len(self.get_dir_list())) + " dossiers contenant " + str(len(self.image_list)) + \
+ " images selectionnés\n\nActions à réaliser :"
+ if self.enable_compress_radio_button.checkState():
+ msg += "\nCompression des images"
+ if self.enable_zip_radio_button.checkState():
+ msg += "\nCréation de .zip"
+ if self.enable_thumb_radio_button.checkState():
+ msg += "\nCréation de miniatures"
+ msg += "\n\nÊtes-vous sûr de vouloir continuer ?"
+ confirmation_dialog = QMessageBox.question(self, 'Confirmation', msg,
+ QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
+ if confirmation_dialog == QMessageBox.Yes:
+ # Start compress thread
+ self.reset_progress_compress()
+ self.reset_progress_zip()
+ self.reset_progress_thumb()
+ self.set_ui_enabled(False, False)
+ self.compresser = Compresser(self.get_dir_list(), self.image_list, self.dir_path_line_edit.text(),
+ self.dir_thumb_path_line_edit.text(),
+ self.enable_compress_radio_button.checkState(),
+ self.enable_zip_radio_button.checkState(),
+ self.enable_thumb_radio_button.checkState())
+ self.compresser.signals.finished_signal.connect(self.compress_finished)
+ self.compresser.signals.new_compress_task_started.connect(self.compress_progress_text.setText)
+ self.compresser.signals.new_zip_task_started.connect(self.zip_progress_text.setText)
+ self.compresser.signals.new_thumb_task_started.connect(self.thumb_progress_text.setText)
+ self.compresser.signals.compress_done.connect(self.add_progress_compress)
+ self.compresser.signals.zip_done.connect(self.add_progress_zip)
+ self.compresser.signals.thumb_done.connect(self.add_progress_thumb)
+ self.thread_pool.start(self.compresser)
+
+ def stop_compress(self):
+ self.compresser.stop()
+
+ def reset_progress_scan(self):
+ self.scan_progress_text.setText("Scan")
+ self.scan_progress_bar.setMinimum(0)
+ self.scan_progress_bar.setMaximum(len(self.get_dir_list()))
+ self.scan_progress_bar.setValue(0)
+
+ def reset_progress_compress(self):
+ self.compress_progress_text.setText("Compression")
+ self.compress_progress_bar.setMinimum(0)
+ self.compress_progress_bar.setMaximum(len(self.image_list))
+ self.compress_progress_bar.setValue(0)
+
+ def reset_progress_zip(self):
+ self.zip_progress_text.setText("Création de .zip")
+ self.zip_progress_bar.setMinimum(0)
+ self.zip_progress_bar.setMaximum(len(self.get_dir_list()))
+ self.zip_progress_bar.setValue(0)
+
+ def reset_progress_thumb(self):
+ self.thumb_progress_text.setText("Création de miniatures")
+ self.thumb_progress_bar.setMinimum(0)
+ self.thumb_progress_bar.setMaximum(len(self.image_list))
+ self.thumb_progress_bar.setValue(0)
+
+ def add_progress_scan(self):
+ self.scan_progress_bar.setValue(self.scan_progress_bar.value() + 1)
+
+ def add_progress_compress(self):
+ self.compress_progress_bar.setValue(self.compress_progress_bar.value() + 1)
+
+ def add_progress_zip(self):
+ self.zip_progress_bar.setValue(self.zip_progress_bar.value() + 1)
+
+ def add_progress_thumb(self):
+ self.thumb_progress_bar.setValue(self.thumb_progress_bar.value() + 1)
+
+ def compress_finished(self):
+ self.set_ui_enabled(True, False)
+ if self.compresser.is_aborted():
+ QMessageBox.warning(self, "Annulé", "Compression stoppée")
+ else:
+ QMessageBox.information(self, "Terminé", "Compression terminée")
+
+ def open_dir(self):
+ dialog = create_file_dialog()
+ dialog.selectFile(self.dir_path_line_edit.text())
+ if dialog.exec_():
+ self.dir_path_line_edit.setText(dialog.selectedFiles()[0])
+
+ def open_thumb_dir(self):
+ dialog = create_file_dialog()
+ dialog.selectFile(self.dir_thumb_path_line_edit.text())
+ if dialog.exec_():
+ self.dir_thumb_path_line_edit.setText(dialog.selectedFiles()[0])
-def get_new_path(img):
- """
- Replace the original path to the thumbnail one (replace 'photos' by 'photos_thumb')
- :param img: original path
- :return: modified path
- """
- return img.replace("/photos/", "/photos_thumb/", 1)
+class HelpDialog(QDialog):
+ def __init__(self, parent=None):
+ QDialog.__init__(self, parent)
+ self.resize(300, 100)
+ self.main_layout = QVBoxLayout()
+ self.setLayout(self.main_layout)
+ title = QLabel("Compression de photos")
+ font = title.font()
+ font.setBold(True)
+ font.setPixelSize(20)
+ title.setFont(font)
+ title.setAlignment(Qt.AlignCenter)
+ self.main_layout.addWidget(title)
-def zip_dir(path):
- """
- Compress images in the specified directory and sub-directories
- Create one zip per folder
+ self.tabs = QTabWidget()
+ self.tab1 = QWidget()
+ self.tab2 = QWidget()
- :param path: directory to get files in
- :return:
- """
- for root, dirs, files in os.walk(path):
- if is_directory_valid(root, files):
- print("Compressing '" + root + "'", end="")
- with ZipFile(os.path.join(root, get_current_dir(root)) + ".zip", "w", ZIP_DEFLATED) as zip_file:
- for fn in files:
- if not fn.endswith("zip") and is_file_valid_image(fn):
- print(".", end="")
- absolute_file_name = os.path.join(root, fn)
- zippped_file_name = absolute_file_name[len(root)+len(os.sep):] # XXX: relative path
- zip_file.write(absolute_file_name, zippped_file_name)
- print("done")
- print("COMPRESSION FINISHED")
+ self.tabs.addTab(self.tab1, "À Propos")
+ self.tabs.addTab(self.tab2, "Librairies")
+ self.create_about_tab()
+ self.create_libs_tab()
+ self.main_layout.addWidget(self.tabs)
+ def create_about_tab(self):
+ self.tab1.layout = QVBoxLayout(self)
+ author = QLabel("(c) 2018 Arnaud VERGNET")
+ author.setAlignment(Qt.AlignCenter)
+ self.tab1.layout.addWidget(author)
-def is_directory_valid(path, files):
- """
- Check if the given path is not hidden or without images
- :param files: files in the folder
- :param path: Path to check
- :return: True if path contains a hidden folder or is empty, False otherwise
- """
- directories = path.split(os.sep)
- valid = len(files) > 0
- for dn in directories: # check if directory or one of its parent are not hidden
- if dn.startswith(".") or not valid:
- valid = False
- break
- if valid:
- valid_files = []
- for fn in files: # check if directory contains valid images
- if is_file_valid_image(fn):
- valid_files.append(fn)
- valid = len(valid_files) > 0
- return valid
+ github = QLabel("Disponible sur GitHub sous license GPLv3")
+ github.setAlignment(Qt.AlignCenter)
+ self.tab1.layout.addWidget(github)
+ gh_link = QLabel()
+ gh_link.setOpenExternalLinks(True)
+ gh_link.setText("https://github.com/Keplyx")
+ gh_link.setAlignment(Qt.AlignCenter)
+ self.tab1.layout.addWidget(gh_link)
+ self.tab1.setLayout(self.tab1.layout)
-def is_file_valid_image(file):
- return file.endswith("png") or file.endswith("jpg") or file.endswith("jpeg")
+ def create_libs_tab(self):
+ self.tab2.layout = QVBoxLayout(self)
+ qt_lib = QLabel("Qt5")
+ qt_lib.setAlignment(Qt.AlignCenter)
+ self.tab2.layout.addWidget(qt_lib)
+ python_lib = QLabel("python3 avec PyQt5")
+ python_lib.setAlignment(Qt.AlignCenter)
+ self.tab2.layout.addWidget(python_lib)
-def get_current_dir(path):
- """
- Get the name of the current directory
- :param path: Path to search the name in
- :return: directory name
- """
- return os.path.basename(os.path.normpath(path))
+ self.tab2.setLayout(self.tab2.layout)
-
-def get_confirmation(path):
- """
- Tell the user which folders will be compressed, and asks for confirmation
- :param path: Root path for search
- :return: True if user confirmed, False otherwise
- """
- print("The following folders will be compressed (hidden and empty folders are ignored):")
- for root, dirs, files in os.walk(path):
- if is_directory_valid(root, files):
- print(root)
- confirmation = input("Are you sure you want to proceed? [Y/n]")
- return confirmation == "Y" or confirmation == "y"
+ @pyqtSlot()
+ def on_click(self):
+ for currentQTableWidgetItem in self.tableWidget.selectedItems():
+ print(currentQTableWidgetItem.row(), currentQTableWidgetItem.column(), currentQTableWidgetItem.text())
if __name__ == '__main__':
- # Get path from arguments or use the script's path
- if len(sys.argv) > 1:
- directory = sys.argv[1]
- else:
- directory = os.path.dirname(os.path.realpath(__file__))
- if get_confirmation(directory):
- zip_dir(directory)
- compress_images(get_images(directory))
- else:
- print("Compression aborted")
+ app = QApplication(sys.argv)
+ main_window = MainWindow()
+ main_window.show()
+ sys.exit(app.exec_())