forked from flameshot-org/flameshot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: pull some complexity out of CaptureWidget constructor
There is a fair bit going on in the constructor and in particular some parts around screens is intermingled between different blocks of platform specific #ifdefs, which makes it a bit hard to follow. In this commit I'm pulling different parts of the logic out to their own functions to make it so people can go about refactoring individual pieces of logic more confidently. I've tried to to make too many changes beyond moving code around (although it did all change indentation too, which makes a diff a bit more difficult to follow. From the new `initInitialScreenshot()` method I've pulled out the setting of `topLeft` that I added previously, that's gone down into `positionWindow()` where it belongs. I've pulled `initWindowFlags()` out of window sizing and positioning code just to avoid intermingling the #ifdefs. In `positionWindow()` I've added in the setting of `topLeft` from the request and left some TODO comments. Now that getting the screenshot and setting the window position are separate it may make sense to do some sanity checking. I would also like to figure out why the windows and macOS cases need to be different and if we can change them to make editing a pin nicer there too. For setting the button area I don't know what most of this code is doing. I suspect some if it could be handled by the code in `ScreenGrabber()` which looks at geometries already. I moved the creation of the button widget and the call to get the relevant areas into the existing `initButtons()` method, it just seemed appropriate.
- Loading branch information
Showing
2 changed files
with
128 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters