Skip to content

Commit

Permalink
Merge pull request #19 from alexpdev/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
alexpdev authored Nov 7, 2021
2 parents e74fff0 + 13b773d commit be28ac9
Show file tree
Hide file tree
Showing 19 changed files with 505 additions and 473 deletions.
Binary file removed assets/CheckTabScreenShot.png
Binary file not shown.
Binary file removed assets/CreateTabScreenShot.png
Binary file not shown.
Binary file removed assets/InfoTabScreenShot.png
Binary file not shown.
Binary file added assets/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/torrent-icon.png
Binary file not shown.
Binary file added assets/torrentfile.ico
Binary file not shown.
Binary file removed assets/torrentfile.png
Binary file not shown.
Binary file removed assets/transparent.png
Binary file not shown.
644 changes: 330 additions & 314 deletions coverage.xml

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion tests/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import shutil
import string
import atexit
import time


TESTS = os.path.dirname(os.path.abspath(__file__))
Expand Down Expand Up @@ -106,4 +107,8 @@ def tstdir():

@atexit.register
def teardown():
rmpath(TESTDIR)
try:
rmpath(TESTDIR)
except PermissionError:
time.sleep(1.5)
teardown()
9 changes: 0 additions & 9 deletions tests/test_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import os
import pytest
from pathlib import Path

from PyQt6.QtWidgets import QApplication, QMainWindow, QStatusBar

Expand Down Expand Up @@ -94,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

Expand Down
34 changes: 29 additions & 5 deletions torrentfileQt/checkTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -122,12 +123,13 @@ 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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -328,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)
Expand Down Expand Up @@ -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)
87 changes: 65 additions & 22 deletions torrentfileQt/createTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import os
import threading
from collections.abc import Sequence

from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import (
Expand All @@ -33,18 +34,23 @@
QSpacerItem,
QToolButton,
QWidget,
QPlainTextEdit,
QLabel,
QLineEdit
)
from torrentfile import TorrentFile, TorrentFileHybrid, TorrentFileV2
from torrentfile.utils import path_stat

from torrentfileQt.qss import (
checkBoxSheet,
comboBoxSheet,
labelSheet,
push2ButtonSheet,
pushButtonSheet,
toolButtonSheet,
textEditSheet,
createLineEditSheet
)
from torrentfileQt.widgets import Label, LineEdit, PlainTextEdit


class CreateWidget(QWidget):
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
30 changes: 28 additions & 2 deletions torrentfileQt/infoTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
4 changes: 2 additions & 2 deletions torrentfileQt/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading

0 comments on commit be28ac9

Please sign in to comment.