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

feat(WeaselDeployer): add Get Schemata button to run plum script #174

Merged
merged 7 commits into from
Apr 6, 2018
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
38 changes: 38 additions & 0 deletions WeaselDeployer/SwitcherSettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <algorithm>
#include <set>
#include <rime_levers_api.h>
#include <WeaselUtility.h>


SwitcherSettingsDialog::SwitcherSettingsDialog(RimeSwitcherSettings* settings)
Expand Down Expand Up @@ -83,6 +84,9 @@ LRESULT SwitcherSettingsDialog::OnInitDialog(UINT, WPARAM, LPARAM, BOOL&) {

hotkeys_.Attach(GetDlgItem(IDC_HOTKEYS));
hotkeys_.EnableWindow(FALSE);

get_schemata_.Attach(GetDlgItem(IDC_GET_SCHEMATA));
get_schemata_.EnableWindow(TRUE);

Populate();

Expand All @@ -96,6 +100,40 @@ LRESULT SwitcherSettingsDialog::OnClose(UINT, WPARAM, LPARAM, BOOL&) {
return 0;
}

LRESULT SwitcherSettingsDialog::OnGetSchemata(WORD, WORD, HWND hWndCtl, BOOL&) {
HKEY hKey;
LSTATUS ret = RegOpenKey(HKEY_LOCAL_MACHINE, _T("Software\\Rime\\Weasel"), &hKey);
if (ret == ERROR_SUCCESS) {
WCHAR value[MAX_PATH];
DWORD len = sizeof(value);
DWORD type = 0;
DWORD data = 0;
ret = RegQueryValueExW(hKey, L"WeaselRoot", NULL, &type, (LPBYTE)value, &len);
if (ret == ERROR_SUCCESS && type == REG_SZ) {
WCHAR parameters[MAX_PATH + 37];
wcscpy_s<_countof(parameters)>(parameters, (std::wstring(L"/k \"") + value + L"\\rime-install.bat\" --select :all").c_str());
SHELLEXECUTEINFOW cmd = {
sizeof(SHELLEXECUTEINFO),
SEE_MASK_NOCLOSEPROCESS | SEE_MASK_NOASYNC,
hWndCtl,
L"open",
L"cmd",
parameters,
NULL,
SW_SHOW,
NULL, NULL, NULL, NULL, NULL, NULL, NULL
};
ShellExecuteExW(&cmd);
WaitForSingleObject(cmd.hProcess, INFINITE);
CloseHandle(cmd.hProcess);
api_->load_settings(reinterpret_cast<RimeCustomSettings *>(settings_));
Populate();
}
}
RegCloseKey(hKey);
return 0;
}

LRESULT SwitcherSettingsDialog::OnOK(WORD, WORD code, HWND, BOOL&) {
if (modified_ && settings_ && schema_list_.GetItemCount() != 0) {
const char** selection = new const char*[schema_list_.GetItemCount()];
Expand Down
7 changes: 5 additions & 2 deletions WeaselDeployer/SwitcherSettingsDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ class SwitcherSettingsDialog : public CDialogImpl<SwitcherSettingsDialog> {
BEGIN_MSG_MAP(SwitcherSettingsDialog)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MESSAGE_HANDLER(WM_CLOSE, OnClose)
COMMAND_HANDLER(IDC_GET_SCHEMATA, BN_CLICKED, OnGetSchemata)
COMMAND_ID_HANDLER(IDOK, OnOK)
NOTIFY_HANDLER(IDC_SCHEMA_LIST, LVN_ITEMCHANGED, OnSchemaListItemChanged)
END_MSG_MAP()

LRESULT OnInitDialog(UINT, WPARAM, LPARAM, BOOL&);
LRESULT OnClose(UINT, WPARAM, LPARAM, BOOL&);
LRESULT OnOK(WORD, WORD code, HWND, BOOL&);
LRESULT OnGetSchemata(WORD, WORD, HWND, BOOL&);
LRESULT OnOK(WORD, WORD, HWND, BOOL&);
LRESULT OnSchemaListItemChanged(int, LPNMHDR, BOOL&);

void Populate();
Expand All @@ -33,6 +35,7 @@ class SwitcherSettingsDialog : public CDialogImpl<SwitcherSettingsDialog> {

CCheckListViewCtrl schema_list_;
CStatic description_;
CEdit hotkeys_;
CEdit hotkeys_;
CButton get_schemata_;
};

Binary file modified WeaselDeployer/WeaselDeployer.rc
Binary file not shown.
Binary file modified WeaselDeployer/resource.h
Binary file not shown.
1 change: 1 addition & 0 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ exit /b
rem call :build_essay
copy %WEASEL_ROOT%\LICENSE.txt output\
copy %WEASEL_ROOT%\README.md output\README.txt
copy %WEASEL_ROOT%\plum\rime-install.bat output\
set plum_dir=plum
set rime_dir=output/data
bash plum/rime-install
Expand Down
2 changes: 2 additions & 0 deletions output/install.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ Section "Weasel"
program_files:
File "LICENSE.txt"
File "README.txt"
File "rime-install.bat"
File "rime-install-config.bat"
File "weasel.dll"
${If} ${RunningX64}
File "weaselx64.dll"
Expand Down
5 changes: 5 additions & 0 deletions output/rime-install-config.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
rem for downloading Git for Windows installer
set git_mirror=taobao

rem Rime configuration manager and downloaded packages
set plum_dir=%APPDATA%\plum