From 513b39b7188ddb582467a182f56d1a3ab9c38c20 Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <vital.had@gmail.com>
Date: Tue, 3 Dec 2024 11:58:13 +0800
Subject: [PATCH] Restore Qt4 support

---
 configure.ac                | 95 +++++++++++++++++++++++++++++--------
 src/qjackctlGraph.cpp       |  4 ++
 src/qjackctlGraphForm.cpp   |  4 ++
 src/qjackctlMainForm.cpp    | 54 +++++++++++++++++++++
 src/qjackctlPaletteForm.cpp | 24 ++++++++++
 src/qjackctlPatchbay.cpp    |  8 +++-
 src/qjackctlSessionForm.cpp |  4 ++
 src/qjackctlSetupForm.cpp   | 25 ++++++++++
 src/qjackctlSocketForm.cpp  |  8 ++++
 src/src.pro                 |  7 ++-
 10 files changed, 211 insertions(+), 22 deletions(-)

diff --git configure.ac configure.ac
index e9f98cd..d238f79 100644
--- configure.ac
+++ configure.ac
@@ -77,6 +77,11 @@ else
 fi
 AC_SUBST(ac_debug)
 
+# Enable Qt4/5 availability.
+AC_ARG_ENABLE(qt4,
+  AS_HELP_STRING([--enable-qt4], [enable Qt4 build (default=no)]),
+  [ac_qt4="$enableval"],
+  [ac_qt4="no"])
 
 # Disable system tray argument option.
 AC_ARG_ENABLE(system_tray,
@@ -161,16 +166,32 @@ ac_path=$PATH
 ac_pkg_config_path=$PKG_CONFIG_PATH
 ac_with_paths=""
 
-# Set for alternate Qt installation dir.
+# Set for alternate Qt4/5 installation dir.
 AC_ARG_WITH(qt,
   AS_HELP_STRING([--with-qt=PATH], [use alternate Qt install path]),
   [ac_qt_path="$withval"], [ac_qt_path="no"])
 
+AC_ARG_WITH(qt4,
+  AS_HELP_STRING([--with-qt4=PATH], [use alternate Qt4 install path]),
+  [ac_qt4_path="$withval"], [ac_qt4_path="no"])
+AC_ARG_WITH(qt5,
+  AS_HELP_STRING([--with-qt5=PATH], [use alternate Qt5 install path]),
+  [ac_qt5_path="$withval"], [ac_qt5_path="no"])
+
 if test "x$ac_qt_path" != "xno"; then
    ac_path="$ac_qt_path/bin:$ac_path"
    ac_pkg_config_path="$ac_qt_path/lib/pkgconfig:$ac_pkg_config_path"
 fi
 
+if test "x$ac_qt4_path" != "xno"; then
+   ac_path="$ac_qt4_path/bin:$ac_path"
+   ac_qt4="yes"
+fi
+if test "x$ac_qt5_path" != "xno"; then
+   ac_path="$ac_qt5_path/bin:$ac_path"
+   ac_qt4="no"
+fi
+
 # Set for alternate JACK installation dir.
 AC_ARG_WITH(jack,
   AS_HELP_STRING([--with-jack=PATH], [use alternate JACK install path]),
@@ -269,8 +290,13 @@ fi
 # Check for proper qmake path/version alternatives.
 AC_PATH_TOOL(ac_qmake, qmake, [no], $ac_path)
 if test "x$ac_qmake" = "xno"; then
-   AC_PATH_TOOL(ac_cv_qmake, qmake-qt5, [no], $ac_path)
-   ac_qmake=$ac_cv_qmake
+   if test "x$ac_qt4" = "xyes"; then
+      AC_PATH_TOOL(ac_cv_qmake, qmake-qt4, [no], $ac_path)
+      ac_qmake=$ac_cv_qmake
+   else
+      AC_PATH_TOOL(ac_cv_qmake, qmake-qt5, [no], $ac_path)
+      ac_qmake=$ac_cv_qmake
+   fi
 fi
 
 # Check for proper Qt major version.
@@ -279,13 +305,24 @@ AC_CACHE_CHECK([for Qt major version], [ac_cv_qt_version_major], [
    ac_cv_qt_version_major=$(($ac_cv_qt_version_major + 0))
 ])
 ac_qt_version_major=$ac_cv_qt_version_major
-if test $ac_qt_version_major -lt 5; then
-	AC_PATH_TOOL(ac_cv_qmake, qmake-qt5, [no], $ac_path)
-	ac_qmake=$ac_cv_qmake
+if test "x$ac_qt4" = "xyes"; then
+   if test $ac_qt_version_major -ne 4; then
+      AC_PATH_TOOL(ac_cv_qmake, qmake-qt4, [no], $ac_path)
+      ac_qmake=$ac_cv_qmake
+   fi
+else
+   if test $ac_qt_version_major -ne 5; then
+      AC_PATH_TOOL(ac_cv_qmake, qmake-qt5, [no], $ac_path)
+      ac_qmake=$ac_cv_qmake
+   fi
 fi
 
 if test "x$ac_qmake" = "xno"; then
-   AC_MSG_ERROR([qmake-qt5 $ac_errmsg (qt5-devel)])
+   if test "x$ac_qt4" = "xyes"; then
+      AC_MSG_ERROR([qmake-qt4 $ac_errmsg (qt4-devel)])
+   else
+      AC_MSG_ERROR([qmake-qt5 $ac_errmsg (qt5-devel)])
+   fi
 fi
 
 # Check for proper Qt install path.
@@ -325,18 +362,32 @@ if test -d $ac_qt_install_libs; then
    ac_libs="-L$ac_qt_install_libs $ac_libs"
 fi
 
-# Finally, check for proper Qt version.
-AC_CACHE_CHECK([for Qt library version >= 5.1],
-   ac_cv_qtversion, [
-   AC_TRY_COMPILE([#include "QtCore/qglobal.h"], [
-      #if QT_VERSION < 0x050100
-      #error Qt library 5.1 or greater required.
-      #endif
-   ], ac_cv_qtversion="yes", [
-      echo "no; Qt 5.1 or greater is required"
-      exit 1
+# Finally, check for proper Qt4/5 version.
+if test "x$ac_qt4" = "xyes"; then
+   AC_CACHE_CHECK([for Qt library version >= 4.4],
+      ac_cv_qtversion, [
+      AC_TRY_COMPILE([#include "QtCore/qglobal.h"], [
+         #if QT_VERSION < 0x040400 || QT_VERSION >= 0x050000
+         #error Qt library 4.4 or greater required.
+         #endif
+      ], ac_cv_qtversion="yes", [
+         echo "no; Qt 4.4 or greater is required"
+         exit 1
+      ])
    ])
-])
+else
+   AC_CACHE_CHECK([for Qt library version >= 5.1],
+      ac_cv_qtversion, [
+      AC_TRY_COMPILE([#include "QtCore/qglobal.h"], [
+         #if QT_VERSION < 0x050100 || QT_VERSION >= 0x060000
+         #error Qt library 5.1 or greater required.
+         #endif
+      ], ac_cv_qtversion="yes", [
+         echo "no; Qt 5.1 or greater is required"
+         exit 1
+      ])
+   ])
+fi
 
 # Check for Qt moc utility.
 AC_PATH_TOOL(ac_moc, moc, [no], $ac_path)
@@ -492,7 +543,11 @@ fi
 
 # Check D-Bus interface support.
 if test "x$ac_dbus" = "xyes"; then
-   PKG_CHECK_MODULES([QT5DBUS], [Qt5DBus], [ac_dbus="yes"], [ac_dbus="no"])
+   if test "x$ac_qt4" = "xno"; then
+      PKG_CHECK_MODULES([QT5DBUS], [Qt5DBus], [ac_dbus="yes"], [ac_dbus="no"])
+   else
+      PKG_CHECK_MODULES([QT4DBUS], [QtDBus],  [ac_dbus="yes"], [ac_dbus="no"])
+   fi
 fi
 if test "x$ac_dbus" = "xyes"; then
    AC_DEFINE(CONFIG_DBUS, 1, [Define if D-Bus interface is enabled.])
@@ -501,7 +556,7 @@ fi
 AC_SUBST(ac_qdbus)
 
 # Check for unique/single instance support.
-if test "x$ac_xunique" = "xyes"; then
+if test "x$ac_xunique" = "xyes" -a "x$ac_qt4" = "xno"; then
    PKG_CHECK_MODULES([QT5NETWORK], [Qt5Network], [ac_qt5network="yes"], [ac_qt5network="no"])
    if test "x$ac_qt5network" = "xyes"; then
       AC_DEFINE(CONFIG_XUNIQUE, 1, [Define if unique/single instance is enabled.])
diff --git src/qjackctlGraph.cpp src/qjackctlGraph.cpp
index bd0ca71..20ee4cd 100644
--- src/qjackctlGraph.cpp
+++ src/qjackctlGraph.cpp
@@ -2065,7 +2065,11 @@ bool qjackctlGraphCanvas::restoreState (void)
 		return false;
 
 	m_settings->beginGroup(ColorsGroup);
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 	const QRegularExpression rx("^0x");
+#else
+	const QRegExp rx("^0x");
+#endif
 	QStringListIterator key(m_settings->childKeys());
 	while (key.hasNext()) {
 		const QString& sKey = key.next();
diff --git src/qjackctlGraphForm.cpp src/qjackctlGraphForm.cpp
index 56c0a42..0bd84b7 100644
--- src/qjackctlGraphForm.cpp
+++ src/qjackctlGraphForm.cpp
@@ -96,7 +96,11 @@ qjackctlGraphForm::qjackctlGraphForm (
 	zoom_widget->setToolTip(tr("Zoom"));
 
 	QHBoxLayout *zoom_layout = new QHBoxLayout();
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 	zoom_layout->setContentsMargins(0, 0, 0, 0);
+#else
+	zoom_layout->setMargin(0);
+#endif
 	zoom_layout->setSpacing(2);
 
 	QToolButton *zoom_out = new QToolButton();
diff --git src/qjackctlMainForm.cpp src/qjackctlMainForm.cpp
index 7eced21..cbee36c 100644
--- src/qjackctlMainForm.cpp
+++ src/qjackctlMainForm.cpp
@@ -47,7 +47,11 @@
 
 #include <QApplication>
 #include <QSocketNotifier>
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 #include <QRegularExpression>
+#else
+#include <QRegExp>
+#endif
 #include <QMessageBox>
 #include <QTextStream>
 #include <QMenu>
@@ -327,7 +331,11 @@ public:
 		// Constructor.
 		LineEvent(QEvent::Type eType, const QString& sLine)
 			: QEvent(eType), m_sLine(sLine)
+	#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 			{ m_sLine.remove(QRegularExpression("\\x1B\\[[0-9|;]+m")); }
+	#else
+			{ m_sLine.remove(QRegExp("\\x1B\\[[0-9|;]+m")); }
+	#endif
 		// Accessor.
 		const QString& line() const
 			{ return m_sLine; }
@@ -1224,7 +1232,11 @@ void qjackctlMainForm::startJack (void)
 
 	// Stabilize emerging server state...
 	QPalette pal;
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 	pal.setColor(QPalette::WindowText, Qt::yellow);
+#else
+	pal.setColor(QPalette::Foreground, Qt::yellow);
+#endif
 	m_ui.ServerStateTextLabel->setPalette(pal);
 	m_ui.StartToolButton->setEnabled(false);
 	updateServerState(QJACKCTL_ACTIVATING);
@@ -1812,8 +1824,13 @@ void qjackctlMainForm::jackCleanup (void)
 void qjackctlMainForm::jackStabilize (void)
 {
 	QPalette pal;
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 	pal.setColor(QPalette::WindowText,
 		m_pJackClient == nullptr ? Qt::darkYellow : Qt::yellow);
+#else
+	pal.setColor(QPalette::Foreground,
+		m_pJackClient == nullptr ? Qt::darkYellow : Qt::yellow);
+#endif
 	m_ui.ServerStateTextLabel->setPalette(pal);
 	m_ui.StartToolButton->setEnabled(m_pJackClient == nullptr);
 	m_ui.StopToolButton->setEnabled(m_pJackClient != nullptr);
@@ -2070,9 +2087,17 @@ void qjackctlMainForm::updateDisplayEffect (void)
 	QPalette pal;
 	if (m_pSetup->bDisplayEffect) {
 		QPixmap pm(":/images/displaybg1.png");
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 		pal.setBrush(QPalette::Window, QBrush(pm));
+#else
+		pal.setBrush(QPalette::Background, QBrush(pm));
+#endif
 	} else {
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 		pal.setColor(QPalette::Window, Qt::black);
+#else
+		pal.setColor(QPalette::Background, Qt::black);
+#endif
 	}
 	m_ui.StatusDisplayFrame->setPalette(pal);
 }
@@ -2447,7 +2472,11 @@ void qjackctlMainForm::updateXrunCount (void)
 	#endif
 
 	QPalette pal;
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 	pal.setColor(QPalette::WindowText, color);
+#else
+	pal.setColor(QPalette::Foreground, color);
+#endif
 	m_ui.XrunCountTextLabel->setPalette(pal);
 
 	QString sText = QString::number(m_iXrunCount);
@@ -3106,13 +3135,25 @@ bool qjackctlMainForm::startJackClient ( bool bDetach )
 
 	// All displays are highlighted from now on.
 	QPalette pal;
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 	pal.setColor(QPalette::WindowText, Qt::yellow);
+#else
+	pal.setColor(QPalette::Foreground, Qt::yellow);
+#endif
 	m_ui.ServerStateTextLabel->setPalette(pal);
 	m_ui.DspLoadTextLabel->setPalette(pal);
 	m_ui.ServerModeTextLabel->setPalette(pal);
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 	pal.setColor(QPalette::WindowText, Qt::darkYellow);
+#else
+	pal.setColor(QPalette::Foreground, Qt::darkYellow);
+#endif
 	m_ui.SampleRateTextLabel->setPalette(pal);
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 	pal.setColor(QPalette::WindowText, Qt::green);
+#else
+	pal.setColor(QPalette::Foreground, Qt::green);
+#endif
 	m_ui.TimeDisplayTextLabel->setPalette(pal);
 	m_ui.TransportStateTextLabel->setPalette(pal);
 	m_ui.TransportBpmTextLabel->setPalette(pal);
@@ -3189,11 +3230,19 @@ void qjackctlMainForm::stopJackClient (void)
 
 	// Displays are dimmed again.
 	QPalette pal;
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 	pal.setColor(QPalette::WindowText, Qt::darkYellow);
+#else
+	pal.setColor(QPalette::Foreground, Qt::darkYellow);
+#endif
 	m_ui.ServerModeTextLabel->setPalette(pal);
 	m_ui.DspLoadTextLabel->setPalette(pal);
 	m_ui.SampleRateTextLabel->setPalette(pal);
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 	pal.setColor(QPalette::WindowText, Qt::darkGreen);
+#else
+	pal.setColor(QPalette::Foreground, Qt::darkGreen);
+#endif
 	m_ui.TimeDisplayTextLabel->setPalette(pal);
 	m_ui.TransportStateTextLabel->setPalette(pal);
 	m_ui.TransportBpmTextLabel->setPalette(pal);
@@ -3617,8 +3666,13 @@ void qjackctlMainForm::refreshStatus (void)
 			// Blink server mode indicator?...
 			if (m_pSetup && m_pSetup->bDisplayBlink) {
 				QPalette pal;
+	#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 				pal.setColor(QPalette::WindowText,
 					(++m_iStatusBlink % 2) ? Qt::darkYellow: Qt::yellow);
+	#else
+				pal.setColor(QPalette::Foreground,
+					(++m_iStatusBlink % 2) ? Qt::darkYellow: Qt::yellow);
+	#endif
 				m_ui.ServerModeTextLabel->setPalette(pal);
 			}
 		#ifdef CONFIG_JACK_REALTIME
diff --git src/qjackctlPaletteForm.cpp src/qjackctlPaletteForm.cpp
index 0833181..7984386 100644
--- src/qjackctlPaletteForm.cpp
+++ src/qjackctlPaletteForm.cpp
@@ -970,22 +970,38 @@ bool qjackctlPaletteForm::PaletteModel::setData (
 		if (m_generate) {
 			m_palette.setBrush(QPalette::Inactive, cr, color);
 			switch (cr) {
+	#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 				case QPalette::WindowText:
+	#else
+				case QPalette::Foreground:
+	#endif
 				case QPalette::Text:
 				case QPalette::ButtonText:
 				case QPalette::Base:
 					break;
 				case QPalette::Dark:
+	#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 					m_palette.setBrush(QPalette::Disabled, QPalette::WindowText, color);
+	#else
+				m_palette.setBrush(QPalette::Disabled, QPalette::Foreground, color);
+	#endif
 					m_palette.setBrush(QPalette::Disabled, QPalette::Dark, color);
 					m_palette.setBrush(QPalette::Disabled, QPalette::Text, color);
 					m_palette.setBrush(QPalette::Disabled, QPalette::ButtonText, color);
 					index_begin = PaletteModel::index(0, 0);
 					index_end = PaletteModel::index(m_nrows - 1, 3);
 					break;
+	#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 				case QPalette::Window:
+	#else
+				case QPalette::Background:
+	#endif
 					m_palette.setBrush(QPalette::Disabled, QPalette::Base, color);
+	#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 					m_palette.setBrush(QPalette::Disabled, QPalette::Window, color);
+	#else
+					m_palette.setBrush(QPalette::Disabled, QPalette::Background, color);
+	#endif
 					index_begin = PaletteModel::index(QPalette::Base, 0);
 					break;
 				case QPalette::Highlight:
@@ -1264,7 +1280,11 @@ qjackctlPaletteForm::ColorEditor::ColorEditor ( QWidget *parent )
 	: QWidget(parent)
 {
 	QLayout *layout = new QHBoxLayout(this);
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 	layout->setContentsMargins(0, 0, 0, 0);
+#else
+	layout->setMargin(0);
+#endif
 	m_button = new qjackctlPaletteForm::ColorButton(this);
 	layout->addWidget(m_button);
 	QObject::connect(m_button,
@@ -1310,7 +1330,11 @@ qjackctlPaletteForm::RoleEditor::RoleEditor ( QWidget *parent )
 	m_edited = false;
 
 	QHBoxLayout *layout = new QHBoxLayout(this);
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 	layout->setContentsMargins(0, 0, 0, 0);
+#else
+	layout->setMargin(0);
+#endif
 	layout->setSpacing(0);
 
 	m_label = new QLabel(this);
diff --git src/qjackctlPatchbay.cpp src/qjackctlPatchbay.cpp
index 1a8b5ff..33f785a 100644
--- src/qjackctlPatchbay.cpp
+++ src/qjackctlPatchbay.cpp
@@ -34,14 +34,16 @@
 #include <QMenu>
 #include <QToolTip>
 #include <QScrollBar>
-#include <QRegularExpression>
 
 #include <QDragEnterEvent>
 #include <QDragMoveEvent>
 
 #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+#include <QRegularExpression>
 #include <QMimeData>
 #include <QDrag>
+#else
+#include <QRegExp>
 #endif
 
 // Interactivity socket form.
@@ -589,7 +591,11 @@ bool qjackctlSocketList::copySocketItem (void)
 		int iSocketNo = 1;
 		QString sSocketName = pSocketItem->socketName();;
 		QString sSocketMask = sSocketName;
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 		sSocketMask.remove(QRegularExpression("[ |0-9]+$")).append(" %1");
+#else
+		sSocketMask.remove(QRegExp("[ |0-9]+$")).append(" %1");
+#endif
 		const int iSocketType = pSocketItem->socketType();
 		do { sSocketName = sSocketMask.arg(++iSocketNo); }
 		while (findSocket(sSocketName, iSocketType));
diff --git src/qjackctlSessionForm.cpp src/qjackctlSessionForm.cpp
index b6cf933..310bf8e 100644
--- src/qjackctlSessionForm.cpp
+++ src/qjackctlSessionForm.cpp
@@ -94,7 +94,11 @@ qjackctlSessionInfraClientItemEditor::qjackctlSessionInfraClientItemEditor (
 
 	QHBoxLayout *pLayout = new QHBoxLayout();
 	pLayout->setSpacing(0);
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 	pLayout->setContentsMargins(0, 0, 0, 0);
+#else
+	pLayout->setMargin(0);
+#endif
 	pLayout->addWidget(m_pItemEdit);
 	if (m_pBrowseButton)
 		pLayout->addWidget(m_pBrowseButton);
diff --git src/qjackctlSetupForm.cpp src/qjackctlSetupForm.cpp
index e6ab629..fde8cee 100644
--- src/qjackctlSetupForm.cpp
+++ src/qjackctlSetupForm.cpp
@@ -127,8 +127,13 @@ qjackctlSetupForm::qjackctlSetupForm ( QWidget *pParent )
 	m_iDirtyOptions = 0;
 
 	// Set dialog validators...
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 	m_ui.PresetComboBox->setValidator(
 		new QRegularExpressionValidator(QRegularExpression("[\\w-]+"), m_ui.PresetComboBox));
+#else
+	m_ui.PresetComboBox->setValidator(
+		new QRegExpValidator(QRegExp("[\\w-]+"), m_ui.PresetComboBox));
+#endif
 	m_ui.FramesComboBox->setValidator(
 		new QIntValidator(m_ui.FramesComboBox));
 	m_ui.SampleRateComboBox->setValidator(
@@ -626,7 +631,11 @@ void qjackctlSetupForm::setup ( qjackctlSetup *pSetup )
 		|| !font.fromString(m_pSetup->sMessagesFont))
 		font = QFont("Monospace", 8);
 	pal = m_ui.MessagesFontTextLabel->palette();
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 	pal.setColor(QPalette::Window, pal.base().color());
+#else
+	pal.setColor(QPalette::Background, pal.base().color());
+#endif
 	m_ui.MessagesFontTextLabel->setPalette(pal);
 	m_ui.MessagesFontTextLabel->setFont(font);
 	m_ui.MessagesFontTextLabel->setText(
@@ -636,7 +645,11 @@ void qjackctlSetupForm::setup ( qjackctlSetup *pSetup )
 		|| !font.fromString(m_pSetup->sConnectionsFont))
 		font = QFont(sSansSerif, 10);
 	pal = m_ui.ConnectionsFontTextLabel->palette();
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 	pal.setColor(QPalette::Window, pal.base().color());
+#else
+	pal.setColor(QPalette::Background, pal.base().color());
+#endif
 	m_ui.ConnectionsFontTextLabel->setPalette(pal);
 	m_ui.ConnectionsFontTextLabel->setFont(font);
 	m_ui.ConnectionsFontTextLabel->setText(
@@ -1529,12 +1542,24 @@ void qjackctlSetupForm::chooseDisplayFont2 (void)
 void qjackctlSetupForm::toggleDisplayEffect ( bool bOn )
 {
 	QPalette pal;
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 	pal.setColor(QPalette::WindowText, Qt::green);
+#else
+	pal.setColor(QPalette::Foreground, Qt::green);
+#endif
 	if (bOn) {
 		QPixmap pm(":/images/displaybg1.png");
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 		pal.setBrush(QPalette::Window, QBrush(pm));
+#else
+		pal.setBrush(QPalette::Background, QBrush(pm));
+#endif
 	} else {
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 		pal.setColor(QPalette::Window, Qt::black);
+#else
+		pal.setColor(QPalette::Background, Qt::black);
+#endif
 	}
 	m_ui.DisplayFont1TextLabel->setPalette(pal);
 	m_ui.DisplayFont2TextLabel->setPalette(pal);
diff --git src/qjackctlSocketForm.cpp src/qjackctlSocketForm.cpp
index 00c58db..2fe115e 100644
--- src/qjackctlSocketForm.cpp
+++ src/qjackctlSocketForm.cpp
@@ -28,7 +28,11 @@
 #include "qjackctlAliases.h"
 
 #include <QMessageBox>
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 #include <QRegularExpression>
+#else
+#include <QRegExp>
+#endif
 #include <QButtonGroup>
 #include <QHeaderView>
 #include <QPixmap>
@@ -916,7 +920,11 @@ void qjackctlSocketForm::clientNameChanged (void)
 		if (!sSocketName.isEmpty()) {
 			int iSocketNo = 0;
 			QString sSocketMask = sSocketName;
+	#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
 			sSocketMask.remove(QRegularExpression("[ |0-9]+$")).append(" %1");
+	#else
+			sSocketMask.remove(QRegExp("[ |0-9]+$")).append(" %1");
+	#endif
 			do { sSocketName = sSocketMask.arg(++iSocketNo); }
 			while (m_pSocketList->findSocket(sSocketName, iSocketType));
 			m_ui.SocketNameLineEdit->setText(sSocketName);
diff --git src/src.pro src/src.pro
index a22ff06..5203ad3 100644
--- src/src.pro
+++ src/src.pro
@@ -135,7 +135,12 @@ unix {
 }
 
 # XML/DOM support
-QT += widgets xml
+QT += xml
+
+# QT5 support
+!lessThan(QT_MAJOR_VERSION, 5) {
+	QT += widgets
+}
 
 win32 {
 	CONFIG += static
