nemethviktor / GeoTagNinja

A lightweight photo geotagger for Windows.
https://geotag.ninja
GNU General Public License v3.0
25 stars 2 forks source link

Retain layout of panes and column widths between sessions #109

Closed ForgeSource closed 4 months ago

ForgeSource commented 5 months ago

Is your feature request related to a problem? Please describe. When I use GeoTagNinja, I spend some time changing the size of the panes (map, data, preview) and the width of the columns in the data pane. But when I close GeoTagNinja and next use it, these have all reverted to their default position/size.

Describe the solution you'd like Retain the layout of the panes and column widths that the user has selected between sessions.

Describe alternatives you've considered None.

Additional context Most other Windows programmes (including GeoSetter) seem to be able to do this, so I'm hopeful that it won't be too difficult.

nemethviktor commented 5 months ago

Hi, acknowledged, I'll look into it once done w/ ticket 107

senarvi commented 5 months ago

I guess persisting the values that the user enters in dialogs, would be nice too - at least during one session. When I import a GPX file, I have to enter the time zone and offset (which is, by the way, not a bug of GeoTagNinja, since I have to enter it in other software too). The next time I open the dialog, they are reset to the default values, so I have to enter the correct values again. This is not a big deal, but if you're going to look into saving the window layout, you could consider what it would take to save the previous input values too.

ForgeSource commented 5 months ago

Thank you for agreeing to look into this. At the risk of scope creep (please let me know if you'd prefer this raised as a separate ticket), would it also be possible to implement a FILTER function by column? Why? Well, my main use case is to reverse geotag my photographs, so I want to select those which DO have Co-ordinates associated with them but DO NOT have a Location.

senarvi commented 5 months ago

@ForgeSource how do you do reverse geocoding? What happens if you sort your pictures by Location and try to do it for those pictures that don't have it?

ForgeSource commented 5 months ago

I usually end up with a mixture of images in a directory (I use YYYY-MM), some of which have Longitude/Latitude co-ordinates and others which don't. For those which do have co-ordinates, and which don't already have the IPTC Country/Location/etc tags, I want to add this IPTC information. I've just tried your suggestion (sorting by location) and GeoTagNinja just ignores those images without co-ordinates, so it does indeed achieve my requirements - thanks. I can imagine other use cases where being able to filter by a particular column (and thus work with a sub-set of images) could be useful, hence the Enhancement suggestion. (I'm also aware that it's much easier to suggest enhancements than it is to find the time to actually implement them!)

nemethviktor commented 5 months ago

Adding actual filtering into the main listview is admittedly beyond my capabilities as it's not natively supported by the winforms listview so that i won't quite do now I'm afraid. As for the other requests (mostly re: retaining information in and across sessions), I'll have a look next week at some stage :) - theoretically column order and width should already be retained across sessions but if not I'll have a look as to why.

nemethviktor commented 4 months ago

Hi,

Can you pls have a look at https://drive.google.com/open?id=16laoPJcsJJz6mdkcjWvoQu6wWXiILbQy&usp=drive_fs in particular wrt your original request (panel size retention)

ForgeSource commented 4 months ago

Thank you! Unfortunately, it still doesn't remember the position of the panels. It now opens with the panels in a different position than before (the map pane is much smaller) - but it opens like this every time I restart GTN, regardless of the positions when I last exited.

nemethviktor commented 4 months ago

Hmm it has worked for me...at least the ones I've tried anyway...what windows culture setting are you on?

ForgeSource commented 4 months ago

Windows 11 Pro. Region=United Kingdom. Regional format= English (United Kingdom).

nemethviktor commented 4 months ago

image

Same as mine (Windows that is.) It works for me....the above was retained across app exit/restart. Which particular part you are finding that isn't being retained? I admittedly didn't include everything but most things are in the list.

nemethviktor commented 4 months ago

Just to triple check google drive not being an idiot, your now-current version is 8956 [20240709:2039] right? (Help/About)

ForgeSource commented 4 months ago

Yes - same version. I set mine up to be approximately the same as your screen shot. After quit and restart, my map pane is about one third the width of my total screen. I'm running GTN in a Maximized window on a 2560x1440 display, in case that helps.

nemethviktor commented 4 months ago

