From b2a5f517d979361c5f04182e602155ed4e6439e1 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Thu, 23 Jul 2020 20:28:53 +0300 Subject: [PATCH] Add showname alignment option for theme makers (#189) * Add alignment options for shownames * Make shownames align to the left by default like before * Use this branch as an opportunity to fix showname not being resized according to misc/ folder courtroom_design.ini --- src/courtroom.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index effef54..943a8f8 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -84,7 +84,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_vp_chatbox = new AOImage(this, ao_app); ui_vp_showname = new QLabel(ui_vp_chatbox); - ui_vp_showname->setAlignment(Qt::AlignHCenter); + ui_vp_showname->setAlignment(Qt::AlignLeft); ui_vp_chat_arrow = new AOMovie(ui_vp_chatbox, ao_app); ui_vp_chat_arrow->set_play_once(false); @@ -1873,7 +1873,7 @@ void Courtroom::handle_chatmessage_2() { ui_vp_chatbox->set_image("chatblank"); } - else // Aw yeah dude do some showname resizing magic + else // Aw yeah dude do some showname magic { if (!ui_vp_chatbox->set_image("chat")) ui_vp_chatbox->set_image("chatbox"); @@ -1913,6 +1913,19 @@ void Courtroom::handle_chatmessage_2() ->get_design_element("showname_extra_width", "courtroom_design.ini", customchar) .toInt(); + QString align = + ao_app + ->get_design_element("showname_align", "courtroom_design.ini", + customchar) + .toLower(); + if (align == "right") + ui_vp_showname->setAlignment(Qt::AlignRight); + else if (align == "center") + ui_vp_showname->setAlignment(Qt::AlignHCenter); + else if (align == "justify") + ui_vp_showname->setAlignment(Qt::AlignHCenter); + else + ui_vp_showname->setAlignment(Qt::AlignLeft); if (extra_width > 0) { if (fm_width > default_width.width && @@ -1934,6 +1947,10 @@ void Courtroom::handle_chatmessage_2() else ui_vp_showname->resize(default_width.width, ui_vp_showname->height()); } + else + { + ui_vp_showname->resize(default_width.width, ui_vp_showname->height()); + } } ui_vp_message->hide();