Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: begin adding settings menu #647

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

python357-1
Copy link
Collaborator

This PR addresses the "Settings Menu" item in the tagstudio roadmap

@CyanVoxel CyanVoxel added Type: UI/UX User interface and/or user experience Priority: High An important issue requiring attention labels Dec 16, 2024
@CyanVoxel CyanVoxel added this to the Alpha v9.5 (Post-SQL) milestone Dec 16, 2024
@VasigaranAndAngel

This comment was marked as outdated.

@@ -30,7 +30,7 @@ def value(self) -> str:

@value.setter
def value(self, value: str):
if self.__value != value:
if self.__value != value and value is not None:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Computerdores I'm sure this is not at all an ideal solution to this problem, but it seems to fix the problem I was having with changing the language while TagStudio is running and having any non-translated elements have no text. If you have a better way of fixing this, I'm all ears

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you are right it is definitely not ideal as it would introduce another bug. I have an idea for a proper fix - I'll give this PR a review later and include the fix there.

@python357-1 python357-1 marked this pull request as ready for review January 11, 2025 06:54
@python357-1 python357-1 added the Status: Review Needed A review of this is needed label Jan 11, 2025
@python357-1
Copy link
Collaborator Author

@CyanVoxel After a very quick 4 weeks of development, the extremely basic settings menu is complete and ready for review

(sarcasm) but seriously it is ready for review

Copy link
Collaborator

@Computerdores Computerdores left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issues I noticed while testing:

  • The view menu is empty so clicking it doesn't do anything (should probably be removed)
  • Changing the "Show filenames" option has no effect without restarting TS
  • Changing the language has no effect (at least changing to es-MX doesn't)
  • The Dark mode setting doesn't work for me (Windows 10, Windows is set to dark mode, TS is set to light mode; TS shows in dark mode anyways)

tagstudio/src/qt/translations.py Outdated Show resolved Hide resolved
Comment on lines 46 to 50
if isinstance(path, str):
path_value = Path(path)

if path is None:
path_value = Path(self.filename)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second if can be an else instead - it would be more intuitive that way

Suggested change
if isinstance(path, str):
path_value = Path(path)
if path is None:
path_value = Path(self.filename)
if isinstance(path, str):
path_value = Path(path)
else:
path_value = Path(self.filename)

Comment on lines 5 to 6
# Cant think of any library-specific properties lol
test_prop: bool = False
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is the list of excluded file extensions that could be here, no?

Comment on lines 35 to 37
if not Path(path).exists():
logger.info("Cache file does not exist - creating", path=path)
open(path, "w").close()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail if the parent directory doesn't exist. I would suggest taking the logic from the if path is None: case and using it for both cases with the path being chosen based on whether path is None

Comment on lines 347 to 373
settings_menu_action = QAction("&Settings", menu_bar)
settings_menu_action.triggered.connect(lambda: self.open_settings_menu())
edit_menu.addAction(settings_menu_action)

edit_menu.addSeparator()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put this under "File" instead of "Edit" since all the other options under "Edit" are about editing the currently open library, while all the options in the Settings menu are unrelated to the library.

Comment on lines 327 to 350
# def fill_libs_widget(self, layout: QVBoxLayout):
# settings = self.driver.settings
# settings.beginGroup(SettingItems.LIBS_LIST)
# lib_items: dict[str, tuple[str, str]] = {}
# for item_tstamp in settings.allKeys():
# val = str(settings.value(item_tstamp, type=str))
# cut_val = val
# if len(val) > 45:
# cut_val = f"{val[0:10]} ... {val[-10:]}"
# lib_items[item_tstamp] = (val, cut_val)

# settings.endGroup()

# new_keys = set(lib_items.keys())
# if new_keys == self.render_libs:
# # no need to re-render
# return

# # sort lib_items by the key
# libs_sorted = sorted(lib_items.items(), key=lambda item: item[0], reverse=True)

# self.render_libs = new_keys
# self._fill_libs_widget(libs_sorted, layout)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be removed, no?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What did you change about this file?

@python357-1
Copy link
Collaborator Author

just to be sure - are you on the most recent commit? es-MX should not be an option in the language list, and dark mode is not in the settings anymore
image

@Computerdores
Copy link
Collaborator

Computerdores commented Jan 11, 2025

just to be sure - are you on the most recent commit? es-MX should not be an option in the language list, and dark mode is not in the settings anymore

god dammit - let me fetch real quick

@Computerdores
Copy link
Collaborator

I updated my comment - the dark mode and language thing were due to me forgetting to fetch, but the other two are still applicable

@python357-1
Copy link
Collaborator Author

everything should be addressed

Copy link
Collaborator

@Computerdores Computerdores left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most stuff indeed seems to be fixed.

Notes:

  • search_library is still reported by GitHub to have been changed
  • You have added some strings in this PR that aren't using the Translation system
  • (There is still the commented out stuff in preview_panel, but that is more of a nit anyways)

tagstudio/src/core/settings/tssettings.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@VasigaranAndAngel VasigaranAndAngel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in my review, i've included fixes for some type issues reported by mypy/pyright, along with a few doubts i have and some minor nitpicks and suggestions.

  • There are three classes inherited from BaseModel (TSSettings, LibSettings, TSCachedData) that have almost the same methods. what if it's modularized?
  • Can you add docstrings for methods

if len(filecontents.strip()) != 0:
settings_data = toml.loads(filecontents.decode("utf-8"))

settings_data["filename"] = str(path)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the purpose of saving the file path of it's own?

tagstudio/src/core/tscacheddata.py Outdated Show resolved Hide resolved
requirements.txt Outdated Show resolved Hide resolved
tagstudio/src/core/settings/libsettings.py Outdated Show resolved Hide resolved
tagstudio/src/core/library/alchemy/library.py Show resolved Hide resolved
tagstudio/src/qt/ts_qt.py Outdated Show resolved Hide resolved
tagstudio/src/qt/ts_qt.py Outdated Show resolved Hide resolved
tagstudio/src/qt/ts_qt.py Outdated Show resolved Hide resolved
tagstudio/src/qt/ts_qt.py Outdated Show resolved Hide resolved
tagstudio/src/qt/ts_qt.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: High An important issue requiring attention Status: Review Needed A review of this is needed Type: UI/UX User interface and/or user experience
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

4 participants