diff --git a/src/huggle_core/generic.cpp b/src/huggle_core/generic.cpp index ae1c31d33..4416e55a0 100644 --- a/src/huggle_core/generic.cpp +++ b/src/huggle_core/generic.cpp @@ -15,6 +15,11 @@ #include "exception.hpp" #include "hooks.hpp" #include "localization.hpp" +#ifdef QT6_BUILD +#include +#else +#include +#endif using namespace Huggle; @@ -210,3 +215,15 @@ bool Generic::SecondsToTimeSpan(int time, int *days, int *hours, int *minutes, i *seconds = remaining_time; return true; } + +bool Generic::RegexExactMatch(const QString& regex, const QString& input_text) +{ +#ifdef QT6_BUILD + QRegularExpression re(regex); + QRegularExpressionMatch match = re.match(input_text); + return match.hasMatch() && (match.captured(0) == input_text); +#else + QRegEx re(regex); + return re.exactMatch(input_text); +#endif +} diff --git a/src/huggle_core/generic.hpp b/src/huggle_core/generic.hpp index 0bb9f7f8b..6ce2392de 100644 --- a/src/huggle_core/generic.hpp +++ b/src/huggle_core/generic.hpp @@ -60,6 +60,8 @@ namespace Huggle * \return new string */ HUGGLE_EX_CORE QString ShrinkText(const QString &text, int size, bool html = true, int minimum = 2); + + HUGGLE_EX_CORE bool RegexExactMatch(const QString& regex, const QString& input_text); } } diff --git a/src/huggle_ui/blockuserform.cpp b/src/huggle_ui/blockuserform.cpp index ce683c044..6507287b0 100644 --- a/src/huggle_ui/blockuserform.cpp +++ b/src/huggle_ui/blockuserform.cpp @@ -8,10 +8,11 @@ //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. -#include "blockuserform.hpp" #include #include #include +#include "ui_blockuserform.h" +#include "blockuserform.hpp" #include #include #include @@ -24,7 +25,6 @@ #include #include #include -#include "ui_blockuserform.h" #include "mainwindow.hpp" #include "history.hpp" #include "uigeneric.hpp" diff --git a/src/huggle_ui/blockuserform.hpp b/src/huggle_ui/blockuserform.hpp index aa06a93b5..7e01b1ac6 100644 --- a/src/huggle_ui/blockuserform.hpp +++ b/src/huggle_ui/blockuserform.hpp @@ -11,9 +11,9 @@ #ifndef BLOCKUSER_H #define BLOCKUSER_H +#include #include -#include #include #include #include "hw.hpp" @@ -31,7 +31,7 @@ namespace Huggle class ApiQuery; //! This form can be used to block users from editing, which requires the block permission - class BlockUserForm : public HW + class HUGGLE_EX_UI BlockUserForm : public HW { Q_OBJECT public: diff --git a/src/huggle_ui/custommessage.cpp b/src/huggle_ui/custommessage.cpp index 40e362aa4..e65726b4e 100644 --- a/src/huggle_ui/custommessage.cpp +++ b/src/huggle_ui/custommessage.cpp @@ -8,12 +8,12 @@ //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. +#include "ui_custommessage.h" #include "custommessage.hpp" #include #include #include #include -#include "ui_custommessage.h" using namespace Huggle; diff --git a/src/huggle_ui/custommessage.hpp b/src/huggle_ui/custommessage.hpp index 3aa444ba8..042275467 100644 --- a/src/huggle_ui/custommessage.hpp +++ b/src/huggle_ui/custommessage.hpp @@ -12,6 +12,7 @@ #define CUSTOMMESSAGE_H #include +#include #include "hw.hpp" namespace Ui @@ -24,7 +25,7 @@ namespace Huggle class WikiUser; //! This form can be used to send a custom message to users - class CustomMessage : public HW + class HUGGLE_EX_UI CustomMessage : public HW { Q_OBJECT public: diff --git a/src/huggle_ui/editbaritem.cpp b/src/huggle_ui/editbaritem.cpp index 7d4a718be..ba03d9b1a 100644 --- a/src/huggle_ui/editbaritem.cpp +++ b/src/huggle_ui/editbaritem.cpp @@ -60,7 +60,11 @@ void EditBarItem::SetFrame(Qt::GlobalColor colour) { //this->setStyleSheet("QFrame { border-color: " + color + " }"); QPalette px; +#ifdef QT6_BUILD + px.setColor(QPalette::WindowText, colour); +#else px.setColor(QPalette::Foreground, colour); +#endif this->setPalette(px); } diff --git a/src/huggle_ui/hugglelog.cpp b/src/huggle_ui/hugglelog.cpp index 92f1e1482..5079d06be 100644 --- a/src/huggle_ui/hugglelog.cpp +++ b/src/huggle_ui/hugglelog.cpp @@ -8,6 +8,7 @@ //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. +#include "ui_hugglelog.h" #include "hugglelog.hpp" #include #include @@ -16,7 +17,6 @@ #include #include #include -#include "ui_hugglelog.h" using namespace Huggle; @@ -24,7 +24,11 @@ HuggleLog::HuggleLog(QWidget *parent) : QDockWidget(parent), ui(new Ui::HuggleLo { this->ui->setupUi(this); this->setWindowTitle(_l("logs-widget-name")); +#ifdef QT6_BUILD + this->lock = new HMUTEX_TYPE(); +#else this->lock = new QMutex(QMutex::Recursive); +#endif this->ui->textEdit->setUndoRedoEnabled(false); this->ui->textEdit->resize(this->ui->textEdit->width(), 60); this->Modified = false; diff --git a/src/huggle_ui/hugglelog.hpp b/src/huggle_ui/hugglelog.hpp index 050056516..748c0d8df 100644 --- a/src/huggle_ui/hugglelog.hpp +++ b/src/huggle_ui/hugglelog.hpp @@ -18,7 +18,7 @@ #include -class QMutex; +class HMUTEX_TYPE; namespace Ui { @@ -42,7 +42,7 @@ namespace Huggle bool Modified; private: - QMutex *lock; + HMUTEX_TYPE* lock; QList Text; Ui::HuggleLog *ui; }; diff --git a/src/huggle_ui/hw.hpp b/src/huggle_ui/hw.hpp index f38f08648..39daeae72 100644 --- a/src/huggle_ui/hw.hpp +++ b/src/huggle_ui/hw.hpp @@ -11,9 +11,9 @@ #ifndef HW_HPP #define HW_HPP -#include #include #include +#include namespace Huggle { diff --git a/src/huggle_ui/reportuser.cpp b/src/huggle_ui/reportuser.cpp index 1680e8c23..b9b20457d 100644 --- a/src/huggle_ui/reportuser.cpp +++ b/src/huggle_ui/reportuser.cpp @@ -18,7 +18,11 @@ #include "blockuserform.hpp" #include "ui_reportuser.h" #include +#ifdef QT6_BUILD +#include +#else #include +#endif #include #include #include @@ -594,9 +598,14 @@ void Huggle::ReportUser::on_pushButton_6_clicked() bool ReportUser::checkUserIsReported() { QString regex = this->reportedUser->GetSite()->GetProjectConfig()->ReportUserCheckPattern; - regex.replace("$username", QRegExp::escape(this->reportedUser->Username)); - QRegExp pattern(regex); + regex.replace("$username", HREGEX_TYPE::escape(this->reportedUser->Username)); + HREGEX_TYPE pattern(regex); +#ifdef QT6_BUILD + QRegularExpressionMatch match = pattern.match(this->reportContent); + return match.hasMatch() && (match.captured(0) == this->reportContent); +#else return pattern.exactMatch(this->reportContent); +#endif } void ReportUser::insertUser() diff --git a/src/huggle_ui/requestprotect.cpp b/src/huggle_ui/requestprotect.cpp index 68b542fc4..4a677d691 100644 --- a/src/huggle_ui/requestprotect.cpp +++ b/src/huggle_ui/requestprotect.cpp @@ -71,8 +71,7 @@ void RequestProtect::Tick() // make a regex out of the pattern string QString regex_str = this->page->GetSite()->GetProjectConfig()->RFPP_Regex; regex_str.replace("$title", this->page->PageName); - QRegExp rx(regex_str); - if (rx.exactMatch(PageText)) + if (Generic::RegexExactMatch(regex_str, PageText)) { this->Fail(_l("reqprotection-duplicate")); return; diff --git a/src/huggle_ui/requestprotect.hpp b/src/huggle_ui/requestprotect.hpp index 35217b7b4..7a7a084bc 100644 --- a/src/huggle_ui/requestprotect.hpp +++ b/src/huggle_ui/requestprotect.hpp @@ -15,7 +15,6 @@ #include #include "hw.hpp" -#include #include #include #include diff --git a/src/huggle_ui/updateform.cpp b/src/huggle_ui/updateform.cpp index f2199d8f0..c613eec97 100644 --- a/src/huggle_ui/updateform.cpp +++ b/src/huggle_ui/updateform.cpp @@ -522,7 +522,9 @@ static HUGGLE_LPCSTR QString2Msdn(QString text) #ifdef UNICODE wchar_t *temp = (wchar_t*)calloc(text.length() + 1, sizeof(wchar_t)); text.toWCharArray(temp); - return _wcsdup(_T(temp)); + wchar_t* result = _wcsdup(temp); // Duplicate the wchar_t array + free(temp); // Free the initially allocated memory + return result; #else QByteArray byte_array = text.toLocal8Bit(); return _strdup(byte_array.constData()); diff --git a/src/huggle_ui/whitelistform.cpp b/src/huggle_ui/whitelistform.cpp index dcc6f29a5..f8cc15dda 100644 --- a/src/huggle_ui/whitelistform.cpp +++ b/src/huggle_ui/whitelistform.cpp @@ -48,7 +48,7 @@ void WhitelistForm::OnTick() while (this->Whitelist.count() > 0 && i < 200) { QString xx = this->Whitelist.at(0); - xx = xx.replace(QRegExp("[^\\w\\s]"), ""); + xx = xx.replace(HREGEX_TYPE("[^\\w\\s]"), ""); this->ui->listWidget->addItem(xx); this->Whitelist.removeAt(0); i++;