TagStudio icon indicating copy to clipboard operation
TagStudio copied to clipboard

Only show 'Close Library' if your in a library

Open CarterPillow opened this issue 1 year ago • 6 comments

This is my first commit like ever on anything I know I made a lot of changes but I don't think this should have any effect outside of just only showing the close button when inside a library!

CarterPillow avatar Sep 06 '24 20:09 CarterPillow

I would suggest also hiding the "Refresh Directories", "Save Library" and "Save Library Backup" Buttons

Computerdores avatar Sep 06 '24 20:09 Computerdores

I honestly did not even think of that but this hides all the buttons in the "files" menu that do not have any effect until you open a library I will look to see if there is anything else that might benefit from being hidden til you open a library.

CarterPillow avatar Sep 06 '24 20:09 CarterPillow

Before opening a library image

After image

eivl avatar Sep 07 '24 07:09 eivl

A better way to approach this in my opinion would be to simply disable the menu options instead of removing them entirely, for example how the Edit menu handles this: image

This way the options don't change locations making them more difficult to find based on the state of the library, plus the user is made aware of all options whether they're presently available or not.

CyanVoxel avatar Sep 07 '24 20:09 CyanVoxel

Before Opening a Library image image

After image image

I looked at how the items were disabled in the version you showed (Alpha 9.4.0) and decided to add the "update_clipboard_actions" function over. Not the code from it since none of that is added yet just the function its self. This means that all the buttons will be enabled at first but since its the same function the ones that need to be disabled will be checked then disabled in the same code so its not a problem.

CarterPillow avatar Sep 08 '24 13:09 CarterPillow

I woke up to a lot of merges and this no longer working so ill have a look at what broke it and fix this pr lol

CarterPillow avatar Sep 09 '24 11:09 CarterPillow

@CarterPillow Is this something you're still interested in working on?

CyanVoxel avatar Nov 08 '24 19:11 CyanVoxel

@CyanVoxel Actually yeah! I'll have a look and see if I can't update the code to work.

CarterPillow avatar Nov 08 '24 19:11 CarterPillow

That didn't take long! hopefully this is all working again lol.

CarterPillow avatar Nov 09 '24 11:11 CarterPillow

A very minor nit, but the function name calls the toolbar a clipboard, which usually refers to copy/paste. I feel update_menu_actions or update_toolbar_actions would be a more proper name. Thanks!

seakrueger avatar Nov 15 '24 21:11 seakrueger

  1. It's not enabling the actions when i close the library and reopen a library. to fix it call update_clipboard_actions() from the QtDriver.open_library() method so it will enable actions when opening a library.
  2. format with ruff and do mypy check. (Install pre-commit if you haven’t yet.)
  • why are there two options for enabling and disabling? what if there is only one option named toggle_action_state that stores a bool value? if it's True, the action should be enabled or disabled and if False, it should not.
  • I prefer storing actions and/or menus (only if all the menu items are should be toggled) that need to be toggled when opening and closing the library, rather than enabling everything and explicitly disabling unwanted actions with the data() option.

btw, i personally like using QAction.property() rather than QAction.data() for its simplicity in this case.

  1. weird that issue was not happening for me but i added it there hopefully that will eliminate that bug for anyone else who might be getting it.

  2. I will do that ruff thing now.

  3. The reason I have 2 separate data options is because they have different behaviors. Autofill needs to be disabled on launch but not kept enabled when closing a library so if I just used 1 with true meaning it should be enabled/disabled then autofill would be kept open outside of libraries for example. I could just have 1 data variable for enable / disable and make it true if you want to keep it enabled after close and mark it false if you want to keep it disabled after open but i felt like that was overly complex and would just lead to a lot of confusion. This is just more explicit. I will look into property() vs data() though and make that change if it fits thank you for the recommendation. If i miss understood your point here about enable/disable let me know.

CarterPillow avatar Nov 18 '24 16:11 CarterPillow

A very minor nit, but the function name calls the toolbar a clipboard, which usually refers to copy/paste. I feel update_menu_actions or update_toolbar_actions would be a more proper name. Thanks!

This is a good idea. I think i only used update_clipboard_actions name because when i started this it was already a method but not sure. anyways now that the method is just this code I changed it to update_menu_actions.

CarterPillow avatar Nov 18 '24 16:11 CarterPillow

3. If i miss understood your point here about enable/disable let me know.

i meant only set the data if it’s a library related action. then enable or disable only those actions. alternatively you could just create a list of library related actions and toggle all of them together. it’d be simpler. no need to bother with any properties.

VasigaranAndAngel avatar Nov 18 '24 16:11 VasigaranAndAngel

i meant only set the data if it’s a library related action. then enable or disable only those actions. alternatively you could just create a list of library related actions and toggle all of them together. it’d be simpler. no need to bother with any properties.

I feel like 1 lists with properties would be more efficient then 2 lists. and on the off chance that something would need to be both enabled and disabled idk if that is needed ever but this current code would account for this.

CarterPillow avatar Nov 20 '24 01:11 CarterPillow

@CarterPillow Any updates or help needed on this?

CyanVoxel avatar Dec 05 '24 08:12 CyanVoxel

working on this in #713

mashed5894 avatar Jan 30 '25 23:01 mashed5894