Skip to content

Commit

Permalink
fix menu and actions as per project settings
Browse files Browse the repository at this point in the history
  • Loading branch information
seowings committed Dec 22, 2023
1 parent ae2cc80 commit 0e9518c
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 79 deletions.
53 changes: 30 additions & 23 deletions src/staticwordpress/gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@
get_remote_content,
extract_urls_from_raw_text,
)
from .workflow import SWWorkflowObject
from .logger import SWLoggerWidget
from .editor import SWIPythonWidget
from .rawtext import SWRawTextDialog
from .config import SWConfigDialog
from .project import SWProjectDialog
from .utils import GUI_SETTINGS, logging_decorator
from ..gui.workflow import SWWorkflowObject
from ..gui.logger import SWLoggerWidget
from ..gui.editor import SWIPythonWidget
from ..gui.rawtext import SWRawTextDialog
from ..gui.config import SWConfigDialog
from ..gui.project import SWProjectDialog
from ..gui.utils import GUI_SETTINGS, logging_decorator


# +++++++++++++++++++++++++++++++++++++++++++++++++++++
# IMPLEMENATIONS
Expand Down Expand Up @@ -299,11 +300,11 @@ def closeEvent(self, event):

def set_expert_mode(self):
expert_widgets = [
"action_wordpress_404_page",
"action_wordpress_redirects",
"action_wordpress_robots_txt",
"action_wordpress_search_index",
"action_wordpress_webpages",
"action_wordpress_create_404_page",
"action_wordpress_create_redirects",
"action_wordpress_create_robots_txt",
"action_wordpress_create_search_index",
"action_wordpress_crawl_webpages",
]

for widget_name in expert_widgets:
Expand All @@ -330,7 +331,7 @@ def help(self):

def start_ipython_console(self):
""" """
if self.findChild(QAction, "action_ipython_widget").isChecked():
if self.findChild(QAction, "action_start_ipython_console").isChecked():
if self.ipython_console is None:
self.ipython_console = SWIPythonWidget(interface_={"iface": self})
self.dockwidget_ipython.setWidget(self.ipython_console)
Expand Down Expand Up @@ -443,7 +444,7 @@ def open_project(self):
# self._project.save()

@logging_decorator
def show_project(self):
def show_project_settings(self):
"""showing static-wordpress Project File"""
if self._project.is_open():
project_dialog = SWProjectDialog(
Expand Down Expand Up @@ -592,7 +593,7 @@ def stop_process(self) -> None:
self.update_statusbar("Stoping Processing", 100)

@is_project_open
def crawl_website(self) -> None:
def crawl_webpages(self) -> None:
if self._bg_thread.isRunning():
self._bg_thread.quit()

Expand Down Expand Up @@ -788,6 +789,10 @@ def update_widgets(self) -> None:
self._project.is_open()
and (self._project.has_wordpress() or self._project.can_crawl())
)
self.findChild(QMenu, "menu_tools").setEnabled(
self._project.is_open()
and (self._project.has_wordpress() or self._project.can_crawl())
)

