diff --git a/assets/CheckTabScreenShot.png b/assets/CheckTabScreenShot.png deleted file mode 100644 index 5612e49..0000000 Binary files a/assets/CheckTabScreenShot.png and /dev/null differ diff --git a/assets/CreateTabScreenShot.png b/assets/CreateTabScreenShot.png deleted file mode 100644 index 2af10de..0000000 Binary files a/assets/CreateTabScreenShot.png and /dev/null differ diff --git a/assets/InfoTabScreenShot.png b/assets/InfoTabScreenShot.png deleted file mode 100644 index 99b80b3..0000000 Binary files a/assets/InfoTabScreenShot.png and /dev/null differ diff --git a/assets/favicon.png b/assets/favicon.png new file mode 100644 index 0000000..ffcfa70 Binary files /dev/null and b/assets/favicon.png differ diff --git a/assets/torrent-icon.png b/assets/torrent-icon.png deleted file mode 100644 index 33a0b28..0000000 Binary files a/assets/torrent-icon.png and /dev/null differ diff --git a/assets/torrentfile.ico b/assets/torrentfile.ico new file mode 100644 index 0000000..51c322b Binary files /dev/null and b/assets/torrentfile.ico differ diff --git a/assets/torrentfile.png b/assets/torrentfile.png deleted file mode 100644 index 14f7fa5..0000000 Binary files a/assets/torrentfile.png and /dev/null differ diff --git a/assets/transparent.png b/assets/transparent.png deleted file mode 100644 index 483df25..0000000 Binary files a/assets/transparent.png and /dev/null differ diff --git a/coverage.xml b/coverage.xml index f14ddf9..9f12ac5 100644 --- a/coverage.xml +++ b/coverage.xml @@ -1,14 +1,14 @@ - + C:\Users\asp\Documents\Code\repos\torrentfileQt - + - + @@ -16,23 +16,23 @@ - + - - + + - + - - - + + + - - - + + + @@ -41,12 +41,12 @@ - + - + @@ -60,9 +60,14 @@ - + - + + + + + + @@ -70,80 +75,80 @@ - - + + - + - + - + - + - + - + - + - + - + - + - + - + - - - + + + - - + + - - + + + + - - @@ -151,13 +156,13 @@ + + - - @@ -165,13 +170,13 @@ + + - - @@ -179,36 +184,29 @@ + + - - - + - + - - - - - - - @@ -219,7 +217,7 @@ - + @@ -227,7 +225,7 @@ - + @@ -236,34 +234,32 @@ - - - - - + + + - + - + - + - + - + - + @@ -272,7 +268,7 @@ - + @@ -281,17 +277,17 @@ - - - - + + + + - - + + @@ -301,93 +297,93 @@ - - + + + - + - - - - - + + + + - + - - + + + - + - - - + + - + - - - - + + + + - - - - - - - + + + + + + + - + + - - + - + + - - - - - - + + + + + + - - + + - - - - - - - - - + + + + + + + + + - @@ -403,22 +399,22 @@ + - - - + + - + + - - + - + + - - + @@ -437,112 +433,123 @@ - - - + + + + - + - - - + + + - + + - - - + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - + + + + - + - - + - + - + - + - + - + - + - @@ -554,6 +561,7 @@ + @@ -570,146 +578,177 @@ + + - - + + - - - - - - - + + + + + + + + - - - + + - - + - + - + + - - + - + - - + - - + + - - + + + + + - - - - - - - - + + + + + - + - - + + + - - + - - - - - - - + + + + + + - + - + - + + - - - + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -720,15 +759,13 @@ - - - - - + + + - + @@ -778,8 +815,8 @@ - - + + @@ -787,61 +824,61 @@ - + - + - + - - + + - - - - + + + + - + - - - - + + + + - + - + - - + + - + - + - + - + @@ -853,26 +890,26 @@ - - + + - + - + - - + + - + - + @@ -883,18 +920,36 @@ - + - + + + + + + + + + + + + + + + + + + + - + @@ -941,13 +996,11 @@ - + - + - - @@ -962,21 +1015,22 @@ + - - - - - - - - - - + + + + + + + + + + + - - - + + @@ -1061,44 +1115,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/context.py b/tests/context.py index 1a9392b..bea9822 100644 --- a/tests/context.py +++ b/tests/context.py @@ -22,6 +22,7 @@ import shutil import string import atexit +import time TESTS = os.path.dirname(os.path.abspath(__file__)) @@ -106,4 +107,8 @@ def tstdir(): @atexit.register def teardown(): - rmpath(TESTDIR) + try: + rmpath(TESTDIR) + except PermissionError: + time.sleep(1.5) + teardown() diff --git a/tests/test_gui.py b/tests/test_gui.py index b84e458..e7f3c92 100644 --- a/tests/test_gui.py +++ b/tests/test_gui.py @@ -19,7 +19,6 @@ import os import pytest -from pathlib import Path from PyQt6.QtWidgets import QApplication, QMainWindow, QStatusBar @@ -65,7 +64,6 @@ def ttorrent1(tfile, request): return outfile - @pytest.fixture(scope="module", params=[TorrentFile, TorrentFileV2, TorrentFileHybrid]) def ttorrent2(tfile, request): path = tfile @@ -95,14 +93,6 @@ def test_window_menubar1(wind): assert wind.menubar is not None -def test_window_menubar_action1(wind): - menubar = wind.menubar - menubar.actionDocs.trigger() - menubar.actionRepo.trigger() - menubar.actionExit.trigger() - assert True - - def test_window_statusbar1(wind): assert wind.statusbar is not None diff --git a/torrentfileQt/checkTab.py b/torrentfileQt/checkTab.py index ffb24e1..9b402f6 100644 --- a/torrentfileQt/checkTab.py +++ b/torrentfileQt/checkTab.py @@ -34,21 +34,22 @@ QToolButton, QTreeWidget, QTreeWidgetItem, + QLineEdit, + QLabel ) from torrentfile.progress import CheckerClass from torrentfileQt.qss import ( logTextEditSheet, + lineEditSheet, + labelSheet, pushButtonSheet, toolButtonSheet, treeSheet, headerSheet, ) -from torrentfileQt.widgets import Label, LineEdit - - class CheckWidget(QWidget): labelRole = QFormLayout.ItemRole.LabelRole @@ -108,6 +109,7 @@ class ReCheckButton(QPushButton): text (`str`): The text displayed on the button itself. parent (`QWidget`, default=None): This widgets parent widget. """ + process = None def __init__(self, text, parent=None): @@ -121,19 +123,19 @@ def __init__(self, text, parent=None): def submit(self): tree = self.widget.treeWidget + tree.clear() textEdit = self.widget.textEdit + textEdit.clear() searchInput = self.widget.searchInput fileInput = self.widget.fileInput metafile = fileInput.text() content = searchInput.text() - tree.setRoot(content) CheckerClass.register_callback(textEdit.callback) logging.debug("Registering Callback, setting root") piece_hasher(metafile, content, tree) # tree.start_thread(metafile, content) - class BrowseTorrents(QToolButton): """BrowseButton ToolButton for activating filebrowser. @@ -230,7 +232,8 @@ def getProgressBar(self): def set_top(self, path, icon): pix = QIcon(icon) self.setIcon(0, pix) - self.setText(1, path) + if path: + self.setText(1, path) def setTotal(self, total): self.total = total @@ -276,6 +279,7 @@ class TreeWidget(QTreeWidget): Args: parent(`QWidget`, default=None) """ + valueUpdate = pyqtSignal([list]) addPathChild = pyqtSignal([str, int]) @@ -294,7 +298,7 @@ def __init__(self, parent=None): self.itemWidgets = {} self.paths = [] self.total = 0 - self.item_tree = {"widget" : self.item} + self.item_tree = {"widget": self.item} self.valueUpdate.connect(self.updateValue) self.addPathChild.connect(self.add_path_child) @@ -307,7 +311,7 @@ def updateValue(self, args): def clear(self): super().clear() - self.item_tree = {"widget" : self.invisibleRootItem()} + self.item_tree = {"widget": self.invisibleRootItem()} self.itemWidgets = {} self.paths = [] self.root = None @@ -327,6 +331,7 @@ def add_path_child(self, path, size): item_tree[partial] = {"widget": item} if i == len(partials) - 1: item.setTotal(size) + item.set_top(None, "./assets/file.png") progressbar = ProgressBar() self.setItemWidget(item, 2, progressbar) item.setProgressBar(progressbar) @@ -337,7 +342,6 @@ def add_path_child(self, path, size): class LogTextEdit(QPlainTextEdit): - def __init__(self, parent=None): super().__init__(parent=parent) self._parent = parent @@ -368,3 +372,23 @@ def piece_hasher(metafile, content, tree): tree.addPathChild.emit(relpath, length) itemWidgets.append(relpath) tree.valueUpdate.emit([actual, expected, relpath, size]) + +class LineEdit(QLineEdit): + def __init__(self, parent=None): + super().__init__(parent=parent) + self._parent = parent + self.setStyleSheet(lineEditSheet) + +class Label(QLabel): + """Label Identifier for Window Widgets. + + Subclass: QLabel + """ + + def __init__(self, text, parent=None): + super().__init__(text, parent=parent) + self.setStyleSheet(labelSheet) + font = self.font() + font.setBold(True) + font.setPointSize(12) + self.setFont(font) diff --git a/torrentfileQt/createTab.py b/torrentfileQt/createTab.py index 3217583..536ac14 100644 --- a/torrentfileQt/createTab.py +++ b/torrentfileQt/createTab.py @@ -19,6 +19,7 @@ import os import threading +from collections.abc import Sequence from PyQt6.QtCore import Qt from PyQt6.QtWidgets import ( @@ -33,6 +34,9 @@ QSpacerItem, QToolButton, QWidget, + QPlainTextEdit, + QLabel, + QLineEdit ) from torrentfile import TorrentFile, TorrentFileHybrid, TorrentFileV2 from torrentfile.utils import path_stat @@ -40,11 +44,13 @@ from torrentfileQt.qss import ( checkBoxSheet, comboBoxSheet, + labelSheet, push2ButtonSheet, pushButtonSheet, toolButtonSheet, + textEditSheet, + createLineEditSheet ) -from torrentfileQt.widgets import Label, LineEdit, PlainTextEdit class CreateWidget(QWidget): @@ -68,13 +74,13 @@ def setup_Ui(self): self.hlayout3 = QHBoxLayout() self.hlayout0 = QHBoxLayout() - self.path_label = Label("Path:", parent=self) - self.output_label = Label("Save Path:", parent=self) - self.version_label = Label("Meta-version", parent=self) - self.comment_label = Label("Comment:", parent=self) - self.announce_label = Label("Trackers:", parent=self) - self.source_label = Label("Source:", parent=self) - self.piece_length_label = Label("Piece Length:", parent=self) + self.path_label = Label("Path: ", parent=self) + self.output_label = Label("Save Path: ", parent=self) + self.version_label = Label("Meta Version: ", parent=self) + self.comment_label = Label("Comment: ", parent=self) + self.announce_label = Label("Trackers: ", parent=self) + self.source_label = Label("Source: ", parent=self) + self.piece_length_label = Label("Piece Length: ", parent=self) self.path_input = LineEdit(parent=self) self.output_input = LineEdit(parent=self) @@ -93,7 +99,6 @@ def setup_Ui(self): self.v2button = QRadioButton("v2", parent=self) self.hybridbutton = QRadioButton("v1+2 (hybrid)", parent=self) - self.output_input.setDisabled(True) self.spacer = QSpacerItem(50, 0) self.path_label.setAlignment(Qt.AlignmentFlag.AlignLeft) @@ -124,18 +129,19 @@ def setup_Ui(self): self.layout.addLayout(self.hlayout1, 1, 1, 1, 3) self.layout.addWidget(self.version_label, 2, 0, 1, 1) self.layout.addLayout(self.hlayout0, 2, 1, 1, 3) - self.layout.addWidget(self.source_label, 3, 0, 1, 1) - self.layout.addWidget(self.source_input, 3, 1, 1, 3) - self.layout.addWidget(self.comment_label, 4, 0, 1, 1) - self.layout.addWidget(self.comment_input, 4, 1, 1, 3) - self.layout.addWidget(self.piece_length_label, 5, 0, 1, 1) - self.layout.addLayout(self.hlayout2, 5, 1, 1, 3) - self.layout.addWidget(self.output_label, 6, 0, 1, 1) - self.layout.addLayout(self.hlayout3, 6, 1, 1, 3) + self.layout.addWidget(self.piece_length_label, 3, 0, 1, 1) + self.layout.addLayout(self.hlayout2, 3, 1, 1, 3) + self.layout.addWidget(self.output_label, 4, 0, 1, 1) + self.layout.addLayout(self.hlayout3, 4, 1, 1, 3) + self.layout.addWidget(self.source_label, 5, 0, 1, 1) + self.layout.addWidget(self.source_input, 5, 1, 1, 3) + self.layout.addWidget(self.comment_label, 6, 0, 1, 1) + self.layout.addWidget(self.comment_input, 6, 1, 1, 3) self.layout.addWidget(self.announce_label, 7, 0, 1, 1) self.layout.addWidget(self.announce_input, 7, 1, 1, 3) self.layout.addWidget(self.submit_button, 8, 0, 1, 4) - + for i in range(1, self.layout.columnCount()): + self.layout.setColumnStretch(i, 1) self.layout.setObjectName("createWidget_formLayout") self.hlayout2.setObjectName("createWidget_hlayout2") self.submit_button.setObjectName("createWidget_submit_button") @@ -261,9 +267,10 @@ def browse(self, path=None): caption = "Choose File" if not path: path = QFileDialog.getOpenFileName(parent=self, caption=caption) - if not path: - return - path = os.path.realpath(path) + if not isinstance(path, str): + path = os.path.normpath(path[0]) + else: + path = os.path.normpath(path) self.window.path_input.clear() self.window.path_input.insert(path) self.window.output_input.clear() @@ -314,7 +321,10 @@ def browse(self, path=None): outfile = os.path.splitext(os.path.split(str(path))[-1])[0] + ".torrent" outpath = os.path.realpath(os.path.join(outdir, outfile)) self.window.output_input.insert(outpath) - _, size, piece_length = path_stat(path) + try: + _, size, piece_length = path_stat(path) + except PermissionError: + return if piece_length < (2 ** 20): val = f"{piece_length//(2**10)}KB" else: @@ -346,3 +356,36 @@ class CheckBox(QCheckBox): def __init__(self, label, parent=None): super().__init__(label, parent=parent) self.setStyleSheet(checkBoxSheet) + +class PlainTextEdit(QPlainTextEdit): + def __init__(self, parent=None): + super().__init__(parent=parent) + self._parent = parent + self.setBackgroundVisible(True) + self.setStyleSheet(textEditSheet) + + def callback(self, msg): + self.insertPlainText(msg) + self.insertPlainText("\n\n") + + + +class Label(QLabel): + """Label Identifier for Window Widgets. + + Subclass: QLabel + """ + + def __init__(self, text, parent=None): + super().__init__(text, parent=parent) + self.setStyleSheet(labelSheet) + font = self.font() + font.setBold(True) + font.setPointSize(12) + self.setFont(font) + +class LineEdit(QLineEdit): + def __init__(self, parent=None): + super().__init__(parent=parent) + self._parent = parent + self.setStyleSheet(createLineEditSheet) diff --git a/torrentfileQt/infoTab.py b/torrentfileQt/infoTab.py index f9e126a..dc99aaf 100644 --- a/torrentfileQt/infoTab.py +++ b/torrentfileQt/infoTab.py @@ -31,11 +31,12 @@ QPushButton, QTreeWidgetItem, QWidget, + QLineEdit, + QLabel, ) -from torrentfileQt.qss import pushButtonSheet +from torrentfileQt.qss import pushButtonSheet, infoLineEditSheet, labelSheet from torrentfileQt.treewidget import TreeWidget -from torrentfileQt.widgets import InfoLineEdit, Label class InfoWidget(QWidget): @@ -251,3 +252,28 @@ def parse_filetree(filetree): for k, v in out.items(): paths[os.path.join(key, k)] = v return paths + +class Label(QLabel): + """Label Identifier for Window Widgets. + + Subclass: QLabel + """ + + def __init__(self, text, parent=None): + super().__init__(text, parent=parent) + self.setStyleSheet(labelSheet) + font = self.font() + font.setBold(True) + font.setPointSize(12) + self.setFont(font) + + +class InfoLineEdit(QLineEdit): + def __init__(self, parent=None): + super().__init__(parent=parent) + self.setReadOnly(True) + self.setStyleSheet(infoLineEditSheet) + self.setDragEnabled(True) + font = self.font() + font.setBold(True) + self.setFont(font) diff --git a/torrentfileQt/menu.py b/torrentfileQt/menu.py index 73c8914..2053ae2 100644 --- a/torrentfileQt/menu.py +++ b/torrentfileQt/menu.py @@ -74,7 +74,7 @@ def repository(self): webbrowser.open_new_tab("https://github.com/alexpdev/torrentfileQt") def about_qt(self): - self.window.app.aboutQt() + self.window.app.aboutQt() # pragma: nocover def exit_app(self): - self.parent().app.quit() + self.parent().app.quit() # pragma: nocover diff --git a/torrentfileQt/qss.py b/torrentfileQt/qss.py index 2933537..71fcbae 100644 --- a/torrentfileQt/qss.py +++ b/torrentfileQt/qss.py @@ -178,63 +178,36 @@ QPushButton{ margin-top: 3px; margin-bottom: 3px; - border-style: solid; - border-top-color: transparent; - border-right-color: transparent; - border-left-color: transparent; + margin-left: 8px; + margin-right: 8px; + border-style: outset; + border-top-color: #e18133; + border-right-color: #e67f2f; + border-left-color: #e67f2f; border-bottom-color: #e67e22; - border-width: 1px; - border-radius: 4px; - padding: 2px; - font: 14pt bold; - color: #dedede; - background-color: #111; - } - QPushButton::default{ - border-style: solid; - border-top-color: transparent; - border-right-color: transparent; - border-left-color: transparent; - border-bottom-color: #e67e22; - border-radius: 4px; - border-width: 1px; - padding: 2px; + border-radius: 8px; + border-width: 3px; + padding-top: 4px; + padding-bottom: 4px; font: 14pt bold; color: #dedede; background-color: #111; } QPushButton:hover{ - border-style: solid; - border-top-color: transparent; - border-right-color: #e67e22; - border-left-color: #e67e22; - border-bottom-color: #e67e22; - border-width: 2px; - border-radius: 3px; + border-style: inset; + border-width: 3px; color: #efefefef; - padding: 2px; - background-color: #444; + background-color: #200; } QPushButton:pressed{ - border-style: solid; - border-top-color: #e67e22; - border-right-color: #e67e22; - border-left-color: #e67e22; - border-bottom-color: #e67e22; - border-radius: 2px; - border-bottom-width: 2px; - padding: 1px; + border-style: inset; + border-bottom-width: 3px; color: #ffffff; - - background-color: #444; + background-color: #112; } QPushButton:disabled{ border-style: solid; - border-top-color: transparent; - border-right-color: transparent; - border-left-color: transparent; - border-bottom-color: transparent; - border-bottom-width: 2px; + border-bottom-width: 1px; border-style: solid; color: #bbb; padding-bottom: 1px; @@ -244,7 +217,7 @@ push2ButtonSheet = """ QPushButton { - border-style: solid; + border-style: outset; border-top-color: #e67e22; border-right-color: #e67e22; border-left-color: #e67e22; @@ -256,7 +229,7 @@ background-color: #444; } QPushButton:hover{ - border-style: solid; + border-style: outset; border-top-color: transparent; border-right-color: transparent; border-left-color: transparent; @@ -426,7 +399,27 @@ } """ -altLineEditSheet = """ + +createLineEditSheet = """ + QLineEdit { + border-color: #1a1a1a; + font: 12pt; + border-width: 1px; + border-radius: 4px; + border-style: inset; + padding: 0 8px; + color: #FFFFFF; + background: #646464; + selection-background-color: #411; + selection-color: #0ff; + } + QLineEdit::disabled { + background-color: #444; + color: #ddd; + } + """ + +infoLineEditSheet = """ QLineEdit { border-color: #3a3a3a; border-bottom-width: 2px; @@ -449,6 +442,7 @@ QComboBox { color: #FFF; background: #3a3a3a; + font-size: 10pt; } QComboBox:editable { background: #1e1d23; @@ -486,7 +480,7 @@ background-color: #646464; border: #1a1a1a 2px solid; color: #fff; - font: 7pt; + font: 10pt; border-radius: 4px; } """ diff --git a/torrentfileQt/treewidget.py b/torrentfileQt/treewidget.py index eb5b115..824d79f 100644 --- a/torrentfileQt/treewidget.py +++ b/torrentfileQt/treewidget.py @@ -29,7 +29,7 @@ def apply_value(self, tree): for item in self.apply_value(value): yield item elif isinstance(value, dict): - item = TreeItem(self, 0) + item = TreeItem(type=0) item.setText(0, key) for child in self.apply_value(value): item.addChild(child) diff --git a/torrentfileQt/widgets.py b/torrentfileQt/widgets.py deleted file mode 100644 index 5b3e6a4..0000000 --- a/torrentfileQt/widgets.py +++ /dev/null @@ -1,67 +0,0 @@ -#! /usr/bin/python3 -# -*- coding: utf-8 -*- - -############################################################################## -# Copyright 2020 AlexPDev -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -############################################################################## - -from PyQt6.QtWidgets import QLabel, QLineEdit, QPlainTextEdit - -from .qss import altLineEditSheet, labelSheet, lineEditSheet, textEditSheet - - -class LineEdit(QLineEdit): - def __init__(self, parent=None): - super().__init__(parent=parent) - self._parent = parent - self.setStyleSheet(lineEditSheet) - - -class Label(QLabel): - """Label Identifier for Window Widgets. - - Subclass: QLabel - """ - - def __init__(self, text, parent=None): - super().__init__(text, parent=parent) - self.setStyleSheet(labelSheet) - font = self.font() - font.setBold(True) - font.setPointSize(12) - self.setFont(font) - - -class InfoLineEdit(QLineEdit): - def __init__(self, parent=None): - super().__init__(parent=parent) - self.setReadOnly(True) - self.setStyleSheet(altLineEditSheet) - self.setDragEnabled(True) - font = self.font() - font.setBold(True) - self.setFont(font) - - -class PlainTextEdit(QPlainTextEdit): - def __init__(self, parent=None): - super().__init__(parent=parent) - self._parent = parent - self.setBackgroundVisible(True) - self.setStyleSheet(textEditSheet) - - def callback(self, msg): - self.insertPlainText(msg) - self.insertPlainText("\n\n") diff --git a/torrentfileQt/window.py b/torrentfileQt/window.py index 0593a37..15d6b5c 100644 --- a/torrentfileQt/window.py +++ b/torrentfileQt/window.py @@ -57,14 +57,14 @@ def __init__(self, parent=None, app=None): self.app = app self.menubar = MenuBar(parent=self) self.statusbar = QStatusBar(parent=self) - self.icon = QIcon("./assets/torrent-icon.png") + self.icon = QIcon("./assets/favicon.png") self.setObjectName("Mainwindow") self.setWindowTitle("Torrentfile Tools") self.setWindowIcon(self.icon) self.setMenuBar(self.menubar) self.setStatusBar(self.statusbar) self.setStyleSheet(mainWindowSheet) - self.resize(600, 700) + self.resize(800, 600) self._setupUI() def _setupUI(self):