src: add doc for getting a token
This commit is contained in:
parent
25b84864db
commit
88e979e566
34
src/main.py
34
src/main.py
@ -41,6 +41,16 @@ import re
|
||||
import unicodedata
|
||||
from time import gmtime, strftime
|
||||
|
||||
class ProvidersEnum(Enum):
|
||||
STABLE_DIFFUSION = 0
|
||||
OPENAI = 1
|
||||
WAIFU_DIFFUSION = 2
|
||||
OPENJOURNEY = 3
|
||||
NITRO_DIFFUSION = 4
|
||||
ANALOG_DIFFUSION = 5
|
||||
PORTRAIT_PLUS = 6
|
||||
ANYTHING = 7
|
||||
|
||||
|
||||
class ImaginerApplication(Adw.Application):
|
||||
"""The main application singleton class."""
|
||||
@ -57,6 +67,7 @@ class ImaginerApplication(Adw.Application):
|
||||
self.create_action("imagine", self.on_imagine_action, ["<primary>Return"])
|
||||
self.create_action("choose_output", self.on_file_chooser, ["<primary>s"])
|
||||
self.create_action("new_window", self.on_new_window_action, ["<primary>n"])
|
||||
self.create_action("open_doc", self.on_open_doc_action)
|
||||
|
||||
def on_quit_action(self, action, _):
|
||||
"""Callback for the app.quit action."""
|
||||
@ -93,6 +104,19 @@ class ImaginerApplication(Adw.Application):
|
||||
response = requests.post(url, headers=headers, json=payload)
|
||||
return response.content
|
||||
|
||||
def on_open_doc_action(self, action, _):
|
||||
"""Callback for the app.open_doc action."""
|
||||
url = "https://imaginer.codeberg.page/help/"
|
||||
|
||||
provider = self.win.provider.props.selected
|
||||
|
||||
if provider == ProvidersEnum.OPENAI.value:
|
||||
url += "openai.html"
|
||||
else:
|
||||
url += "huggingface.html"
|
||||
|
||||
GLib.spawn_command_line_async(f"xdg-open {url}")
|
||||
|
||||
def on_file_chooser(self, widget, _):
|
||||
"""Callback for the app.choose_output action."""
|
||||
self.file_chooser.show()
|
||||
@ -153,16 +177,6 @@ class ImaginerApplication(Adw.Application):
|
||||
|
||||
self.provider = self.win.provider.props.selected
|
||||
|
||||
class ProvidersEnum(Enum):
|
||||
STABLE_DIFFUSION = 0
|
||||
OPENAI = 1
|
||||
WAIFU_DIFFUSION = 2
|
||||
OPENJOURNEY = 3
|
||||
NITRO_DIFFUSION = 4
|
||||
ANALOG_DIFFUSION = 5
|
||||
PORTRAIT_PLUS = 6
|
||||
ANYTHING = 7
|
||||
|
||||
prompt = self.win.prompt.get_text()
|
||||
negative_prompt = self.win.negative_prompt.get_text()
|
||||
self.token = self.win.token.get_text()
|
||||
|
@ -86,6 +86,18 @@ template ImaginerWindow : Adw.ApplicationWindow {
|
||||
|
||||
Adw.PasswordEntryRow token {
|
||||
title: _("API Token");
|
||||
|
||||
[suffix]
|
||||
MenuButton menu_duplicate {
|
||||
valign: center;
|
||||
tooltip-text: _("How to get a token");
|
||||
icon-name: "info-symbolic";
|
||||
popover: popover_info_token;
|
||||
|
||||
styles [
|
||||
"flat",
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -150,3 +162,13 @@ menu main_menu {
|
||||
Gtk.StringList provider_model{
|
||||
strings [_("Stable Diffusion"), _("OpenAI"), _("Waifu Diffusion"), _("Open Journey"), _("Nitro Diffusion"), _("Analog Diffusion"), _("Portrait Plus"), _("Anything")]
|
||||
}
|
||||
|
||||
Popover popover_info_token {
|
||||
Button {
|
||||
label: _("Open the documentation to see how to get a token");
|
||||
action-name: "app.open_doc";
|
||||
styles [
|
||||
"flat",
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user