renaming some functions and starting qss theme functionality

This commit is contained in:
David Skoland 2018-02-09 01:13:47 +01:00
parent 403e5b4328
commit 4ec662d826
7 changed files with 45 additions and 13 deletions

View File

@ -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()

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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();

View File

@ -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()

View File

@ -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");