From 5d7f2ea2d6e64cf91eb5add3fe03df4fafc2020f Mon Sep 17 00:00:00 2001 From: "craig.p.drummond" Date: Sun, 5 Apr 2015 20:09:16 +0000 Subject: [PATCH] CMake option to enabkle touch-friendly support. Disable by default (apart from in Windows) as it only really works under windows. --- CMakeLists.txt | 2 ++ ChangeLog | 3 ++- INSTALL | 5 +++++ config.h.cmake | 1 + gui/interfacesettings.cpp | 6 +++--- gui/settings.cpp | 10 +++++++--- support/CMakeLists.txt | 15 ++++++++++----- support/touchproxystyle.cpp | 4 ++++ support/utils.cpp | 2 ++ support/utils.h | 5 +++++ 10 files changed, 41 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c2a479734..82845702d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,8 +62,10 @@ else (WIN32 OR APPLE) endif (WIN32 OR APPLE) if (WIN32) set(USE_SYSTEM_MENU_ICON OFF) + option(ENABLE_TOUCH_SUPPORT "Enable option to make interface more touch-friendly" ON) else (WIN32) option(USE_SYSTEM_MENU_ICON "Use system menu icon" ON) + option(ENABLE_TOUCH_SUPPORT "Enable option to make interface more touch-friendly" OFF) endif (WIN32) option(ENABLE_CDPARANOIA "Enable CDParanoia libraries (required for AudioCD support)" ON) option(ENABLE_CDDB "Enable CDDB libraries (either this or MusicBrianz required for AudioCD support)" ON) diff --git a/ChangeLog b/ChangeLog index 63969c79d..6478b2849 100644 --- a/ChangeLog +++ b/ChangeLog @@ -40,7 +40,8 @@ Options' button. 25. Allow local socket path to start with ~ 26. Ensure consistent order when drag'n'drop from list views as per tree views. -27. Remove touch friendly setting from OSX builds - no touch screen Macs? +27. Remove touch friendly setting from builds unless -DENABLE_TOUCH_SUPPORT=ON + is passed to CMake. 1.5.2 ----- diff --git a/INSTALL b/INSTALL index c16b6a246..484a9bb99 100644 --- a/INSTALL +++ b/INSTALL @@ -94,6 +94,11 @@ The following options may be passed to CMake: Podcasts) Default: ON + -DENABLE_TOUCH_SUPPORT=ON + Enable support for making Cantata more touch-friendly. Currently only + really works under Windows. + Default: Windows:ON, Others:OFF + Specific to Qt-only builds:: diff --git a/config.h.cmake b/config.h.cmake index 10d894096..9b1808318 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -44,6 +44,7 @@ #cmakedefine IOKIT_FOUND 1 #cmakedefine QT_MAC_EXTRAS_FOUND 1 #cmakedefine UNITY_MENU_HACK 1 +#cmakedefine ENABLE_TOUCH_SUPPORT 1 #ifdef ENABLE_UBUNTU #define CANTATA_REV_URL "com.ubuntu.developer.nikwen.cantata-touch-reboot" //Sadly, it requires the com.ubuntu.developer.nikwen prefix to be published to the click store diff --git a/gui/interfacesettings.cpp b/gui/interfacesettings.cpp index 97c9bbdc3..0d52b833c 100644 --- a/gui/interfacesettings.cpp +++ b/gui/interfacesettings.cpp @@ -178,11 +178,11 @@ InterfaceSettings::InterfaceSettings(QWidget *p) connect(playlistsView, SIGNAL(currentIndexChanged(int)), SLOT(playlistsViewChanged())); connect(playQueueView, SIGNAL(currentIndexChanged(int)), SLOT(playQueueViewChanged())); connect(forceSingleClick, SIGNAL(toggled(bool)), SLOT(forceSingleClickChanged())); - #ifdef Q_OS_MAC // No touch screen Macs? + #ifdef ENABLE_TOUCH_SUPPORT + connect(touchFriendly, SIGNAL(toggled(bool)), SLOT(touchFriendlyChanged())); + #else REMOVE(touchFriendly) REMOVE(touchFriendlyNoteLabel) - #else - connect(touchFriendly, SIGNAL(toggled(bool)), SLOT(touchFriendlyChanged())); #endif connect(views, SIGNAL(itemChanged(QListWidgetItem*)), SLOT(viewItemChanged(QListWidgetItem*))); diff --git a/gui/settings.cpp b/gui/settings.cpp index d09712916..b58303bba 100644 --- a/gui/settings.cpp +++ b/gui/settings.cpp @@ -824,10 +824,10 @@ int Settings::menu() bool Settings::touchFriendly() { - #ifdef Q_OS_MAC // No touch screen Macs? - return false; - #else + #ifdef ENABLE_TOUCH_SUPPORT return cfg.get("touchFriendly", false); + #else + return false; #endif } @@ -1378,7 +1378,11 @@ void Settings::saveShowMenubar(bool v) void Settings::saveTouchFriendly(bool v) { + #ifdef ENABLE_TOUCH_SUPPORT cfg.set("touchFriendly", v); + #else + Q_UNUSED(v) + #endif } void Settings::saveFilteredOnly(bool v) diff --git a/support/CMakeLists.txt b/support/CMakeLists.txt index 01c38fb59..2932bc3a7 100644 --- a/support/CMakeLists.txt +++ b/support/CMakeLists.txt @@ -12,12 +12,17 @@ endif (ENABLE_QT5) add_library(support-core STATIC ${SUPPORT_CORE_MOC_SRCS} ${SUPPORT_CORE_SRCS}) if (NOT ENABLE_UBUNTU) - set(SUPPORT_SRCS icon.cpp fancytabwidget.cpp messagewidget.cpp buddylabel.cpp action.cpp actioncollection.cpp flickcharm.cpp - configuration.cpp lineedit.cpp gtkstyle.cpp spinner.cpp messagebox.cpp inputdialog.cpp thread.cpp squeezedtextlabel.cpp - proxystyle.cpp touchproxystyle.cpp pagewidget.cpp combobox.cpp configdialog.cpp) + set (SUPPORT_SRCS icon.cpp fancytabwidget.cpp messagewidget.cpp buddylabel.cpp action.cpp actioncollection.cpp lineedit.cpp + configuration.cpp gtkstyle.cpp spinner.cpp messagebox.cpp inputdialog.cpp thread.cpp squeezedtextlabel.cpp proxystyle.cpp + touchproxystyle.cpp pagewidget.cpp combobox.cpp configdialog.cpp) + + set(SUPPORT_MOC_HDRS fancytabwidget.h messagewidget.h inputdialog.h pagewidget.h action.h actioncollection.h configdialog.h) + + if (ENABLE_TOUCH_SUPPORT) + set(SUPPORT_SRCS ${SUPPORT_SRCS} flickcharm.cpp) + set(SUPPORT_MOC_HDRS ${SUPPORT_MOC_HDRS} flickcharm.h) + endif (ENABLE_TOUCH_SUPPORT) - set(SUPPORT_MOC_HDRS fancytabwidget.h messagewidget.h inputdialog.h pagewidget.h action.h actioncollection.h flickcharm.h - configdialog.h) if (ENABLE_QT5) set(SUPPORT_MOC_HDRS ${SUPPORT_MOC_HDRS} combobox.h) endif (ENABLE_QT5) diff --git a/support/touchproxystyle.cpp b/support/touchproxystyle.cpp index 49ab48f23..e82d86ec7 100644 --- a/support/touchproxystyle.cpp +++ b/support/touchproxystyle.cpp @@ -65,6 +65,7 @@ static void drawSpinButton(QPainter *painter, const QRect &r, const QColor &col, painter->restore(); } +#ifdef ENABLE_TOUCH_SUPPORT class ComboItemDelegate : public QStyledItemDelegate { public: @@ -158,6 +159,7 @@ public: } QComboBox *combo; }; +#endif TouchProxyStyle::TouchProxyStyle(int modView, bool touchSpin, bool gtkOverlayStyleScrollbar) : touchStyleSpin(touchSpin) @@ -489,6 +491,7 @@ void TouchProxyStyle::polish(QWidget *widget) } } + #ifdef ENABLE_TOUCH_SUPPORT if (Utils::touchFriendly()) { if (qobject_cast(widget)) { FlickCharm::self()->activateOn(widget); @@ -497,5 +500,6 @@ void TouchProxyStyle::polish(QWidget *widget) combo->setItemDelegate(new ComboItemDelegate(combo)); } } + #endif ProxyStyle::polish(widget); } diff --git a/support/utils.cpp b/support/utils.cpp index 8a26494d9..f486b6dec 100644 --- a/support/utils.cpp +++ b/support/utils.cpp @@ -951,6 +951,7 @@ Utils::Desktop Utils::currentDe() return Other; } +#ifdef ENABLE_TOUCH_SUPPORT static bool isTouchFriendly=false; void Utils::setTouchFriendly(bool t) { @@ -961,6 +962,7 @@ bool Utils::touchFriendly() { return isTouchFriendly; } +#endif QPainterPath Utils::buildPath(const QRectF &r, double radius) { diff --git a/support/utils.h b/support/utils.h index a773f95e1..8ded03d93 100644 --- a/support/utils.h +++ b/support/utils.h @@ -132,8 +132,13 @@ namespace Utils Other }; extern Desktop currentDe(); + #ifdef ENABLE_TOUCH_SUPPORT extern void setTouchFriendly(bool t); extern bool touchFriendly(); + #else + inline void setTouchFriendly(bool) { } + inline bool touchFriendly() { return false; } + #endif extern QPainterPath buildPath(const QRectF &r, double radius); }