Odd, same here. My monitor is 2560x1600 but I don't think that makes any difference. I'm trying to repo it not working but I've dragged things around a fair bit and it's still ok for me. I'll try to dig around a little more tho. Is it that it's not doing anything (ie nothing gets retained) or just the wrong values get retained?

ForgeSource commented 4 months ago

Hmmm. I've left the Map pane alone, and made the Image pane as small as possible (maybe 15% or so of the total window height?). On restart, the Image pane is about one third of screen height. Leave Map alone. Make Image as big as possible (perhaps 80/90% of screen height). On restart, Image pane is about two thirds of screen height. Next, set Files and Image at about 50% each, and extend Map as wide as possible (perhaps 95% width). On restart, Maps stays at 95%, but Files are ~two thirds and Image is ~one third height. Next, set Files and Image at about 50% each, and Maps about 50% width. On restart, Map is only about 10% wide. Again, Files are ~two thirds and Image is ~one third height. Lastly (for now), set Maps as narrow as possible. Files and Image at about 50% each. On restart, Map is again about 10% wide. Files are ~two thirds and Image is ~one third height.

nemethviktor commented 4 months ago

Hmm okay well I have no idea but let's see what the the program sees., that might help. Same link as above there is a new version. You'll need to uninstall the existing one because this has the same build number and Windows won't let you install over an existing one w/ identical build numbers.

There is a log file at c:\Users\yourusername\AppData\Roaming\GeoTagNinja\logfile.txt Your task is the following: Once you've installed the new version, launch GTN. Play around with the panel widths etc and then exit the app. Then check the log. Do not restart the app yet. image

See I've set the width a bit silly above on purpose. You should see the values in the log at the end such as image

Either copy the log file someplace (not in the same folder as it'd get deleted) or just take a note of the settings. FrmMainApp.FrmMainApp_FormClosing|Writing setting.settingId ....

Close the log. Restart the app. If for some odd reason it works now, good, otherwise don't do anything, just close the app. Check the log again. Towards the beginning you should have: image

The expectation is that for FrmMainApp.AppStartupApplyVisualStyleDefaults|Reading settingsApplicationDesignValue .... and FrmMainApp.AppStartupApplyVisualStyleDefaults|Assinging value ... the values should match what were saved in the initial step (e.g. 45 for lvw_FileListSizeWidth / lvw_FileListSizeWidth above)

ForgeSource commented 4 months ago

After changing values, and closing GTN: 2024-07-09 22:34:57.4658|DEBUG|FrmMainApp.AppStartupApplyVisualStyleDefaults|Reading settingsApplicationDesignValue lvw_FileListSizeWidth, dataInSQL 2446. 2024-07-09 22:34:57.4658|DEBUG|FrmMainApp.AppStartupApplyVisualStyleDefaults|Reading settingsApplicationDesignValue lvw_FileListSizeHeight, dataInSQL 954.

After restarting GTN (when panes did not retain their size): 024-07-09 22:37:46.2943|DEBUG|FrmMainApp.AppStartupApplyVisualStyleDefaults|Reading settingsApplicationDesignValue lvw_FileListSizeWidth, dataInSQL 102. 2024-07-09 22:37:46.2943|DEBUG|FrmMainApp.AppStartupApplyVisualStyleDefaults|Reading settingsApplicationDesignValue lvw_FileListSizeHeight, dataInSQL 462.

nemethviktor commented 4 months ago

Hmm okay that's interesting. Let's try to figure out where it goes wrong. If you're willing to download https://download.sqlitebrowser.org/DB.Browser.for.SQLite-3.12.2-win64.zip (no need to install)

Within that app open c:\Users\yourusername\AppData\Roaming\GeoTagNinja\database.sqlite then Browse Data tab and Settings table image

In the settingId header search for lvw_FileListSizeWidth (or whichever other value) and see if you get the value you expect (ie what was written) or the one you see (ie what was read)? image

ps I'm off to zzzz so won't reply till tomorrow. :)

nemethviktor commented 4 months ago

Hi,

I think you've deleted a message (i got an email but it's not showing here) -- however... I just can't replicate the issue. Are you using multiple monitors, tabbed desktop or something out of the ordinary by any chance? Logically if the app was writing and reading wrong data to/from SQL here then it'd be doing the same thing everywhere else and it wouldn't generally function.

ForgeSource commented 4 months ago

