diff options
| author | David Skoland <davidskoland@gmail.com> | 2018-02-09 01:13:47 +0100 |
|---|---|---|
| committer | David Skoland <davidskoland@gmail.com> | 2018-02-09 01:13:47 +0100 |
| commit | 4ec662d82620945e54c9f7060758bd01b1382644 (patch) | |
| tree | e9ccdf8e0cd6357f83b5fd562c7f602ad49022ed | |
| parent | 403e5b43288dd945ca504d3b0dfeb2757227c879 (diff) | |
renaming some functions and starting qss theme functionality
| -rw-r--r-- | aoapplication.cpp | 8 | ||||
| -rw-r--r-- | aoapplication.h | 14 | ||||
| -rw-r--r-- | courtroom.cpp | 2 | ||||
| -rw-r--r-- | lobby.cpp | 20 | ||||
| -rw-r--r-- | lobby.h | 1 | ||||
| -rw-r--r-- | path_functions.cpp | 2 | ||||
| -rw-r--r-- | text_file_functions.cpp | 11 |
7 files changed, 45 insertions, 13 deletions
diff --git a/aoapplication.cpp b/aoapplication.cpp index e170c990..12e540cd 100644 --- a/aoapplication.cpp +++ b/aoapplication.cpp @@ -86,15 +86,17 @@ void AOApplication::destruct_courtroom() courtroom_constructed = false; } -QString AOApplication::get_version_string(){ +QString AOApplication::get_version_string() +{ return QString::number(RELEASE) + "." + QString::number(MAJOR_VERSION) + "." + QString::number(MINOR_VERSION); } -void AOApplication::set_user_theme(){ - user_theme = read_user_theme(); +void AOApplication::reload_theme() +{ + current_theme = read_theme(); } void AOApplication::set_favorite_list() diff --git a/aoapplication.h b/aoapplication.h index 3d1936c9..e1245607 100644 --- a/aoapplication.h +++ b/aoapplication.h @@ -77,6 +77,8 @@ public: int get_minor_version() {return MINOR_VERSION;} QString get_version_string(); + /////////////////////////////////////////// + void set_favorite_list(); QVector<server_type>& get_favorite_list() {return favorite_list;} void add_favorite_server(int p_server); @@ -84,8 +86,10 @@ public: void set_server_list(); QVector<server_type>& get_server_list() {return server_list;} - void set_user_theme(); - QString get_user_theme() {return user_theme;} + //reads the theme from config.ini and sets it accordingly + void reload_theme(); + + //QString get_theme() {return current_theme;} QString get_current_char(); @@ -103,8 +107,10 @@ public: QString get_evidence_path(); //implementation in text_file_functions.cpp + + QString read_file(QString p_path); QString read_config(QString searchline); - QString read_user_theme(); + QString read_theme(); int read_blip_rate(); bool get_blank_blip(); int get_default_music(); @@ -143,7 +149,7 @@ private: const int MAJOR_VERSION = 4; const int MINOR_VERSION = 8; - QString user_theme = "default"; + QString current_theme = "default"; QVector<server_type> server_list; QVector<server_type> favorite_list; diff --git a/courtroom.cpp b/courtroom.cpp index 74ee6e9f..ca94f434 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -1973,7 +1973,7 @@ void Courtroom::on_change_character_clicked() void Courtroom::on_reload_theme_clicked() { - ao_app->set_user_theme(); + ao_app->reload_theme(); //to update status on the background set_background(current_background); @@ -4,6 +4,7 @@ #include "aoapplication.h" #include "networkmanager.h" #include "aosfxplayer.h" +#include "file_functions.h" #include <QDebug> #include <QScrollBar> @@ -51,14 +52,27 @@ Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow() connect(ui_chatmessage, SIGNAL(returnPressed()), this, SLOT(on_chatfield_return_pressed())); connect(ui_cancel, SIGNAL(clicked()), ao_app, SLOT(loading_cancelled())); - set_widgets(); + //set_widgets(); + set_theme(); +} + +void Lobby::set_theme() +{ + ao_app->reload_theme(); + + //check if our current theme is a valid qss theme + if (!file_exists(ao_app->get_theme_path() + "lobby.qss")) + { + set_widgets(); + return; + } + + this->setStyleSheet(ao_app->read_file(ao_app->get_theme_path() + "lobby.qss")); } //sets images, position and size void Lobby::set_widgets() { - ao_app->set_user_theme(); - QString filename = "lobby_design.ini"; pos_size_type f_lobby = ao_app->get_element_dimensions("lobby", filename); @@ -23,6 +23,7 @@ class Lobby : public QMainWindow public: Lobby(AOApplication *p_ao_app); + void set_theme(); void set_widgets(); void list_servers(); void list_favorites(); diff --git a/path_functions.cpp b/path_functions.cpp index 754ce9e3..6e772dbb 100644 --- a/path_functions.cpp +++ b/path_functions.cpp @@ -53,7 +53,7 @@ QString AOApplication::get_data_path() QString AOApplication::get_theme_path() { - return get_base_path() + "themes/" + user_theme.toLower() + "/"; + return get_base_path() + "themes/" + current_theme.toLower() + "/"; } QString AOApplication::get_default_theme_path() diff --git a/text_file_functions.cpp b/text_file_functions.cpp index 47a9df36..2bc89034 100644 --- a/text_file_functions.cpp +++ b/text_file_functions.cpp @@ -8,6 +8,15 @@ #include <QDebug> #include <QColor> +QString AOApplication::read_file(QString p_path) +{ + QFile file(p_path); + if (!file.open(QFile::ReadOnly)) + return ""; + + return file.readAll(); +} + QString AOApplication::read_config(QString searchline) { QString return_value = ""; @@ -42,7 +51,7 @@ QString AOApplication::read_config(QString searchline) return return_value; } -QString AOApplication::read_user_theme() +QString AOApplication::read_theme() { QString result = read_config("theme"); |
