renaming some functions and starting qss theme functionality
This commit is contained in:
		
							parent
							
								
									403e5b4328
								
							
						
					
					
						commit
						4ec662d826
					
				@ -86,15 +86,17 @@ void AOApplication::destruct_courtroom()
 | 
				
			|||||||
  courtroom_constructed = false;
 | 
					  courtroom_constructed = false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QString AOApplication::get_version_string(){
 | 
					QString AOApplication::get_version_string()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
  return
 | 
					  return
 | 
				
			||||||
  QString::number(RELEASE) + "." +
 | 
					  QString::number(RELEASE) + "." +
 | 
				
			||||||
  QString::number(MAJOR_VERSION) + "." +
 | 
					  QString::number(MAJOR_VERSION) + "." +
 | 
				
			||||||
  QString::number(MINOR_VERSION);
 | 
					  QString::number(MINOR_VERSION);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void AOApplication::set_user_theme(){
 | 
					void AOApplication::reload_theme()
 | 
				
			||||||
  user_theme = read_user_theme();
 | 
					{
 | 
				
			||||||
 | 
					  current_theme = read_theme();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void AOApplication::set_favorite_list()
 | 
					void AOApplication::set_favorite_list()
 | 
				
			||||||
 | 
				
			|||||||
@ -77,6 +77,8 @@ public:
 | 
				
			|||||||
  int get_minor_version() {return MINOR_VERSION;}
 | 
					  int get_minor_version() {return MINOR_VERSION;}
 | 
				
			||||||
  QString get_version_string();
 | 
					  QString get_version_string();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ///////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void set_favorite_list();
 | 
					  void set_favorite_list();
 | 
				
			||||||
  QVector<server_type>& get_favorite_list() {return favorite_list;}
 | 
					  QVector<server_type>& get_favorite_list() {return favorite_list;}
 | 
				
			||||||
  void add_favorite_server(int p_server);
 | 
					  void add_favorite_server(int p_server);
 | 
				
			||||||
@ -84,8 +86,10 @@ public:
 | 
				
			|||||||
  void set_server_list();
 | 
					  void set_server_list();
 | 
				
			||||||
  QVector<server_type>& get_server_list() {return server_list;}
 | 
					  QVector<server_type>& get_server_list() {return server_list;}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void set_user_theme();
 | 
					  //reads the theme from config.ini and sets it accordingly
 | 
				
			||||||
  QString get_user_theme() {return user_theme;}
 | 
					  void reload_theme();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //QString get_theme() {return current_theme;}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  QString get_current_char();
 | 
					  QString get_current_char();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -103,8 +107,10 @@ public:
 | 
				
			|||||||
  QString get_evidence_path();
 | 
					  QString get_evidence_path();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //implementation in text_file_functions.cpp
 | 
					  //implementation in text_file_functions.cpp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  QString read_file(QString p_path);
 | 
				
			||||||
  QString read_config(QString searchline);
 | 
					  QString read_config(QString searchline);
 | 
				
			||||||
  QString read_user_theme();
 | 
					  QString read_theme();
 | 
				
			||||||
  int read_blip_rate();
 | 
					  int read_blip_rate();
 | 
				
			||||||
  bool get_blank_blip();
 | 
					  bool get_blank_blip();
 | 
				
			||||||
  int get_default_music();
 | 
					  int get_default_music();
 | 
				
			||||||
@ -143,7 +149,7 @@ private:
 | 
				
			|||||||
  const int MAJOR_VERSION = 4;
 | 
					  const int MAJOR_VERSION = 4;
 | 
				
			||||||
  const int MINOR_VERSION = 8;
 | 
					  const int MINOR_VERSION = 8;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  QString user_theme = "default";
 | 
					  QString current_theme = "default";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  QVector<server_type> server_list;
 | 
					  QVector<server_type> server_list;
 | 
				
			||||||
  QVector<server_type> favorite_list;
 | 
					  QVector<server_type> favorite_list;
 | 
				
			||||||
 | 
				
			|||||||
@ -1973,7 +1973,7 @@ void Courtroom::on_change_character_clicked()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void Courtroom::on_reload_theme_clicked()
 | 
					void Courtroom::on_reload_theme_clicked()
 | 
				
			||||||
{ 
 | 
					{ 
 | 
				
			||||||
  ao_app->set_user_theme();
 | 
					  ao_app->reload_theme();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //to update status on the background
 | 
					  //to update status on the background
 | 
				
			||||||
  set_background(current_background);
 | 
					  set_background(current_background);
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										18
									
								
								lobby.cpp
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								lobby.cpp
									
									
									
									
									
								
							@ -4,6 +4,7 @@
 | 
				
			|||||||
#include "aoapplication.h"
 | 
					#include "aoapplication.h"
 | 
				
			||||||
#include "networkmanager.h"
 | 
					#include "networkmanager.h"
 | 
				
			||||||
#include "aosfxplayer.h"
 | 
					#include "aosfxplayer.h"
 | 
				
			||||||
 | 
					#include "file_functions.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QDebug>
 | 
					#include <QDebug>
 | 
				
			||||||
#include <QScrollBar>
 | 
					#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_chatmessage, SIGNAL(returnPressed()), this, SLOT(on_chatfield_return_pressed()));
 | 
				
			||||||
  connect(ui_cancel, SIGNAL(clicked()), ao_app, SLOT(loading_cancelled()));
 | 
					  connect(ui_cancel, SIGNAL(clicked()), ao_app, SLOT(loading_cancelled()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //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();
 | 
					    set_widgets();
 | 
				
			||||||
 | 
					    return;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  this->setStyleSheet(ao_app->read_file(ao_app->get_theme_path() + "lobby.qss"));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//sets images, position and size
 | 
					//sets images, position and size
 | 
				
			||||||
void Lobby::set_widgets()
 | 
					void Lobby::set_widgets()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  ao_app->set_user_theme();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  QString filename = "lobby_design.ini";
 | 
					  QString filename = "lobby_design.ini";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  pos_size_type f_lobby = ao_app->get_element_dimensions("lobby", filename);
 | 
					  pos_size_type f_lobby = ao_app->get_element_dimensions("lobby", filename);
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										1
									
								
								lobby.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								lobby.h
									
									
									
									
									
								
							@ -23,6 +23,7 @@ class Lobby : public QMainWindow
 | 
				
			|||||||
public:
 | 
					public:
 | 
				
			||||||
  Lobby(AOApplication *p_ao_app);
 | 
					  Lobby(AOApplication *p_ao_app);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void set_theme();
 | 
				
			||||||
  void set_widgets();
 | 
					  void set_widgets();
 | 
				
			||||||
  void list_servers();
 | 
					  void list_servers();
 | 
				
			||||||
  void list_favorites();
 | 
					  void list_favorites();
 | 
				
			||||||
 | 
				
			|||||||
@ -53,7 +53,7 @@ QString AOApplication::get_data_path()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
QString AOApplication::get_theme_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()
 | 
					QString AOApplication::get_default_theme_path()
 | 
				
			||||||
 | 
				
			|||||||
@ -8,6 +8,15 @@
 | 
				
			|||||||
#include <QDebug>
 | 
					#include <QDebug>
 | 
				
			||||||
#include <QColor>
 | 
					#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 AOApplication::read_config(QString searchline)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  QString return_value = "";
 | 
					  QString return_value = "";
 | 
				
			||||||
@ -42,7 +51,7 @@ QString AOApplication::read_config(QString searchline)
 | 
				
			|||||||
  return return_value;
 | 
					  return return_value;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QString AOApplication::read_user_theme()
 | 
					QString AOApplication::read_theme()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  QString result = read_config("theme");
 | 
					  QString result = read_config("theme");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user