Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20bd93b76b | ||
|
|
a63e3534c1 |
No files matched your search
@@ -440,9 +440,10 @@ Drag the divider to resize navigation. The window remembers its size, position,
|
||||
Switching sections preserves your edits. Save, Cancel, Import and Export stay below every page.
|
||||
|
||||
Open the desired chat in Telegram Desktop or Microsoft Teams, then open Settings → Languages →
|
||||
**Languages for a chat…**. Select the chat and click the languages to include. Choose
|
||||
**Use languages**, then **Save** in Settings. The subset order is saved from the main
|
||||
layout list when editing the profile; one-language profiles are supported. **Remove profile** restores default behavior.
|
||||
**Languages for a chat** in the navigation tree. Find the contact, select the chat and
|
||||
choose the layouts to include. Click **Apply** to keep Settings open or **Save** to close it.
|
||||
A profile can contain a single layout and cycles through its layouts in the order shown.
|
||||
Use **Remove profile** and apply or save the change to restore default behavior.
|
||||
|
||||
For a matching chat, **Alt+Shift**, **Win+Space** (and reverse **Win+Shift+Space**) cycle
|
||||
through that subset. KSwitcher's **Next layout** conversion uses the same subset.
|
||||
@@ -461,10 +462,11 @@ From v0.6.53, chat profiles (application, visible chat name and ordered language
|
||||
**Українською.** Вибирайте розділ у дереві Settings або шукайте окремий параметр через **Search settings**.
|
||||
Перетягніть розділювач, щоб змінити ширину дерева. Settings запам’ятовує розмір і положення вікна
|
||||
та активний розділ. Перехід між розділами зберігає чернетку. Save, Cancel, Import і Export доступні знизу. Відкрий потрібний чат у Telegram або Teams, потім **Settings → Languages → Languages
|
||||
for a chat…**. Вибери чат і потрібні мови, натисни **Use languages**, а потім **Save**.
|
||||
for a chat** у дереві налаштувань. Знайдіть контакт, виберіть чат і потрібні розкладки.
|
||||
Натисніть **Apply**, щоб залишити Settings відкритим, або **Save**, щоб закрити його.
|
||||
Набір діє для **Alt+Shift**, **Win+Space**, **Win+Shift+Space** та **Next layout** KSwitcher.
|
||||
Можна вибрати й одну мову; порядок зберігається із загального списку під час редагування профілю. **Remove profile**
|
||||
повертає звичайну поведінку. Без профілю системні комбінації працюють як раніше,
|
||||
Можна вибрати одну розкладку. Розкладки перемикаються в порядку, показаному в списку.
|
||||
Натисніть **Remove profile** і застосуйте або збережіть зміни, щоб повернути звичайну поведінку. Без профілю системні комбінації працюють як раніше,
|
||||
а Next layout використовує загальний набір. Видалені з Windows розкладки пропускаються;
|
||||
якщо доступних мов профілю не залишилося, використовується загальний набір.
|
||||
Прямі комбінації мов не змінюються; явно задані комбінації KSwitcher мають пріоритет.
|
||||
@@ -478,11 +480,11 @@ Telegram ігнорується. Teams підтримує зазначений
|
||||
|
||||
### Telegram Web in Chrome — v0.6.51
|
||||
|
||||
Open a chat in Telegram Web K (`https://web.telegram.org/k/`) in Chrome, then use **Settings → Languages → Languages for a chat...** and select **Telegram Web: name**. Choose languages, then **Use languages → Save**. The same subset applies to Alt+Shift, Win+Space, Win+Shift+Space and Next layout. Web profiles are separate from desktop Telegram profiles. Same-name chats across browser profiles/accounts share a web profile.
|
||||
Open a chat in Telegram Web K (`https://web.telegram.org/k/`) in Chrome, then use **Settings → Languages → Languages for a chat** and select the contact with **Telegram Web** in the App column. Choose layouts and click **Apply** or **Save**. The same subset applies to Alt+Shift, Win+Space, Win+Shift+Space and Next layout. Web profiles are separate from desktop Telegram profiles. Same-name chats across browser profiles/accounts share a web profile.
|
||||
|
||||
Recognition uses Chrome accessibility: the address bar and active document must both identify a Telegram chat, then the visible header supplies the name. The app watches foreground/focus and address/header-change events; it does not use OCR, a polling timer, an extension, or message-history extraction. The address bar, home page and unsupported URLs do not match. Web A and other browsers have not been validated and are not advertised as supported. Page or accessibility changes can make a chat unavailable instead of guessing.
|
||||
|
||||
**Українською.** З v0.6.51 підтримано Telegram Web K у Chrome. Відкрий чат, потім **Settings → Languages → Languages for a chat...**, вибери **Telegram Web: ім’я**, мови та **Use languages → Save**. Набір діє для Alt+Shift, Win+Space, Win+Shift+Space і Next layout. Вебпрофілі окремі від Telegram Desktop; однакові назви в різних акаунтах/профілях браузера мають спільний вебпрофіль. Адреса й назва беруться через accessibility, без OCR, таймера, розширення та читання історії повідомлень. В адресному рядку, на головній сторінці й для непідтримуваних адрес профіль не діє. Web A та інші браузери не перевірені й не заявлені як підтримувані.
|
||||
**Українською.** З v0.6.51 підтримано Telegram Web K у Chrome. Відкрий чат, потім **Settings → Languages → Languages for a chat**, вибери контакт із **Telegram Web** у колонці App та потрібні розкладки, а потім натисни **Apply** або **Save**. Набір діє для Alt+Shift, Win+Space, Win+Shift+Space і Next layout. Вебпрофілі окремі від Telegram Desktop; однакові назви в різних акаунтах/профілях браузера мають спільний вебпрофіль. Адреса й назва беруться через accessibility, без OCR, таймера, розширення та читання історії повідомлень. В адресному рядку, на головній сторінці й для непідтримуваних адрес профіль не діє. Web A та інші браузери не перевірені й не заявлені як підтримувані.
|
||||
|
||||
### Snippet autocomplete — v0.6.69
|
||||
|
||||
|
||||
+144
-193
@@ -1210,7 +1210,8 @@ LRESULT CALLBACK historyProc(HWND w, UINT msg, WPARAM wp, LPARAM lp)
|
||||
#ifndef KS_RESIDENT_APP
|
||||
constexpr int LanguagesPage = 1, ShortcutsPage = 2, ClipboardPage = 3, SnippetsPage = 4, MousePage = 5;
|
||||
constexpr int ExceptionsPage = 13, PersonalDictionariesPage = 14, WordBoundariesPage = 15, SnippetMacros = 320;
|
||||
constexpr int CustomReplacementsPage = 16;
|
||||
constexpr int CustomReplacementsPage = 16, ChatLanguagesPage = 20;
|
||||
constexpr int ChatContacts = 710, ChatLayouts = 711, ChatProfileStatus = 712, ChatRemoveProfile = 713, ChatSearch = 714;
|
||||
constexpr int ClipboardExcludedApps = 243, ClipboardAppName = 244, ClipboardAddApp = 245,
|
||||
ClipboardRemoveApp = 246, ClipboardAppPicker = 247;
|
||||
constexpr UINT AppWindowPicked = WM_APP + 78;
|
||||
@@ -1254,6 +1255,7 @@ constexpr struct SettingsSection
|
||||
{"openbao", L"OpenBao", L"Connect to OpenBao and synchronize your saved settings.", SyncPage},
|
||||
{"google-drive", L"Google Drive", L"Synchronize settings across PCs or manage manual backups.", SyncPage},
|
||||
{"ocr", L"Image text recognition", L"Choose Windows OCR or Tesseract. Recognition runs on this computer.", ClipboardPage},
|
||||
{"chat-languages", L"Languages for a chat", L"Choose which keyboard layouts to cycle through in a chat.", LanguagesPage},
|
||||
};
|
||||
constexpr wchar_t SettingsWindowFile[] = L"configurator-window.json";
|
||||
struct SettingsWindowState
|
||||
@@ -1353,6 +1355,9 @@ struct SettingsView
|
||||
SIZE mouseProfileCheckSize{};
|
||||
unsigned mouseEvents{}, rawMouseEvents{};
|
||||
bool rawMouseRegistered{};
|
||||
std::vector<std::wstring> chatKeys;
|
||||
int chatSelection = -1;
|
||||
bool updatingChatContacts{};
|
||||
SnippetView snippets;
|
||||
HWND clipboardPickerOutline{};
|
||||
};
|
||||
@@ -1863,6 +1868,8 @@ void reflowSettingsPage(HWND pane, WindowLayout &layout, int width, int height)
|
||||
}
|
||||
layout.height = fitSettingsColumns(layout, page.first, page.end, available, grid);
|
||||
const int extra = height * 96 / static_cast<int>(dpi) - layout.height;
|
||||
if (v.selectedPage == ChatLanguagesPage)
|
||||
stretchSettingsEditors(layout, page.first, page.end, std::min(extra, 160), {ChatContacts, ChatLayouts}, true);
|
||||
if (v.selectedPage == SnippetsPage)
|
||||
stretchSettingsEditors(layout, page.first, page.end, extra, {301, 303}, available < grid.wrapAt);
|
||||
if (v.selectedPage == MousePage)
|
||||
@@ -1954,6 +1961,7 @@ void reflowClipboard(HWND pane, WindowLayout &layout, int width, int height)
|
||||
if (scale(pane, layout.height) > height)
|
||||
fit(width - GetSystemMetricsForDpi(SM_CXVSCROLL, dpi));
|
||||
}
|
||||
void refreshChatLanguages(SettingsView &v);
|
||||
void selectSettingsPage(SettingsView &v, int selected)
|
||||
{
|
||||
if (selected < 0 || selected >= (int)v.pages.size() || selected == v.selectedPage) return;
|
||||
@@ -1968,6 +1976,7 @@ void selectSettingsPage(SettingsView &v, int selected)
|
||||
ShowWindow(layout.controls[i].first, SW_HIDE);
|
||||
}
|
||||
v.selectedPage = selected;
|
||||
if (selected == ChatLanguagesPage) refreshChatLanguages(v);
|
||||
SetWindowTextW(v.heading, settingsSections[selected].name);
|
||||
SetWindowTextW(v.description, settingsSections[selected].description);
|
||||
const auto &page = v.pages[selected];
|
||||
@@ -2274,81 +2283,42 @@ void indexSettingsControl(SettingsView &v, int page, HWND child)
|
||||
}
|
||||
v.searchEntries.push_back({page, child, target, std::move(text), aliases});
|
||||
}
|
||||
struct ChatLanguagesView
|
||||
void fillChatLanguages(SettingsView &v)
|
||||
{
|
||||
HWND parent{};
|
||||
SettingsView *settings{};
|
||||
std::vector<std::wstring> keys;
|
||||
Settings draft;
|
||||
int selection = -1;
|
||||
bool dirty{};
|
||||
bool updatingList{};
|
||||
std::wstring search;
|
||||
};
|
||||
void collectChatLanguages(HWND w, ChatLanguagesView *v)
|
||||
{
|
||||
if (!v->dirty || v->selection < 0) return;
|
||||
std::vector<std::wstring> cycle;
|
||||
for (size_t i = 0; i < v->settings->order.size(); ++i)
|
||||
if (SendDlgItemMessageW(w, 711, LB_GETSEL, i, 0) > 0)
|
||||
cycle.push_back(v->settings->app->layouts[v->settings->order[i]].id);
|
||||
if (cycle.empty()) throw std::runtime_error("Select at least one language.");
|
||||
v->draft.chatCycles[v->keys[v->selection]] = std::move(cycle);
|
||||
v->dirty = false;
|
||||
}
|
||||
void fillChatLanguages(HWND w, ChatLanguagesView *v)
|
||||
{
|
||||
int index = v->selection;
|
||||
EnableWindow(GetDlgItem(w, 711), index >= 0);
|
||||
EnableWindow(GetDlgItem(w, IDOK), index >= 0);
|
||||
if (index < 0)
|
||||
HWND pane = v.viewport;
|
||||
const bool selected = v.chatSelection >= 0;
|
||||
EnableWindow(GetDlgItem(pane, ChatLayouts), selected && !v.order.empty());
|
||||
if (!selected)
|
||||
{
|
||||
SendDlgItemMessageW(w, 711, LB_SETSEL, FALSE, -1);
|
||||
EnableWindow(GetDlgItem(w, 713), FALSE);
|
||||
value(w, 712, v->keys.empty() ? L"Open a chat, then reopen this dialog to add it." :
|
||||
L"No contacts match your search.");
|
||||
SendDlgItemMessageW(pane, ChatLayouts, LB_SETSEL, FALSE, -1);
|
||||
EnableWindow(GetDlgItem(pane, ChatRemoveProfile), FALSE);
|
||||
value(pane, ChatProfileStatus, v.chatKeys.empty() ?
|
||||
L"Open a chat, then return to this page." : L"No matching chat selected.");
|
||||
return;
|
||||
}
|
||||
const auto &draft = v->draft;
|
||||
auto saved = draft.chatCycles.find(v->keys[index]);
|
||||
const auto &cycle = saved == draft.chatCycles.end() ? draft.cycle : saved->second;
|
||||
for (size_t i = 0; i < v->settings->order.size(); ++i)
|
||||
const auto saved = v.draft.chatCycles.find(v.chatKeys[v.chatSelection]);
|
||||
const bool hasProfile = saved != v.draft.chatCycles.end();
|
||||
const auto &cycle = hasProfile ? saved->second : v.draft.cycle;
|
||||
for (size_t i = 0; i < v.order.size(); ++i)
|
||||
{
|
||||
auto &layout = v->settings->app->layouts[v->settings->order[i]];
|
||||
SendDlgItemMessageW(w, 711, LB_SETSEL,
|
||||
std::find(cycle.begin(), cycle.end(), layout.id) != cycle.end(), i);
|
||||
const auto &layout = v.app->layouts[v.order[i]];
|
||||
SendDlgItemMessageW(pane, ChatLayouts, LB_SETSEL, std::ranges::find(cycle, layout.id) != cycle.end(), i);
|
||||
}
|
||||
value(w, 712, saved == draft.chatCycles.end() ? L"No profile yet. Select the languages for this chat." :
|
||||
L"Chat profile. Select languages, or remove it to use the defaults.");
|
||||
EnableWindow(GetDlgItem(w, 713), saved != draft.chatCycles.end());
|
||||
value(pane, ChatProfileStatus, hasProfile ? L"Chat profile" : L"Using the default language cycle");
|
||||
EnableWindow(GetDlgItem(pane, ChatRemoveProfile), hasProfile);
|
||||
}
|
||||
void selectChatRow(HWND list, int index)
|
||||
void filterChatRows(SettingsView &v, const std::wstring &previous)
|
||||
{
|
||||
int row = -1;
|
||||
if (index >= 0)
|
||||
{
|
||||
LVFINDINFOW find{LVFI_PARAM};
|
||||
find.lParam = index;
|
||||
row = ListView_FindItem(list, -1, &find);
|
||||
}
|
||||
ListView_SetItemState(list, -1, 0, LVIS_SELECTED | LVIS_FOCUSED);
|
||||
if (row >= 0)
|
||||
{
|
||||
ListView_SetItemState(list, row, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
|
||||
ListView_EnsureVisible(list, row, FALSE);
|
||||
}
|
||||
}
|
||||
void filterChatRows(HWND w, ChatLanguagesView *v)
|
||||
{
|
||||
auto list = GetDlgItem(w, 710);
|
||||
auto search = lower(v->search);
|
||||
int selection = -1;
|
||||
v->updatingList = true;
|
||||
auto list = GetDlgItem(v.viewport, ChatContacts);
|
||||
const auto search = lower(value(v.viewport, ChatSearch));
|
||||
int selectedRow = -1;
|
||||
v.chatSelection = -1;
|
||||
v.updatingChatContacts = true;
|
||||
SendMessageW(list, WM_SETREDRAW, FALSE, 0);
|
||||
ListView_DeleteAllItems(list);
|
||||
for (size_t i = 0; i < v->keys.size(); ++i)
|
||||
for (size_t i = 0; i < v.chatKeys.size(); ++i)
|
||||
{
|
||||
const auto &key = v->keys[i];
|
||||
const auto &key = v.chatKeys[i];
|
||||
auto contact = key.substr(key.find(L'\n') + 1);
|
||||
if (lower(contact).find(search) == std::wstring::npos) continue;
|
||||
auto app = key.starts_with(L"telegram\n") ? L"Telegram" :
|
||||
@@ -2358,153 +2328,99 @@ void filterChatRows(HWND w, ChatLanguagesView *v)
|
||||
item.iItem = ListView_GetItemCount(list);
|
||||
item.pszText = contact.data();
|
||||
item.lParam = static_cast<LPARAM>(i);
|
||||
int row = ListView_InsertItem(list, &item);
|
||||
const int row = ListView_InsertItem(list, &item);
|
||||
if (row < 0) continue;
|
||||
ListView_SetItemText(list, row, 1, const_cast<wchar_t *>(app));
|
||||
if (selection < 0 || static_cast<int>(i) == v->selection) selection = static_cast<int>(i);
|
||||
if (selectedRow < 0 || key == previous)
|
||||
{
|
||||
selectedRow = row;
|
||||
v.chatSelection = static_cast<int>(i);
|
||||
}
|
||||
}
|
||||
if (selectedRow >= 0)
|
||||
{
|
||||
ListView_SetItemState(list, selectedRow, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
|
||||
ListView_EnsureVisible(list, selectedRow, FALSE);
|
||||
}
|
||||
selectChatRow(list, selection);
|
||||
SendMessageW(list, WM_SETREDRAW, TRUE, 0);
|
||||
InvalidateRect(list, nullptr, TRUE);
|
||||
v->updatingList = false;
|
||||
v->selection = selection;
|
||||
fillChatLanguages(w, v);
|
||||
v.updatingChatContacts = false;
|
||||
fillChatLanguages(v);
|
||||
}
|
||||
LRESULT CALLBACK chatLanguagesProc(HWND w, UINT msg, WPARAM wp, LPARAM lp)
|
||||
std::wstring selectedChatKey(const SettingsView &v)
|
||||
{
|
||||
auto *v = (ChatLanguagesView *)GetWindowLongPtrW(w, GWLP_USERDATA);
|
||||
if (!v) return DefWindowProcW(w, msg, wp, lp);
|
||||
try
|
||||
{
|
||||
if (msg == WM_NOTIFY && !v->updatingList)
|
||||
{
|
||||
auto *change = reinterpret_cast<const NMLISTVIEW *>(lp);
|
||||
if (change->hdr.idFrom == 710 && change->hdr.code == LVN_ITEMCHANGED &&
|
||||
(change->uNewState & LVIS_SELECTED) && !(change->uOldState & LVIS_SELECTED))
|
||||
{
|
||||
int selected = static_cast<int>(change->lParam);
|
||||
if (selected == v->selection) return 0;
|
||||
try { collectChatLanguages(w, v); }
|
||||
catch (...)
|
||||
{
|
||||
v->updatingList = true;
|
||||
selectChatRow(change->hdr.hwndFrom, v->selection);
|
||||
v->updatingList = false;
|
||||
throw;
|
||||
}
|
||||
v->selection = selected;
|
||||
fillChatLanguages(w, v);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (msg == WM_COMMAND)
|
||||
{
|
||||
int id = LOWORD(wp);
|
||||
if (id == 711 && HIWORD(wp) == LBN_SELCHANGE) { v->dirty = true; return 0; }
|
||||
if (id == 714 && HIWORD(wp) == EN_CHANGE && !v->updatingList)
|
||||
{
|
||||
try { collectChatLanguages(w, v); }
|
||||
catch (...)
|
||||
{
|
||||
v->updatingList = true;
|
||||
value(w, 714, v->search);
|
||||
v->updatingList = false;
|
||||
throw;
|
||||
}
|
||||
v->search = value(w, 714);
|
||||
filterChatRows(w, v);
|
||||
return 0;
|
||||
}
|
||||
if (id == IDOK || id == 713)
|
||||
{
|
||||
int selected = v->selection;
|
||||
if (id == IDOK && selected < 0) return 0;
|
||||
if (selected < 0 || selected >= (int)v->keys.size())
|
||||
throw std::runtime_error("Open a Telegram or Teams chat, then reopen this dialog.");
|
||||
if (id == 713)
|
||||
{
|
||||
v->draft.chatCycles.erase(v->keys[selected]);
|
||||
v->dirty = false;
|
||||
fillChatLanguages(w, v);
|
||||
return 0;
|
||||
}
|
||||
collectChatLanguages(w, v);
|
||||
validateSettings(v->draft);
|
||||
v->settings->draft.chatCycles = std::move(v->draft.chatCycles);
|
||||
DestroyWindow(w);
|
||||
return 0;
|
||||
}
|
||||
if (id == IDCANCEL) { DestroyWindow(w); return 0; }
|
||||
}
|
||||
if (msg == WM_CLOSE) { DestroyWindow(w); return 0; }
|
||||
if (msg == WM_DPICHANGED)
|
||||
{
|
||||
resizeForDpi(w, wp, lp);
|
||||
auto list = GetDlgItem(w, 710);
|
||||
ListView_SetColumnWidth(list, 0, scale(w, 442));
|
||||
ListView_SetColumnWidth(list, 1, scale(w, 140));
|
||||
return 0;
|
||||
}
|
||||
if (msg == WM_NCDESTROY)
|
||||
{
|
||||
EnableWindow(v->parent, TRUE);
|
||||
SetForegroundWindow(v->parent);
|
||||
disposeFont(w);
|
||||
delete v;
|
||||
SetWindowLongPtrW(w, GWLP_USERDATA, 0);
|
||||
}
|
||||
}
|
||||
catch (const std::exception &e) { error(w, e); }
|
||||
return DefWindowProcW(w, msg, wp, lp);
|
||||
return v.chatSelection < 0 ? std::wstring{} : v.chatKeys[v.chatSelection];
|
||||
}
|
||||
void showChatLanguages(HWND parent, SettingsView *settings)
|
||||
void refreshChatLanguages(SettingsView &v)
|
||||
{
|
||||
const auto previous = selectedChatKey(v);
|
||||
std::set<std::wstring> keys;
|
||||
for (const auto &[key, cycle] : settings->draft.chatCycles) keys.insert(key);
|
||||
struct Context { std::set<std::wstring> &keys; const Settings &settings; } context{keys, settings->draft};
|
||||
for (const auto &[key, cycle] : v.draft.chatCycles) keys.insert(key);
|
||||
EnumWindows([](HWND candidate, LPARAM context) -> BOOL
|
||||
{
|
||||
if (!IsWindowVisible(candidate)) return TRUE;
|
||||
auto &data = *(Context *)context;
|
||||
auto &contacts = *reinterpret_cast<std::set<std::wstring> *>(context);
|
||||
auto key = lower(processName(candidate)) == L"chrome" ? readChromeChat(candidate) : windowChatKey(candidate);
|
||||
if (!key.empty()) data.keys.insert(std::move(key));
|
||||
if (!key.empty()) contacts.insert(std::move(key));
|
||||
return TRUE;
|
||||
}, (LPARAM)&context);
|
||||
}, reinterpret_cast<LPARAM>(&keys));
|
||||
v.chatKeys.assign(keys.begin(), keys.end());
|
||||
SendDlgItemMessageW(v.viewport, ChatLayouts, LB_RESETCONTENT, 0, 0);
|
||||
for (int index : v.order)
|
||||
SendDlgItemMessageW(v.viewport, ChatLayouts, LB_ADDSTRING, 0,
|
||||
reinterpret_cast<LPARAM>(v.app->layouts[index].name.c_str()));
|
||||
filterChatRows(v, previous);
|
||||
}
|
||||
void editChatLanguages(SettingsView &v)
|
||||
{
|
||||
if (v.chatSelection < 0) return;
|
||||
std::vector<std::wstring> cycle;
|
||||
for (size_t i = 0; i < v.order.size(); ++i)
|
||||
if (SendDlgItemMessageW(v.viewport, ChatLayouts, LB_GETSEL, i, 0) > 0)
|
||||
cycle.push_back(v.app->layouts[v.order[i]].id);
|
||||
const bool hasLayouts = !cycle.empty();
|
||||
if (hasLayouts) v.draft.chatCycles[v.chatKeys[v.chatSelection]] = std::move(cycle);
|
||||
fillChatLanguages(v);
|
||||
if (!hasLayouts) value(v.viewport, ChatProfileStatus, L"Select at least one layout, or remove the profile.");
|
||||
}
|
||||
void sizeChatContactColumns(HWND list)
|
||||
{
|
||||
RECT bounds{};
|
||||
GetClientRect(list, &bounds);
|
||||
const int appWidth = scale(list, 140);
|
||||
const int scrollWidth = GetSystemMetricsForDpi(SM_CXVSCROLL, GetDpiForWindow(list));
|
||||
ListView_SetColumnWidth(list, 0, std::max(0L, bounds.right - appWidth - scrollWidth));
|
||||
ListView_SetColumnWidth(list, 1, appWidth);
|
||||
}
|
||||
LRESULT CALLBACK chatContactsProc(HWND list, UINT msg, WPARAM wp, LPARAM lp, UINT_PTR, DWORD_PTR)
|
||||
{
|
||||
const auto result = DefSubclassProc(list, msg, wp, lp);
|
||||
if (msg == WM_SIZE) sizeChatContactColumns(list);
|
||||
return result;
|
||||
}
|
||||
void createChatLanguages(HWND pane)
|
||||
{
|
||||
INITCOMMONCONTROLSEX controls{sizeof(controls), ICC_LISTVIEW_CLASSES};
|
||||
InitCommonControlsEx(&controls);
|
||||
HWND w = makeWindow(*settings->app, L"KSwitcher.ChatLanguages", L"Languages for a chat", chatLanguagesProc, 640, 524);
|
||||
auto *v = new ChatLanguagesView{parent, settings, {keys.begin(), keys.end()}};
|
||||
v->draft = settings->draft;
|
||||
v->updatingList = true;
|
||||
SetWindowLongPtrW(w, GWLP_HWNDPARENT, (LONG_PTR)parent);
|
||||
SetWindowLongPtrW(w, GWLP_USERDATA, (LONG_PTR)v);
|
||||
label(w, L"&Find contact", 18, 19, 106);
|
||||
edit(w, 714, 130, 14, 492);
|
||||
auto list = control(w, WC_LISTVIEWW, L"", WS_TABSTOP | WS_BORDER | LVS_REPORT | LVS_SINGLESEL |
|
||||
LVS_SHOWSELALWAYS | LVS_NOSORTHEADER, 710, 18, 48, 604, 136);
|
||||
label(pane, L"&Find contact", 24, 68, 660);
|
||||
edit(pane, ChatSearch, 24, 94, 660);
|
||||
const auto list = control(pane, WC_LISTVIEWW, L"", WS_TABSTOP | WS_BORDER | LVS_REPORT | LVS_SINGLESEL |
|
||||
LVS_SHOWSELALWAYS | LVS_NOSORTHEADER, ChatContacts, 24, 126, 660, 106);
|
||||
ListView_SetExtendedListViewStyle(list, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_LABELTIP);
|
||||
for (const auto &[title, width] : {std::pair{L"Contact", 442}, std::pair{L"App", 140}})
|
||||
for (const auto *title : {L"Contact", L"App"})
|
||||
{
|
||||
LVCOLUMNW column{LVCF_TEXT | LVCF_WIDTH};
|
||||
LVCOLUMNW column{LVCF_TEXT};
|
||||
column.pszText = const_cast<wchar_t *>(title);
|
||||
column.cx = scale(w, width);
|
||||
ListView_InsertColumn(list, Header_GetItemCount(ListView_GetHeader(list)), &column);
|
||||
}
|
||||
control(w, L"STATIC", L"Open a chat, then reopen this dialog to add it.", 0, 712, 18, 194, 604, 26);
|
||||
label(w, L"Click languages to include (saved in the order shown)", 18, 228, 604);
|
||||
control(w, L"LISTBOX", L"", WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY | LBS_MULTIPLESEL | LBS_NOINTEGRALHEIGHT | WS_BORDER,
|
||||
711, 18, 256, 604, 132);
|
||||
for (int i : settings->order)
|
||||
SendDlgItemMessageW(w, 711, LB_ADDSTRING, 0, (LPARAM)settings->app->layouts[i].name.c_str());
|
||||
label(w, L"Applies to Alt+Shift, Win+Space and KSwitcher Next layout.", 18, 402, 604);
|
||||
label(w, L"Switch chats freely. Use languages, then Save settings.", 18, 430, 604);
|
||||
button(w, L"&Remove profile", 713, 18, 476, 170);
|
||||
button(w, L"&Use languages", IDOK, 300, 476, 170);
|
||||
button(w, L"&Cancel", IDCANCEL, 486, 476, 136);
|
||||
filterChatRows(w, v);
|
||||
EnableWindow(parent, FALSE);
|
||||
showRequestedWindow(w);
|
||||
SetFocus(GetDlgItem(w, 714));
|
||||
SetWindowSubclass(list, chatContactsProc, 1, 0);
|
||||
sizeChatContactColumns(list);
|
||||
control(pane, L"STATIC", L"", 0, ChatProfileStatus, 24, 242, 660, 24);
|
||||
label(pane, L"Select layouts to include, in the order shown.", 24, 270, 660);
|
||||
control(pane, L"LISTBOX", L"", WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY | LBS_MULTIPLESEL | LBS_NOINTEGRALHEIGHT |
|
||||
WS_BORDER, ChatLayouts, 24, 296, 660, 80);
|
||||
button(pane, L"&Remove profile", ChatRemoveProfile, 24, 388, 170);
|
||||
label(pane, L"Applies to Alt+Shift, Win+Space, Win+Shift+Space and KSwitcher Next layout.", 24, 424, 660);
|
||||
}
|
||||
#include "ui_app_languages.inl"
|
||||
#include "ui_mouse_buttons.inl"
|
||||
@@ -2647,6 +2563,7 @@ void fillSettings(HWND root, SettingsView *v)
|
||||
v->order.push_back(i);
|
||||
v->selection = 0;
|
||||
fillLayouts(v);
|
||||
if (v->selectedPage == ChatLanguagesPage) refreshChatLanguages(*v);
|
||||
fillMouseProfiles(root, *v);
|
||||
fillCorrectionOptions(w, s);
|
||||
v->filling = false;
|
||||
@@ -3057,6 +2974,20 @@ LRESULT CALLBACK settingsProc(HWND w, UINT msg, WPARAM wp, LPARAM lp)
|
||||
if (LOWORD(wp) != WA_INACTIVE) updateSettingsState(w, v);
|
||||
break;
|
||||
case WM_NOTIFY:
|
||||
if (reinterpret_cast<const NMHDR *>(lp)->idFrom == ChatContacts &&
|
||||
reinterpret_cast<const NMHDR *>(lp)->code == LVN_ITEMCHANGED)
|
||||
{
|
||||
const auto &change = *reinterpret_cast<const NMLISTVIEW *>(lp);
|
||||
if (!v->updatingChatContacts && ((change.uNewState ^ change.uOldState) & LVIS_SELECTED))
|
||||
{
|
||||
if (change.uNewState & LVIS_SELECTED)
|
||||
v->chatSelection = static_cast<int>(change.lParam);
|
||||
else if (!ListView_GetSelectedCount(change.hdr.hwndFrom))
|
||||
v->chatSelection = -1;
|
||||
fillChatLanguages(*v);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (reinterpret_cast<const NMHDR *>(lp)->idFrom == SettingsNavigation)
|
||||
{
|
||||
const auto code = reinterpret_cast<const NMHDR *>(lp)->code;
|
||||
@@ -3189,7 +3120,25 @@ LRESULT CALLBACK settingsProc(HWND w, UINT msg, WPARAM wp, LPARAM lp)
|
||||
}
|
||||
if (id == 263) { collectLayout(v); showAppLanguages(w, v); return 0; }
|
||||
if (handleMouseBindings(w, *v, wp)) return 0;
|
||||
if (id == 259) { collectLayout(v); showChatLanguages(w, v); return 0; }
|
||||
if (id == ChatSearch && HIWORD(wp) == EN_CHANGE)
|
||||
{
|
||||
if (v->ready) filterChatRows(*v, selectedChatKey(*v));
|
||||
return 0;
|
||||
}
|
||||
if (id == ChatLayouts && HIWORD(wp) == LBN_SELCHANGE)
|
||||
{
|
||||
editChatLanguages(*v);
|
||||
return 0;
|
||||
}
|
||||
if (id == ChatRemoveProfile && HIWORD(wp) == BN_CLICKED)
|
||||
{
|
||||
if (v->chatSelection >= 0)
|
||||
{
|
||||
v->draft.chatCycles.erase(v->chatKeys[v->chatSelection]);
|
||||
fillChatLanguages(*v);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (id == 230)
|
||||
{
|
||||
collectLayout(v);
|
||||
@@ -3985,8 +3934,7 @@ void showSettings(App &app, bool visible)
|
||||
hotkeyEdit(app, pane, 231, 454, 234, 230);
|
||||
label(pane, L"Backspace / Delete clears it", 454, 270, 230);
|
||||
button(pane, L"Re&fresh layouts", 253, 454, 322, 230);
|
||||
button(pane, L"Languages for a &chat...", 259, 24, 378, 230);
|
||||
button(pane, L"Languages for &applications...", 263, 272, 378, 300);
|
||||
button(pane, L"Languages for &applications...", 263, 24, 378, 300);
|
||||
page();
|
||||
|
||||
settingsGroupLabel(pane, L"Keyboard shortcuts", 24, 68);
|
||||
@@ -4111,6 +4059,9 @@ void showSettings(App &app, bool visible)
|
||||
createOcrSettings(pane);
|
||||
page();
|
||||
|
||||
createChatLanguages(pane);
|
||||
page();
|
||||
|
||||
v->splitter = control(w, L"STATIC", L"Resize navigation pane", SS_NOTIFY | WS_TABSTOP,
|
||||
SettingsSplitter, 0, 0, 0, 0);
|
||||
SetWindowSubclass(v->splitter, settingsSplitterProc, 1, reinterpret_cast<DWORD_PTR>(v));
|
||||
|
||||
+62
-45
@@ -854,13 +854,16 @@ int main(int argc,char **argv)
|
||||
SendMessageW(GetDlgItem(correction, 414), BM_CLICK, 0, 0);
|
||||
require(!saveEnabled(), "reverting an inline correction edit disables Save");
|
||||
HWND navigation = settingsNavigation(parent);
|
||||
constexpr int sections = 20;
|
||||
constexpr int chatLanguagesPage = 20;
|
||||
constexpr int sections = 21;
|
||||
require(navigation && TreeView_GetCount(navigation) == sections &&
|
||||
TreeView_GetParent(navigation, settingsSection(navigation, 10)) == settingsSection(navigation, 7) &&
|
||||
TreeView_GetParent(navigation, settingsSection(navigation, 11)) == settingsSection(navigation, 0),
|
||||
"correction and computer settings are nested under their sections");
|
||||
require(TreeView_GetParent(navigation, settingsSection(navigation, 19)) == settingsSection(navigation, 3),
|
||||
"image text recognition is nested under Clipboard");
|
||||
require(TreeView_GetParent(navigation, settingsSection(navigation, chatLanguagesPage)) ==
|
||||
settingsSection(navigation, 1), "chat profiles appear under Languages");
|
||||
for (int section = 12; section <= 16; ++section)
|
||||
require(TreeView_GetParent(navigation, settingsSection(navigation, section)) == settingsSection(navigation, 11),
|
||||
"each correction subsection belongs to the correction branch");
|
||||
@@ -1124,44 +1127,51 @@ int main(int argc,char **argv)
|
||||
"search reveals the embedded OpenBao page");
|
||||
SetWindowTextW(search, L"");
|
||||
selectSettingsPage(parent, 1);
|
||||
require(!saveEnabled(),"changing sections leaves Settings clean");
|
||||
SendMessageW(parent, WM_COMMAND, 259, 0);
|
||||
HWND dialog = findTestWindow(L"KSwitcher.ChatLanguages", nullptr);
|
||||
require(dialog && !IsWindowEnabled(parent), "chat dialog opens with disabled parent");
|
||||
auto findFixtureChat = [&](HWND chatDialog) {
|
||||
SetDlgItemTextW(chatDialog, 714, L"! fIXTURE CHAT");
|
||||
HWND list = GetDlgItem(chatDialog, 710);
|
||||
require(!saveEnabled() && !GetDlgItem(pane, 259), "Languages uses the tree to open chat profiles");
|
||||
selectSettingsPage(parent, chatLanguagesPage);
|
||||
constexpr int contactsId = 710, layoutsId = 711, removeProfileId = 713, searchContactsId = 714;
|
||||
require(IsWindowVisible(GetDlgItem(pane, contactsId)) && IsWindowEnabled(parent) &&
|
||||
!findTestWindow(L"KSwitcher.ChatLanguages", nullptr), "chat profiles open within Settings");
|
||||
auto findFixtureChat = [&] {
|
||||
const auto chatPage = settingsViewport(parent);
|
||||
SetDlgItemTextW(chatPage, searchContactsId, L"! fIXTURE CHAT");
|
||||
const auto list = GetDlgItem(chatPage, contactsId);
|
||||
require(ListView_GetItemCount(list) == 1, "case-insensitive contact search finds saved chat");
|
||||
wchar_t appName[32]{};
|
||||
ListView_GetItemText(list, 0, 1, appName, std::size(appName));
|
||||
require(std::wstring(appName) == L"Telegram", "chat list shows the source app separately");
|
||||
};
|
||||
SetDlgItemTextW(dialog, 714, L"No matching fixture 8031");
|
||||
require(ListView_GetItemCount(GetDlgItem(dialog, 710)) == 0 &&
|
||||
!IsWindowEnabled(GetDlgItem(dialog, IDOK)), "empty search results disable profile actions");
|
||||
findFixtureChat(dialog);
|
||||
require(SendDlgItemMessageW(dialog, 711, LB_GETSELCOUNT, 0, 0) == 1, "saved single language selected");
|
||||
RedrawWindow(dialog, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN);
|
||||
RECT rect{}; GetClientRect(dialog, &rect);
|
||||
HDC dc = GetDC(dialog);
|
||||
auto selectChatLayouts = [&](bool select) {
|
||||
const auto chatPage = settingsViewport(parent);
|
||||
SendDlgItemMessageW(chatPage, layoutsId, LB_SETSEL, select, -1);
|
||||
SendMessageW(chatPage, WM_COMMAND, MAKEWPARAM(layoutsId, LBN_SELCHANGE), 0);
|
||||
};
|
||||
SetDlgItemTextW(pane, searchContactsId, L"No matching fixture 8031");
|
||||
require(ListView_GetItemCount(GetDlgItem(pane, contactsId)) == 0 &&
|
||||
!IsWindowEnabled(GetDlgItem(pane, layoutsId)) &&
|
||||
!IsWindowEnabled(GetDlgItem(pane, removeProfileId)), "empty search disables profile editing");
|
||||
findFixtureChat();
|
||||
require(SendDlgItemMessageW(pane, layoutsId, LB_GETSELCOUNT, 0, 0) == 1, "saved single language selected");
|
||||
selectChatLayouts(false);
|
||||
require(SendDlgItemMessageW(pane, layoutsId, LB_GETSELCOUNT, 0, 0) == 1 && !saveEnabled(),
|
||||
"deselecting the last layout keeps the profile");
|
||||
findFixtureChat();
|
||||
RedrawWindow(parent, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN);
|
||||
RECT rect{};
|
||||
GetClientRect(parent, &rect);
|
||||
HDC dc = GetDC(parent);
|
||||
auto clip = ks::screenshotClip(dc, rect.right, rect.bottom, {});
|
||||
ReleaseDC(dialog, dc);
|
||||
ReleaseDC(parent, dc);
|
||||
ks::atomicWrite(std::filesystem::path(ks::executable()).parent_path() / L"chat-languages.png",
|
||||
ks::encodePng(ks::decodeImage(clip)));
|
||||
SendDlgItemMessageW(dialog, 711, LB_SETSEL, TRUE, -1);
|
||||
SendMessageW(dialog, WM_COMMAND, MAKEWPARAM(711, LBN_SELCHANGE), 0);
|
||||
SendMessageW(dialog, WM_COMMAND, IDCANCEL, 0);
|
||||
require(!IsWindow(dialog) && IsWindowEnabled(parent), "cancel closes dialog");
|
||||
require(!saveEnabled(),"cancelled chat edits do not enable Save");
|
||||
SendMessageW(parent, WM_COMMAND, 259, 0);
|
||||
dialog = findTestWindow(L"KSwitcher.ChatLanguages", nullptr);
|
||||
findFixtureChat(dialog);
|
||||
require(SendDlgItemMessageW(dialog, 711, LB_GETSELCOUNT, 0, 0) == 1, "cancel discards language edits");
|
||||
SendDlgItemMessageW(dialog, 711, LB_SETSEL, TRUE, -1);
|
||||
SendMessageW(dialog, WM_COMMAND, MAKEWPARAM(711, LBN_SELCHANGE), 0);
|
||||
SendMessageW(dialog, WM_COMMAND, IDOK, 0);
|
||||
require(!IsWindow(dialog) && IsWindowEnabled(parent), "profile applies to settings draft");
|
||||
require(saveEnabled() == (app.layouts.size()>1),"accepted chat edits refresh Save immediately");
|
||||
selectChatLayouts(true);
|
||||
require(saveEnabled() == (app.layouts.size() > 1) && saveEnabled() == applyEnabled(),
|
||||
"editing a profile immediately refreshes Apply and Save");
|
||||
require(app.settings.chatCycles.at(key).size() == 1, "inline editing leaves saved settings untouched");
|
||||
selectSettingsPage(parent, 1);
|
||||
selectSettingsPage(parent, chatLanguagesPage);
|
||||
require(SendDlgItemMessageW(pane, layoutsId, LB_GETSELCOUNT, 0, 0) == static_cast<LRESULT>(app.layouts.size()),
|
||||
"profile edits survive navigating away and returning");
|
||||
selectSettingsPage(parent, 16);
|
||||
SetDlgItemTextW(correction, 412, L"Релізик\r\nрелізик, словечко");
|
||||
SetDlgItemTextW(correction, 416, L" HeLo = Hello\r\n");
|
||||
@@ -1174,26 +1184,33 @@ int main(int argc,char **argv)
|
||||
ks::showSettings(app);
|
||||
parent = app.settingsWindow;
|
||||
require(!saveEnabled(),"reopened saved Settings is clean");
|
||||
SendMessageW(parent, WM_COMMAND, 259, 0);
|
||||
dialog = findTestWindow(L"KSwitcher.ChatLanguages", nullptr);
|
||||
findFixtureChat(dialog);
|
||||
SendMessageW(dialog, WM_COMMAND, 713, 0);
|
||||
require(IsWindow(dialog), "chat reset keeps dialog open");
|
||||
SendMessageW(dialog, WM_COMMAND, IDOK, 0);
|
||||
require(saveEnabled() && status().find(L"Unsaved settings")==0,"removing child profile immediately marks parent dirty");
|
||||
RedrawWindow(parent,nullptr,nullptr,RDW_INVALIDATE|RDW_UPDATENOW|RDW_ALLCHILDREN);
|
||||
GetClientRect(parent,&rect); dc=GetDC(parent);
|
||||
clip=ks::screenshotClip(dc,rect.right,rect.bottom,{}); ReleaseDC(parent,dc);
|
||||
ks::atomicWrite(std::filesystem::path(ks::executable()).parent_path()/L"settings-unsaved.png",
|
||||
selectSettingsPage(parent, chatLanguagesPage);
|
||||
findFixtureChat();
|
||||
const auto chatPage = settingsViewport(parent);
|
||||
require(SendDlgItemMessageW(chatPage, layoutsId, LB_GETSELCOUNT, 0, 0) ==
|
||||
static_cast<LRESULT>(app.layouts.size()), "reopening shows the saved profile");
|
||||
SendMessageW(GetDlgItem(chatPage, removeProfileId), BM_CLICK, 0, 0);
|
||||
require(saveEnabled() && applyEnabled() && status().starts_with(L"Unsaved settings"),
|
||||
"removing a profile immediately marks Settings dirty");
|
||||
RedrawWindow(parent, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN);
|
||||
GetClientRect(parent, &rect);
|
||||
dc = GetDC(parent);
|
||||
clip = ks::screenshotClip(dc, rect.right, rect.bottom, {});
|
||||
ReleaseDC(parent, dc);
|
||||
ks::atomicWrite(std::filesystem::path(ks::executable()).parent_path() / L"settings-unsaved.png",
|
||||
ks::encodePng(ks::decodeImage(clip)));
|
||||
SendMessageW(parent, WM_COMMAND, IDOK, 0);
|
||||
require(!app.settings.chatCycles.contains(key), "remove profile restores default");
|
||||
SendMessageW(parent, WM_COMMAND, SettingsApply, 0);
|
||||
require(IsWindow(parent) && !saveEnabled() && !applyEnabled() &&
|
||||
!app.settings.chatCycles.contains(key) &&
|
||||
!ks::loadSettings(root / L"settings.json", app.layouts).chatCycles.contains(key),
|
||||
"Apply restores the default, saves the removal and keeps Settings open");
|
||||
SendMessageW(parent, WM_COMMAND, IDCANCEL, 0);
|
||||
// Existing shared sets become independent application drafts on edit.
|
||||
app.settings.appLanguageSets[L"Legacy shared"] = {{app.layouts[0].id}, {L"Codex.exe", L"notepad"}};
|
||||
ks::showSettings(app);
|
||||
parent = app.settingsWindow;
|
||||
SendMessageW(parent, WM_COMMAND, 263, 0);
|
||||
dialog = findTestWindow(L"KSwitcher.AppLanguages", nullptr);
|
||||
HWND dialog = findTestWindow(L"KSwitcher.AppLanguages", nullptr);
|
||||
require(dialog && !IsWindowEnabled(parent), "application language editor opens");
|
||||
auto selectApp = [&](const wchar_t *name) {
|
||||
int index = (int)SendDlgItemMessageW(dialog, 720, LB_FINDSTRINGEXACT, -1, (LPARAM)name);
|
||||
|
||||
Reference in new issue
Block a user