1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

Cfg: Add 'Gui - Shortcuts'

This commit is contained in:
gnosygnu
2016-12-24 10:35:22 -05:00
parent 1ffc4191a8
commit bc9633f87f
7 changed files with 223 additions and 21 deletions

View File

@@ -0,0 +1,46 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons.apps.cfgs.enums; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*;
import gplx.gfui.*; import gplx.xowa.guis.bnds.*;
public class Xoitm_gui_binding {
public static String[] To_gui(String val) {
Gfui_bnd_parser parser = Gfui_bnd_parser.new_en_();
String[] rv = new String[2];
int pipe_pos = String_.FindFwd(val, "|");
if (pipe_pos == -1) throw Err_.new_wo_type("cfg.binding:unknown gui binding; val=" + val);
rv[0] = Xog_bnd_box_.To_gui_str(String_.Mid(val, 0, pipe_pos));
rv[1] = parser.Xto_norm(String_.Mid(val, pipe_pos + 1, String_.Len(val)));
return rv;
}
public static String To_db_str(String val) {
Gfui_bnd_parser parser = Gfui_bnd_parser.new_en_();
String[] rv = new String[2];
int pipe_pos = String_.FindFwd(val, "|");
if (pipe_pos == -1) throw Err_.new_wo_type("cfg.binding:unknown gui binding; val=" + val);
rv[0] = Xog_bnd_box_.To_key_str(String_.Mid(val, 0, pipe_pos));
rv[1] = parser.Xto_gfui(String_.Mid(val, pipe_pos + 1, String_.Len(val)));
return rv[0] + "|" + rv[1];
}
public static String[] To_ary(String val) {
String[] rv = new String[2];
int pipe_pos = String_.FindFwd(val, "|");
rv[0] = String_.Mid(val, 0, pipe_pos);
rv[1] = String_.Mid(val, pipe_pos + 1, String_.Len(val));
return rv;
}
}

View File

@@ -34,7 +34,7 @@ public class Xoitm_gui_tid {
, Tid__io_file = 6
, Tid__io_dir = 7
, Tid__btn = 8
, Tid__label = 9
, Tid__gui_binding = 9
;
private static final Hash_adp to_uid_hash = Hash_adp_.New();
private static final Xoitm_gui_tid[] to_key_ary = new Xoitm_gui_tid[10];
@@ -48,7 +48,7 @@ public class Xoitm_gui_tid {
, Itm__io_file = New(Tid__io_file , "io.file")
, Itm__io_dir = New(Tid__io_dir , "io.dir")
, Itm__btn = New(Tid__btn , "btn")
, Itm__lbl = New(Tid__label , "label")
, Itm__gui_binding = New(Tid__gui_binding , "gui.binding")
;
private static Xoitm_gui_tid New(int uid, String key) {
Xoitm_gui_tid rv = new Xoitm_gui_tid(uid, key);
@@ -68,6 +68,7 @@ public class Xoitm_gui_tid {
else if (String_.Eq(db_type, "int")) return Itm__int.key;
else if (String_.Eq(db_type, "memo")) return Itm__memo.key;
else if (String_.Eq(db_type, "io.cmd")) return Itm__io_cmd.key;
else if (String_.Eq(db_type, "gui.binding")) return Itm__gui_binding.key;
else if (String_.Has_at_bgn(db_type, "list:")) return Itm__list.key;
else if (String_.Eq(db_type, "btn")) return Itm__btn.key;
else return Itm__str.key;

View File

@@ -61,13 +61,22 @@ public class Xoedit_itm_html {
case Xoitm_gui_tid.Tid__io_cmd:
String[] lines = Xocfg_mgr.Parse_io_cmd(val);
bfr.Add_str_u8_fmt
( "<input class=\"xocfg__io_cmd__exe__txt\" id=\"{2}-exe\" data-xocfg-key=\"{2}\" data-xocfg-gui=\"{0}-exe\" accesskey=\"d\" type=\"text\"{1} value=\"{3}\"></input>\n"
( "<input class=\"xocfg__io_cmd__exe__txt\" id=\"{2}-exe\" data-xocfg-key=\"{2}\" data-xocfg-gui=\"{0}-exe\" accesskey=\"d\" type=\"text\"{1} value=\"{3}\"></input>\n"
+ "<button class=\"xocfg__io_cmd__exe__btn\" onclick='xowa_io_select(\"file\", \"{2}-exe\", \"Please select a file.\");'>...</button><br/>\n"
, gui_type_key, gui_args, key, lines[0]);
bfr.Add_str_u8_fmt
( "<input class=\"xocfg__io_cmd__arg__txt\" id=\"{2}-arg\" data-xocfg-key=\"{2}\" data-xocfg-gui=\"{0}-arg\" accesskey=\"d\" type=\"text\"{1} value='{3}'>\n"
( "<input class=\"xocfg__io_cmd__arg__txt\" id=\"{2}-arg\" data-xocfg-key=\"{2}\" data-xocfg-gui=\"{0}-arg\" accesskey=\"d\" type=\"text\"{1} value=\"{3}\">\n"
, gui_type_key, gui_args, key, lines[1]);
break;
case Xoitm_gui_tid.Tid__gui_binding:
String[] flds = Xoitm_gui_binding.To_gui(val);
bfr.Add_str_u8_fmt
( "<input class=\"xocfg__gui_binding__box__txt\" id=\"{2}-box\" data-xocfg-key=\"{2}\" data-xocfg-gui=\"{0}-box\" accesskey=\"d\" type=\"text\"{1} value=\"{3}\"></input>\n"
, gui_type_key, gui_args, key, flds[0]);
bfr.Add_str_u8_fmt
( "<input class=\"xocfg__gui_binding__ipt__txt\" id=\"{2}-ipt\" data-xocfg-key=\"{2}\" data-xocfg-gui=\"{0}-ipt\" accesskey=\"d\" type=\"text\"{1} value=\"{3}\"'>\n"
, gui_type_key, gui_args, key, flds[1]);
break;
case Xoitm_gui_tid.Tid__btn:
bfr.Add_str_u8_fmt("<button id=\"{2}\" data-xocfg-key=\"{2}\" data-xocfg-gui=\"{0}\" class=\"xocfg__btn\" {1}>{3}</button>", gui_type_key, gui_args, key, name);
break;

View File

@@ -31,14 +31,22 @@ public class Xocfg_edit_svc {
String ctx = args.Get_as_str("ctx");
String key = args.Get_as_str("key");
String val = args.Get_as_str("val");
String gui = args.Get_as_str("gui");
if (String_.Has_at_bgn(gui, "gui.binding")) {
val = gplx.xowa.addons.apps.cfgs.enums.Xoitm_gui_binding.To_db_str(val);
}
app.Cfg().Set_str(ctx, key, val);
app.Gui__cbk_mgr().Send_json(cbk_trg, "xo.cfg_edit.upsert__recv", Gfobj_nde.New().Add_str("key", key));
}
public void Revert(Json_nde args) {
String ctx = args.Get_as_str("ctx");
String key = args.Get_as_str("key");
String gui = args.Get_as_str("gui");
app.Cfg().Del(ctx, key);
String val = app.Cfg().Get_str(ctx, key);
if (String_.Has_at_bgn(gui, "gui.binding")) {
val = String_.Concat_with_str("|", gplx.xowa.addons.apps.cfgs.enums.Xoitm_gui_binding.To_gui(val));
}
app.Gui__cbk_mgr().Send_json(cbk_trg, "xo.cfg_edit.revert__recv", Gfobj_nde.New().Add_str("key", key).Add_str("val", val));
}
public void Load(Json_nde args) {