Apologies. I'd been playing around with the placement of panes in GTN before examining the SQLdb, so the values I posted were meaningless and I deleted them; I then had to go to bed myself.

I am running two monitors, but not a tabbed desktop or anything else abnormal.

I've re-run the whole exercise that you asked for, and these are the results:

After changing values, and closing GTN: 2024-07-10 14:25:01.6821|DEBUG|FrmMainApp.AppStartupApplyVisualStyleDefaults|Reading settingsApplicationDesignValue lvw_FileListSizeWidth, dataInSQL 1074. 2024-07-10 14:25:01.6821|DEBUG|FrmMainApp.AppStartupApplyVisualStyleDefaults|Reading settingsApplicationDesignValue lvw_FileListSizeHeight, dataInSQL 862.

After restarting GTN (when panes did not retain their size): 2024-07-10 14:28:26.2514|DEBUG|FrmMainApp.AppStartupApplyVisualStyleDefaults|Reading settingsApplicationDesignValue lvw_FileListSizeWidth, dataInSQL 89. 2024-07-10 14:28:26.2574|DEBUG|FrmMainApp.AppStartupApplyVisualStyleDefaults|Reading settingsApplicationDesignValue lvw_FileListSizeHeight, dataInSQL 548.

On examining database.sqlite: generic lvw_FileListSizeHeight 954 generic lvw_FileListSizeWidth 324

nemethviktor commented 4 months ago

I'm out of ideas but I think (although couldn't really make any sense as to why) the two monitors might be doing something. Are you willing to 1) move the app to another monitor and see if it behaves and 2) just disconnect one of the monitors and see what happens? Not sure if you read C# but the underlying logic is dreadfully simple. There's a somewhat manual list of items such as ("splitContainerMainSizeWidth", splitContainerMain.Width.ToString(provider: CultureInfo.InvariantCulture)), ("splitContainerMainSizeHeight", splitContainerMain.Height.ToString(provider: CultureInfo.InvariantCulture)),

You can decipher what those are but if not the first of each is just a name (the one you see in sqlite) and the 2nd is the numeric value of the relevant control converted to string (as originally it's an int).

That stuff then gets written into SQL like a number of other things (ie we retain it along the other settings like your API key and whatnot)

Then when you restart the app it reads stuff back.

Dictionary<string, int> settingsApplicationDesignValuesDict = new()
{
    { "splitContainerMainSizeWidth", 0 },
    { "splitContainerMainSizeHeight", 0 },
....

it's a key-value-pair list of sorts and everything is initialised as 0. We then attempt to query the number from SQL

string dataInSQL =
    HelperDataApplicationSettings.DataReadSQLiteSettings(tableName: "settings", settingTabPage: "generic",
        settingId: settingsApplicationDesignValue, returnBlankIfNull: true);

and if it's there and isn't something silly (ie not a number or some other thing) then we convert the string back to int and assign it to update the currently 0 value with the real value.

...
// trimmedDictValueKey  is something like "splitContainerMainSize"
switch (dictValueKey) 
{ 
    case "splitContainerMainSizeWidth":
    case "splitContainerMainSizeHeight":
        splitContainerMain.Size = new Size(
            width: settingsApplicationDesignValuesDict[key: trimmedDictValueKey + "Width"],
            height: settingsApplicationDesignValuesDict[key: trimmedDictValueKey + "Height"]
        );
        break;
...

So it's pretty simple, not sure how it can go so wrong. :/

ForgeSource commented 4 months ago

Many thanks for trying. My coding days are long ago (and ended at C / Pascal / FORTRAN, so C# is new to me), but I'll try moving the app to my other screen, and also disconnecting one screen. I'll also try it on a laptop with 1 or 2 screens and see what happens. Might be a day or so before I report back...

ForgeSource commented 4 months ago

Quick update:

Screen shots of GTN (1) Before Exiting and (2) after Restarting.

GTN1

GTN2

nemethviktor commented 4 months ago

I was about to say I can't get it to show and then randomly it did on one of my other VMs. Apparently this is a bug in the winforms logic/system.. Anyway, I've patched it now, I think it works (it certainly does on the VM) but do check (same link as above).

ForgeSource commented 4 months ago

Yes! That appears to have fixed it. Very many thanks for the effort involved in resolving this.

nemethviktor commented 4 months ago

Yeyy - happy to help! :)