Skip to content

Commit

Permalink
Update: Dark Theme & Storage functions
Browse files Browse the repository at this point in the history
  • Loading branch information
srilakshmikanthanp committed Aug 27, 2023
1 parent a5d1853 commit 25a12ee
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 40 deletions.
14 changes: 7 additions & 7 deletions assets/styles/dark.qss
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
/*********************** Common to All ************************/

QFrame, QWidget {
background: #272727;
background: #1e1e1e;
color: #FFFFFF;
font-family: sans-serif;
margin: 2px 0px 2px 0px;
font-weight: 500;
}

QFrame {
background: #272727;
background: #1e1e1e;
border-radius: 8px;
}

Expand Down Expand Up @@ -49,11 +49,11 @@ QTabWidget::tab-bar {
}

QTabBar::tab {
border-bottom: 3px solid #272727;
border-bottom: 3px solid #1e1e1e;
color: #0000;
padding: 6px;
margin: 2px;
background-color: #272727;
background-color: #1e1e1e;
}

QTabBar::tab:selected {
Expand Down Expand Up @@ -97,7 +97,7 @@ QScrollBar::sub-page:vertical {
}

QMenu {
background-color: #272727;
background-color: #1e1e1e;
border: none;
border-radius: 5px;
padding: 6px;
Expand All @@ -106,7 +106,7 @@ QMenu {
}

QMenu::item {
background-color: #272727;
background-color: #1e1e1e;
color: #FFFFFF;
border: none;
border-radius: 5px;
Expand All @@ -121,6 +121,6 @@ QMenu::item:selected {
}

QMenu::item:disabled {
background-color: #272727;
background-color: #1e1e1e;
color: gray;
}
59 changes: 55 additions & 4 deletions store/storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,23 @@ Storage::Storage(QObject *parent) : QObject(parent) {
* @param hostname
* @param token
*/
void Storage::setClientToken(const QString &hostname, const QString &token) {
void Storage::setClientCert(const QString &hostname, const QString &token) {
settings->beginGroup(clientGroup);
settings->setValue(hostname, token);
settings->endGroup();
}

/**
* @brief has the cert for the hostname
*/
bool Storage::hasClientCert(const QString &hostname) {
settings->beginGroup(clientGroup);
auto token = settings->value(hostname);
settings->endGroup();

return !token.isNull();
}

/**
* @brief Get the JWT token for the hostname
*
Expand All @@ -35,7 +46,7 @@ void Storage::setClientToken(const QString &hostname, const QString &token) {
*
* @throw std::invalid_argument if hostname not found
*/
QString Storage::getClientToken(const QString &hostname) {
QString Storage::getClientCert(const QString &hostname) {
settings->beginGroup(clientGroup);
auto token = settings->value(hostname);
settings->endGroup();
Expand All @@ -53,12 +64,23 @@ QString Storage::getClientToken(const QString &hostname) {
* @param hostname
* @param token
*/
void Storage::setServerToken(const QString &hostname, const QString &token) {
void Storage::setServerCert(const QString &hostname, const QString &token) {
settings->beginGroup(serverGroup);
settings->setValue(hostname, token);
settings->endGroup();
}

/**
* @brief has the cert for the hostname
*/
bool Storage::hasServerCert(const QString &hostname) {
settings->beginGroup(serverGroup);
auto token = settings->value(hostname);
settings->endGroup();

return !token.isNull();
}

/**
* @brief Get the JWT token for the hostname
*
Expand All @@ -67,7 +89,7 @@ void Storage::setServerToken(const QString &hostname, const QString &token) {
*
* @throw std::invalid_argument if hostname not found
*/
QString Storage::getServerToken(const QString &hostname) {
QString Storage::getServerCert(const QString &hostname) {
settings->beginGroup(serverGroup);
auto token = settings->value(hostname);
settings->endGroup();
Expand All @@ -78,4 +100,33 @@ QString Storage::getServerToken(const QString &hostname) {

return token.toString();
}

/**
* @brief Set the current state of the server or client
*
* @param isServer
*/
void Storage::setHostIsServer(bool isServer) {
settings->beginGroup(generalGroup);
settings->setValue(hostStateKey, isServer);
settings->endGroup();
}

/**
* @brief Get the current state of the server or client
*
* @return true if server
* @return false if client
*/
bool Storage::getHostIsServer() {
settings->beginGroup(generalGroup);
auto isServer = settings->value(hostStateKey);
settings->endGroup();

if (isServer.isNull()) {
return false;
}

return isServer.toBool();
}
} // namespace srilakshmikanthanp::clipbirdesk::storage
66 changes: 37 additions & 29 deletions store/storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@

namespace srilakshmikanthanp::clipbirdesk::storage {
class Storage : public QObject {
private: // variables
private: // settings

QSettings *settings = new QSettings("srilakshmikanthanp", "clipbird");
const char* clientGroup = "client";
const char* serverGroup = "server";

private: // groups
const char* clientGroup = "client";
const char* generalGroup = "general";
const char* serverGroup = "server";

private: // keys
const char* hostStateKey = "hostState";

private: // qt

Expand All @@ -22,8 +28,6 @@ class Storage : public QObject {

/**
* @brief Construct a new SQLStore object
*
* @param parent
*/
Storage(QObject *parent = nullptr);

Expand All @@ -33,40 +37,44 @@ class Storage : public QObject {
virtual ~Storage() = default;

/**
* @brief Store Client hostname and JWT token
*
* @param hostname
* @param token
* @brief Store Client hostname and JWT cert
*/
void setClientCert(const QString &hostname, const QString &cert);

/**
* @brief has the cert for the hostname
*/
bool hasClientCert(const QString &hostname);

/**
* @brief Get the JWT cert for the hostname
*/
QString getClientCert(const QString &hostname);

/**
* @brief Store the server hostname and JWT cert
*/
void setServerCert(const QString &hostname, const QString &cert);

/**
* @brief has the cert for the hostname
*/
void setClientToken(const QString &hostname, const QString &token);
bool hasServerCert(const QString &hostname);

/**
* @brief Get the JWT token for the hostname
*
* @param hostname
* @return QString
*
* @throw std::invalid_argument if hostname not found
* @brief Get the JWT cert for the hostname
*/
QString getClientToken(const QString &hostname);
QString getServerCert(const QString &hostname);

/**
* @brief Store the server hostname and JWT token
*
* @param hostname
* @param token
* @brief Set the current state of the server or client
*/
void setServerToken(const QString &hostname, const QString &token);
void setHostIsServer(bool isServer);

/**
* @brief Get the JWT token for the hostname
*
* @param hostname
* @return QString
*
* @throw std::invalid_argument if hostname not found
* @brief Get the current state of the server or client
*/
QString getServerToken(const QString &hostname);
bool getHostIsServer();
};

} // namespace srilakshmikanthanp::clipbirdesk::storage

0 comments on commit 25a12ee

Please sign in to comment.