diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/courtroom.cpp | 38 | ||||
| -rw-r--r-- | src/lobby.cpp | 62 | ||||
| -rw-r--r-- | src/text_file_functions.cpp | 39 |
3 files changed, 132 insertions, 7 deletions
diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 433041c..c87da55 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -709,6 +709,8 @@ void Courtroom::set_widgets() ui_char_select_right->set_image("arrow_right.png"); set_size_and_pos(ui_spectator, "spectator"); + + set_dropdowns(); } void Courtroom::set_fonts() @@ -719,7 +721,7 @@ void Courtroom::set_fonts() set_font(ui_ms_chatlog, "ms_chatlog"); set_font(ui_server_chatlog, "server_chatlog"); set_font(ui_music_list, "music_list"); - set_font(ui_area_list, "music_list"); + set_font(ui_area_list, "area_list"); // Set color of labels and checkboxes const QString design_file = "courtroom_fonts.ini"; @@ -739,21 +741,43 @@ void Courtroom::set_font(QWidget *widget, QString p_identifier) int f_weight = ao_app->get_font_size(p_identifier, design_file); QString class_name = widget->metaObject()->className(); - QString fontt = ao_app->get_font_name(p_identifier + "_font", design_file); - widget->setFont(QFont(fontt, f_weight)); + QString font_name = ao_app->get_font_name(p_identifier + "_font", design_file); + widget->setFont(QFont(font_name, f_weight)); QColor f_color = ao_app->get_color(p_identifier + "_color", design_file); + int bold = ao_app->get_font_size(p_identifier + "_bold", design_file); // is the font bold or not? + + QString is_bold = ""; + if(bold == 1) is_bold = "bold"; + QString style_sheet_string = class_name + " { background-color: rgba(0, 0, 0, 0);\n" + - "color: rgba(" + - QString::number(f_color.red()) + ", " + - QString::number(f_color.green()) + ", " + - QString::number(f_color.blue()) + ", 255); }"; + "color: rgba(" + + QString::number(f_color.red()) + ", " + + QString::number(f_color.green()) + ", " + + QString::number(f_color.blue()) + ", 255);\n" + "font: " + is_bold + "; }"; widget->setStyleSheet(style_sheet_string); } +void Courtroom::set_dropdown(QWidget *widget, QString target_tag) +{ + QString f_file = "courtroom_stylesheets.css"; + QString style_sheet_string = ao_app->get_stylesheet(target_tag, f_file); + if (style_sheet_string != "") + widget->setStyleSheet(style_sheet_string); +} + +void Courtroom::set_dropdowns() +{ + set_dropdown(ui_text_color, "[TEXT COLOR]"); + set_dropdown(ui_pos_dropdown, "[POS DROPDOWN]"); + set_dropdown(ui_emote_dropdown, "[EMOTE DROPDOWN]"); + set_dropdown(ui_mute_list, "[MUTE LIST]"); +} + void Courtroom::set_window_title(QString p_title) { this->setWindowTitle(p_title); diff --git a/src/lobby.cpp b/src/lobby.cpp index 6f257ce..7df2cdc 100644 --- a/src/lobby.cpp +++ b/src/lobby.cpp @@ -153,6 +153,8 @@ void Lobby::set_widgets() ui_loading_background->hide(); + set_fonts(); + set_stylesheets(); } void Lobby::set_size_and_pos(QWidget *p_widget, QString p_identifier) @@ -173,6 +175,66 @@ void Lobby::set_size_and_pos(QWidget *p_widget, QString p_identifier) } } +void Lobby::set_fonts() +{ + set_font(ui_player_count, "player_count"); + set_font(ui_description, "description"); + set_font(ui_chatbox, "chatbox"); + set_font(ui_chatname, "chatname"); + set_font(ui_chatmessage, "chatmessage"); + set_font(ui_loading_text, "loading_text"); + set_font(ui_server_list, "server_list"); +} + +void Lobby::set_stylesheet(QWidget *widget, QString target_tag) +{ + QString f_file = "lobby_stylesheets.css"; + QString style_sheet_string = ao_app->get_stylesheet(target_tag, f_file); + if (style_sheet_string != "") + widget->setStyleSheet(style_sheet_string); +} + +void Lobby::set_stylesheets() +{ + set_stylesheet(ui_player_count, "[PLAYER COUNT]"); + set_stylesheet(ui_description, "[DESCRIPTION]"); + set_stylesheet(ui_chatbox, "[CHAT BOX]"); + set_stylesheet(ui_chatname, "[CHAT NAME]"); + set_stylesheet(ui_chatmessage, "[CHAT MESSAGE]"); + set_stylesheet(ui_loading_text, "[LOADING TEXT]"); + set_stylesheet(ui_server_list, "[SERVER LIST]"); +} + +void Lobby::set_font(QWidget *widget, QString p_identifier) +{ + QString design_file = "lobby_fonts.ini"; + int f_weight = ao_app->get_font_size(p_identifier, design_file); + QString class_name = widget->metaObject()->className(); + QString font_name = ao_app->get_font_name("font_" + p_identifier, design_file); + QFont font(font_name, f_weight); + bool use = static_cast<bool>(ao_app->get_font_size("use_custom_fonts", design_file)); + if(use) + { + widget->setFont(font); + QColor f_color = ao_app->get_color(p_identifier + "_color", design_file); + bool bold = static_cast<bool>(ao_app->get_font_size(p_identifier + "_bold", design_file)); // is the font bold or not? + bool center = static_cast<bool>(ao_app->get_font_size(p_identifier + "_center", design_file)); // should it be centered? + QString is_bold = ""; + if(bold) is_bold = "bold"; + QString is_center = ""; + if(center) is_center = "qproperty-alignment: AlignCenter;"; + QString style_sheet_string = class_name + " { background-color: rgba(0, 0, 0, 0);\n" + + "color: rgba(" + + QString::number(f_color.red()) + ", " + + QString::number(f_color.green()) + ", " + + QString::number(f_color.blue()) + ", 255);\n" + + is_center + "\n" + + "font: " + is_bold + "; }"; + widget->setStyleSheet(style_sheet_string); + } + return; +} + void Lobby::set_loading_text(QString p_text) { ui_loading_text->clear(); diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index ae17ac5..ad82581 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -350,6 +350,45 @@ QColor AOApplication::get_color(QString p_identifier, QString p_file) return return_color; } +QString AOApplication::get_stylesheet(QString target_tag, QString p_file) +{ + QString design_ini_path = get_theme_path(p_file); + + QFile design_ini; + + design_ini.setFileName(design_ini_path); + + if(!design_ini.open(QIODevice::ReadOnly)) + return ""; + + QTextStream in(&design_ini); + + QString f_text; + + bool tag_found = false; + + while(!in.atEnd()) + { + QString line = in.readLine(); + + if (line.startsWith(target_tag, Qt::CaseInsensitive)) + { + tag_found = true; + continue; + } + + if(tag_found) + { + if((line.startsWith("[") && line.endsWith("]"))) + break; + f_text.append(line); + } + } + + design_ini.close(); + return f_text; +} + QColor AOApplication::get_chat_color(QString p_identifier, QString p_chat) { QColor return_color(255, 255, 255); |
