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

Improve app config #237

Merged
merged 2 commits into from
Oct 2, 2023
Merged

Conversation

crizzitello
Copy link
Contributor

Comment on lines +80 to +82
inline static const auto gnomeSS = QStringLiteral("/usr/bin/gnome-screenshot");
inline static const auto gnomeWindowCommand = QStringLiteral("gnome-screenshot -w -f %file");
inline static const auto gnomeAreaCommand = QStringLiteral("gnome-screenshot -a -f %file");
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if this is accurate anymore. Gnome changed their screenshot app to pop up a UI. I don't know if the CLI works the same anymore (or, really, at all)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It might not be current but it will work for those with gnome-screenshot installed,

Ill see if there is another newer tool for gnome to check for, Oh its now a part of the shell not a standalone application. perhaps we can recommend a tool for those users. and ill add it to the list.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, yes, that's true. I thought they replaced the binary but it looks like it's not called gnome-screenshot anymore.

Edit: The new screenshotting functionality is apparently built-in to the gnome shell. It doesn't appear that there's a way to invoke it from the terminal.

@JoelAtDeluxe
Copy link
Contributor

The changes look fine to me. A couple of thoughts:

  1. Probably not the defaults i'd use, but they're reasonable enough, and obviously you need to pick something.
  2. There's a bit of repetition in the code that could be turned into a small lambda -- that's what I'd do in a different language (I'll show below what I'm thinking)
  3. I haven't programmed in C++ in awhile, so take everything with a grain of salt.
  if (appConfig->value(CONFIG::SHORTCUT_SCREENSHOT).isNull())
    appConfig->setValue(CONFIG::SHORTCUT_SCREENSHOT, defaultValue(CONFIG::SHORTCUT_SCREENSHOT));

  //why not:
  auto setDefaultIfNull = [appConfig](QString field){  // is it a QString? This is how lazy I am: I can't be bothered to look right now.
    if (appConfig->value(field).isNull())
      appConfig->setValue(field, defaultValue(field));
  }
  setDefaultIfNull(CONFIG::SHORTCUT_SCREENSHOT);
  setDefaultIfNull(CONFIG::I_FORGET_THE_OTHER_FIELDS);

@crizzitello
Copy link
Contributor Author

 auto setDefaultIfNull = [appConfig](QString field){  // is it a QString? This is how lazy I am: I can't be bothered to look right now.
    if (appConfig->value(field).isNull())
      appConfig->setValue(field, defaultValue(field));
  }

Fixed it we don't even need to see the config if we try to read and it's empty we just get the default due to the change in the value method . Good call :D

@jkennedyvz jkennedyvz merged commit 96e8a9a into ashirt-ops:main Oct 2, 2023
5 checks passed
@crizzitello crizzitello deleted the improveAppConfig branch October 2, 2023 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically determine linux screen capture application
3 participants