Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUILD-975] Add config button #1077

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ankihub/gui/js_message_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from ..db import ankihub_db
from ..settings import url_view_note
from .config_dialog import get_config_dialog_manager
from .operations.scheduling import suspend_notes, unsuspend_notes

VIEW_NOTE_PYCMD = "ankihub_view_note"
Expand All @@ -28,6 +29,7 @@
GET_NOTE_SUSPENSION_STATES_PYCMD = "ankihub_get_note_suspension_states"
COPY_TO_CLIPBOARD_PYCMD = "ankihub_copy_to_clipboard"
OPEN_LINK_PYCMD = "ankihub_open_link"
OPEN_CONFIG_PYCMD = "ankihub_open_config"

POST_MESSAGE_TO_ANKIHUB_JS_PATH = (
Path(__file__).parent / "web/post_message_to_ankihub_js.js"
Expand Down Expand Up @@ -107,6 +109,9 @@ def _on_js_message(handled: Tuple[bool, Any], message: str, context: Any) -> Any
openLink(url)

return (True, None)
elif message == OPEN_CONFIG_PYCMD:
get_config_dialog_manager().open_config()
return (True, None)

return handled

Expand Down
9 changes: 9 additions & 0 deletions ankihub/gui/web/sidebar_tabs.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@
d="M15.75 2.25L21 2.25C21.1989 2.25 21.3897 2.32902 21.5303 2.46967C21.671 2.61032 21.75 2.80109 21.75 3V8.25C21.75 8.66421 21.4142 9 21 9C20.5858 9 20.25 8.66421 20.25 8.25V4.81066L8.03033 17.0303C7.73744 17.3232 7.26256 17.3232 6.96967 17.0303C6.67678 16.7374 6.67678 16.2626 6.96967 15.9697L19.1893 3.75L15.75 3.75C15.3358 3.75 15 3.41421 15 3C15 2.58579 15.3358 2.25 15.75 2.25ZM5.25 6.75C4.42157 6.75 3.75 7.42157 3.75 8.25V18.75C3.75 19.5784 4.42157 20.25 5.25 20.25H15.75C16.5784 20.25 17.25 19.5784 17.25 18.75V10.5C17.25 10.0858 17.5858 9.75 18 9.75C18.4142 9.75 18.75 10.0858 18.75 10.5V18.75C18.75 20.4069 17.4069 21.75 15.75 21.75H5.25C3.59315 21.75 2.25 20.4069 2.25 18.75V8.25C2.25 6.59315 3.59315 5.25 5.25 5.25H13.5C13.9142 5.25 14.25 5.58579 14.25 6C14.25 6.41421 13.9142 6.75 13.5 6.75H5.25Z" />
</svg>
</button>
<button id="open-config-button" onclick="pycmd('ankihub_open_config')">
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd"
d="M6.27176 1.44389C6.34655 1.06995 6.67488 0.800781 7.05623 0.800781H8.94454C9.32589 0.800781 9.65422 1.06995 9.72901 1.44389L9.99339 2.76581C10.5568 2.98045 11.0767 3.28344 11.536 3.65784L12.8147 3.2253C13.1759 3.1031 13.5732 3.25286 13.7639 3.58311L14.708 5.21844C14.8987 5.54869 14.8297 5.96762 14.5433 6.21936L13.5299 7.10994C13.5763 7.40006 13.6004 7.6976 13.6004 8.00078C13.6004 8.30395 13.5763 8.6015 13.5299 8.89161L14.5433 9.78219C14.8297 10.0339 14.8987 10.4529 14.708 10.7831L13.7639 12.4184C13.5732 12.7487 13.1759 12.8985 12.8147 12.7763L11.5361 12.3437C11.0767 12.7181 10.5568 13.0211 9.99339 13.2357L9.72901 14.5577C9.65422 14.9316 9.32589 15.2008 8.94454 15.2008H7.05623C6.67488 15.2008 6.34655 14.9316 6.27176 14.5577L6.00738 13.2357C5.44393 13.0211 4.92407 12.7181 4.46473 12.3437L3.1861 12.7763C2.82486 12.8985 2.42759 12.7487 2.23692 12.4185L1.29276 10.7831C1.10209 10.4529 1.17103 10.0339 1.45748 9.7822L2.47085 8.89162C2.42448 8.60151 2.40039 8.30396 2.40039 8.00078C2.40039 7.69761 2.42448 7.40006 2.47085 7.10995L1.45748 6.21937C1.17103 5.96763 1.10209 5.54871 1.29276 5.21845L2.23692 3.58312C2.42759 3.25287 2.82486 3.10311 3.1861 3.22531L4.46472 3.65785C4.92406 3.28344 5.44392 2.98045 6.00738 2.76581L6.27176 1.44389ZM8.00039 10.4008C9.32587 10.4008 10.4004 9.32626 10.4004 8.00078C10.4004 6.6753 9.32587 5.60078 8.00039 5.60078C6.6749 5.60078 5.60039 6.6753 5.60039 8.00078C5.60039 9.32626 6.6749 10.4008 8.00039 10.4008Z" />
</svg>
</button>
<button onclick="pycmd('ankihub_close_sidebar')">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd"
Expand Down Expand Up @@ -199,6 +205,9 @@
(function () {
const openInBrowserButton = document.querySelector('#open-in-browser-button');
addTooltip(openInBrowserButton, "Open in browser");

const openConfigButton = document.querySelector('#open-config-button');
addTooltip(openConfigButton, "Configuration");
})();
</script>

Expand Down
Loading