From 286d2f76e84df4bda459f3a7dc323fcf8d6670bf Mon Sep 17 00:00:00 2001 From: Craig Drummond Date: Mon, 14 Aug 2017 22:42:17 +0100 Subject: [PATCH] Remove unity menu icon work-around. --- CMakeLists.txt | 4 ---- ChangeLog | 1 + config.h.cmake | 16 --------------- gui/mainwindow.cpp | 42 +++++++++++++-------------------------- gui/stdactions.cpp | 11 +++++----- models/playqueuemodel.cpp | 5 ++--- widgets/toolbutton.cpp | 18 +---------------- widgets/toolbutton.h | 7 ------- 8 files changed, 23 insertions(+), 81 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d26a5f05e..3f61a3ce6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,10 +85,6 @@ else () set(CANTATA_ICON_INSTALL_PREFIX ${SHARE_INSTALL_PREFIX}/icons/hicolor) endif () -if (NOT APPLE AND NOT WIN32) - set(UNITY_MENU_HACK ON) -endif () - if (NOT WIN32 AND NOT APPLE AND ENABLE_DEVICES_SUPPORT AND ENABLE_UDISKS2) set(WITH_SOLID_UDISKS2 ON) endif () diff --git a/ChangeLog b/ChangeLog index 681ba2f36..4ded276a9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ 3. Fix potential issue with priority menu items being disabled. 4. When adding items with a custom priority, or updating a custom priority, add option to have this priority decrease with each item. +5. Remove unity menu icon work-around. 2.1.0 ----- diff --git a/config.h.cmake b/config.h.cmake index 85a600e23..60bdd44cb 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -44,7 +44,6 @@ #cmakedefine ENABLE_HTTP_SERVER 1 #cmakedefine IOKIT_FOUND 1 #cmakedefine QT_MAC_EXTRAS_FOUND 1 -#cmakedefine UNITY_MENU_HACK 1 #cmakedefine ENABLE_SIMPLE_MPD_SUPPORT 1 #cmakedefine HAVE_CDIO_PARANOIA_H 1 @@ -52,12 +51,7 @@ #cmakedefine HAVE_CDIO_CDDA_H 1 #cmakedefine HAVE_CDIO_PARANOIA_CDDA_H 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 -#else #define CANTATA_REV_URL "@PROJECT_REV_URL@" -#endif #define CANTATA_URL "@PROJECT_URL@" #define CANTATA_SYS_CONFIG_DIR Utils::systemDir(QLatin1String("config")) @@ -66,16 +60,6 @@ #define CANTATA_SYS_TRANS_DIR Utils::systemDir(QLatin1String("translations")) #define CANTATA_SYS_SCRIPTS_DIR Utils::systemDir(QLatin1String("scripts")) -#ifdef UNITY_MENU_HACK -#define HIDE_MENU_ICON(A) menuIcons ? A : Icon() -#define HIDE_MENU_ICON_NAME(A) menuIcons ? A : 0 -#define UNITY_MENU_ICON_CHECK bool menuIcons=Utils::Unity!=Utils::currentDe() && !QCoreApplication::testAttribute(Qt::AA_DontShowIconsInMenus); -#else -#define HIDE_MENU_ICON(A) A -#define HIDE_MENU_ICON_NAME(A) A -#define UNITY_MENU_ICON_CHECK -#endif - #define LINUX_LIB_DIR "@LINUX_LIB_DIR@" #define CANTATA_ICON_THEME "@CANTATA_ICON_THEME@" diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 1a984fe2f..9bb756324 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -231,8 +231,6 @@ void MainWindow::init() } #endif - UNITY_MENU_ICON_CHECK - toolbar->ensurePolished(); toolbar->adjustSize(); coverWidget->setSize(toolbar->height()); @@ -247,12 +245,12 @@ void MainWindow::init() setWindowIcon(Icons::self()->appIcon); prefAction=ActionCollection::get()->createAction("configure", Utils::KDE==Utils::currentDe() ? tr("Configure Cantata...") : tr("Preferences"), - HIDE_MENU_ICON(Icons::self()->configureIcon)); + Icons::self()->configureIcon); connect(prefAction, SIGNAL(triggered()),this, SLOT(showPreferencesDialog())); - quitAction = ActionCollection::get()->createAction("quit", tr("Quit"), HIDE_MENU_ICON(MonoIcon::icon(FontAwesome::poweroff, MonoIcon::constRed, MonoIcon::constRed))); + quitAction = ActionCollection::get()->createAction("quit", tr("Quit"), MonoIcon::icon(FontAwesome::poweroff, MonoIcon::constRed, MonoIcon::constRed)); connect(quitAction, SIGNAL(triggered()), this, SLOT(quit())); quitAction->setShortcut(QKeySequence::Quit); - Action *aboutAction=ActionCollection::get()->createAction("about", tr("About Cantata..."), HIDE_MENU_ICON(Icons::self()->appIcon)); + Action *aboutAction=ActionCollection::get()->createAction("about", tr("About Cantata..."), Icons::self()->appIcon); connect(aboutAction, SIGNAL(triggered()),this, SLOT(showAboutDialog())); #ifdef Q_OS_MAC prefAction->setMenuRole(QAction::PreferencesRole); @@ -262,15 +260,15 @@ void MainWindow::init() restoreAction = new Action(tr("Show Window"), this); connect(restoreAction, SIGNAL(triggered()), this, SLOT(restoreWindow())); - serverInfoAction=ActionCollection::get()->createAction("mpdinfo", tr("Server information..."), HIDE_MENU_ICON(MonoIcon::icon(FontAwesome::server, iconCol))); + serverInfoAction=ActionCollection::get()->createAction("mpdinfo", tr("Server information..."), MonoIcon::icon(FontAwesome::server, iconCol)); connect(serverInfoAction, SIGNAL(triggered()),this, SLOT(showServerInfo())); serverInfoAction->setEnabled(Settings::self()->firstRun()); - refreshDbAction = ActionCollection::get()->createAction("refresh", tr("Refresh Database"), HIDE_MENU_ICON(Icons::self()->refreshIcon)); + refreshDbAction = ActionCollection::get()->createAction("refresh", tr("Refresh Database"), Icons::self()->refreshIcon); doDbRefreshAction = new Action(refreshDbAction->icon(), tr("Refresh"), this); refreshDbAction->setEnabled(false); connectAction = new Action(Icons::self()->connectIcon, tr("Connect"), this); - connectionsAction = new Action(HIDE_MENU_ICON(MonoIcon::icon(FontAwesome::server, iconCol)), tr("Collection"), this); - outputsAction = new Action(HIDE_MENU_ICON(MonoIcon::icon(FontAwesome::volumeup, iconCol)), tr("Outputs"), this); + connectionsAction = new Action(MonoIcon::icon(FontAwesome::server, iconCol), tr("Collection"), this); + outputsAction = new Action(MonoIcon::icon(FontAwesome::volumeup, iconCol), tr("Outputs"), this); stopAfterTrackAction = ActionCollection::get()->createAction("stopaftertrack", tr("Stop After Track"), Icons::self()->toolbarStopIcon); QList seeks=QList() << 5 << 30 << 60; @@ -291,23 +289,23 @@ void MainWindow::init() } } - addPlayQueueToStoredPlaylistAction = new Action(HIDE_MENU_ICON(Icons::self()->playlistListIcon), tr("Add To Stored Playlist"), this); + addPlayQueueToStoredPlaylistAction = new Action(Icons::self()->playlistListIcon, tr("Add To Stored Playlist"), this); #ifdef ENABLE_DEVICES_SUPPORT - copyToDeviceAction = new Action(HIDE_MENU_ICON(StdActions::self()->copyToDeviceAction->icon()), Utils::strippedText(StdActions::self()->copyToDeviceAction->text()), this); + copyToDeviceAction = new Action(StdActions::self()->copyToDeviceAction->icon(), Utils::strippedText(StdActions::self()->copyToDeviceAction->text()), this); copyToDeviceAction->setMenu(DevicesModel::self()->menu()->duplicate(0)); #endif cropPlayQueueAction = ActionCollection::get()->createAction("cropplaylist", tr("Crop Others")); addStreamToPlayQueueAction = ActionCollection::get()->createAction("addstreamtoplayqueue", tr("Add Stream URL")); QIcon clearIcon = MonoIcon::icon(FontAwesome::times, MonoIcon::constRed, MonoIcon::constRed); - clearPlayQueueAction = ActionCollection::get()->createAction("clearplaylist", tr("Clear"), HIDE_MENU_ICON(clearIcon)); + clearPlayQueueAction = ActionCollection::get()->createAction("clearplaylist", tr("Clear"), clearIcon); clearPlayQueueAction->setShortcut(Qt::ControlModifier+Qt::Key_K); centerPlayQueueAction = ActionCollection::get()->createAction("centerplaylist", tr("Center On Current Track"), Icons::self()->centrePlayQueueOnTrackIcon); - expandInterfaceAction = ActionCollection::get()->createAction("expandinterface", tr("Expanded Interface"), HIDE_MENU_ICON(MonoIcon::icon(FontAwesome::expand, iconCol))); + expandInterfaceAction = ActionCollection::get()->createAction("expandinterface", tr("Expanded Interface"), MonoIcon::icon(FontAwesome::expand, iconCol)); expandInterfaceAction->setCheckable(true); songInfoAction = ActionCollection::get()->createAction("showsonginfo", tr("Show Current Song Information"), Icons::self()->infoIcon); songInfoAction->setShortcut(Qt::Key_F12); songInfoAction->setCheckable(true); - fullScreenAction = ActionCollection::get()->createAction("fullScreen", tr("Full Screen"), HIDE_MENU_ICON(MonoIcon::icon(FontAwesome::arrowsalt, iconCol))); + fullScreenAction = ActionCollection::get()->createAction("fullScreen", tr("Full Screen"), MonoIcon::icon(FontAwesome::arrowsalt, iconCol)); #ifndef Q_OS_MAC fullScreenAction->setShortcut(Qt::Key_F11); #endif @@ -315,11 +313,11 @@ void MainWindow::init() repeatPlayQueueAction = ActionCollection::get()->createAction("repeatplaylist", tr("Repeat"), Icons::self()->repeatIcon); singlePlayQueueAction = ActionCollection::get()->createAction("singleplaylist", tr("Single"), Icons::self()->singleIcon, tr("When 'Single' is activated, playback is stopped after current song, or song is repeated if 'Repeat' is enabled.")); consumePlayQueueAction = ActionCollection::get()->createAction("consumeplaylist", tr("Consume"), Icons::self()->consumeIcon, tr("When consume is activated, a song is removed from the play queue after it has been played.")); - searchPlayQueueAction = ActionCollection::get()->createAction("searchplaylist", tr("Find in Play Queue"), HIDE_MENU_ICON(Icons::self()->searchIcon)); + searchPlayQueueAction = ActionCollection::get()->createAction("searchplaylist", tr("Find in Play Queue"), Icons::self()->searchIcon); addAction(searchPlayQueueAction); searchPlayQueueAction->setShortcut(Qt::ControlModifier+Qt::ShiftModifier+Qt::Key_F); #ifdef ENABLE_HTTP_STREAM_PLAYBACK - streamPlayAction = ActionCollection::get()->createAction("streamplay", tr("Play Stream"), HIDE_MENU_ICON(Icons::self()->httpStreamIcon)); + streamPlayAction = ActionCollection::get()->createAction("streamplay", tr("Play Stream"), Icons::self()->httpStreamIcon); streamPlayAction->setCheckable(true); streamPlayAction->setChecked(false); streamPlayAction->setVisible(false); @@ -524,18 +522,6 @@ void MainWindow::init() singlePlayQueueAction->setChecked(false); consumePlayQueueAction->setChecked(false); - #ifdef UNITY_MENU_HACK - if (!menuIcons) { - // These buttons have actions that are in the menubar, as wall as in the main window. - // Under unity we dont want any icons in menus - so the actions themselves have no icons. - // But the toolbuttuns need icons! - #ifdef ENABLE_HTTP_STREAM_PLAYBACK - streamPlayButton->setIcon(Icons::self()->httpStreamIcon); - #endif - savePlayQueueButton->setIcon(Icons::self()->savePlayQueueIcon); - clearPlayQueueButton->setIcon(MonoIcon::icon(FontAwesome::times, MonoIcon::constRed, MonoIcon::constRed)); - } - #endif expandedSize=Settings::self()->mainWindowSize(); collapsedSize=Settings::self()->mainWindowCollapsedSize(); diff --git a/gui/stdactions.cpp b/gui/stdactions.cpp index 771996bd3..f6b3351da 100644 --- a/gui/stdactions.cpp +++ b/gui/stdactions.cpp @@ -73,7 +73,6 @@ static QMenu * priorityMenu() StdActions::StdActions() { - UNITY_MENU_ICON_CHECK QColor col=Utils::monoIconColor(); prevTrackAction = ActionCollection::get()->createAction("prevtrack", QObject::tr("Previous Track"), Icons::self()->toolbarPrevIcon); nextTrackAction = ActionCollection::get()->createAction("nexttrack", QObject::tr("Next Track"), Icons::self()->toolbarNextIcon); @@ -83,7 +82,7 @@ StdActions::StdActions() stopAfterTrackAction = ActionCollection::get()->createAction("stopaftertrack", QObject::tr("Stop After Track"), Icons::self()->toolbarStopIcon); increaseVolumeAction = ActionCollection::get()->createAction("increasevolume", QObject::tr("Increase Volume")); decreaseVolumeAction = ActionCollection::get()->createAction("decreasevolume", QObject::tr("Decrease Volume")); - savePlayQueueAction = ActionCollection::get()->createAction("saveplayqueue", QObject::tr("Save As"), HIDE_MENU_ICON(Icons::self()->savePlayQueueIcon)); + savePlayQueueAction = ActionCollection::get()->createAction("saveplayqueue", QObject::tr("Save As"), Icons::self()->savePlayQueueIcon); appendToPlayQueueAction = ActionCollection::get()->createAction("appendtoplayqueue", QObject::tr("Append"), Icons::self()->appendToPlayQueueIcon); setToolTip(appendToPlayQueueAction, QObject::tr("Append To Play Queue")); appendToPlayQueueAndPlayAction = ActionCollection::get()->createAction("appendtoplayqueueandplay", QObject::tr("Append And Play")); @@ -103,20 +102,20 @@ StdActions::StdActions() addToStoredPlaylistAction = new Action(Icons::self()->playlistListIcon, QObject::tr("Add To Playlist"), 0); #ifdef TAGLIB_FOUND - organiseFilesAction = ActionCollection::get()->createAction("orgfiles", QObject::tr("Organize Files"), HIDE_MENU_ICON(MonoIcon::icon(FontAwesome::folderopeno, col))); + organiseFilesAction = ActionCollection::get()->createAction("orgfiles", QObject::tr("Organize Files"), MonoIcon::icon(FontAwesome::folderopeno, col)); editTagsAction = ActionCollection::get()->createAction("edittags", QObject::tr("Edit Track Information"), 0); #endif #ifdef ENABLE_REPLAYGAIN_SUPPORT - replaygainAction = ActionCollection::get()->createAction("replaygain", QObject::tr("ReplayGain"), HIDE_MENU_ICON(MonoIcon::icon(FontAwesome::barchart, col))); + replaygainAction = ActionCollection::get()->createAction("replaygain", QObject::tr("ReplayGain"), MonoIcon::icon(FontAwesome::barchart, col)); #endif #ifdef ENABLE_DEVICES_SUPPORT - copyToDeviceAction = new Action(HIDE_MENU_ICON(MonoIcon::icon(FontAwesome::mobile, col)), QObject::tr("Copy Songs To Device"), 0); + copyToDeviceAction = new Action(MonoIcon::icon(FontAwesome::mobile, col), QObject::tr("Copy Songs To Device"), 0); copyToDeviceAction->setMenu(DevicesModel::self()->menu()); deleteSongsAction = new Action(MonoIcon::icon(FontAwesome::trash, MonoIcon::constRed), QObject::tr("Delete Songs"), 0); #endif setCoverAction = new Action(QObject::tr("Set Image"), 0); removeAction = new Action(Icons::self()->removeIcon, QObject::tr("Remove"), 0); - searchAction = ActionCollection::get()->createAction("search", QObject::tr("Find"), HIDE_MENU_ICON(Icons::self()->searchIcon)); + searchAction = ActionCollection::get()->createAction("search", QObject::tr("Find"), Icons::self()->searchIcon); searchAction->setShortcut(Qt::ControlModifier+Qt::Key_F); addToStoredPlaylistAction->setMenu(PlaylistsModel::self()->menu()); diff --git a/models/playqueuemodel.cpp b/models/playqueuemodel.cpp index f4b74aa64..d0f163584 100644 --- a/models/playqueuemodel.cpp +++ b/models/playqueuemodel.cpp @@ -222,13 +222,12 @@ PlayQueueModel::PlayQueueModel(QObject *parent) connect(DevicesModel::self(), SIGNAL(updatedDetails(QList)), SLOT(updateDetails(QList))); #endif - UNITY_MENU_ICON_CHECK removeDuplicatesAction=new Action(tr("Remove Duplicates"), this); removeDuplicatesAction->setEnabled(false); QColor col=Utils::monoIconColor(); - undoAction=ActionCollection::get()->createAction("playqueue-undo", tr("Undo"), HIDE_MENU_ICON(MonoIcon::icon(FontAwesome::undo, col))); + undoAction=ActionCollection::get()->createAction("playqueue-undo", tr("Undo"), MonoIcon::icon(FontAwesome::undo, col)); undoAction->setShortcut(Qt::ControlModifier+Qt::Key_Z); - redoAction=ActionCollection::get()->createAction("playqueue-redo", tr("Redo"), HIDE_MENU_ICON(MonoIcon::icon(FontAwesome::repeat, col))); + redoAction=ActionCollection::get()->createAction("playqueue-redo", tr("Redo"), MonoIcon::icon(FontAwesome::repeat, col)); redoAction->setShortcut(Qt::ControlModifier+Qt::ShiftModifier+Qt::Key_Z); connect(undoAction, SIGNAL(triggered()), this, SLOT(undo())); connect(redoAction, SIGNAL(triggered()), this, SLOT(redo())); diff --git a/widgets/toolbutton.cpp b/widgets/toolbutton.cpp index ea00804c4..1bd7b5fd8 100644 --- a/widgets/toolbutton.cpp +++ b/widgets/toolbutton.cpp @@ -78,12 +78,6 @@ void ToolButton::paintEvent(QPaintEvent *e) if (opt.state&QStyle::State_MouseOver && this!=QApplication::widgetAt(QCursor::pos())) { opt.state&=~QStyle::State_MouseOver; } - #ifdef UNITY_MENU_HACK - if (!icon.isNull()) { - opt.icon=icon; - opt.toolButtonStyle=Qt::ToolButtonIconOnly; - } - #endif p.drawComplexControl(QStyle::CC_ToolButton, opt); } @@ -91,17 +85,7 @@ QSize ToolButton::sizeHint() const { if (!sh.isValid()) { ensurePolished(); - #ifdef UNITY_MENU_HACK - if (!icon.isNull()) { - QStyleOptionToolButton opt; - opt.icon=icon; - opt.toolButtonStyle=Qt::ToolButtonIconOnly; - initStyleOption(&opt); - opt.features=QStyleOptionToolButton::None; - sh = style()->sizeFromContents(QStyle::CT_ToolButton, &opt, opt.iconSize, this).expandedTo(QApplication::globalStrut()); - } else - #endif - sh = QToolButton::sizeHint(); + sh = QToolButton::sizeHint(); if (sh.width()>sh.height()) { sh.setWidth(sh.height()); diff --git a/widgets/toolbutton.h b/widgets/toolbutton.h index c161c36a5..bf0d2471d 100644 --- a/widgets/toolbutton.h +++ b/widgets/toolbutton.h @@ -26,7 +26,6 @@ #include #include "support/icon.h" -#include "config.h" class QMenu; class ToolButton : public QToolButton @@ -36,15 +35,9 @@ public: QSize sizeHint() const; void setMenu(QMenu *m); void paintEvent(QPaintEvent *e); - #ifdef UNITY_MENU_HACK - void setIcon(const QIcon &i) { icon=i; } - #endif private: mutable QSize sh; - #ifdef UNITY_MENU_HACK - QIcon icon; - #endif #ifdef Q_OS_MAC bool allowMouseOver; #endif