Handle Qt6.6 Deprecations (#4908)

This commit is contained in:
Zach H 2023-10-13 20:53:47 -04:00 committed by GitHub
parent b9cfc29059
commit c1b0d50237
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 4 deletions

View file

@ -470,15 +470,23 @@ void ChatView::showSystemPopup(const QString &userName)
QColor ChatView::getCustomMentionColor() QColor ChatView::getCustomMentionColor()
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
QColor customColor = QColor::fromString("#" + SettingsCache::instance().getChatMentionColor());
#else
QColor customColor; QColor customColor;
customColor.setNamedColor("#" + SettingsCache::instance().getChatMentionColor()); customColor.setNamedColor("#" + SettingsCache::instance().getChatMentionColor());
#endif
return customColor.isValid() ? customColor : DEFAULT_MENTION_COLOR; return customColor.isValid() ? customColor : DEFAULT_MENTION_COLOR;
} }
QColor ChatView::getCustomHighlightColor() QColor ChatView::getCustomHighlightColor()
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
QColor customColor = QColor::fromString("#" + SettingsCache::instance().getChatMentionColor());
#else
QColor customColor; QColor customColor;
customColor.setNamedColor("#" + SettingsCache::instance().getChatHighlightColor()); customColor.setNamedColor("#" + SettingsCache::instance().getChatMentionColor());
#endif
return customColor.isValid() ? customColor : DEFAULT_MENTION_COLOR; return customColor.isValid() ? customColor : DEFAULT_MENTION_COLOR;
} }

View file

@ -65,8 +65,8 @@ private:
QTextCursor prepareBlock(bool same = false); QTextCursor prepareBlock(bool same = false);
void appendCardTag(QTextCursor &cursor, const QString &cardName); void appendCardTag(QTextCursor &cursor, const QString &cardName);
void appendUrlTag(QTextCursor &cursor, QString url); void appendUrlTag(QTextCursor &cursor, QString url);
QColor getCustomMentionColor(); static QColor getCustomMentionColor();
QColor getCustomHighlightColor(); static QColor getCustomHighlightColor();
void showSystemPopup(const QString &userName); void showSystemPopup(const QString &userName);
bool isModeratorSendingGlobal(QFlags<ServerInfo_User::UserLevelFlag> userLevelFlag, QString message); bool isModeratorSendingGlobal(QFlags<ServerInfo_User::UserLevelFlag> userLevelFlag, QString message);
void checkTag(QTextCursor &cursor, QString &message); void checkTag(QTextCursor &cursor, QString &message);

View file

@ -937,8 +937,12 @@ MessagesSettingsPage::MessagesSettingsPage()
void MessagesSettingsPage::updateColor(const QString &value) void MessagesSettingsPage::updateColor(const QString &value)
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
QColor colorToSet = QColor::fromString("#" + value);
#else
QColor colorToSet; QColor colorToSet;
colorToSet.setNamedColor("#" + value); colorToSet.setNamedColor("#" + value);
#endif
if (colorToSet.isValid()) { if (colorToSet.isValid()) {
SettingsCache::instance().setChatMentionColor(value); SettingsCache::instance().setChatMentionColor(value);
updateMentionPreview(); updateMentionPreview();
@ -947,8 +951,12 @@ void MessagesSettingsPage::updateColor(const QString &value)
void MessagesSettingsPage::updateHighlightColor(const QString &value) void MessagesSettingsPage::updateHighlightColor(const QString &value)
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
QColor colorToSet = QColor::fromString("#" + value);
#else
QColor colorToSet; QColor colorToSet;
colorToSet.setNamedColor("#" + value); colorToSet.setNamedColor("#" + value);
#endif
if (colorToSet.isValid()) { if (colorToSet.isValid()) {
SettingsCache::instance().setChatHighlightColor(value); SettingsCache::instance().setChatHighlightColor(value);
updateHighlightPreview(); updateHighlightPreview();

View file

@ -106,7 +106,8 @@ bool Servatrice_DatabaseInterface::checkSql()
if (!sqlDatabase.isValid()) if (!sqlDatabase.isValid())
return false; return false;
if (!sqlDatabase.exec("select 1").isActive()) auto query = QSqlQuery(sqlDatabase);
if (query.exec("select 1") && query.isActive())
return openDatabase(); return openDatabase();
return true; return true;
} }