# Show Toolbarss
self.findChild(QToolBar, "toolbar_github").setEnabled(
Expand All @@ -799,22 +804,24 @@ def update_widgets(self) -> None:

# Show Menubar Icons
if self._project.src_type == SOURCE.ZIP:
self.findChild(QAction, "action_wordpress_webpages").setText(
self.findChild(QAction, "action_wordpress_crawl_webpages").setText(
"&Download Zip File"
)
self.findChild(QAction, "action_wordpress_additional_files").setVisible(
False
)
self.findChild(
QAction, "action_wordpress_crawl_additional_files"
).setVisible(False)
else:
self.findChild(QAction, "action_wordpress_webpages").setText(
self.findChild(QAction, "action_wordpress_crawl_webpages").setText(
"&Crawl Webpages"
)
self.findChild(QAction, "action_wordpress_additional_files").setVisible(
self.findChild(QAction, "action_edit_expert_mode").isChecked()
self.findChild(
QAction, "action_wordpress_crawl_additional_files"
).setVisible(
self.findChild(QAction, "action_edit_set_expert_mode").isChecked()
)

for project_tool in [
"action_utilities_clean_output_folder",
"action_tools_clean_output_folder",
]:
self.findChild(QAction, project_tool).setVisible(self._project.is_open())

Expand Down
4 changes: 2 additions & 2 deletions src/staticwordpress/gui/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@
from ..core.constants import (
REDIRECTS,
USER_AGENT,
CONFIGS,
SHARE_FOLDER_PATH,
SOURCE,
HOST,
CONFIGS,
SHARE_FOLDER_PATH,
)

from ..core.project import Project
Expand Down
108 changes: 54 additions & 54 deletions src/staticwordpress/share/gui.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
{
"name": "menu_tools",
"text": "&Tools",
"enable": true,
"enable": false,
"icon": "",
"parent": ""
},
Expand Down Expand Up @@ -75,7 +75,7 @@
"ACTIONS": [
{
"icon": "/icons/file-outline.svg",
"name": "action_project_new",
"name": "action_project_new_project",
"visible": true,
"text": "&New",
"shortcut": "Ctrl+N",
Expand All @@ -88,7 +88,7 @@
},
{
"icon": "/icons/folder-outline.svg",
"name": "action_project_open",
"name": "action_project_open_project",
"visible": true,
"text": "&Open",
"shortcut": "Ctrl+O",
Expand All @@ -101,20 +101,20 @@
},
{
"icon": "/icons/project_settings.svg",
"name": "action_project_settings",
"name": "action_project_show_project_settings",
"visible": true,
"text": "&Settings",
"shortcut": "Ctrl+C",
"tooltip": "Check (Ctrl+C)",
"function": "self.show_project",
"function": "self.show_project_settings",
"setCheckable": false,
"menu": "menu_project",
"seperator": false,
"toolbar": "toolbar_project"
},
{
"icon": "/icons/project_close.svg",
"name": "action_project_close",
"name": "action_project_close_project",
"visible": true,
"text": "&Close",
"shortcut": "Ctrl+X",
Expand All @@ -127,7 +127,7 @@
},
{
"icon": "/icons/exit-to-app.svg",
"name": "action_project_exit",
"name": "action_project_close",
"visible": true,
"text": "&Exit",
"shortcut": "Ctrl+Q",
Expand All @@ -153,7 +153,7 @@
},
{
"icon": "/icons/python.svg",
"name": "action_ipython_widget",
"name": "action_start_ipython_console",
"visible": true,
"text": "&IPython",
"shortcut": "F4",
Expand All @@ -166,7 +166,7 @@
},
{
"icon": "/icons/bug-outline.svg",
"name": "action_edit_debug",
"name": "action_edit_set_debug_mode",
"visible": true,
"text": "&Debug",
"shortcut": "F5",
Expand All @@ -179,7 +179,7 @@
},
{
"icon": "/icons/person.svg",
"name": "action_edit_expert_mode",
"name": "action_edit_set_expert_mode",
"visible": true,
"text": "&Expert Mode",
"shortcut": "F10",
Expand All @@ -192,7 +192,7 @@
},
{
"icon": "/icons/configs.svg",
"name": "action_file_project_close",
"name": "action_project_show_configs",
"visible": true,
"text": "&Configurations",
"shortcut": "F12",
Expand All @@ -203,48 +203,22 @@
"seperator": false,
"toolbar": "toolbar_edit"
},
{
"icon": "/icons/play.svg",
"name": "action_wordpress_batch_processing",
"visible": true,
"text": "Start &Batch Process",
"shortcut": "Ctrl+F6",
"tooltip": "Start Batch Process (Ctrl+F6)",
"function": "self.start_batch_process",
"setCheckable": false,
"menu": "menu_wordpress",
"seperator": false,
"toolbar": "toolbar_wordpres"
},
{
"icon": "/icons/stop.svg",
"name": "action_wordpress_stop_processing",
"visible": true,
"text": "&Stop Process",
"shortcut": "Ctrl+F7",
"tooltip": "Stop Current Process (Ctrl+F7)",
"seperator": false,
"function": "self.stop_process",
"setCheckable": false,
"menu": "menu_wordpress",
"toolbar": "toolbar_wordpres"
},
{
"icon": "/icons/crawl_website.svg",
"name": "action_wordpress_webpages",
"name": "action_wordpress_crawl_webpages",
"visible": false,
"text": "&Crawl Webpages",
"shortcut": "Ctrl+1 (Ctrl+1)",
"tooltip": "Crawl Webpages",
"text": "&Crawl WebPages",
"shortcut": "Ctrl+1",
"tooltip": "Crawl WebPages (Ctrl+1)",
"seperator": false,
"function": "self.crawl_website",
"function": "self.crawl_webpages",
"setCheckable": false,
"menu": "menu_wordpress",
"toolbar": ""
},
{
"icon": "/icons/additionals.svg",
"name": "action_wordpress_additional_files",
"name": "action_wordpress_crawl_additional_files",
"visible": false,
"text": "Crawl &Additional Files",
"shortcut": "Ctrl+2",
Expand All @@ -257,7 +231,7 @@
},
{
"icon": "/icons/search.svg",
"name": "action_wordpress_search_index",
"name": "action_wordpress_create_search_index",
"visible": false,
"text": "Prepare &Search Index",
"shortcut": "Ctrl+3",
Expand All @@ -270,7 +244,7 @@
},
{
"icon": "/icons/error.svg",
"name": "action_wordpress_404_page",
"name": "action_wordpress_create_404_page",
"visible": false,
"text": "Create &404 Page",
"shortcut": "Ctrl+4",
Expand All @@ -283,7 +257,7 @@
},
{
"icon": "/icons/redirects.svg",
"name": "action_wordpress_redirects",
"name": "action_wordpress_create_redirects",
"visible": false,
"text": "Create &Redirects",
"shortcut": "Ctrl+5",
Expand All @@ -296,20 +270,46 @@
},
{
"icon": "/icons/robots_txt.svg",
"name": "action_wordpress_robots_txt",
"name": "action_wordpress_create_robots_txt",
"visible": false,
"text": "Create Robots.&txt",
"shortcut": "Ctrl+6",
"tooltip": "Copy Robots.txt File (Ctrl+6)",
"seperator": false,
"tooltip": "Create Robots.txt File (Ctrl+6)",
"seperator": true,
"function": "self.create_robots_txt",
"setCheckable": false,
"menu": "menu_wordpress",
"toolbar": ""
},
{
"icon": "/icons/play.svg",
"name": "action_wordpress_start_batch_process",
"visible": true,
"text": "Start &Batch Process",
"shortcut": "Ctrl+F6",
"tooltip": "Start Batch Process (Ctrl+F6)",
"function": "self.start_batch_process",
"setCheckable": false,
"menu": "menu_wordpress",
"seperator": false,
"toolbar": "toolbar_wordpres"
},
{
"icon": "/icons/stop.svg",
"name": "action_wordpress_stop_process",
"visible": true,
"text": "&Stop Process",
"shortcut": "Ctrl+F7",
"tooltip": "Stop Current Process (Ctrl+F7)",
"seperator": false,
"function": "self.stop_process",
"setCheckable": false,
"menu": "menu_wordpress",
"toolbar": "toolbar_wordpres"
},
{
"icon": "/icons/pencil-outline.svg",
"name": "action_github_create_repositoy",
"name": "action_github_create_github_repositoy",
"visible": true,
"text": "&Create on GitHub",
"shortcut": "Ctrl+F9",
Expand All @@ -322,7 +322,7 @@
},
{
"icon": "/icons/delete-repo.svg",
"name": "action_github_delete_repositoy",
"name": "action_github_delete_github_repository",
"visible": true,
"text": "&Delete from GitHub",
"shortcut": "Ctrl+Shift+F9",
Expand Down Expand Up @@ -374,7 +374,7 @@
},
{
"icon": "/icons/web-remove.svg",
"name": "action_utilities_clear_crawl_cache",
"name": "action_tools_clear_crawl_cache",
"visible": true,
"text": "C&lear Crawl Cache",
"shortcut": "Ctrl+F2",
Expand All @@ -387,7 +387,7 @@
},
{
"icon": "/icons/text-recognition.svg",
"name": "action_utilities_extract_url_from_raw_text",
"name": "action_tools_extract_url_from_raw_text",
"visible": true,
"text": "&Extract Urls From Text",
"shortcut": "Ctrl+F4",
Expand All @@ -400,7 +400,7 @@
},
{
"icon": "/icons/delete-outline.svg",
"name": "action_utilities_clean_output_folder",
"name": "action_tools_clean_output_folder",
"visible": false,
"text": "Clean &Output Directory",
"shortcut": "Ctrl+F5",
Expand Down

0 comments on commit 0e9518c

Please sign in to comment.