Skip to content

Commit 9de63a2

Browse files
committed
Add modal for adding a URL entry
1 parent 88d0b47 commit 9de63a2

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

src/tagstudio/qt/ts_qt.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
from tagstudio.qt.utils.custom_runnable import CustomRunnable
9898
from tagstudio.qt.utils.file_deleter import delete_file
9999
from tagstudio.qt.utils.function_iterator import FunctionIterator
100+
from tagstudio.qt.views.add_url_entry_panel_view import AddUrlEntryPanel
100101
from tagstudio.qt.views.main_window import MainWindow
101102
from tagstudio.qt.views.panel_modal import PanelModal
102103
from tagstudio.qt.views.splash import SplashScreen
@@ -426,6 +427,10 @@ def set_open_last_loaded_on_startup(checked: bool):
426427
lambda: self.add_tag_action_callback()
427428
)
428429

430+
self.main_window.menu_bar.new_url_entry_action.triggered.connect(
431+
lambda: self.add_url_entry_action_callback()
432+
)
433+
429434
self.main_window.menu_bar.select_all_action.triggered.connect(
430435
self.select_all_action_callback
431436
)
@@ -775,6 +780,7 @@ def close_library(self, is_shutdown: bool = False):
775780
self.main_window.menu_bar.color_manager_action.setEnabled(False)
776781
self.main_window.menu_bar.ignore_modal_action.setEnabled(False)
777782
self.main_window.menu_bar.new_tag_action.setEnabled(False)
783+
self.main_window.menu_bar.new_url_entry_action.setEnabled(False)
778784
self.main_window.menu_bar.fix_unlinked_entries_action.setEnabled(False)
779785
self.main_window.menu_bar.fix_ignored_entries_action.setEnabled(False)
780786
self.main_window.menu_bar.fix_dupe_files_action.setEnabled(False)
@@ -846,6 +852,17 @@ def add_tag_action_callback(self):
846852
)
847853
self.modal.show()
848854

855+
def add_url_entry_action_callback(self):
856+
panel = AddUrlEntryPanel(self.lib)
857+
self.modal = PanelModal(
858+
panel,
859+
Translations["entry.new.url"],
860+
Translations["entry.add"],
861+
has_save=True,
862+
)
863+
864+
self.modal.show()
865+
849866
def select_all_action_callback(self):
850867
"""Set the selection to all visible items."""
851868
self.main_window.thumb_layout.select_all()
@@ -1650,6 +1667,7 @@ def _init_library(self, path: Path, open_status: LibraryStatus):
16501667
self.main_window.menu_bar.color_manager_action.setEnabled(True)
16511668
self.main_window.menu_bar.ignore_modal_action.setEnabled(True)
16521669
self.main_window.menu_bar.new_tag_action.setEnabled(True)
1670+
self.main_window.menu_bar.new_url_entry_action.setEnabled(True)
16531671
self.main_window.menu_bar.fix_unlinked_entries_action.setEnabled(True)
16541672
self.main_window.menu_bar.fix_ignored_entries_action.setEnabled(True)
16551673
self.main_window.menu_bar.fix_dupe_files_action.setEnabled(True)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from PySide6.QtCore import Qt
2+
from PySide6.QtWidgets import QLineEdit, QVBoxLayout
3+
4+
from tagstudio.qt.views.panel_modal import PanelWidget
5+
6+
7+
class AddUrlEntryPanel(PanelWidget):
8+
def __init__(self, text):
9+
super().__init__()
10+
11+
self.setMinimumWidth(480)
12+
self.root_layout = QVBoxLayout(self)
13+
self.root_layout.setContentsMargins(6, 0, 6, 0)
14+
self.root_layout.setAlignment(Qt.AlignmentFlag.AlignTop)
15+
16+
self.url_line = QLineEdit()
17+
self.root_layout.addWidget(self.url_line)

src/tagstudio/qt/views/main_window.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class MainMenuBar(QMenuBar):
6969

7070
edit_menu: QMenu
7171
new_tag_action: QAction
72+
new_url_entry_action: QAction
7273
select_all_action: QAction
7374
select_inverse_action: QAction
7475
clear_select_action: QAction
@@ -192,6 +193,14 @@ def setup_edit_menu(self):
192193

193194
self.edit_menu.addSeparator()
194195

196+
# New URL Entry
197+
self.new_url_entry_action = QAction(Translations["entry.new.url"], self)
198+
199+
self.new_url_entry_action.setEnabled(False)
200+
self.edit_menu.addAction(self.new_url_entry_action)
201+
202+
self.edit_menu.addSeparator()
203+
195204
# Select All
196205
self.select_all_action = QAction(Translations["select.all"], self)
197206
self.select_all_action.setShortcut(

src/tagstudio/resources/translations/en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@
6969
"entries.unlinked.search_and_relink": "&Search && Relink",
7070
"entries.unlinked.title": "Fix Unlinked Entries",
7171
"entries.unlinked.unlinked_count": "Unlinked Entries: {count}",
72+
"entry.add": "Add Entry",
73+
"entry.add.url": "Add URL Entry",
74+
"entry.new": "New Entry",
75+
"entry.new.url": "New URL Entry",
7276
"ffmpeg.missing.description": "FFmpeg and/or FFprobe were not found. FFmpeg is required for multimedia playback and thumbnails.",
7377
"ffmpeg.missing.status": "{ffmpeg}: {ffmpeg_status}<br>{ffprobe}: {ffprobe_status}",
7478
"field.copy": "Copy Field",

0 commit comments

Comments
 (0)