From d5fa97c3bbf569346959de8778d51c3073cd3383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Hohnst=C3=A4dt?= Date: Mon, 26 Apr 2021 18:23:39 +0200 Subject: [PATCH] Drop support for Qt4 Version 2.4.0 was the last one with Qt4 support --- configure.ac | 21 +++++++++++---------- lib/base.h | 4 ---- lib/func.cpp | 10 ---------- lib/func.h | 9 --------- lib/main.cpp | 17 +++-------------- lib/sql.cpp | 4 ---- widgets/Help.cpp | 8 -------- widgets/MW_help.cpp | 4 ++-- widgets/XcaApplication.cpp | 5 ----- widgets/XcaHeaderView.cpp | 4 ---- widgets/XcaTreeView.cpp | 4 ---- widgets/clicklabel.cpp | 4 ---- widgets/kvView.cpp | 4 ---- 13 files changed, 16 insertions(+), 82 deletions(-) diff --git a/configure.ac b/configure.ac index b3853b5c..938664da 100644 --- a/configure.ac +++ b/configure.ac @@ -149,12 +149,13 @@ if test -n "${_QTDIR}" && test -d "${_QTDIR}"; then fi AC_ARG_WITH([qt-version], - AS_HELP_STRING([--with-qt-version], [Select the Qt version]), + AS_HELP_STRING([--with-qt-version], + [Select the Qt version: 5 or 6 if both are installed]), [WANT_QT_VERSION="$withval"], [WANT_QT_VERSION=detect]) if test "${WANT_QT_VERSION}" = detect -o "${WANT_QT_VERSION}" = 5; then - PKG_CHECK_MODULES(Qt5, [Qt5Core >= 5.0 Qt5Widgets >= 5.0 Qt5Sql >= 5.0 Qt5Help >= 5.0], [ + PKG_CHECK_MODULES(Qt5, [Qt5Core Qt5Widgets Qt5Sql Qt5Help], [ _QT_HOST_BINS="`pkg-config --variable=host_bins Qt5Core`" QT_MOC="${_QT_HOST_BINS}/moc" QT_UIC="${_QT_HOST_BINS}/uic" @@ -170,8 +171,8 @@ if test "${WANT_QT_VERSION}" = detect -o "${WANT_QT_VERSION}" = 5; then ],[ : ]) fi -if test "${WANT_QT_VERSION}" = detect -o "${WANT_QT_VERSION}" = 4; then - PKG_CHECK_MODULES(Qt4, [QtCore >= 4.7 QtCore < 5.0 QtGui >= 4.7 QtGui < 5.0 QtSql >= 4.7 QtSql < 5.0 QtHelp < 5.0], [ +if test "${WANT_QT_VERSION}" = detect -o "${WANT_QT_VERSION}" = 6; then + PKG_CHECK_MODULES(Qt6, [Qt6Core Qt6Gui Qt6Sql Qt6Help], [ QT_MOC="`pkg-config --variable=moc_location QtCore`" QT_UIC="`pkg-config --variable=uic_location QtCore`" if test -n "${QT_MOC}"; then @@ -179,13 +180,13 @@ if test "${WANT_QT_VERSION}" = detect -o "${WANT_QT_VERSION}" = 4; then fi if test "$HOST" = "DARWIN"; then FRAMEDIR=`pkg-config --variable=libdir QtCore` - Qt4_CFLAGS="$Qt4_CFLAGS -F${FRAMEDIR} -I${FRAMEDIR}/QtCore.framework/Headers -I${FRAMEDIR}/QtGui.framework/Headers -I${FRAMEDIR}/QtSql.framework/Headers" - Qt4_LDFLAGS=" -Xlinker -rpath -Xlinker ${FRAMEDIR}" + Qt6_CFLAGS="$Qt4_CFLAGS -F${FRAMEDIR} -I${FRAMEDIR}/QtCore.framework/Headers -I${FRAMEDIR}/QtGui.framework/Headers -I${FRAMEDIR}/QtSql.framework/Headers" + Qt6_LDFLAGS=" -Xlinker -rpath -Xlinker ${FRAMEDIR}" fi - WANT_QT_VERSION=4 - QT_VERSION=4 - QT_CFLAGS="${Qt4_CFLAGS}" - QT_LIBS="${Qt4_LIBS}${Qt4_LDFLAGS}" + WANT_QT_VERSION=6 + QT_VERSION=6 + QT_CFLAGS="${Qt6_CFLAGS}" + QT_LIBS="${Qt6_LIBS}${Qt6_LDFLAGS}" ],[ : ]) fi diff --git a/lib/base.h b/lib/base.h index ed6adb84..6d3c4d18 100644 --- a/lib/base.h +++ b/lib/base.h @@ -31,11 +31,7 @@ #define C_FILE ((strrchr(__FILE__, '/') ? : __FILE__- 1) + 1) #define TRACE qDebug("File: %s Func: %s Line: %d", C_FILE, __func__, __LINE__); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #define nativeSeparator(s) QDir::toNativeSeparators(s) -#else -#define nativeSeparator(s) QDir::convertSeparators(s) -#endif #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0])) #define MIN(a,b) ((a)<(b)) ? (a) : (b) diff --git a/lib/func.cpp b/lib/func.cpp index 60c16c33..6610e84b 100644 --- a/lib/func.cpp +++ b/lib/func.cpp @@ -22,11 +22,7 @@ #if defined(Q_OS_MAC) #include - #if QT_VERSION < 0x050000 -#include - #else #include - #endif #endif #include #include @@ -318,16 +314,10 @@ const QString getUserSettingsDir() rv = portable_app() ? getPrefix() + "/settings" : specialFolder(CSIDL_APPDATA) + "/xca"; #elif defined(Q_OS_MAC) - #if QT_VERSION < 0x050000 - rv = QDesktopServices::storageLocation(QDesktopServices::DataLocation); - rv.insert(rv.count() - QCoreApplication::applicationName().count(), - QCoreApplication::organizationName()); - #else rv = QStandardPaths::writableLocation( QStandardPaths::GenericDataLocation) + "/data/" + QCoreApplication::organizationName() + "/" + QCoreApplication::applicationName(); - #endif #else rv = QDir::homePath() + "/.xca"; #endif diff --git a/lib/func.h b/lib/func.h index e4013486..4ff76c95 100644 --- a/lib/func.h +++ b/lib/func.h @@ -85,15 +85,6 @@ void *d2i_bytearray(void *(*d2i)(void*, unsigned char**, long), #define I2D_VOID(a) ((int (*)(const void *, unsigned char **))(a)) #define D2I_VOID(a) ((void *(*)(void *, unsigned char **, long))(a)) -static inline QString htmlEscape(const QString &html) -{ -#if QT_VERSION < 0x050000 - return Qt::escape(html); -#else - return html.toHtmlEscaped(); -#endif -} - QString appendXcaComment(QString current, QString msg); /* from version.cpp */ diff --git a/lib/main.cpp b/lib/main.cpp index e5d4edbd..0bb16a45 100644 --- a/lib/main.cpp +++ b/lib/main.cpp @@ -55,7 +55,8 @@ static void segv_handler_gui(int) } #endif -void myMsgOutput(QtMsgType type, const char *msg) +void myMessageOutput(QtMsgType type, const QMessageLogContext &, + const QString &msg) { static QElapsedTimer *t; static int abort_on_warning = -1; @@ -83,27 +84,19 @@ void myMsgOutput(QtMsgType type, const char *msg) case QtWarningMsg: warn_msg = "WARNING"; severity = COL_LRED "Warning"; break; case QtCriticalMsg: warn_msg = "CRITICAL"; severity = COL_RED "Critical"; break; case QtFatalMsg: warn_msg = "FATAL"; severity = COL_RED "Fatal"; break; -#if QT_VERSION >= 0x050000 case QtInfoMsg: severity = COL_CYAN "Info"; break; -#endif default: severity = COL_CYAN "Default"; break; } console_write(stderr, QString(COL_YELL "%1%2 %3:" COL_RESET " %4\n") .arg(el/1000, 4) .arg((el%1000)/100, 2, 10, QChar('0')) - .arg(severity).arg(QString::fromUtf8(msg)).toUtf8()); + .arg(severity).arg(msg).toUtf8()); if (abort_on_warning == 1 && warn_msg) { qFatal("Abort on %s", warn_msg); } } -#if QT_VERSION >= 0x050000 -void myMessageOutput(QtMsgType t, const QMessageLogContext &, const QString &m) -{ - myMsgOutput(t, m.toUtf8().constData()); -} -#endif static void cmd_version(FILE *fp) { @@ -305,11 +298,7 @@ int main(int argc, char *argv[]) puts(CCHAR(arguments::doc(xca_special))); return 0; } -#if QT_VERSION < 0x050000 - qInstallMsgHandler(myMsgOutput); -#else qInstallMessageHandler(myMessageOutput); -#endif #if defined(Q_OS_WIN32) AttachConsole(-1); diff --git a/lib/sql.cpp b/lib/sql.cpp index 17ab51a7..44829748 100644 --- a/lib/sql.cpp +++ b/lib/sql.cpp @@ -171,11 +171,7 @@ QSqlError XSqlQuery::lastError() return QSqlError(QString("%1 - %2").arg(e.driverText()) .arg(query_details()), e.databaseText(), e.type(), -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) e.nativeErrorCode() -#else - e.number() -#endif ); } diff --git a/widgets/Help.cpp b/widgets/Help.cpp index 0d987efe..494d7bdd 100644 --- a/widgets/Help.cpp +++ b/widgets/Help.cpp @@ -30,15 +30,7 @@ Help::~Help() void Help::display(const QUrl &url) { -#if QT_VERSION < 0x050000 - QString path = url.path(); - int pos = path.lastIndexOf("/"); - if (pos != -1) - path = path.mid(pos+1); - textbox->setSource(QUrl(path)); -#else textbox->setSource(QUrl(url.fileName())); -#endif textbox->scrollToAnchor(url.fragment()); show(); raise(); diff --git a/widgets/MW_help.cpp b/widgets/MW_help.cpp index 00eb3c91..ddb6e497 100644 --- a/widgets/MW_help.cpp +++ b/widgets/MW_help.cpp @@ -101,8 +101,8 @@ void MainWindow::about() QString lang(QLocale::languageToString(QLocale(sl[0]).language())); QStringList row { QString("%1").arg(lang), - htmlEscape(sl[2]), - htmlEscape(email), + sl[2].toHtmlEscaped(), + email.toHtmlEscaped(), }; rows << tag[0] + row.join(tag[0] + tag[1]) + tag[1]; } diff --git a/widgets/XcaApplication.cpp b/widgets/XcaApplication.cpp index 30b13488..a3f9d660 100644 --- a/widgets/XcaApplication.cpp +++ b/widgets/XcaApplication.cpp @@ -98,13 +98,8 @@ void XcaApplication::setupLanguage(QLocale l) #endif << getI18nDir() #ifndef WIN32 -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) << "/usr/local/share/qt5/translations/" << "/usr/share/qt5/translations/" -#else - << "/usr/local/share/qt4/translations/" - << "/usr/share/qt4/translations/" -#endif << "/usr/share/qt/translations/" #endif ; diff --git a/widgets/XcaHeaderView.cpp b/widgets/XcaHeaderView.cpp index 041c7610..720e7382 100644 --- a/widgets/XcaHeaderView.cpp +++ b/widgets/XcaHeaderView.cpp @@ -13,11 +13,7 @@ XcaHeaderView::XcaHeaderView() :QHeaderView(Qt::Horizontal) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) setSectionsMovable(true); -#else - setMovable(true); -#endif } void XcaHeaderView::contextMenuEvent(QContextMenuEvent *e) diff --git a/widgets/XcaTreeView.cpp b/widgets/XcaTreeView.cpp index 9d6fb3cc..2b74e389 100644 --- a/widgets/XcaTreeView.cpp +++ b/widgets/XcaTreeView.cpp @@ -41,11 +41,7 @@ XcaTreeView::XcaTreeView(QWidget *parent) this, SLOT(resizeColumnToContents(int))); connect(this, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(doubleClick(const QModelIndex &))); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) header()->setSectionsClickable(true); -#else - header()->setClickable(true); -#endif throttle.setSingleShot(true); connect(&throttle, SIGNAL(timeout()), this, SLOT(columnsResize())); connect(&throttle, SIGNAL(timeout()), proxy, SLOT(invalidate())); diff --git a/widgets/clicklabel.cpp b/widgets/clicklabel.cpp index 6a6bf116..ea2134cc 100644 --- a/widgets/clicklabel.cpp +++ b/widgets/clicklabel.cpp @@ -73,12 +73,8 @@ CopyLabel::CopyLabel(QWidget *parent) { setFrameStyle(QFrame::StyledPanel); setTextFormat(Qt::PlainText); - -#if QT_VERSION >= 0x040200 setTextInteractionFlags( Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard ); -#endif } - diff --git a/widgets/kvView.cpp b/widgets/kvView.cpp index ce8753f3..d1dbe274 100644 --- a/widgets/kvView.cpp +++ b/widgets/kvView.cpp @@ -168,11 +168,7 @@ kvView::kvView(QWidget *parent) setAlternatingRowColors(true); horizontalHeader()->setDefaultSectionSize(200); horizontalHeader()->setStretchLastSection(true); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) verticalHeader()->setSectionsMovable(true); -#else - verticalHeader()->setMovable(true); -#endif verticalHeader()->setDefaultSectionSize(24); setEditTriggers(QAbstractItemView::AllEditTriggers);