Skip to content

Commit

Permalink
Add About tab to settings dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
vanjac committed Jul 29, 2022
1 parent 4800205 commit f2509e8
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
44 changes: 43 additions & 1 deletion src/SettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ INT_PTR CALLBACK generalProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPar
SetDlgItemText(hwnd, IDC_START_FOLDER_PATH, selected);
PropSheet_Changed(GetParent(hwnd), hwnd);
}
return TRUE;
} else if (LOWORD(wParam) == IDC_EXPLORER_SETTINGS && HIWORD(wParam) == BN_CLICKED) {
// https://docs.microsoft.com/en-us/windows/win32/shell/executing-control-panel-items#folder-options
ShellExecute(nullptr, L"open",
Expand Down Expand Up @@ -184,6 +185,7 @@ INT_PTR CALLBACK trayProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
settings::setTrayDirection(settings::TRAY_DOWN);
else if (IsDlgButtonChecked(hwnd, IDC_TRAY_DIR_RIGHT))
settings::setTrayDirection(settings::TRAY_RIGHT);
SetWindowLongPtr(hwnd, DWLP_MSGRESULT, PSNRET_NOERROR);
return TRUE;
} else if (notif->code == PSN_HELP) {
ShellExecute(nullptr, L"open",
Expand All @@ -204,12 +206,14 @@ INT_PTR CALLBACK trayProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
} else if (!checked && tray) {
PostMessage(tray, WM_CLOSE, 0, 0);
}
return TRUE;
} else if (LOWORD(wParam) == IDC_TRAY_FOLDER_BROWSE && HIWORD(wParam) == BN_CLICKED) {
CComHeapPtr<wchar_t> selected;
if (chooseFolder(GetParent(hwnd), selected)) {
SetDlgItemText(hwnd, IDC_TRAY_FOLDER_PATH, selected);
PropSheet_Changed(GetParent(hwnd), hwnd);
}
return TRUE;
} else if (LOWORD(wParam) == IDC_RESET_TRAY_POSITION && HIWORD(wParam) == BN_CLICKED) {
settings::setTrayPosition(settings::DEFAULT_TRAY_POSITION);
settings::setTraySize(settings::DEFAULT_TRAY_SIZE);
Expand All @@ -220,6 +224,7 @@ INT_PTR CALLBACK trayProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
if (GetDlgItemText(hwnd, IDC_TRAY_FOLDER_PATH, path, _countof(path)))
openTray(path);
}
return TRUE;
} else if (LOWORD(wParam) == IDC_TRAY_FOLDER_PATH
&& (HIWORD(wParam) == CBN_EDITCHANGE || HIWORD(wParam) == CBN_SELCHANGE)) {
PropSheet_Changed(GetParent(hwnd), hwnd);
Expand All @@ -236,13 +241,45 @@ INT_PTR CALLBACK trayProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
}
}

INT_PTR CALLBACK aboutProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
switch (message) {
case WM_NOTIFY: {
NMHDR *notif = (NMHDR *)lParam;
if (notif->code == PSN_KILLACTIVE) {
SetWindowLongPtr(hwnd, DWLP_MSGRESULT, FALSE);
return TRUE;
} else if (notif->code == PSN_APPLY) {
SetWindowLongPtr(hwnd, DWLP_MSGRESULT, PSNRET_NOERROR);
return TRUE;
}
return FALSE;
}
case WM_COMMAND:
if (LOWORD(wParam) == IDC_UPDATES_LINK && HIWORD(wParam) == BN_CLICKED) {
ShellExecute(nullptr, L"open", L"https://github.com/vanjac/chromafile/releases",
nullptr, nullptr, SW_SHOWNORMAL);
return TRUE;
} else if (LOWORD(wParam) == IDC_HELP_LINK && HIWORD(wParam) == BN_CLICKED) {
ShellExecute(nullptr, L"open", L"https://github.com/vanjac/chromafile/wiki",
nullptr, nullptr, SW_SHOWNORMAL);
return TRUE;
} else if (LOWORD(wParam) == IDC_SOURCE_LINK && HIWORD(wParam) == BN_CLICKED) {
ShellExecute(nullptr, L"open", L"https://github.com/vanjac/chromafile",
nullptr, nullptr, SW_SHOWNORMAL);
return TRUE;
}
return FALSE;
}
return FALSE;
}

void openSettingsDialog() {
if (settingsDialog) {
SetActiveWindow(settingsDialog);
return;
}

PROPSHEETPAGE pages[2];
PROPSHEETPAGE pages[3];

pages[0] = {sizeof(PROPSHEETPAGE)};
pages[0].dwFlags = PSP_HASHELP;
Expand All @@ -256,6 +293,11 @@ void openSettingsDialog() {
pages[1].pszTemplate = MAKEINTRESOURCE(IDD_SETTINGS_TRAY);
pages[1].pfnDlgProc = trayProc;

pages[2] = {sizeof(PROPSHEETPAGE)};
pages[2].hInstance = GetModuleHandle(nullptr);
pages[2].pszTemplate = MAKEINTRESOURCE(IDD_SETTINGS_ABOUT);
pages[2].pfnDlgProc = aboutProc;

PROPSHEETHEADER sheet = {sizeof(sheet)};
sheet.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_NOCONTEXTHELP | PSH_MODELESS;
sheet.hInstance = GetModuleHandle(nullptr);
Expand Down
5 changes: 5 additions & 0 deletions src/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
#define IDC_TRAY_DIR_RIGHT 1007
#define IDC_RESET_TRAY_POSITION 1008

#define IDD_SETTINGS_ABOUT 106
#define IDC_UPDATES_LINK 1001
#define IDC_HELP_LINK 1002
#define IDC_SOURCE_LINK 1003

#define IDS_SETTINGS_CAPTION 200
#define IDS_SETTINGS_COMMAND 201
#define IDS_REFRESH_COMMAND 202
Expand Down
14 changes: 14 additions & 0 deletions src/resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,20 @@ IDD_SETTINGS_TRAY DIALOGEX
PUSHBUTTON "R&eset tray position", IDC_RESET_TRAY_POSITION, 42, 135, 70, 14
}

IDD_SETTINGS_ABOUT DIALOGEX
0, 0, 227, 215 // PROP_MED_CXDLG, PROP_MED_CYDLG
STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "About"
FONT 8, "MS Shell Dlg", 400, 0, 0x0 {
ICON IDR_APP_ICON, -1, 7, 7, 0, 0
LTEXT "chromafile", -1, 35, 7, 49, 8
LTEXT "Version:", -1, 35, 15, 28, 8
LTEXT CHROMAFILE_VERSION_STRING, -1, 70, 15, 28, 8
PUSHBUTTON "Latest updates", IDC_UPDATES_LINK, 7, 28, 66, 14
PUSHBUTTON "Help", IDC_HELP_LINK, 80, 28, 66, 14
PUSHBUTTON "Source code", IDC_SOURCE_LINK, 153, 28, 66, 14
}

STRINGTABLE {
IDS_SETTINGS_CAPTION, "chromafile Settings"
IDS_SETTINGS_COMMAND, "Settings"
Expand Down

0 comments on commit f2509e8

Please sign in to comment.