Closed crizzitello closed 2 years ago
If we don't switch over to using QSettings is any of the rest of this worthwhile? What is the benefit to using QSettings over JSON? Go doesn't have an ini parser as part of the std library and we'd need to update aterm in order to make this change.
If we don't switch over to using QSettings is any of the rest of this worthwhile?
Yes some of this can be applied to the old code. The singleton pattern, use of QStrings, the CONFIG struct
What is the benefit to using QSettings over JSON?
QSettings makes the code alot easier to read and is really the class made for Settings. We can read or write a single value instead of always reading the full file. QSettings does allow us to define a QSettings "Backend", The default is to use a system backend ( conf on linux and registry on windows).
Go doesn't have an ini parser as part of the std library and we'd need to update aterm in order to make this change.
Parsing the ini format is pretty easy. Values can be a bit different if we store things like QtObjects. The keys without a /
are put in the "general" section.
[General]
accessKey=xxxxxxxxxxxxxxxxxxxxxxxx
apiURL=http://localhost:3000
captureClipboardShortcut=Ctrl+Alt+3
captureWindowExec=spectacle -a -bno %file
captureWindowShortcut=Ctrl+Alt+2
evidenceRepo=/home/chris/evidence
screenshotCommand=spectacle -r -bno %file
screenshotShortcut=Ctrl+Alt+1
secretKey="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
other sections could be in the file these depend on the key string used for example a keys of screenshot/command
and screenshot/shortcut
would put in the file
[screenshot]
command=value
shortcut=value
Now with a json backend.
Currently Does
CONFIG
members as interface to the keys.QStandardDirs::AppLocalDataLocation
WithQStandardDirs::GenericDataLocation/ashirt
QString operationName()
QString operationSlug()
void setOperationDetails(const QString &operationSlug, const QString &operationName)
QList<model::Tag> getLastUsedTags()
void setLastUsedTags(QList<model::Tag> lastTags)
operationChanged(QString operationSlug, QString operationName)