fixed a bug related to image scaling

This commit is contained in:
David Skoland 2017-03-02 12:03:38 +01:00
parent 26660a7b86
commit 9ccb75e5f8
6 changed files with 32 additions and 41 deletions

View File

@ -143,6 +143,7 @@ void AOCharMovie::stop()
{ {
//for all intents and purposes, stopping is the same as hiding. at no point do we want a frozen gif to display //for all intents and purposes, stopping is the same as hiding. at no point do we want a frozen gif to display
m_movie->stop(); m_movie->stop();
preanim_timer->stop();
this->hide(); this->hide();
} }

View File

@ -9,7 +9,7 @@ AOEvidenceButton::AOEvidenceButton(QWidget *p_parent, AOApplication *p_ao_app, i
ui_selector = new AOImage(p_parent, ao_app); ui_selector = new AOImage(p_parent, ao_app);
ui_selector->resize(71, 71); ui_selector->resize(71, 71);
ui_selector->move(p_x - 1, p_y - 1); ui_selector->move(p_x - 1, p_y - 1);
ui_selector->set_scaled_image("evidence_selector.png"); ui_selector->set_image("evidence_selector.png");
ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents); ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents);
ui_selector->hide(); ui_selector->hide();

View File

@ -20,10 +20,16 @@ void AOImage::set_image(QString p_image)
QString theme_image_path = ao_app->get_theme_path() + p_image; QString theme_image_path = ao_app->get_theme_path() + p_image;
QString default_image_path = ao_app->get_default_theme_path() + p_image; QString default_image_path = ao_app->get_default_theme_path() + p_image;
QString final_image_path;
if (file_exists(theme_image_path)) if (file_exists(theme_image_path))
this->setPixmap(theme_image_path); final_image_path = theme_image_path;
else else
this->setPixmap(default_image_path); final_image_path = default_image_path;
QPixmap f_pixmap(final_image_path);
this->setPixmap(f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio));
} }
void AOImage::set_image_from_path(QString p_path) void AOImage::set_image_from_path(QString p_path)
@ -41,20 +47,3 @@ void AOImage::set_image_from_path(QString p_path)
this->setPixmap(f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio)); this->setPixmap(f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio));
} }
void AOImage::set_scaled_image(QString p_image)
{
QString theme_image_path = ao_app->get_theme_path() + p_image;
QString default_image_path = ao_app->get_default_theme_path() + p_image;
QString final_image_path;
if (file_exists(theme_image_path))
final_image_path = theme_image_path;
else
final_image_path = default_image_path;
QPixmap f_pixmap(final_image_path);
this->setPixmap(f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio));
}

View File

@ -18,7 +18,6 @@ public:
void set_image(QString p_image); void set_image(QString p_image);
void set_image_from_path(QString p_path); void set_image_from_path(QString p_path);
void set_scaled_image(QString p_image);
void set_size_and_pos(QString identifier); void set_size_and_pos(QString identifier);
}; };

View File

