-
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.
Added APISettings class. Implemented functionality of Settings Dialog.
- Loading branch information
Ugnius
committed
Jun 14, 2018
1 parent
647986e
commit b33a60d
Showing
13 changed files
with
326 additions
and
23 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
<!DOCTYPE RCC> | ||
<RCC version="1.0"> | ||
<qresource> | ||
<file>resources/configs/api.ini</file> | ||
<file>resources/languages.json</file> | ||
</qresource> | ||
</RCC> |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#include "apisettings.h" | ||
|
||
APISettings::APISettings(QObject *parent) | ||
: QObject(parent) { | ||
} | ||
|
||
APISettings::APISettings(QObject *parent, const QString &name, const QString &fullName) | ||
: QObject(parent), name(name), fullName(fullName) { | ||
} | ||
|
||
APISettings::~APISettings() { | ||
} | ||
|
||
void APISettings::readSettings() { | ||
if (name == "") { | ||
throw std::invalid_argument("API name has not been set."); | ||
} | ||
QSettings settings; | ||
apiKey = settings.value(name + "/key", "API_KEY").toString(); | ||
textType = settings.value(name + "/text_type", "text").toString(); | ||
defaultSourceLanguage = settings.value(name + "/source", "lt").toString(); | ||
defaultTargetLanguage = settings.value(name + "/target", "en").toString(); | ||
} | ||
|
||
void APISettings::writeSettings() { | ||
if (name == "") { | ||
throw std::invalid_argument("API name has not been set."); | ||
} | ||
QSettings settings; | ||
settings.setValue(name + "/key", apiKey); | ||
settings.setValue(name + "/text_type", textType); | ||
settings.setValue(name + "/source", defaultSourceLanguage); | ||
settings.setValue(name + "/target", defaultTargetLanguage); | ||
} | ||
|
||
QString APISettings::getName() const { | ||
return name; | ||
} | ||
|
||
void APISettings::setName(const QString &name) { | ||
this->name = name; | ||
} | ||
|
||
QString APISettings::getFullName() const { | ||
return fullName; | ||
} | ||
|
||
void APISettings::setFullName(const QString &fullName) { | ||
this->fullName = fullName; | ||
} | ||
|
||
QString APISettings::getApiKey() const { | ||
return apiKey; | ||
} | ||
|
||
void APISettings::setApiKey(const QString &apiKey) { | ||
this->apiKey = apiKey; | ||
} | ||
|
||
QString APISettings::getTextType() const { | ||
return textType; | ||
} | ||
|
||
void APISettings::setTextType(const QString &textType) { | ||
this->textType = textType; | ||
} | ||
|
||
QString APISettings::getDefaultSourceLanguage() const { | ||
return defaultSourceLanguage; | ||
} | ||
|
||
void APISettings::setDefaultSourceLanguage(const QString &defaultSourceLanguage) { | ||
this->defaultSourceLanguage = defaultSourceLanguage; | ||
} | ||
|
||
QString APISettings::getDefaultTargetLanguage() const { | ||
return defaultTargetLanguage; | ||
} | ||
|
||
void APISettings::setDefaultTargetLanguage(const QString &defaultTargetLanguage) { | ||
this->defaultTargetLanguage = defaultTargetLanguage; | ||
} |
Oops, something went wrong.