Commit Graph

24 Commits

Author SHA1 Message Date
Haris Gušić
d1428889b9 Implement config checking (#1859)
* Add error handling functions to ConfigHandler

Refurbished functions setValue and value which were previously unused.
These functions now set/get a setting with error handling.
Currently recognizes only errors recognizable by QSettings.

* Make use of value and setValue in ConfigHandler

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Add checker for unrecognized general options

Extraneous config options in [General] will be reported as errors.
Added some placeholder functions to be implemented in future commits.

* Introduce keysFromGroup function

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Check shortcut names for duplicates

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix notification spam

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Implement shortcut conflict checking

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix reading of fallbacks on error

If there is a config error, some values would not be loaded correctly.
Using the newly implemented function ConfigHandler::contains instead of
QSettings::contains solves this issue.

These changes reveal u bug that causes a crash on startup.

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix crashes introduced in previous commit

Because ConfigHandler is a dependency of most other classes,
calling functions from those classes inside ConfigHandler caused
infinite recursions in some cases.

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Add config file watcher

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Add missing config options

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix bug in shortcut conflict detection

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Add error resolved notification

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Add GUI error message overlay

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Add indicator in config window

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Use ConfigHandler::fileChanged in ConfigWindow

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix watcher sometimes not firing

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Improve config file watching performance

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Add new way to handle config

This is only a fundamental implementation. Future commits will replace
everything with this new paradigm.

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix getButtons and related functions

Also refactored related code to use QList instead of QVector because
QSettings does not work well with QVector.

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Make good use of the new way

* Implement proper checking for basic types

Everything is covered, apart from KeySequence.

* Move fallback path to ExistingDir value handler

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Use consistent naming scheme in ConfigHandler

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Implement config getters/setters via macro

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Surround text with tr and clang-format

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix colors being saved obfuscated

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Add ValueHandler::represenation

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Move ValueHandler to separate files

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* confighandler.cpp: rename macro CUSTOM to OPTION

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix bug with shortcut conflict checker

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Update docs and fix setAllTheButtons

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Handle filenamePattern properly

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix failing build due to wrong function name

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix QSet error due to Qt version mismatch

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Replace QSharedPointer::get with data for older Qt versions

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix failing build on MacOS and ubuntu 18.04

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Add column headers to recognizedGeneralOptions map

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix ubuntu 18.04 error

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix false positive when shortcuts empty

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix wrong shortcut group prefix

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Implement proper shortcut checking

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Add shortcut map in ConfigHandler

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Move ConfigShortcuts functions to ShortcutsWidget

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix minor bugs

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Add fallback scheme: Pictures, HOME, TMP

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Add config --check CLI option

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Add config error log to GUI

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Rename ValueHandler::description to expected

* Convert Qt's #AARRGGBB to #RRGGBBAA and vice versa

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Remove obsolete `saveAfterCopyPath`

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix errors in example config

Also added an additional ; in front of actual comments to differentiate
them from commented options.

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Allow special value 'picker' in userColors

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Allow only name, #RRGGBB, and #RRGGBBAA color formats

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>
2021-09-15 11:56:01 -05:00
Haris Gušić
41ca51bc10 Improve screenshot path handling (#1815)
* Make --path work correctly with relative paths

Relative paths are taken relative to the working directory of the calling
command, not relative to the daemon's working directory.

* Allow file paths in --path and refactor

* Remove some redundancy

These actions are already performed in the respective functions in
FlameshotDBusAdapter.

* Tweak --path error checker a bit more

* Rework FileNameHandler and update references

The class now has a much simpler interface.

- Screenshot paths are now universally determined by the function
  properScreenshotPath
- Some unreferenced methods have been removed
- The documentation of properScreenshotPath documents the changes well.

* Add crude tests for --path

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix failing build on Windows

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Add a test for invalid path

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Make tests clearer

Thanks to @mmahmoudian for his review and contribution.

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fix bug in properScreenshotPath

Auto-numeration did not work when the screenshot was automatically
saved when copied to clipboard.

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Fall back to default pictures location

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Revert "Remove some redundancy"

This was not redundancy. I had actually introduced a bug with this.

This reverts commit 011ef737564892e494518443e6b80ccf3d286ae1.

* Change default path only on interactive save

Previously, the default save path was changed every time a screenshot
was saved. Now, that only happens when it gets saved from the GUI.

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Change --path help text

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>

* Allow other image formats

Signed-off-by: Haris Gušić <harisgusic.dev@gmail.com>
2021-08-20 13:10:12 -05:00
Jeremy Borgman
f7e8d34c82 Added strf validation 2021-03-03 14:37:50 -06:00
Yuriy Puchkov
d32ed7704b fix - File name pattern editor 'Clear' and 'Reset' behavior (configuration window)
(cherry picked from commit 116c807f166841e1ba2745e32ae1ef5fd7f25276)
2021-02-26 09:21:19 +02:00
Boyuan Yang
a9c7cc7b04 Use SPDX-License-Identifier
closes: #1374 .

Use SPDX short-form identifiers instead of lengthy copyright
header to document per-file license and copyright.

This commit updates all files under src/ directory where applicable
as well as org.flameshot.Flameshot.metainfo.xml.
2021-02-20 19:22:53 -05:00
Jeremy Borgman
381985afbb Handle exception when locales are not properly configured 2021-02-15 08:07:31 -06:00
Yuriy Puchkov
8848b25305 Join two similar options 'Save path' and 'Save default path for screenshots' 2020-10-06 14:10:32 +03:00
Yuriy Puchkov
b88a5fbce8 Code refactoring - change code style to the new clang-format rules 2020-09-23 15:25:13 +03:00
Yuriy Puchkov
3ff33f036e Buxfix - crased on delete last symbol in Filename format 2020-07-13 21:02:22 +03:00
lupoDharkael
42619158fa Update copyright year 2019-03-04 16:38:45 +01:00
Alfredo Ramos
ee2f583acd Fix some issues detected by Clazy (#384)
* Fix old style connect

* Fix unneeded QString memory allocations
2018-10-24 01:04:42 +02:00
lupoDharkael
17ac6f7a35 Filename: replace colons with dashes 2018-04-23 17:09:19 +02:00
lupoDharkael
595e778673 Fix default filename in Windows 2018-04-16 18:25:05 +02:00
lupoDharkael
ab207d8546 Saves use datetime as default name 2018-04-10 17:02:55 +02:00
lupoDharkael
5746a58582 Code refactor
More flexible tool API
Minor code format fixes
Clipboard freeze fixed(?)
Arrow correcly growing close to the start point
Improve maintainability
Add undo/redo stack
2018-04-10 15:33:08 +02:00
lupoDharkael
16a082c713 Fix MSVC warnings 2018-01-18 17:26:58 +01:00
lupoDharkael
bf9892d05e Use Native File Dialog 2018-01-14 16:21:33 +01:00
lupoDharkael
02865322bf Update copyright 2018-01-12 17:58:30 +01:00
lupoDharkael
6c68d35875 Compatibility with Qt 5.3 and Debian 8 2017-08-21 23:46:30 +02:00
lupoDharkael
4a56f44bb9 Refactor in the mechanism of saving and exporting
- new imgur upload interface.
- rework for a better code structure. It still needs another change separating the Controller from the code dedicated to export data to the system.
- created the concept of "worker", component used to do some work based on a screenshot.
2017-08-16 13:44:33 +02:00
lupoDharkael
924d467c53 general cleanup
-use of the override keyword
-delete unused code
-const correctness
-more uniform code style
-for each with const references when possible
-getters no longer use the word 'get'
-others
2017-08-09 13:20:07 +02:00
lupoDharkael
8870fd1ed4 Add delayed capture support
Adding this option required to modify the dbus API, with this changed I've improved the logic which saves the captures.
2017-07-25 00:05:31 +02:00
lupoDharkael
d4e7c63cb4 Big code refactor
The design was defective and I didn't expect the popularity of the project. After these changes the code will be more mantainable and understandable.

Among the changes we can see:
- A better code structure
- Decoupled button widget from its logic
- More code reuse
- Easier way to add buttons
- Specialized classes
2017-07-19 09:49:24 +02:00
lupoDharkael
ba90513fe7 Add base code for custom filenames 2017-07-11 17:46:22 +02:00