diff --git a/assets/data/profiles.json b/assets/data/profiles.json new file mode 100644 index 0000000..e69de29 diff --git a/coverage.xml b/coverage.xml index 50e7021..a67a423 100644 --- a/coverage.xml +++ b/coverage.xml @@ -1,5 +1,5 @@ - + @@ -458,7 +458,7 @@ - + @@ -791,18 +791,21 @@ + + - + - + + @@ -810,13 +813,15 @@ - + - + + + @@ -825,8 +830,8 @@ - + @@ -837,7 +842,11 @@ - + + + + + @@ -868,36 +877,35 @@ - - - - - - - - + + + + + + + + - - - - + + - + - + - + + @@ -905,97 +913,92 @@ - - + - + - - - - + + + + + - + - - - - - + + + + - - + + + - + - - - - - + + + + + + - - - - - - + + + + + - + - - - - - + + + + + + - - - - + + - + - - + - - - - - + + + + + + + - + - - - - - @@ -1293,8 +1296,6 @@ - - @@ -1380,26 +1381,26 @@ - + + - - - + + + - - - + + + - @@ -1421,10 +1422,33 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/torrentfileQt/createTab.py b/torrentfileQt/createTab.py index 13d3508..b28143b 100644 --- a/torrentfileQt/createTab.py +++ b/torrentfileQt/createTab.py @@ -63,14 +63,12 @@ def __init__(self, parent=None): self.hlayout2 = QHBoxLayout() self.hlayout3 = QHBoxLayout() self.hlayout0 = QHBoxLayout() - # self.hlayout4 = QHBoxLayout() self.path_label = QLabel("Path: ", parent=self) self.output_label = QLabel("Save To: ", parent=self) self.version_label = QLabel("Meta Version: ", parent=self) self.comment_label = QLabel("Comment: ", parent=self) self.announce_label = QLabel("Tracker URLs: ", parent=self) - # self.profile_label = QLabel("Profile: ", parent=self) self.web_seed_label = QLabel("Web-seed URLs:") self.source_label = QLabel("Source: ", parent=self) self.piece_length_label = QLabel("Piece Size: ", parent=self) @@ -80,7 +78,6 @@ def __init__(self, parent=None): self.source_input = QLineEdit(parent=self) self.comment_input = QLineEdit(parent=self) - # self.profile_input = ComboBox.profiles(parent=self) self.announce_input = QPlainTextEdit(parent=self) self.web_seed_input = QPlainTextEdit(parent=self) self.piece_length = ComboBox.piece_length(parent=self) @@ -89,7 +86,6 @@ def __init__(self, parent=None): self.browse_dir_button = BrowseDirButton(parent=self) self.browse_file_button = BrowseFileButton(parent=self) self.output_button = OutButton(parent=self) - # self.profile_button = ProfileButton(parent=self) self.v1button = QRadioButton("v1 (default)", parent=self) self.v1button.setChecked(True) @@ -98,9 +94,11 @@ def __init__(self, parent=None): self.spacer1 = QSpacerItem(150, 0) self.spacer2 = QSpacerItem(70, 0) - # self.profile_label.setAlignment(Qt.AlignmentFlag.AlignRight) self.path_label.setAlignment(Qt.AlignmentFlag.AlignRight) self.path_input.setAlignment(Qt.AlignmentFlag.AlignLeft) + sizePolicy = self.path_input.sizePolicy() + sizePolicy.setHorizontalPolicy(sizePolicy.MinimumExpanding) + self.path_input.setSizePolicy(sizePolicy) self.output_label.setAlignment(Qt.AlignmentFlag.AlignRight) self.output_input.setAlignment(Qt.AlignmentFlag.AlignLeft) self.version_label.setAlignment(Qt.AlignmentFlag.AlignRight) @@ -110,6 +108,7 @@ def __init__(self, parent=None): self.comment_input.setAlignment(Qt.AlignmentFlag.AlignLeft) self.piece_length_label.setAlignment(Qt.AlignmentFlag.AlignRight) + self.hlayout1.addWidget(self.path_input) self.hlayout0.addWidget(self.v1button) self.hlayout0.addWidget(self.v2button) self.hlayout0.addWidget(self.hybridbutton) @@ -121,29 +120,24 @@ def __init__(self, parent=None): self.hlayout2.addItem(self.spacer2) self.hlayout3.addWidget(self.output_input) self.hlayout3.addWidget(self.output_button) - # self.hlayout4.addWidget(self.profile_input) - # self.hlayout4.addWidget(self.profile_button) - - # self.layout.addWidget(self.profile_label,0,0,1,1) - # self.layout.addLayout(self.hlayout4,0,1,1,1) - self.layout.addWidget(self.path_label, 1, 0, 2, 1) - self.layout.addWidget(self.path_input, 1, 1, 1, 3) - self.layout.addLayout(self.hlayout1, 2, 1, 1, 3) - self.layout.addWidget(self.version_label, 5, 0, 1, 1) - self.layout.addLayout(self.hlayout0, 5, 1, 1, 3) - self.layout.addWidget(self.piece_length_label, 4, 0, 1, 1) - self.layout.addLayout(self.hlayout2, 4, 1, 1, 3) - self.layout.addWidget(self.output_label, 3, 0, 1, 1) - self.layout.addLayout(self.hlayout3, 3, 1, 1, 3) - self.layout.addWidget(self.source_label, 9, 0, 1, 1) - self.layout.addWidget(self.source_input, 9, 1, 1, 3) - self.layout.addWidget(self.comment_label, 8, 0, 1, 1) - self.layout.addWidget(self.comment_input, 8, 1, 1, 3) - self.layout.addWidget(self.announce_label, 6, 0, 1, 1) - self.layout.addWidget(self.announce_input, 6, 1, 1, 3) - self.layout.addWidget(self.web_seed_label, 7, 0, 1, 1) - self.layout.addWidget(self.web_seed_input, 7, 1, 1, 3) - self.layout.addWidget(self.submit_button, 10, 0, 1, 4) + + self.layout.addWidget(self.path_label, 0, 0, 1, 1) + self.layout.addLayout(self.hlayout1, 0, 1, 1, 3) + self.layout.addWidget(self.output_label, 1, 0, 1, 1) + self.layout.addLayout(self.hlayout3, 1, 1, 1, 3) + self.layout.addWidget(self.source_label, 2, 0, 1, 1) + self.layout.addWidget(self.source_input, 2, 1, 1, 3) + self.layout.addWidget(self.comment_label, 3, 0, 1, 1) + self.layout.addWidget(self.comment_input, 3, 1, 1, 3) + self.layout.addWidget(self.announce_label, 4, 0, 1, 1) + self.layout.addWidget(self.announce_input, 4, 1, 1, 3) + self.layout.addWidget(self.web_seed_label, 5, 0, 1, 1) + self.layout.addWidget(self.web_seed_input, 5, 1, 1, 3) + self.layout.addWidget(self.piece_length_label, 6, 0, 1, 1) + self.layout.addWidget(self.version_label, 7, 0, 1, 1) + self.layout.addLayout(self.hlayout2, 6, 1, 1, 3) + self.layout.addLayout(self.hlayout0, 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") diff --git a/torrentfileQt/infoTab.py b/torrentfileQt/infoTab.py index f275d7a..87234c5 100644 --- a/torrentfileQt/infoTab.py +++ b/torrentfileQt/infoTab.py @@ -270,10 +270,10 @@ def selectTorrent(self, path=None): if path: meta = pyben.load(path) info = meta["info"] - keywords = {} - keywords["path"] = path - keywords["piece_length"] = info["piece length"] - + keywords = { + "path": path, + "piece_length": info["piece length"] + } # get meta version if "meta version" not in info: keywords["meta version"] = 1 diff --git a/torrentfileQt/menu.py b/torrentfileQt/menu.py index 371c7c1..99adcf5 100644 --- a/torrentfileQt/menu.py +++ b/torrentfileQt/menu.py @@ -18,6 +18,8 @@ ############################################################################## """Module for the menu bar.""" +import os +import json import webbrowser from PySide6.QtGui import QAction @@ -34,7 +36,7 @@ def __init__(self, text, parent=None): self.txt = text font = self.font() self.setObjectName(text + "MenuObject") - font.setPointSize(11) + font.setPointSize(10) self.setFont(font) @@ -47,25 +49,45 @@ def __init__(self, parent=None): self.window = parent self.file_menu = Menu("File") self.help_menu = Menu("Help") + self.profile_menu = Menu("Profiles") self.addMenu(self.file_menu) self.addMenu(self.help_menu) + self.addMenu(self.profile_menu) self.actionExit = QAction(self.window) self.actionAbout = QAction(self.window) self.actionDocs = QAction(self.window) self.actionRepo = QAction(self.window) + self.actionAddProfile = QAction(self.window) self.actionRepo.setText("Github Repository") self.actionExit.setText("Exit") self.actionAbout.setText("About") self.actionDocs.setText("Documentation") + self.actionAddProfile.setText("Add Profile") + self.home = os.path.join(os.path.expanduser("~"), ".torrentfileQt") + self.profile_actions = [] + if os.path.exists(self.home): + profiles_path = os.path.join(self.home, "profiles.json") + if os.path.exists(profiles_path): + with open(profiles_path, "rt") as jsonfile: + profiles = json.load(jsonfile) + for profile in profiles: + action = QAction(self.window) + action.setText(profile) + action.name = profile + self.profile_menu.addAction(action) + self.profile_actions.append(action) self.file_menu.addAction(self.actionExit) self.help_menu.addAction(self.actionAbout) self.help_menu.addAction(self.actionDocs) self.help_menu.addAction(self.actionRepo) + self.profile_menu.addAction(self.actionAddProfile) self.actionExit.triggered.connect(self.exit_app) self.actionAbout.triggered.connect(self.about_qt) self.actionDocs.triggered.connect(documentation) self.actionRepo.triggered.connect(repository) + self.actionAddProfile.triggered.connect(self.add_profile) self.actionDocs.setObjectName("actionDocs") + self.actionAddProfile.setObjectName("actionAddProfile") self.actionExit.setObjectName("actionExit") self.actionAbout.setObjectName("actionAbout") @@ -77,6 +99,9 @@ def exit_app(self): """Close application.""" self.parent().app.quit() # pragma: nocover + def add_profile(self): + """Add a profile.""" + def documentation(): # pragma: no cover """Open webbrowser to TorrentFileQt documentation."""