Skip to content

Commit

Permalink
Add command-line option /top
Browse files Browse the repository at this point in the history
New: Override via command-line option `/top` to enable always on top. Use `/top 0` or `/top false` to disable.
  • Loading branch information
sdneon committed May 26, 2024
1 parent d584b6f commit 81a15f2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Basic on-the-fly image processing is provided - allowing adjusting typical param
* No change:
* F12: toggles span all monitors, or not.
* SHF+F12: toggles always on top.
* New: Override via commandline option `/top` to enable always on top. Use `/top 0` or `/top false` to disable.
* CTRL+F12: toggle to next monitor. Now if there are more than 2 monitors (assuming horizontal row), this hotkey toggles in this cycle: monitor #1, #2, ... #last, all but last `[XX ]`, all but 1st `[ XX]`, and back.
* F1 with CTRL, SHF or ALT combos can now be used as hotkeys for other commands; only F1 shows the help info.

Expand Down
15 changes: 15 additions & 0 deletions src/JPEGView/JPEGView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ static CString ParseCommandLineForStartupFile(LPCTSTR sCommandLine) {
return sStartupFile;
}

static void ParseCommandLineForAlwaysOnTop(LPCTSTR sCommandLine) {
LPCTSTR sTop = Helpers::stristr(sCommandLine, _T("/top"));
if (sTop == NULL) {
return;
}
CString strState(sTop + _tcslen(_T("/top")));
strState.Trim();
bool bAlwaysOnTop = true;
if ( (strState.GetLength() > 0)
&& ((strState.CompareNoCase(_T("false")) == 0) || (strState.Compare(_T("0")) == 0)) )
bAlwaysOnTop = false;
CSettingsProvider::This().SetWindowAlwaysOnTopOnStartup(bAlwaysOnTop);
}

static double ParseCommandLineForAutostart(LPCTSTR sCommandLine) {
LPCTSTR sAutoStart = Helpers::stristr(sCommandLine, _T("/slideshow"));
if (sAutoStart == NULL) {
Expand Down Expand Up @@ -205,6 +219,7 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lp

CString sStartupFile = ParseCommandLineForStartupFile(lpstrCmdLine);
//Allow selection of image later, then auto-start slideshow
ParseCommandLineForAlwaysOnTop(lpstrCmdLine);
double dAutostartSlideShow = ParseCommandLineForAutostart(lpstrCmdLine);
bool bForceFullScreen = ParseCommandLineForFullScreen(lpstrCmdLine);
bool bAutoExit = ParseCommandLineForAutoExit(lpstrCmdLine);
Expand Down
1 change: 1 addition & 0 deletions src/JPEGView/MainDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2414,6 +2414,7 @@ void CMainDlg::ExecuteCommand(int nCommand) {
break;
case IDM_ALWAYS_ON_TOP:
ToggleAlwaysOnTop();
SetToast(m_bAlwaysOnTop? _T("Always on Top"): _T("Not on Top"));

break;
case IDM_FIT_WINDOW_TO_IMAGE:
Expand Down
1 change: 1 addition & 0 deletions src/JPEGView/SettingsProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class CSettingsProvider
LPCTSTR CustomIniEditor() { return m_sIniEditor; }
LPCTSTR GPSMapProvider() { return m_sGPSMapProvider; }
bool WindowAlwaysOnTopOnStartup() { return m_bWindowAlwaysOnTopOnStartup; }
void SetWindowAlwaysOnTopOnStartup(bool bAlwaysOnTop) { m_bWindowAlwaysOnTopOnStartup = bAlwaysOnTop; }
static double ParseTimeInterval(CString &strInterval);

// Returns if a user INI file exists
Expand Down

0 comments on commit 81a15f2

Please sign in to comment.