@ -359,7 +359,7 @@ void Courtroom::set_widgets()
ui_background->move(0, 0); ui_background->move(0, 0);
ui_background->resize(m_courtroom_width, m_courtroom_height); ui_background->resize(m_courtroom_width, m_courtroom_height);
ui_background->set_scaled_image("courtroombackground.png"); ui_background->set_image("courtroombackground.png");
set_size_and_pos(ui_viewport, "viewport"); set_size_and_pos(ui_viewport, "viewport");
@ -399,7 +399,7 @@ void Courtroom::set_widgets()
ui_vp_realization->move(ui_viewport->x(), ui_viewport->y()); ui_vp_realization->move(ui_viewport->x(), ui_viewport->y());
ui_vp_realization->resize(ui_viewport->width(), ui_viewport->height()); ui_vp_realization->resize(ui_viewport->width(), ui_viewport->height());
ui_vp_realization->set_scaled_image("realizationflash.png"); ui_vp_realization->set_image("realizationflash.png");
ui_vp_realization->hide(); ui_vp_realization->hide();
ui_vp_wtce->move(ui_viewport->x(), ui_viewport->y()); ui_vp_wtce->move(ui_viewport->x(), ui_viewport->y());
@ -440,7 +440,7 @@ void Courtroom::set_widgets()
ui_ic_chat_message->setStyleSheet("QLineEdit{background-color: rgba(100, 100, 100, 255);}"); ui_ic_chat_message->setStyleSheet("QLineEdit{background-color: rgba(100, 100, 100, 255);}");
ui_vp_chatbox->set_scaled_image("chatmed.png"); ui_vp_chatbox->set_image("chatmed.png");
ui_vp_chatbox->hide(); ui_vp_chatbox->hide();
ui_muted->resize(ui_ic_chat_message->width(), ui_ic_chat_message->height()); ui_muted->resize(ui_ic_chat_message->width(), ui_ic_chat_message->height());
@ -540,38 +540,36 @@ void Courtroom::set_widgets()
set_size_and_pos(ui_evidence_button, "evidence_button"); set_size_and_pos(ui_evidence_button, "evidence_button");
ui_evidence_button->set_image("evidencebutton.png"); ui_evidence_button->set_image("evidencebutton.png");
//ui_evidence_button->setText("Evidence");
set_size_and_pos(ui_evidence, "evidence_background"); set_size_and_pos(ui_evidence, "evidence_background");
ui_evidence->set_image("evidencebackground.png"); ui_evidence->set_image("evidencebackground.png");
//char select stuff under here //char select stuff under here
ui_char_select_background->set_image("charselect_background.png");
ui_char_select_background->move(0, 0); ui_char_select_background->move(0, 0);
ui_char_select_background->resize(m_courtroom_width, m_courtroom_height); ui_char_select_background->resize(m_courtroom_width, m_courtroom_height);
ui_char_select_background->set_image("charselect_background.png");
//buttons are in the constructor //buttons are in the constructor
ui_selector->set_image("char_selector.png"); ui_selector->set_image("char_selector.png");
ui_selector->hide(); ui_selector->hide();
ui_back_to_lobby->setText("Back to Lobby");
set_size_and_pos(ui_back_to_lobby, "back_to_lobby"); set_size_and_pos(ui_back_to_lobby, "back_to_lobby");
ui_back_to_lobby->setText("Back to Lobby");
set_size_and_pos(ui_char_password, "char_password"); set_size_and_pos(ui_char_password, "char_password");
ui_char_select_left->set_image("arrow_left.png");
ui_char_select_left->move(2, 325); ui_char_select_left->move(2, 325);
ui_char_select_left->resize(20, 20); ui_char_select_left->resize(20, 20);
ui_char_select_left->set_image("arrow_left.png");
ui_char_select_right->set_image("arrow_right.png");
ui_char_select_right->move(691, 325); ui_char_select_right->move(691, 325);
ui_char_select_right->resize(20, 20); ui_char_select_right->resize(20, 20);
ui_char_select_right->set_image("arrow_right.png");
ui_spectator->setText("Spectator");
set_size_and_pos(ui_spectator, "spectator"); set_size_and_pos(ui_spectator, "spectator");
ui_spectator->setText("Spectator");
} }
void Courtroom::set_fonts() void Courtroom::set_fonts()
@ -1056,6 +1054,9 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
text_state = 0; text_state = 0;
anim_state = 0; anim_state = 0;
ui_vp_objection->stop();
ui_vp_player_char->stop();
chat_tick_timer->stop();
chatmessage_is_empty = m_chatmessage[MESSAGE] == " " || m_chatmessage[MESSAGE] == ""; chatmessage_is_empty = m_chatmessage[MESSAGE] == " " || m_chatmessage[MESSAGE] == "";
@ -1133,7 +1134,7 @@ void Courtroom::handle_chatmessage_2()
QString chatbox = ao_app->get_chat(m_chatmessage[CHAR_NAME]); QString chatbox = ao_app->get_chat(m_chatmessage[CHAR_NAME]);
if (chatbox == "") if (chatbox == "")
ui_vp_chatbox->set_scaled_image("chatmed.png"); ui_vp_chatbox->set_image("chatmed.png");
else else
{ {
QString chatbox_path = ao_app->get_base_path() + "misc/" + chatbox + ".png"; QString chatbox_path = ao_app->get_base_path() + "misc/" + chatbox + ".png";

View File

@ -59,29 +59,29 @@ void Lobby::set_widgets()
{ {
ao_app->set_user_theme(); ao_app->set_user_theme();
ui_background->set_image("lobbybackground.png");
ui_background->resize(m_lobby_width, m_lobby_height); ui_background->resize(m_lobby_width, m_lobby_height);
ui_background->set_image("lobbybackground.png");
ui_public_servers->set_image("publicservers_selected.png");
set_size_and_pos(ui_public_servers, "public_servers"); set_size_and_pos(ui_public_servers, "public_servers");
ui_public_servers->set_image("publicservers_selected.png");
ui_favorites->set_image("favorites.png");
set_size_and_pos(ui_favorites, "favorites"); set_size_and_pos(ui_favorites, "favorites");
ui_favorites->set_image("favorites.png");
ui_refresh->set_image("refresh.png");
set_size_and_pos(ui_refresh, "refresh"); set_size_and_pos(ui_refresh, "refresh");
ui_refresh->set_image("refresh.png");
ui_add_to_fav->set_image("addtofav.png");
set_size_and_pos(ui_add_to_fav, "add_to_fav"); set_size_and_pos(ui_add_to_fav, "add_to_fav");
ui_add_to_fav->set_image("addtofav.png");
ui_connect->set_image("connect.png");
set_size_and_pos(ui_connect, "connect"); set_size_and_pos(ui_connect, "connect");
ui_connect->set_image("connect.png");
ui_version->setText("Version: " + ao_app->get_version_string());
set_size_and_pos(ui_version, "version"); set_size_and_pos(ui_version, "version");
ui_version->setText("Version: " + ao_app->get_version_string());
ui_about->set_image("about.png");
set_size_and_pos(ui_about, "about"); set_size_and_pos(ui_about, "about");
ui_about->set_image("about.png");
set_size_and_pos(ui_server_list, "server_list"); set_size_and_pos(ui_server_list, "server_list");
ui_server_list->setStyleSheet("background-color: rgba(0, 0, 0, 0);" ui_server_list->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
@ -110,8 +110,9 @@ void Lobby::set_widgets()
ui_chatmessage->setStyleSheet("background-color: rgba(0, 0, 0, 0);" ui_chatmessage->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
"selection-background-color: rgba(0, 0, 0, 0);"); "selection-background-color: rgba(0, 0, 0, 0);");
ui_loading_background->set_image("loadingbackground.png");
ui_loading_background->resize(m_lobby_width, m_lobby_height); ui_loading_background->resize(m_lobby_width, m_lobby_height);
ui_loading_background->set_image("loadingbackground.png");
set_size_and_pos(ui_loading_text, "loading_label"); set_size_and_pos(ui_loading_text, "loading_label");
ui_loading_text->setFont(QFont("Arial", 20, QFont::Bold)); ui_loading_text->setFont(QFont("Arial", 20, QFont::Bold));