Don't hard code application name, properly assign object owners, Qt handles delete
This commit is contained in:
parent
1ae74460cf
commit
4a885c347d
5 changed files with 7 additions and 12 deletions
|
@ -21,7 +21,7 @@ Settings::Settings(QObject *parent) : QObject(parent)
|
|||
{
|
||||
// Use the same file location as GUI for data exchange
|
||||
if(!mySettings) {
|
||||
mySettings = new QSettings("harbour-batterybuddy", "harbour-batterybuddy");
|
||||
mySettings = new QSettings(appName, appName, this);
|
||||
}
|
||||
|
||||
// Read in the values
|
||||
|
|
|
@ -68,6 +68,7 @@ public:
|
|||
|
||||
private:
|
||||
QSettings *mySettings = nullptr;
|
||||
const char* appName = APP_NAME;
|
||||
|
||||
// Default values
|
||||
int lowAlert = 25;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
MyNotification::MyNotification(QObject* parent) : QObject(parent)
|
||||
{
|
||||
notification.setAppName("Battery Buddy");
|
||||
notification.setAppIcon("harbour-batterybuddy");
|
||||
notification.setAppIcon(APP_NAME);
|
||||
playSound = false;
|
||||
sound.setAudioRole(QAudio::NotificationRole);
|
||||
connect(&sound, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
|
||||
|
|
|
@ -21,7 +21,7 @@ Settings::Settings(QObject *parent) : QObject(parent)
|
|||
{
|
||||
// Use the same file location as GUI for data exchange
|
||||
if(!mySettings) {
|
||||
mySettings = new QSettings("harbour-batterybuddy", "harbour-batterybuddy");
|
||||
mySettings = new QSettings(appName, appName, this);
|
||||
}
|
||||
|
||||
qDebug() << "Using" << mySettings->fileName();
|
||||
|
@ -79,14 +79,7 @@ Settings::Settings(QObject *parent) : QObject(parent)
|
|||
// so we must monitor it and update when it changes.
|
||||
}
|
||||
|
||||
Settings::~Settings()
|
||||
{
|
||||
delete mySettings;
|
||||
}
|
||||
|
||||
int Settings::bound(int value, int min, int max) {
|
||||
return (value <= min ? min : (value >= max ? max : value));
|
||||
}
|
||||
Settings::~Settings() { }
|
||||
|
||||
bool Settings::loadInteger(const char* key, int *value, int min, int max) {
|
||||
oldValue = *value;
|
||||
|
@ -101,7 +94,7 @@ void Settings::updateConfig(QString path) {
|
|||
|
||||
// Use the same file location as GUI for data exchange
|
||||
if(!mySettings) {
|
||||
mySettings = new QSettings("harbour-batterybuddy", "harbour-batterybuddy");
|
||||
mySettings = new QSettings(appName, appName, this);
|
||||
}
|
||||
|
||||
qDebug() << "Reading values...";
|
||||
|
|
|
@ -50,6 +50,7 @@ public:
|
|||
private:
|
||||
QSettings* mySettings = nullptr;
|
||||
QFileSystemWatcher *watcher = nullptr;
|
||||
const char* appName = APP_NAME;
|
||||
|
||||
int oldValue;
|
||||
|
||||
|
|
Loading…
Reference in a new issue