Release KSwitcher v0.7.1 with embedded OpenBao settings

This commit is contained in:
agrynco committed 2026-11-24 17:53:50 +02:00
1 parent 40884cfc9e
commit 0e9e5dd2ef
12 files changed
+239 -158

No files matched your search

+16 -7
View File
@@ -1130,6 +1130,7 @@ constexpr UINT AppWindowPicked = WM_APP + 78;
constexpr int SettingsNavigation = 260, SettingsStatus = 261, SettingsViewport = 264;
constexpr int SettingsBrand = 265, SettingsHeading = 266, SettingsDescription = 267, SettingsGroup = 268;
constexpr int SettingsSearch = 269, GeneralPage = 0, ComputersPage = 7, ManageComputersPage = 10, CorrectionPage = 11;
constexpr int SyncPage = 6, OpenBaoPage = 17, SettingsSyncPanel = 271;
constexpr UINT CollapseSettingsGroupMessage = WM_APP + 188;
constexpr int SettingsSidebarWidth = 214, SettingsHeaderHeight = 82, SettingsFooterHeight = 76;
constexpr int SettingsSplitter = 270, SettingsSplitterWidth = 8;
@@ -1159,6 +1160,7 @@ constexpr struct SettingsSection
{"personal-dictionaries", L"Personal dictionaries", L"Separate words with commas or new lines. Internal hyphens are allowed.", CorrectionPage},
{"word-boundaries", L"Word boundaries", L"Choose which punctuation KSwitcher keeps before and after a corrected word.", CorrectionPage},
{"custom-replacements", L"Custom replacements", L"Define your own corrections, which take priority over dictionary suggestions.", CorrectionPage},
{"openbao", L"OpenBao", L"Connect to OpenBao and synchronize your saved settings.", SyncPage},
};
constexpr wchar_t SettingsWindowFile[] = L"configurator-window.json";
struct SettingsWindowState
@@ -1240,7 +1242,7 @@ struct SettingsView
};
std::array<Page, std::size(settingsSections)> pages;
int selectedPage = -1;
HWND viewport{}, navigation{}, search{}, heading{}, description{}, brand{}, lan{}, splitter{};
HWND viewport{}, navigation{}, search{}, heading{}, description{}, brand{}, lan{}, sync{}, splitter{};
int sidebarWidth = SettingsSidebarWidth;
std::optional<int> splitterDragOffset;
bool splitterHovered{};
@@ -1349,6 +1351,7 @@ void repaintSettingsMatches(const SettingsView &v)
{
InvalidateRect(v.viewport, nullptr, TRUE);
if (v.lan) InvalidateRect(v.lan, nullptr, TRUE);
if (v.sync) InvalidateRect(v.sync, nullptr, TRUE);
}
LRESULT CALLBACK settingsViewportProc(HWND w, UINT msg, WPARAM wp, LPARAM lp)
{
@@ -1523,7 +1526,7 @@ void setSettingsFonts(HWND w, SettingsView &v)
assign(v.brand, font(w, 18, FW_SEMIBOLD), v.brandFont);
HFONT group = font(w, 15, FW_SEMIBOLD);
HFONT field = font(w, 14, FW_SEMIBOLD);
for (HWND pane : {v.viewport, v.lan})
for (HWND pane : {v.viewport, v.lan, v.sync})
if (pane)
{
SetPropW(pane, L"Font", GetPropW(w, L"Font"));
@@ -1707,6 +1710,7 @@ int fitSettingsColumns(WindowLayout &layout, size_t first, size_t end, int width
return bottom + 20;
}
int fitLanSettings(HWND panel, int width);
int fitSyncSettings(HWND panel, int width);
void reflowSettingsPage(HWND pane, WindowLayout &layout, int width, int height)
{
const auto &v = *reinterpret_cast<SettingsView *>(GetWindowLongPtrW(GetParent(pane), GWLP_USERDATA));
@@ -1715,10 +1719,11 @@ void reflowSettingsPage(HWND pane, WindowLayout &layout, int width, int height)
auto fit = [&](int pixels)
{
const int available = std::max(1, pixels * 96 / static_cast<int>(dpi));
if (v.selectedPage == ManageComputersPage)
if (v.selectedPage == ManageComputersPage || v.selectedPage == OpenBaoPage)
{
const int panelWidth = std::max(1, available - 16);
const int panelHeight = fitLanSettings(v.lan, panelWidth);
const int panelHeight = v.selectedPage == ManageComputersPage ? fitLanSettings(v.lan, panelWidth) :
fitSyncSettings(v.sync, panelWidth);
layout.controls[page.first].second = {8, 7, 8 + panelWidth, 7 + panelHeight};
layout.height = panelHeight + 15;
return;
@@ -2392,6 +2397,7 @@ void resizeSettingsForDpi(HWND w, int previousDpi, int nextDpi)
layoutSettings(w, v);
arrangeWindow(v.viewport);
if (v.lan) arrangeWindow(v.lan);
if (v.sync) arrangeWindow(v.sync);
if (previousDpi != nextDpi) scaleMouseTableColumns(w, previousDpi, nextDpi);
}
void collectLayout(SettingsView *v)
@@ -3015,7 +3021,6 @@ LRESULT CALLBACK settingsProc(HWND w, UINT msg, WPARAM wp, LPARAM lp)
return 0;
}
if (id == 257) { showOcrOptions(w, v); return 0; }
if (id == 258) { showSyncOptions(w, *v->app); return 0; }
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; }
@@ -3843,8 +3848,6 @@ void showSettings(App &app, bool visible)
createMousePage(w, *v);
page();
settingsGroupLabel(pane, L"OpenBao", 24, 68);
button(pane, L"S&ync settings...", 258, 24, 110, 210);
page();
label(pane, L"Use the same pairing code on both computers.", 24, 68, 660);
@@ -3915,6 +3918,12 @@ void showSettings(App &app, bool visible)
edit(pane, 416, 24, 132, 660, 248, multiline | ES_WANTRETURN);
page();
v->sync = createSyncSettings(pane, app);
layout->controls.push_back({v->sync, {8, 55, 8 + SyncSettingsWidth, 55 + SyncSettingsHeight}});
for (HWND child = GetWindow(v->sync, GW_CHILD); child; child = GetWindow(child, GW_HWNDNEXT))
indexSettingsControl(*v, OpenBaoPage, child);
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));