Add Qt 5.9 compatibility (#202)
* Added Ubuntu 18 backwards compatibility Co-authored-by: Cents02 <Cents02@Cents0.me>
This commit is contained in:
parent
949a323903
commit
abe80513d8
@ -11,8 +11,11 @@ void AOLineEdit::mouseDoubleClickEvent(QMouseEvent *e)
|
|||||||
void AOLineEdit::focusOutEvent(QFocusEvent *ev)
|
void AOLineEdit::focusOutEvent(QFocusEvent *ev)
|
||||||
{
|
{
|
||||||
int start = selectionStart();
|
int start = selectionStart();
|
||||||
int len = selectionEnd() - start; // We're not using selectionLength because
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||||
// Linux build doesn't run qt5.10
|
int len = selectionLength();
|
||||||
|
#else
|
||||||
|
int len = selectedText().length();
|
||||||
|
#endif
|
||||||
QLineEdit::focusOutEvent(ev);
|
QLineEdit::focusOutEvent(ev);
|
||||||
if (p_selection && start != -1 && len != -1)
|
if (p_selection && start != -1 && len != -1)
|
||||||
this->setSelection(start, len);
|
this->setSelection(start, len);
|
||||||
|
@ -1903,8 +1903,12 @@ void Courtroom::handle_chatmessage_2()
|
|||||||
ui_vp_chatbox->set_image("chatbox");
|
ui_vp_chatbox->set_image("chatbox");
|
||||||
|
|
||||||
QFontMetrics fm(ui_vp_showname->font());
|
QFontMetrics fm(ui_vp_showname->font());
|
||||||
|
// Gotta support the slow paced ubuntu 18 STUCK IN 5.9.5!!
|
||||||
|
#if QT_VERSION > QT_VERSION_CHECK(5, 11, 0)
|
||||||
int fm_width = fm.horizontalAdvance(ui_vp_showname->text());
|
int fm_width = fm.horizontalAdvance(ui_vp_showname->text());
|
||||||
|
#else
|
||||||
|
int fm_width = fm.boundingRect((ui_vp_showname->text())).width();
|
||||||
|
#endif
|
||||||
QString chatbox_path = ao_app->get_theme_path("chat");
|
QString chatbox_path = ao_app->get_theme_path("chat");
|
||||||
QString chatbox = ao_app->get_chat(m_chatmessage[CHAR_NAME]);
|
QString chatbox = ao_app->get_chat(m_chatmessage[CHAR_NAME]);
|
||||||
QString customchar;
|
QString customchar;
|
||||||
@ -1917,7 +1921,8 @@ void Courtroom::handle_chatmessage_2()
|
|||||||
ui_vp_chatbox->set_chatbox(chatbox_path + "box");
|
ui_vp_chatbox->set_chatbox(chatbox_path + "box");
|
||||||
}
|
}
|
||||||
|
|
||||||
//This should probably be called only if any change from the last chat arrow was actually detected.
|
// This should probably be called only if any change from the last chat
|
||||||
|
// arrow was actually detected.
|
||||||
pos_size_type design_ini_result = ao_app->get_element_dimensions(
|
pos_size_type design_ini_result = ao_app->get_element_dimensions(
|
||||||
"chat_arrow", "courtroom_design.ini", customchar);
|
"chat_arrow", "courtroom_design.ini", customchar);
|
||||||
if (design_ini_result.width < 0 || design_ini_result.height < 0) {
|
if (design_ini_result.width < 0 || design_ini_result.height < 0) {
|
||||||
@ -3051,11 +3056,13 @@ void Courtroom::handle_song(QStringList *p_contents)
|
|||||||
(f_song_clear.lastIndexOf("/") + 1));
|
(f_song_clear.lastIndexOf("/") + 1));
|
||||||
int n_char = f_contents.at(1).toInt();
|
int n_char = f_contents.at(1).toInt();
|
||||||
|
|
||||||
//Assume the song doesn't loop unless told otherwise (due to most outdated servers handling looping through serverside)
|
// Assume the song doesn't loop unless told otherwise (due to most outdated
|
||||||
|
// servers handling looping through serverside)
|
||||||
bool looping = false;
|
bool looping = false;
|
||||||
//Channel 0 is the 'master music', other channels would commonly be used for ambience
|
// Channel 0 is the 'master music', other channels would commonly be used for
|
||||||
|
// ambience
|
||||||
int channel = 0;
|
int channel = 0;
|
||||||
//No effects assumed by default - vanilla functionality
|
// No effects assumed by default - vanilla functionality
|
||||||
int effect_flags = 0;
|
int effect_flags = 0;
|
||||||
|
|
||||||
if (n_char < 0 || n_char >= char_list.size()) {
|
if (n_char < 0 || n_char >= char_list.size()) {
|
||||||
@ -4340,7 +4347,12 @@ void Courtroom::on_text_color_changed(int p_color)
|
|||||||
if (markdown_end.isEmpty())
|
if (markdown_end.isEmpty())
|
||||||
markdown_end = markdown_start;
|
markdown_end = markdown_start;
|
||||||
int start = ui_ic_chat_message->selectionStart();
|
int start = ui_ic_chat_message->selectionStart();
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||||
int end = ui_ic_chat_message->selectionEnd() + 1;
|
int end = ui_ic_chat_message->selectionEnd() + 1;
|
||||||
|
#else
|
||||||
|
int end = ui_ic_chat_message->selectedText().length() + 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
ui_ic_chat_message->setCursorPosition(start);
|
ui_ic_chat_message->setCursorPosition(start);
|
||||||
ui_ic_chat_message->insert(markdown_start);
|
ui_ic_chat_message->insert(markdown_start);
|
||||||
ui_ic_chat_message->setCursorPosition(end);
|
ui_ic_chat_message->setCursorPosition(end);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
|
||||||
|
|
||||||
#if (defined(_WIN32) || defined(_WIN64))
|
#if (defined(_WIN32) || defined(_WIN64))
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -34,8 +34,12 @@ void ScrollText::setSeparator(QString separator)
|
|||||||
void ScrollText::updateText()
|
void ScrollText::updateText()
|
||||||
{
|
{
|
||||||
timer.stop();
|
timer.stop();
|
||||||
|
#if QT_VERSION > QT_VERSION_CHECK(5, 11, 0)
|
||||||
singleTextWidth = fontMetrics().horizontalAdvance(_text);
|
singleTextWidth = fontMetrics().horizontalAdvance(_text);
|
||||||
|
#else
|
||||||
|
singleTextWidth = fontMetrics().boundingRect(_text).width();
|
||||||
|
#endif
|
||||||
|
|
||||||
scrollEnabled = (singleTextWidth > width() - leftMargin * 2);
|
scrollEnabled = (singleTextWidth > width() - leftMargin * 2);
|
||||||
|
|
||||||
if (scrollEnabled) {
|
if (scrollEnabled) {
|
||||||
@ -47,8 +51,14 @@ void ScrollText::updateText()
|
|||||||
staticText.setText(_text);
|
staticText.setText(_text);
|
||||||
|
|
||||||
staticText.prepare(QTransform(), font());
|
staticText.prepare(QTransform(), font());
|
||||||
|
#if QT_VERSION > QT_VERSION_CHECK(5, 11, 0)
|
||||||
wholeTextSize = QSize(fontMetrics().horizontalAdvance(staticText.text()),
|
wholeTextSize = QSize(fontMetrics().horizontalAdvance(staticText.text()),
|
||||||
fontMetrics().height());
|
fontMetrics().height());
|
||||||
|
#else
|
||||||
|
wholeTextSize = QSize(fontMetrics().boundingRect(staticText.text()).width(),
|
||||||
|
fontMetrics().height());
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScrollText::paintEvent(QPaintEvent *)
|
void ScrollText::paintEvent(QPaintEvent *)
|
||||||
|
Loading…
Reference in New Issue
Block a user