1 parent
ee9b953533
commit
15b251e7fb
14 files changed
+1674
-26
No files matched your search
+26
-7
@@ -9,10 +9,13 @@
|
||||
#include "richtext.h"
|
||||
#include "ui_geometry.h"
|
||||
#include "diagnostics.h"
|
||||
#include "google_drive.h"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <commctrl.h>
|
||||
#include <commdlg.h>
|
||||
#include <cwchar>
|
||||
#include <dwmapi.h>
|
||||
#include <map>
|
||||
#include <richedit.h>
|
||||
@@ -20,6 +23,7 @@
|
||||
#include <shellapi.h>
|
||||
#include <shlobj.h>
|
||||
#include <sstream>
|
||||
#include <thread>
|
||||
#include <wrl/client.h>
|
||||
|
||||
namespace ks
|
||||
@@ -1131,7 +1135,7 @@ constexpr UINT AppWindowPicked = WM_APP + 78;
|
||||
constexpr int SettingsNavigation = 260, SettingsStatus = 261, SettingsViewport = 264, SettingsApply = 272;
|
||||
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 int SyncPage = 6, OpenBaoPage = 17, GoogleDrivePage = 18, SettingsSyncPanel = 271;
|
||||
constexpr UINT CollapseSettingsGroupMessage = WM_APP + 188;
|
||||
constexpr int SettingsSidebarWidth = 214, SettingsHeaderHeight = 82, SettingsFooterHeight = 76;
|
||||
constexpr int SettingsNavigationIndent = 16;
|
||||
@@ -1151,7 +1155,7 @@ constexpr struct SettingsSection
|
||||
{"clipboard", L"Clipboard", L"Configure clipboard history, storage limits and text recognition."},
|
||||
{"snippets", L"Snippets", L"Create text expansions and choose which applications can use them."},
|
||||
{"mouse", L"Mouse", L"Manage profiles, assign actions and test your mouse buttons."},
|
||||
{"sync", L"Sync", L"Back up and synchronize settings through OpenBao."},
|
||||
{"sync", L"Sync", L"Choose a provider to back up or synchronize your settings."},
|
||||
{"computers", L"Computers", L"Share mouse and keyboard with paired computers."},
|
||||
{"diagnostics", L"Diagnostics", L"Manage diagnostic logging and view recent operations."},
|
||||
{"mcp", L"MCP", L"Connect Codex to KSwitcher to read diagnostic logs."},
|
||||
@@ -1163,6 +1167,7 @@ constexpr struct SettingsSection
|
||||
{"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},
|
||||
{"google-drive", L"Google Drive", L"Manually back up saved settings or restore a backup into the Settings draft.", SyncPage},
|
||||
};
|
||||
constexpr wchar_t SettingsWindowFile[] = L"configurator-window.json";
|
||||
struct SettingsWindowState
|
||||
@@ -1284,7 +1289,7 @@ struct SettingsView
|
||||
};
|
||||
std::array<Page, std::size(settingsSections)> pages;
|
||||
int selectedPage = -1;
|
||||
HWND viewport{}, navigation{}, search{}, heading{}, description{}, brand{}, lan{}, sync{}, splitter{};
|
||||
HWND viewport{}, navigation{}, search{}, heading{}, description{}, brand{}, lan{}, sync{}, drive{}, splitter{};
|
||||
int sidebarWidth = SettingsSidebarWidth;
|
||||
std::optional<int> splitterDragOffset;
|
||||
bool splitterHovered{};
|
||||
@@ -1340,6 +1345,7 @@ void snippetWindowPicked(HWND w, WPARAM target, LPARAM phase);
|
||||
bool snippetDraftChanged(HWND, SnippetView *);
|
||||
bool mergeSnippetDraft(HWND, SnippetView *, Settings &);
|
||||
void refreshSnippetDraft(HWND, SnippetView *);
|
||||
void fillSnippets(HWND, SnippetView *);
|
||||
void updateSettingsState(HWND w, SettingsView *v);
|
||||
bool matchesSettingsSearch(const SettingsView &v, const std::wstring &text)
|
||||
{
|
||||
@@ -1391,6 +1397,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);
|
||||
if (v.drive) InvalidateRect(v.drive, nullptr, TRUE);
|
||||
}
|
||||
LRESULT CALLBACK settingsViewportProc(HWND w, UINT msg, WPARAM wp, LPARAM lp)
|
||||
{
|
||||
@@ -1566,7 +1573,7 @@ void setSettingsFonts(HWND w, SettingsView &v, UINT dpi)
|
||||
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, v.sync})
|
||||
for (HWND pane : {v.viewport, v.lan, v.sync, v.drive})
|
||||
if (pane)
|
||||
{
|
||||
SetPropW(pane, L"Font", GetPropW(w, L"Font"));
|
||||
@@ -1751,6 +1758,7 @@ int fitSettingsColumns(WindowLayout &layout, size_t first, size_t end, int width
|
||||
}
|
||||
int fitLanSettings(HWND panel, int width);
|
||||
int fitSyncSettings(HWND panel, int width);
|
||||
int fitDriveSettings(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));
|
||||
@@ -1759,11 +1767,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 || v.selectedPage == OpenBaoPage)
|
||||
if (v.selectedPage == ManageComputersPage || v.selectedPage == OpenBaoPage || v.selectedPage == GoogleDrivePage)
|
||||
{
|
||||
const int panelWidth = std::max(1, available - 16);
|
||||
const int panelHeight = v.selectedPage == ManageComputersPage ? fitLanSettings(v.lan, panelWidth) :
|
||||
fitSyncSettings(v.sync, panelWidth);
|
||||
v.selectedPage == OpenBaoPage ? fitSyncSettings(v.sync, panelWidth) : fitDriveSettings(v.drive, panelWidth);
|
||||
layout.controls[page.first].second = {8, 7, 8 + panelWidth, 7 + panelHeight};
|
||||
layout.height = panelHeight + 15;
|
||||
return;
|
||||
@@ -2432,6 +2440,7 @@ void resizeSettingsForDpi(HWND w, int previousDpi, int nextDpi)
|
||||
arrangeWindow(v.viewport);
|
||||
if (v.lan) arrangeWindow(v.lan);
|
||||
if (v.sync) arrangeWindow(v.sync);
|
||||
if (v.drive) arrangeWindow(v.drive);
|
||||
if (previousDpi != nextDpi) scaleMouseTableColumns(w, previousDpi, nextDpi);
|
||||
}
|
||||
void collectLayout(SettingsView *v)
|
||||
@@ -2796,6 +2805,7 @@ void showOcrOptions(HWND parent, SettingsView *v)
|
||||
}
|
||||
#include "ui_sync.inl"
|
||||
#include "ui_lan.inl"
|
||||
#include "ui_google_drive.inl"
|
||||
bool settingsChanged(SettingsView *v)
|
||||
{
|
||||
try
|
||||
@@ -2868,7 +2878,10 @@ void applySettingsDraft(HWND w, SettingsView *v, bool keepOpen)
|
||||
if (lanEdited) lan->draft.clear();
|
||||
v->draft = v->app->settings;
|
||||
fillSettings(w, v);
|
||||
refreshSnippetDraft(v->viewport, &v->snippets);
|
||||
v->snippets.snippets = v->snippets.saved = v->draft.snippets;
|
||||
if (v->snippets.selection >= static_cast<int>(v->snippets.snippets.size())) v->snippets.selection = -1;
|
||||
fillSnippets(v->viewport, &v->snippets);
|
||||
updateSettingsState(w, v);
|
||||
if (syncEdited) reloadSyncEditor(v->sync);
|
||||
if (lanEdited) refreshLan(v->lan, *lan);
|
||||
}
|
||||
@@ -3971,6 +3984,12 @@ void showSettings(App &app, bool visible)
|
||||
indexSettingsControl(*v, OpenBaoPage, child);
|
||||
page();
|
||||
|
||||
v->drive = createDriveSettings(pane, *v);
|
||||
layout->controls.push_back({v->drive, {8, 55, 8 + DriveSettingsWidth, 55 + DriveSettingsHeight}});
|
||||
for (HWND child = GetWindow(v->drive, GW_CHILD); child; child = GetWindow(child, GW_HWNDNEXT))
|
||||
indexSettingsControl(*v, GoogleDrivePage, 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));
|
||||
|
||||
Reference in new issue
Block a user