diff --git a/CMakeLists.txt b/CMakeLists.txt index 91d6496e2..e68d4595c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -433,6 +433,7 @@ set(CANTATA_SRCS ${CANTATA_CORE_SRCS} ${CANTATA_SRCS} widgets/sizewidget.cpp widgets/servicestatuslabel.cpp widgets/spacerwidget.cpp widgets/songdialog.cpp widgets/stretchheaderview.cpp widgets/tableview.cpp widgets/thinsplitterhandle.cpp widgets/coverwidget.cpp widgets/ratingwidget.cpp widgets/notelabel.cpp widgets/selectorlabel.cpp widgets/titlewidget.cpp widgets/multipagewidget.cpp widgets/singlepagewidget.cpp widgets/stackedpagewidget.cpp + widgets/mirrormenu.cpp context/lyricsettings.cpp context/ultimatelyricsprovider.cpp context/ultimatelyrics.cpp context/lyricsdialog.cpp context/contextwidget.cpp context/view.cpp context/artistview.cpp context/albumview.cpp context/songview.cpp context/contextengine.cpp context/wikipediaengine.cpp context/wikipediasettings.cpp context/othersettings.cpp context/contextsettings.cpp context/togglelist.cpp @@ -456,7 +457,7 @@ set(CANTATA_MOC_HDRS ${CANTATA_CORE_MOC_HDRS} ${CANTATA_MOC_HDRS} widgets/playqueueview.h widgets/groupedview.h widgets/actionitemdelegate.h widgets/volumeslider.h widgets/singlepagewidget.h widgets/searchwidget.h widgets/messageoverlay.h widgets/servicestatuslabel.h widgets/stretchheaderview.h widgets/tableview.h widgets/coverwidget.h widgets/ratingwidget.h widgets/selectorlabel.h widgets/titlewidget.h widgets/multipagewidget.h - widgets/stackedpagewidget.h + widgets/stackedpagewidget.h widgets/mirrormenu.h context/togglelist.h context/ultimatelyrics.h context/ultimatelyricsprovider.h context/lyricsdialog.h context/contextwidget.h context/artistview.h context/albumview.h context/songview.h context/view.h context/contextengine.h context/wikipediaengine.h context/wikipediasettings.h context/othersettings.h context/lastfmengine.h context/metaengine.h diff --git a/ChangeLog b/ChangeLog index 31d48bc19..2c04bbb13 100644 --- a/ChangeLog +++ b/ChangeLog @@ -76,6 +76,8 @@ 54. Ignore 'The' (if configured) when sorting play queue. 55. No longer using discogs - API has changed. 56. Fix context widget backdrop retrieval from fan-art +57. Fix/work-around Qt 5.5 issues with QMenu being used in 2 actions. + 1.5.2 ----- 1. Fix Ubuntu Touch builds. diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 3c93f00f2..3347f07ca 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -50,6 +50,7 @@ #include "searchpage.h" #include "customactions.h" #include "support/gtkstyle.h" +#include "widgets/mirrormenu.h" #ifdef ENABLE_DEVICES_SUPPORT #include "devices/filejob.h" #include "devices/devicespage.h" @@ -267,7 +268,7 @@ MainWindow::MainWindow(QWidget *parent) addPlayQueueToStoredPlaylistAction = new Action(HIDE_MENU_ICON(Icons::self()->playlistFileIcon), i18n("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->setMenu(DevicesModel::self()->menu()); + copyToDeviceAction->setMenu(DevicesModel::self()->menu()->duplicate(0)); #endif cropPlayQueueAction = ActionCollection::get()->createAction("cropplaylist", i18n("Crop Others")); addStreamToPlayQueueAction = ActionCollection::get()->createAction("addstreamtoplayqueue", i18n("Add Stream URL"), HIDE_MENU_ICON(Icons::self()->addRadioStreamIcon)); @@ -323,7 +324,7 @@ MainWindow::MainWindow(QWidget *parent) connectionsGroup=new QActionGroup(connectionsAction->menu()); outputsAction->setMenu(new QMenu(this)); outputsAction->setVisible(false); - addPlayQueueToStoredPlaylistAction->setMenu(PlaylistsModel::self()->menu()); + addPlayQueueToStoredPlaylistAction->setMenu(PlaylistsModel::self()->menu()->duplicate(0)); playPauseTrackButton->setDefaultAction(StdActions::self()->playPauseTrackAction); stopTrackButton->setDefaultAction(StdActions::self()->stopPlaybackAction); diff --git a/gui/stdactions.cpp b/gui/stdactions.cpp index 3fa8ffe9d..fec3c22fe 100644 --- a/gui/stdactions.cpp +++ b/gui/stdactions.cpp @@ -31,8 +31,8 @@ #endif #include "support/icon.h" #include "widgets/icons.h" +#include "widgets/mirrormenu.h" #include "support/globalstatic.h" -#include #include GLOBAL_STATIC(StdActions, instance) diff --git a/models/devicesmodel.cpp b/models/devicesmodel.cpp index 57201eca7..050a1cbac 100644 --- a/models/devicesmodel.cpp +++ b/models/devicesmodel.cpp @@ -35,6 +35,7 @@ #include "http/httpserver.h" #include "support/localize.h" #include "widgets/icons.h" +#include "widgets/mirrormenu.h" #include "devices/mountpoints.h" #include "gui/stdactions.h" #include "support/action.h" @@ -43,7 +44,6 @@ #include "devices/audiocddevice.h" #endif #include "support/globalstatic.h" -#include #include #include #include @@ -722,7 +722,7 @@ void DevicesModel::updateItemMenu() } if (!itemMenu) { - itemMenu = new QMenu(0); + itemMenu = new MirrorMenu(0); } itemMenu->clear(); diff --git a/models/devicesmodel.h b/models/devicesmodel.h index 5dc54991e..2a7bad2e0 100644 --- a/models/devicesmodel.h +++ b/models/devicesmodel.h @@ -33,7 +33,7 @@ class QMimeData; class Device; -class QMenu; +class MirrorMenu; class DevicesModel : public MultiMusicModel { @@ -52,7 +52,7 @@ public: Qt::ItemFlags flags(const QModelIndex &index) const; QStringList playableUrls(const QModelIndexList &indexes) const; void clear(bool clearConfig=true); - QMenu * menu() { return itemMenu; } + MirrorMenu * menu() { return itemMenu; } Device * device(const QString &udi); bool isEnabled() const { return enabled; } void setEnabled(bool e); @@ -106,7 +106,7 @@ private Q_SLOTS: private: QSet volumes; - QMenu *itemMenu; + MirrorMenu *itemMenu; bool enabled; bool inhibitMenuUpdate; Action *configureAction; diff --git a/models/playlistsmodel.cpp b/models/playlistsmodel.cpp index 2e6110ca4..c9a855baa 100644 --- a/models/playlistsmodel.cpp +++ b/models/playlistsmodel.cpp @@ -26,7 +26,6 @@ #include #include -#include #include #include "config.h" #include "playlistsmodel.h" @@ -45,6 +44,7 @@ #include "mpd-interface/mpdconnection.h" #include "playqueuemodel.h" #include "widgets/icons.h" +#include "widgets/mirrormenu.h" #ifdef ENABLE_HTTP_SERVER #include "http/httpserver.h" #endif @@ -728,7 +728,7 @@ void PlaylistsModel::setEnabled(bool e) } #ifndef ENABLE_UBUNTU -QMenu * PlaylistsModel::menu() +MirrorMenu * PlaylistsModel::menu() { if (!itemMenu) { updateItemMenu(true); @@ -1005,7 +1005,7 @@ void PlaylistsModel::updateItemMenu(bool create) if (!create) { return; } - itemMenu = new QMenu(0); + itemMenu = new MirrorMenu(0); } itemMenu->clear(); diff --git a/models/playlistsmodel.h b/models/playlistsmodel.h index 56473cb11..4559d6c35 100644 --- a/models/playlistsmodel.h +++ b/models/playlistsmodel.h @@ -36,7 +36,7 @@ #include "support/icon.h" #include "actionmodel.h" -class QMenu; +class MirrorMenu; class QAction; class PlaylistsModel : public ActionModel @@ -130,7 +130,7 @@ public: void setEnabled(bool e); bool exists(const QString &n) { return 0!=getPlaylist(n); } #ifndef ENABLE_UBUNTU - QMenu * menu(); + MirrorMenu * menu(); #endif static QString strippedText(QString s); void setMultiColumn(bool m) { multiCol=m; } @@ -174,7 +174,7 @@ private: QList items; QSet usedKeys; #ifndef ENABLE_UBUNTU - QMenu *itemMenu; + MirrorMenu *itemMenu; quint32 dropAdjust; QAction *newAction; QMap alignments; diff --git a/support/themes/ambiance-dt.css b/support/themes/ambiance-dt.css index c0cb1b020..807e10c67 100644 --- a/support/themes/ambiance-dt.css +++ b/support/themes/ambiance-dt.css @@ -3,3 +3,5 @@ QToolBar#MainToolBar { background-color: #3c3b37; border: 0px;} QToolBar#MainToolBar:active { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #3c3b37, stop: 1 #575651); border: 0px;} QToolBar#MainToolBar QToolButton,QToolBar#MainToolBar QLabel { color: #bfbbb2;} QToolBar#MainToolBar QToolButton,QToolBar#MainToolBar QLabel:active { color: #dfdbd2;} QToolBar#MainToolBar QToolButton:disabled,QToolBar#MainToolBar QLabel:disabled { color: #9f9b92;} QToolBar#MainToolBar QToolButton { background: transparent; border: 1px outset transparent;} QToolBar#MainToolBar QToolButton:hover { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #464640, stop: 1 #303025); border-radius: 5px; border: 1px outset #3c3b37;} QToolBar#MainToolBar QToolButton:pressed,QToolBar#MainToolBar QToolButton:checked { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #383730, stop: 1 #2b2c27); border-radius: 5px; border: 1px inset #292825;} QToolBar#MainToolBar:separator { width: 1px; background: #3f3b32; margin-top: 4px; margin-bottom: 4px; margin-left: 7px; margin-right: 7px;} QMenu { background-color: #363531; color: #dfdbd2; padding: 1px;} QMenu QLabel { color: #dfdbd2;} QMenu:active { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e07746, stop: 1 #d05726); color: #dfdbd2;} QMenu:disabled { background-color: #363531; color: #8f8b82;} QMenu::separator { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #2b2a26, stop: 1 #4b4a46); height: 2;} /*QMenu::separator { background-color: #2b2a26; height: 1;} */ + +MirrorMenu { background-color: #363531; color: #dfdbd2; padding: 1px;} MirrorMenu QLabel { color: #dfdbd2;} MirrorMenu:active { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e07746, stop: 1 #d05726); color: #dfdbd2;} MirrorMenu:disabled { background-color: #363531; color: #8f8b82;} MirrorMenu::separator { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #2b2a26, stop: 1 #4b4a46); height: 2;} /*MirrorMenu::separator { background-color: #2b2a26; height: 1;} */ diff --git a/support/themes/ambiance.css b/support/themes/ambiance.css index c0cb1b020..764774a28 100644 --- a/support/themes/ambiance.css +++ b/support/themes/ambiance.css @@ -3,3 +3,6 @@ QToolBar#MainToolBar { background-color: #3c3b37; border: 0px;} QToolBar#MainToolBar:active { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #3c3b37, stop: 1 #575651); border: 0px;} QToolBar#MainToolBar QToolButton,QToolBar#MainToolBar QLabel { color: #bfbbb2;} QToolBar#MainToolBar QToolButton,QToolBar#MainToolBar QLabel:active { color: #dfdbd2;} QToolBar#MainToolBar QToolButton:disabled,QToolBar#MainToolBar QLabel:disabled { color: #9f9b92;} QToolBar#MainToolBar QToolButton { background: transparent; border: 1px outset transparent;} QToolBar#MainToolBar QToolButton:hover { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #464640, stop: 1 #303025); border-radius: 5px; border: 1px outset #3c3b37;} QToolBar#MainToolBar QToolButton:pressed,QToolBar#MainToolBar QToolButton:checked { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #383730, stop: 1 #2b2c27); border-radius: 5px; border: 1px inset #292825;} QToolBar#MainToolBar:separator { width: 1px; background: #3f3b32; margin-top: 4px; margin-bottom: 4px; margin-left: 7px; margin-right: 7px;} QMenu { background-color: #363531; color: #dfdbd2; padding: 1px;} QMenu QLabel { color: #dfdbd2;} QMenu:active { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e07746, stop: 1 #d05726); color: #dfdbd2;} QMenu:disabled { background-color: #363531; color: #8f8b82;} QMenu::separator { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #2b2a26, stop: 1 #4b4a46); height: 2;} /*QMenu::separator { background-color: #2b2a26; height: 1;} */ + +MirrorMenu { background-color: #363531; color: #dfdbd2; padding: 1px;} MirrorMenu QLabel { color: #dfdbd2;} MirrorMenu:active { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e07746, stop: 1 #d05726); color: #dfdbd2;} MirrorMenu:disabled { background-color: #363531; color: #8f8b82;} MirrorMenu::separator { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #2b2a26, stop: 1 #4b4a46); height: 2;} /*MirrorMenu::separator { background-color: #2b2a26; height: 1;} */ + diff --git a/support/themes/elementary.css b/support/themes/elementary.css index b28ca9ba2..748023314 100644 --- a/support/themes/elementary.css +++ b/support/themes/elementary.css @@ -3,3 +3,5 @@ QToolBar#MainToolBar { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #dedede, stop: 1 #bbbbbb); border: 0px;} QToolBar#MainToolBar QToolButton,QToolBar#MainToolBar QLabel { color: #3c3c3c;} QToolBar#MainToolBar QToolButton { background: transparent; border: 1px outset transparent;} QToolBar#MainToolBar QToolButton:hover { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #eeeeee, stop: 1 #d8d8d8); border-radius: 4px; border: 1px outset #606060;} QToolBar#MainToolBar QToolButton:pressed,QToolBar#MainToolBar QToolButton:checked { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #a0a0a0, stop: 1 #d8d8d8); border-radius: 4px; border: 1px inset #505050;} QMenu::separator { background-color: #ececec; height: 1;} + +MirrorMenu::separator { background-color: #ececec; height: 1;} diff --git a/support/themes/faience.css b/support/themes/faience.css index f27f4284d..f114e7bda 100644 --- a/support/themes/faience.css +++ b/support/themes/faience.css @@ -3,3 +3,5 @@ QToolBar#MainToolBar { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ececec, stop: 1 #d2d2d2); border: 0px;} QToolBar#MainToolBar:active { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #cccccc, stop: 1 #b0b0b0); border: 0px;} QToolBar#MainToolBar QToolButton,QToolBar#MainToolBar QLabel { color: #222222;} QToolBar#MainToolBar QToolButton,QToolBar#MainToolBar QLabel:active { color: #222222;} QToolBar#MainToolBar QToolButton { background: transparent; border: 1px outset transparent;} QToolBar#MainToolBar QToolButton:hover { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #eeeeee, stop: 1 #d8d8d8); border-radius: 4px; border: 1px outset #606060;} QToolBar#MainToolBar QToolButton:pressed,QToolBar#MainToolBar QToolButton:checked { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #a0a0a0, stop: 1 #d8d8d8); border-radius: 4px; border: 1px inset #505050;} QMenu::separator { background-color: #ececec; height: 1;} + +MirrorMenu::separator { background-color: #ececec; height: 1;} diff --git a/widgets/mirrormenu.cpp b/widgets/mirrormenu.cpp new file mode 100644 index 000000000..0eb10b561 --- /dev/null +++ b/widgets/mirrormenu.cpp @@ -0,0 +1,105 @@ +/* + * Cantata + * + * Copyright (c) 2011-2015 Craig Drummond + * + * ---- + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "mirrormenu.h" +#include + +MirrorMenu::MirrorMenu(QWidget *p) + : QMenu(p) +{ +} + +void MirrorMenu::addAction(QAction *act) +{ + QMenu::addAction(act); + updateMenus(); +} + +QAction * MirrorMenu::addAction(const QString &text) +{ + QAction *act=QMenu::addAction(text); + updateMenus(); + return act; +} + +QAction * MirrorMenu::addAction(const QIcon &icon, const QString &text) +{ + QAction *act=QMenu::addAction(icon, text); + updateMenus(); + return act; +} + +QAction * MirrorMenu::addAction(const QString &text, const QObject *receiver, const char *member, const QKeySequence &shortcut) +{ + QAction *act=QMenu::addAction(text, receiver, member, shortcut); + updateMenus(); + return act; +} + +QAction * MirrorMenu::addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char *member, const QKeySequence &shortcut) +{ + QAction *act=QMenu::addAction(icon, text, receiver, member, shortcut); + updateMenus(); + return act; +} + +void MirrorMenu::removeAction(QAction *act) +{ + QMenu::removeAction(act); + updateMenus(); +} + +void MirrorMenu::clear() +{ + QMenu::clear(); + updateMenus(); +} + +QMenu * MirrorMenu::duplicate(QWidget *p) +{ + QMenu *menu=new QMenu(p); + menus.append(menu); + updateMenu(menu); + connect(menu, SIGNAL(destroyed(QObject*)), this, SLOT(menuDestroyed(QObject*))); + return menu; +} + +void MirrorMenu::updateMenus() +{ + foreach (QMenu *m, menus) { + updateMenu(m); + } +} + +void MirrorMenu::updateMenu(QMenu *menu) +{ + menu->clear(); + menu->addActions(actions()); +} + +void MirrorMenu::menuDestroyed(QObject *obj) +{ + if (qobject_cast(obj)) { + menus.removeAll(static_cast(obj)); + } +} diff --git a/widgets/mirrormenu.h b/widgets/mirrormenu.h new file mode 100644 index 000000000..37648b9f1 --- /dev/null +++ b/widgets/mirrormenu.h @@ -0,0 +1,56 @@ +/* + * Cantata + * + * Copyright (c) 2011-2015 Craig Drummond + * + * ---- + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef MIRROR_MENU_H +#define MIRROR_MENU_H + +#include +#include + +class MirrorMenu : public QMenu +{ + Q_OBJECT +public: + MirrorMenu(QWidget *p); + void addAction(QAction *act); + QAction * addAction(const QString &text); + QAction * addAction(const QIcon &icon, const QString &text); + QAction * addAction(const QString &text, const QObject *receiver, const char *member, const QKeySequence &shortcut = 0); + QAction * addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char *member, const QKeySequence &shortcut = 0); + void removeAction(QAction *act); + void clear(); + QMenu * duplicate(QWidget *p); + +private: + void updateMenus(); + void updateMenu(QMenu *menu); + +private Q_SLOTS: + void menuDestroyed(QObject *obj); + +private: + QList menus; +}; + +#endif +