diff --git a/3rdparty/qocoa/CMakeLists.txt b/3rdparty/qocoa/CMakeLists.txt index 62766b3be..256af2cea 100644 --- a/3rdparty/qocoa/CMakeLists.txt +++ b/3rdparty/qocoa/CMakeLists.txt @@ -24,6 +24,7 @@ else() qprogressindicatorspinning_nonmac.cpp ) set(RESOURCES + qsearchfield_nonmac.qrc qprogressindicatorspinning_nonmac.qrc ) qt5_add_resources(RESOURCES_SOURCES ${RESOURCES}) @@ -31,3 +32,4 @@ endif() add_library(Qocoa STATIC ${SOURCES} ${MOC_SOURCES} ${RESOURCES_SOURCES}) target_link_libraries(Qocoa ${QT_LIBRARIES}) + diff --git a/3rdparty/qocoa/README.md b/3rdparty/qocoa/README.md index fe955c045..6e16f6f75 100644 --- a/3rdparty/qocoa/README.md +++ b/3rdparty/qocoa/README.md @@ -16,7 +16,9 @@ make ``` ## Status -Qocoa classes are currently provided for NSButton, a spinning NSProgressIndicator and NSSearchField. There is a [TODO list](https://github.com/mikemcquaid/Qocoa/blob/master/TODO.md) for classes I hope to implement. +I'm not personally working on this any more but will accept pull-requests. + +[![Build Status](https://travis-ci.org/MikeMcQuaid/Qocoa.svg?branch=master)](https://travis-ci.org/MikeMcQuaid/Qocoa) ## Usage For each class you want to use copy the [`qocoa_mac.h`](https://github.com/mikemcquaid/Qocoa/blob/master/qocoa_mac.h), `$CLASS.h`, `$CLASS_mac.*` and `$CLASS_nonmac.*` files into your source tree and add them to your buildsystem. Examples are provided for [CMake](https://github.com/mikemcquaid/Qocoa/blob/master/CMakeLists.txt) and [QMake](https://github.com/mikemcquaid/Qocoa/blob/master/Qocoa.pro). @@ -28,7 +30,9 @@ For each class you want to use copy the [`qocoa_mac.h`](https://github.com/mikem Qocoa is licensed under the [MIT License](http://en.wikipedia.org/wiki/MIT_License). The full license text is available in [LICENSE.txt](https://github.com/mikemcquaid/Qocoa/blob/master/LICENSE.txt). -The icons are taken from the [Oxygen Project](http://www.oxygen-icons.org/) and are licensed under the [Creative Commons Attribution-ShareAlike 3.0 License](http://creativecommons.org/licenses/by-sa/3.0/). +Magnifier and EditClear icons taken from [QtCreator](http://qt-project.org/) and are licensed under the [LGPL](http://www.gnu.org/copyleft/lesser.html). + +Other icons are taken from the [Oxygen Project](http://www.oxygen-icons.org/) and are licensed under the [Creative Commons Attribution-ShareAlike 3.0 License](http://creativecommons.org/licenses/by-sa/3.0/). ## Gallery ![Qocoa Gallery](https://github.com/mikemcquaid/Qocoa/raw/master/gallery.png) diff --git a/3rdparty/qocoa/qbutton.h b/3rdparty/qocoa/qbutton.h index 920399c39..93e598f80 100644 --- a/3rdparty/qocoa/qbutton.h +++ b/3rdparty/qocoa/qbutton.h @@ -3,7 +3,6 @@ #include #include -#include class QButtonPrivate; class QButton : public QWidget @@ -24,7 +23,7 @@ public: RoundRect = 12, Recessed = 13, RoundedDisclosure = 14, -#ifdef MAC_OS_X_VERSION_10_7 +#ifdef __MAC_10_7 Inline = 15 #endif }; diff --git a/3rdparty/qocoa/qbutton_mac.mm b/3rdparty/qocoa/qbutton_mac.mm index 93f7c7c8b..bd68fda45 100644 --- a/3rdparty/qocoa/qbutton_mac.mm +++ b/3rdparty/qocoa/qbutton_mac.mm @@ -37,7 +37,9 @@ public: switch(bezelStyle) { case QButton::Disclosure: case QButton::Circular: +#ifdef __MAC_10_7 case QButton::Inline: +#endif case QButton::RoundedDisclosure: case QButton::HelpButton: [nsButton setTitle:@""]; @@ -55,7 +57,7 @@ public: font = [NSFont fontWithName:@"Lucida Grande Bold" size:12]; break; -#ifdef MAC_OS_X_VERSION_10_7 +#ifdef __MAC_10_7 case QButton::Inline: font = [NSFont boldSystemFontOfSize:[NSFont systemFontSizeForControlSize:NSSmallControlSize]]; break; @@ -112,7 +114,7 @@ public: qButton->setFixedHeight(22); qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); break; -#ifdef MAC_OS_X_VERSION_10_7 +#ifdef __MAC_10_7 case QButton::Inline: qButton->setMinimumWidth(10); qButton->setFixedHeight(16); @@ -130,7 +132,7 @@ public: [nsButton setButtonType:NSMomentaryPushInButton]; } - [nsButton setBezelStyle:bezelStyle]; + // [nsButton setBezelStyle:bezelStyle]; } void clicked() diff --git a/3rdparty/qocoa/qbutton_nonmac.cpp b/3rdparty/qocoa/qbutton_nonmac.cpp index 4a78bb7f7..0a79e2baf 100644 --- a/3rdparty/qocoa/qbutton_nonmac.cpp +++ b/3rdparty/qocoa/qbutton_nonmac.cpp @@ -20,19 +20,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "qbutton.h" + #include #include - -#include "qbutton.h" +#include +#include class QButtonPrivate : public QObject { diff --git a/3rdparty/qocoa/qocoa_mac.h b/3rdparty/qocoa/qocoa_mac.h index 9d2d5d4b4..2456d6612 100644 --- a/3rdparty/qocoa/qocoa_mac.h +++ b/3rdparty/qocoa/qocoa_mac.h @@ -20,10 +20,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include #include -#include #include #include +#include #include static inline NSString* fromQString(const QString &string) @@ -42,11 +43,11 @@ static inline QString toQString(NSString *string) static inline NSImage* fromQPixmap(const QPixmap &pixmap) { - CGImageRef cgImage = pixmap.toMacCGImageRef(); + CGImageRef cgImage = QtMac::toCGImageRef(pixmap); return [[NSImage alloc] initWithCGImage:cgImage size:NSZeroSize]; } -static inline void setupLayout(void *cocoaView, QWidget *parent) +static inline void setupLayout(NSView *cocoaView, QWidget *parent) { parent->setAttribute(Qt::WA_NativeWindow); QVBoxLayout *layout = new QVBoxLayout(parent); diff --git a/3rdparty/qocoa/qprogressindicatorspinning.h b/3rdparty/qocoa/qprogressindicatorspinning.h index c987e2e6d..ae40a92a2 100644 --- a/3rdparty/qocoa/qprogressindicatorspinning.h +++ b/3rdparty/qocoa/qprogressindicatorspinning.h @@ -17,7 +17,8 @@ public: Aqua = 12 }; - explicit QProgressIndicatorSpinning(QWidget *parent, Thickness thickness = Default); + explicit QProgressIndicatorSpinning(QWidget *parent, + Thickness thickness = Default); public slots: void animate(bool animate = true); private: diff --git a/3rdparty/qocoa/qprogressindicatorspinning_nonmac.cpp b/3rdparty/qocoa/qprogressindicatorspinning_nonmac.cpp index 5cc8fdffd..6cbded6c1 100644 --- a/3rdparty/qocoa/qprogressindicatorspinning_nonmac.cpp +++ b/3rdparty/qocoa/qprogressindicatorspinning_nonmac.cpp @@ -20,17 +20,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include -#include -#include -#include -#include -#include -#include -#include - #include "qprogressindicatorspinning.h" +#include +#include +#include + class QProgressIndicatorSpinningPrivate : public QObject { public: diff --git a/3rdparty/qocoa/qsearchfield.h b/3rdparty/qocoa/qsearchfield.h index d85151714..5abf4986a 100644 --- a/3rdparty/qocoa/qsearchfield.h +++ b/3rdparty/qocoa/qsearchfield.h @@ -2,22 +2,24 @@ #define QSEARCHFIELD_H #include -#include #include -#include -#include -#include +#include class QSearchFieldPrivate; class QSearchField : public QWidget { Q_OBJECT + + Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged USER true); + Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText); + public: explicit QSearchField(QWidget *parent); QString text() const; QString placeholderText() const; - void setFocus(Qt::FocusReason reason); + void setFocus(Qt::FocusReason); + void setMenu(QMenu *menu); public slots: void setText(const QString &text); @@ -31,15 +33,16 @@ signals: void editingFinished(); void returnPressed(); +private slots: + void popupMenu(); + protected: + void changeEvent(QEvent*); void resizeEvent(QResizeEvent*); - bool eventFilter(QObject*, QEvent*); private: friend class QSearchFieldPrivate; QPointer pimpl; - - Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText); }; #endif // QSEARCHFIELD_H diff --git a/3rdparty/qocoa/qsearchfield_mac.mm b/3rdparty/qocoa/qsearchfield_mac.mm index 29b5b06b8..09d799f0b 100644 --- a/3rdparty/qocoa/qsearchfield_mac.mm +++ b/3rdparty/qocoa/qsearchfield_mac.mm @@ -29,8 +29,8 @@ THE SOFTWARE. #import "AppKit/NSSearchField.h" #include -#include #include +#include class QSearchFieldPrivate : public QObject { @@ -95,6 +95,16 @@ public: pimpl->textDidChange(toQString([[notification object] stringValue])); } +-(void)controlTextDidEndEditing:(NSNotification*)notification { + Q_UNUSED(notification); + // No Q_ASSERT here as it is called on destruction. + if (pimpl) + pimpl->textDidEndEditing(); + + if ([[[notification userInfo] objectForKey:@"NSTextMovement"] intValue] == NSReturnTextMovement) + pimpl->returnPressed(); +} + -(BOOL)control: (NSControl *)control textView: (NSTextView *)textView doCommandBySelector: (SEL)commandSelector { @@ -111,16 +121,6 @@ public: return NO; } --(void)controlTextDidEndEditing:(NSNotification*)notification { - // No Q_ASSERT here as it is called on destruction. - if (!pimpl) return; - - pimpl->textDidEndEditing(); - - if ([[[notification userInfo] objectForKey:@"NSTextMovement"] intValue] == NSReturnTextMovement) - pimpl->returnPressed(); -} - @end @interface QocoaSearchField : NSSearchField @@ -129,14 +129,13 @@ public: @implementation QocoaSearchField -(BOOL)performKeyEquivalent:(NSEvent*)event { - // First, check if we have the focus. // If no, it probably means this event isn't for us. NSResponder* firstResponder = [[NSApp keyWindow] firstResponder]; if ([firstResponder isKindOfClass:[NSText class]] && [(NSText*)firstResponder delegate] == self) { - if ([event type] == NSKeyDown && [event modifierFlags] & NSCommandKeyMask) + if ([event type] == NSEventTypeKeyDown && [event modifierFlags] & NSEventModifierFlagCommand) { QString keyString = toQString([event characters]); if (keyString == "a") // Cmd+a @@ -186,6 +185,25 @@ QSearchField::QSearchField(QWidget *parent) : QWidget(parent) [pool drain]; } +void QSearchField::setMenu(QMenu *menu) +{ + Q_ASSERT(pimpl); + if (!pimpl) + return; + +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) + NSMenu *nsMenu = menu->macMenu(); +#else + NSMenu *nsMenu = menu->toNSMenu(); +#endif + + [[pimpl->nsSearchField cell] setSearchMenuTemplate:nsMenu]; +} + +void QSearchField::popupMenu() +{ +} + void QSearchField::setText(const QString &text) { Q_ASSERT(pimpl); @@ -194,10 +212,6 @@ void QSearchField::setText(const QString &text) NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [pimpl->nsSearchField setStringValue:fromQString(text)]; - if (!text.isEmpty()) { - [pimpl->nsSearchField selectText:pimpl->nsSearchField]; - [[pimpl->nsSearchField currentEditor] setSelectedRange:NSMakeRange([[pimpl->nsSearchField stringValue] length], 0)]; - } [pool drain]; } @@ -212,40 +226,6 @@ void QSearchField::setPlaceholderText(const QString &text) [pool drain]; } -QString QSearchField::placeholderText() const { - Q_ASSERT(pimpl); - NSString* placeholder = [[pimpl->nsSearchField cell] placeholderString]; - return toQString(placeholder); -} - -void QSearchField::setFocus(Qt::FocusReason reason) -{ -/* Do nothing: we were previously using makeFirstResponder on search field, but - * that resulted in having the text being selected (and I didn't find any way to - * deselect it) which would result in the user erasing the first letter he just - * typed, after using setText (e.g. if the user typed a letter while having - * focus on the playlist, which means we call setText and give focus to the - * search bar). - * Instead now the focus will take place when calling selectText in setText. - * This obviously breaks the purpose of this function, but we never call only - * setFocus on a search box in Clementine (i.e. without a call to setText - * shortly after). - */ - -// Q_ASSERT(pimpl); -// if (!pimpl) -// return; - -// if ([pimpl->nsSearchField acceptsFirstResponder]) { -// [[pimpl->nsSearchField window] makeFirstResponder: pimpl->nsSearchField]; -// } -} - -void QSearchField::setFocus() -{ - setFocus(Qt::OtherFocusReason); -} - void QSearchField::clear() { Q_ASSERT(pimpl); @@ -274,12 +254,44 @@ QString QSearchField::text() const return toQString([pimpl->nsSearchField stringValue]); } +QString QSearchField::placeholderText() const +{ + Q_ASSERT(pimpl); + if (!pimpl) + return QString(); + + return toQString([[pimpl->nsSearchField cell] placeholderString]); +} + +void QSearchField::setFocus(Qt::FocusReason) +{ + Q_ASSERT(pimpl); + if (!pimpl) + return; + + if ([pimpl->nsSearchField acceptsFirstResponder]) + [[pimpl->nsSearchField window] makeFirstResponder: pimpl->nsSearchField]; +} + +void QSearchField::setFocus() +{ + setFocus(Qt::OtherFocusReason); +} + +void QSearchField::changeEvent(QEvent* event) +{ + if (event->type() == QEvent::EnabledChange) { + Q_ASSERT(pimpl); + if (!pimpl) + return; + + const bool enabled = isEnabled(); + [pimpl->nsSearchField setEnabled: enabled]; + } + QWidget::changeEvent(event); +} + void QSearchField::resizeEvent(QResizeEvent *resizeEvent) { QWidget::resizeEvent(resizeEvent); } - -bool QSearchField::eventFilter(QObject *o, QEvent *e) -{ - return QWidget::eventFilter(o, e); -} diff --git a/3rdparty/qocoa/qsearchfield_nonmac.cpp b/3rdparty/qocoa/qsearchfield_nonmac.cpp index 31641bf6b..d3315b853 100644 --- a/3rdparty/qocoa/qsearchfield_nonmac.cpp +++ b/3rdparty/qocoa/qsearchfield_nonmac.cpp @@ -20,39 +20,48 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../src/core/iconloader.h" #include "qsearchfield.h" +#include +#include +#include +#include +#include +#include + +#include +#include + class QSearchFieldPrivate : public QObject { public: - QSearchFieldPrivate(QSearchField *searchField, QLineEdit *lineEdit, QToolButton *clearButton) - : QObject(searchField), lineEdit(lineEdit), clearButton(clearButton) {} + QSearchFieldPrivate(QSearchField *searchField, QLineEdit *lineEdit, QToolButton *clearButton, QToolButton *searchButton) + : QObject(searchField), lineEdit(lineEdit), clearButton(clearButton), searchButton(searchButton) {} + int lineEditFrameWidth() const { return lineEdit->style()->pixelMetric(QStyle::PM_DefaultFrameWidth); } + int clearButtonPaddedWidth() const { return clearButton->width() + lineEditFrameWidth() * 2; } + int clearButtonPaddedHeight() const { return clearButton->height() + lineEditFrameWidth() * 2; } + + int searchButtonPaddedWidth() const { + return searchButton->width() + lineEditFrameWidth() * 2; + } + + int searchButtonPaddedHeight() const { + return searchButton->height() + lineEditFrameWidth() * 2; + } + QPointer lineEdit; QPointer clearButton; + QPointer searchButton; + QPointer searchMenu; }; QSearchField::QSearchField(QWidget *parent) : QWidget(parent) @@ -67,29 +76,94 @@ QSearchField::QSearchField(QWidget *parent) : QWidget(parent) connect(lineEdit, SIGNAL(textChanged(QString)), this, SLOT(setText(QString))); - QIcon clearIcon(IconLoader::Load("edit-clear-locationbar-ltr")); - + int iconsize = style()->pixelMetric(QStyle::PM_SmallIconSize); QToolButton *clearButton = new QToolButton(this); + QIcon clearIcon = QIcon::fromTheme(QLatin1String("edit-clear"), + QIcon(QLatin1String(":/Qocoa/qsearchfield_nonmac_clear.png"))); clearButton->setIcon(clearIcon); - clearButton->setIconSize(QSize(16, 16)); - clearButton->setStyleSheet("border: none; padding: 0px;"); - clearButton->resize(clearButton->sizeHint()); + clearButton->setIconSize(QSize(iconsize, iconsize)); + clearButton->setFixedSize(QSize(iconsize, iconsize)); + clearButton->setStyleSheet("border: none;"); + clearButton->hide(); connect(clearButton, SIGNAL(clicked()), this, SLOT(clear())); - pimpl = new QSearchFieldPrivate(this, lineEdit, clearButton); + QToolButton *searchButton = new QToolButton(this); + QIcon searchIcon = QIcon(QLatin1String(":/Qocoa/qsearchfield_nonmac_magnifier.png")); + searchButton->setIcon(searchIcon); + searchButton->setIconSize(QSize(iconsize, iconsize)); + searchButton->setFixedSize(QSize(iconsize, iconsize)); + searchButton->setStyleSheet("border: none;"); + searchButton->setPopupMode(QToolButton::InstantPopup); + searchButton->setEnabled(false); + connect(searchButton, SIGNAL(clicked()), this, SLOT(popupMenu())); - const int frame_width = lineEdit->style()->pixelMetric(QStyle::PM_DefaultFrameWidth); + pimpl = new QSearchFieldPrivate(this, lineEdit, clearButton, searchButton); - lineEdit->setStyleSheet(QString("QLineEdit { padding-left: %1px; } ").arg(clearButton->width())); - const int width = frame_width + qMax(lineEdit->minimumSizeHint().width(), pimpl->clearButtonPaddedWidth()); - const int height = frame_width + qMax(lineEdit->minimumSizeHint().height(), pimpl->clearButtonPaddedHeight()); + lineEdit->setStyleSheet(QString("QLineEdit { padding-left: %1px; padding-right: %2px; } ") + .arg(pimpl->searchButtonPaddedWidth()) + .arg(pimpl->clearButtonPaddedWidth())); + const int width = qMax(lineEdit->minimumSizeHint().width(), pimpl->clearButtonPaddedWidth() + pimpl->searchButtonPaddedWidth()); + const int height = qMax(lineEdit->minimumSizeHint().height(), + qMax(pimpl->clearButtonPaddedHeight(), + pimpl->searchButtonPaddedHeight())); lineEdit->setMinimumSize(width, height); QVBoxLayout *layout = new QVBoxLayout(this); layout->setMargin(0); layout->addWidget(lineEdit); +} - lineEdit->installEventFilter(this); +void QSearchField::setMenu(QMenu *menu) +{ + Q_ASSERT(pimpl); + if (!pimpl) + return; + + pimpl->searchMenu = menu; + + QIcon searchIcon = menu ? QIcon(QLatin1String(":/Qocoa/qsearchfield_nonmac_magnifier_menu.png")) + : QIcon(QLatin1String(":/Qocoa/qsearchfield_nonmac_magnifier.png")); + pimpl->searchButton->setIcon(searchIcon); + pimpl->searchButton->setEnabled(isEnabled() && menu); +} + +void QSearchField::popupMenu() +{ + Q_ASSERT(pimpl); + if (!pimpl) + return; + + if (pimpl->searchMenu) { + const QRect screenRect = qApp->desktop()->availableGeometry(pimpl->searchButton); + const QSize sizeHint = pimpl->searchMenu->sizeHint(); + const QRect rect = pimpl->searchButton->rect(); + const int x = pimpl->searchButton->isRightToLeft() + ? rect.right() - sizeHint.width() + : rect.left(); + const int y = pimpl->searchButton->mapToGlobal(QPoint(0, rect.bottom())).y() + sizeHint.height() <= screenRect.height() + ? rect.bottom() + : rect.top() - sizeHint.height(); + QPoint point = pimpl->searchButton->mapToGlobal(QPoint(x, y)); + point.rx() = qMax(screenRect.left(), qMin(point.x(), screenRect.right() - sizeHint.width())); + point.ry() += 1; + + pimpl->searchMenu->popup(point); + } +} + +void QSearchField::changeEvent(QEvent* event) +{ + if (event->type() == QEvent::EnabledChange) { + Q_ASSERT(pimpl); + if (!pimpl) + return; + + const bool enabled = isEnabled(); + pimpl->searchButton->setEnabled(enabled && pimpl->searchMenu); + pimpl->lineEdit->setEnabled(enabled); + pimpl->clearButton->setEnabled(enabled); + } + QWidget::changeEvent(event); } void QSearchField::setText(const QString &text) @@ -98,6 +172,8 @@ void QSearchField::setText(const QString &text) if (!(pimpl && pimpl->clearButton && pimpl->lineEdit)) return; + pimpl->clearButton->setVisible(!text.isEmpty()); + if (text != this->text()) pimpl->lineEdit->setText(text); } @@ -113,26 +189,6 @@ void QSearchField::setPlaceholderText(const QString &text) #endif } -QString QSearchField::placeholderText() const { -#if QT_VERSION >= 0x040700 - return pimpl->lineEdit->placeholderText(); -#else - return QString(); -#endif -} - -void QSearchField::setFocus(Qt::FocusReason reason) -{ - Q_ASSERT(pimpl && pimpl->lineEdit); - if (pimpl && pimpl->lineEdit) - pimpl->lineEdit->setFocus(reason); -} - -void QSearchField::setFocus() -{ - setFocus(Qt::OtherFocusReason); -} - void QSearchField::clear() { Q_ASSERT(pimpl && pimpl->lineEdit); @@ -160,6 +216,30 @@ QString QSearchField::text() const return pimpl->lineEdit->text(); } +QString QSearchField::placeholderText() const { + Q_ASSERT(pimpl && pimpl->lineEdit); + if (!(pimpl && pimpl->lineEdit)) + return QString(); + +#if QT_VERSION >= 0x040700 + return pimpl->lineEdit->placeholderText(); +#else + return QString(); +#endif +} + +void QSearchField::setFocus(Qt::FocusReason reason) +{ + Q_ASSERT(pimpl && pimpl->lineEdit); + if (pimpl && pimpl->lineEdit) + pimpl->lineEdit->setFocus(reason); +} + +void QSearchField::setFocus() +{ + setFocus(Qt::OtherFocusReason); +} + void QSearchField::resizeEvent(QResizeEvent *resizeEvent) { Q_ASSERT(pimpl && pimpl->clearButton && pimpl->lineEdit); @@ -167,22 +247,10 @@ void QSearchField::resizeEvent(QResizeEvent *resizeEvent) return; QWidget::resizeEvent(resizeEvent); - const int x = pimpl->lineEditFrameWidth(); + const int x = width() - pimpl->clearButtonPaddedWidth(); const int y = (height() - pimpl->clearButton->height())/2; pimpl->clearButton->move(x, y); -} -bool QSearchField::eventFilter(QObject *o, QEvent *e) -{ - if (pimpl && pimpl->lineEdit && o == pimpl->lineEdit) { - // Forward some lineEdit events to QSearchField (only those we need for - // now, but some might be added later if needed) - switch (e->type()) { - case QEvent::FocusIn: - case QEvent::FocusOut: - QApplication::sendEvent(this, e); - break; - } - } - return QWidget::eventFilter(o, e); + pimpl->searchButton->move(pimpl->lineEditFrameWidth() * 2, + (height() - pimpl->searchButton->height())/2); } diff --git a/CMakeLists.txt b/CMakeLists.txt index 92f7a61c6..9ff190127 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,7 +106,6 @@ pkg_check_modules(LIBGPOD libgpod-1.0>=0.7.92) pkg_check_modules(LIBMTP libmtp>=1.0) pkg_check_modules(LIBPULSE libpulse) pkg_check_modules(LIBXML libxml-2.0) -pkg_check_modules(LIBGLU REQUIRED glu) pkg_check_modules(IMOBILEDEVICE libimobiledevice-1.0) pkg_check_modules(USBMUXD libusbmuxd) pkg_check_modules(PLIST libplist) @@ -125,19 +124,16 @@ if(DBUS_FOUND) find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS DBus) get_target_property(QT_DBUSXML2CPP_EXECUTABLE Qt5::qdbusxml2cpp LOCATION) endif() -if(NOT APPLE) - find_package(Qt5 COMPONENTS WebKitWidgets) -endif(NOT APPLE) if(APPLE) - if(NOT QT_MAC_USE_COCOA) - message(FATAL_ERROR "Cocoa support is required") - endif(NOT QT_MAC_USE_COCOA) -endif(APPLE) + find_package(Qt5 REQUIRED COMPONENTS MacExtras) +endif() if(UNIX AND X11_FOUND AND DBUS_FOUND) set(QT_LIBRARIES Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network Qt5::Sql Qt5::OpenGL Qt5::Xml Qt5::X11Extras Qt5::DBus) elseif(UNIX AND X11_FOUND) set(QT_LIBRARIES Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network Qt5::Sql Qt5::OpenGL Qt5::Xml Qt5::X11Extras) +elseif(APPLE) + set(QT_LIBRARIES Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network Qt5::Sql Qt5::OpenGL Qt5::Xml Qt5::MacExtras) else() set(QT_LIBRARIES Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network Qt5::Sql Qt5::OpenGL Qt5::Xml) endif() @@ -179,7 +175,7 @@ if(LASTFM5_INCLUDE_DIRS AND LASTFM51_INCLUDE_DIRS) set(HAVE_LIBLASTFM1 ON) endif() -# CHROMAPRINT +# CHECK INCLUDES CHECK_INCLUDE_FILES(chromaprint.h CHROMAPRINT_H) # Use system sha2 if it's available @@ -340,6 +336,7 @@ add_definitions(-DQT_NO_CAST_TO_ASCII -DQT_STRICT_ITERATORS) include_directories(${GLIB_INCLUDE_DIRS}) include_directories(${GLIBCONFIG_INCLUDE_DIRS}) +include_directories(${TAGLIB_INCLUDE_DIRS}) if(ENABLE_IMOBILEDEVICE AND IMOBILEDEVICE_VERSION VERSION_GREATER 1.1.1) set(IMOBILEDEVICE_USES_UDIDS ON) diff --git a/dist/CMakeLists.txt b/dist/CMakeLists.txt index e1f6dd71c..fe141f902 100644 --- a/dist/CMakeLists.txt +++ b/dist/CMakeLists.txt @@ -10,5 +10,5 @@ if (UNIX) install(FILES ../data/icons/128x128/strawberry.png DESTINATION share/icons/hicolor/128x128/apps/) install(FILES ../data/icons/128x128/strawberry.svg DESTINATION share/icons/hicolor/scalable/apps/) install(FILES strawberry.desktop DESTINATION share/applications) - install(FILES strawberry.1 strawberry-tagreader.1 DESTINATION share/man/man1) + install(FILES strawberry.1 unix/strawberry-tagreader.1 DESTINATION share/man/man1) endif (UNIX) diff --git a/ext/libstrawberry-common/core/logging.cpp b/ext/libstrawberry-common/core/logging.cpp index eed1a15c8..058f5d8db 100644 --- a/ext/libstrawberry-common/core/logging.cpp +++ b/ext/libstrawberry-common/core/logging.cpp @@ -239,7 +239,7 @@ QString LinuxDemangle(const QString &symbol) { } QString DemangleSymbol(const QString &symbol) { -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS return DarwinDemangle(symbol); #elif defined(Q_OS_LINUX) return LinuxDemangle(symbol); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 48f336ae9..e63966eab 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -785,13 +785,10 @@ optional_source(APPLE core/macsystemtrayicon.mm core/macscreensaver.cpp core/macfslistener.mm - core/scoped_nsautorelease_pool.mm widgets/osd_mac.mm engine/osxdevicefinder.cpp - device/macdevicelister.mm - globalshortcuts/shortcutgrabber.mm - globalshortcuts/macglobalshortcutbackend.mm globalshortcuts/globalshortcutgrabber.mm + globalshortcuts/macglobalshortcutbackend.mm HEADERS core/mac_startup.h core/macsystemtrayicon.h @@ -799,8 +796,6 @@ optional_source(APPLE core/macfslistener.h core/mac_utilities.h core/mac_delegate.h - engine/osxdevicefinder.h - device/macdevicelister.h globalshortcuts/macglobalshortcutbackend.h ) @@ -965,7 +960,7 @@ endif (NOT CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT ENABLE_WIN32_CONSOLE) # Resource file for windows if(WIN32) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../dist/windres.rc.in ${CMAKE_CURRENT_BINARY_DIR}/windres.rc) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../dist/windows/windres.rc.in ${CMAKE_CURRENT_BINARY_DIR}/windres.rc) set(STRAWBERRY-WIN32-RESOURCES windres.rc) endif(WIN32) @@ -987,73 +982,55 @@ target_link_libraries(strawberry # macdeploy.py relies on the blob being built first. add_dependencies(strawberry strawberry-tagreader) -set_target_properties(strawberry PROPERTIES - MACOSX_BUNDLE_INFO_PLIST "../dist/Info.plist" -) +#set_target_properties(strawberry PROPERTIES + #MACOSX_BUNDLE_INFO_PLIST "../dist/macos/Info.plist" +#) if (APPLE) - install(FILES ../dist/strawberry.icns - DESTINATION "${CMAKE_BINARY_DIR}/strawberry.app/Contents/Resources") - install(FILES ../dist/qt.conf - DESTINATION "${CMAKE_BINARY_DIR}/strawberry.app/Contents/Resources") - install(FILES ../dist/sparkle_pub.pem - DESTINATION "${CMAKE_BINARY_DIR}/strawberry.app/Contents/Resources") + install(FILES ../dist/macos/strawberry.icns DESTINATION "${CMAKE_BINARY_DIR}/strawberry.app/Contents/Resources") + install(FILES ../dist/macos/qt.conf DESTINATION "${CMAKE_BINARY_DIR}/strawberry.app/Contents/Resources") + install(FILES ../dist/macos/sparkle_pub.pem DESTINATION "${CMAKE_BINARY_DIR}/strawberry.app/Contents/Resources") - install(DIRECTORY "${QT_QTGUI_LIBRARY_RELEASE}/Versions/Current/Resources/" - DESTINATION "${CMAKE_BINARY_DIR}/strawberry.app/Contents/Resources") + install(DIRECTORY "${QT_QTGUI_LIBRARY_RELEASE}/Versions/Current/Resources/" DESTINATION "${CMAKE_BINARY_DIR}/strawberry.app/Contents/Resources") if (HAVE_SPARKLE) - install(DIRECTORY "${SPARKLE}/Versions/Current/Resources" - DESTINATION "${CMAKE_BINARY_DIR}/strawberry.app/Contents/Frameworks/Sparkle.framework") + install(DIRECTORY "${SPARKLE}/Versions/Current/Resources" DESTINATION "${CMAKE_BINARY_DIR}/strawberry.app/Contents/Frameworks/Sparkle.framework") endif (HAVE_SPARKLE) - install(FILES "${QT_QTCORE_LIBRARY_RELEASE}/Contents/Info.plist" - DESTINATION "${CMAKE_BINARY_DIR}/strawberry.app/Contents/Frameworks/QtCore.framework/Versions/4/Resources") - install(FILES "${QT_QTGUI_LIBRARY_RELEASE}/Contents/Info.plist" - DESTINATION "${CMAKE_BINARY_DIR}/strawberry.app/Contents/Frameworks/QtGui.framework/Versions/4/Resources") - install(FILES "${QT_QTNETWORK_LIBRARY_RELEASE}/Contents/Info.plist" - DESTINATION "${CMAKE_BINARY_DIR}/strawberry.app/Contents/Frameworks/QtNetwork.framework/Versions/4/Resources") - install(FILES "${QT_QTOPENGL_LIBRARY_RELEASE}/Contents/Info.plist" - DESTINATION "${CMAKE_BINARY_DIR}/strawberry.app/Contents/Frameworks/QtOpenGL.framework/Versions/4/Resources") - install(FILES "${QT_QTSQL_LIBRARY_RELEASE}/Contents/Info.plist" - DESTINATION "${CMAKE_BINARY_DIR}/strawberry.app/Contents/Frameworks/QtSql.framework/Versions/4/Resources") - install(FILES "${QT_QTSVG_LIBRARY_RELEASE}/Contents/Info.plist" - DESTINATION "${CMAKE_BINARY_DIR}/strawberry.app/Contents/Frameworks/QtSvg.framework/Versions/4/Resources") - install(FILES "${QT_QTXML_LIBRARY_RELEASE}/Contents/Info.plist" - DESTINATION "${CMAKE_BINARY_DIR}/strawberry.app/Contents/Frameworks/QtXml.framework/Versions/4/Resources") + install(FILES "${QT_QTCORE_LIBRARY_RELEASE}/Contents/Info.plist" DESTINATION "${CMAKE_BINARY_DIR}/strawberry.app/Contents/Frameworks/QtCore.framework/Versions/4/Resources") + install(FILES "${QT_QTGUI_LIBRARY_RELEASE}/Contents/Info.plist" DESTINATION "${CMAKE_BINARY_DIR}/strawberry.app/Contents/Frameworks/QtGui.framework/Versions/4/Resources") + install(FILES "${QT_QTNETWORK_LIBRARY_RELEASE}/Contents/Info.plist" DESTINATION "${CMAKE_BINARY_DIR}/strawberry.app/Contents/Frameworks/QtNetwork.framework/Versions/4/Resources") + install(FILES "${QT_QTOPENGL_LIBRARY_RELEASE}/Contents/Info.plist" DESTINATION "${CMAKE_BINARY_DIR}/strawberry.app/Contents/Frameworks/QtOpenGL.framework/Versions/4/Resources") + install(FILES "${QT_QTSQL_LIBRARY_RELEASE}/Contents/Info.plist" DESTINATION "${CMAKE_BINARY_DIR}/strawberry.app/Contents/Frameworks/QtSql.framework/Versions/4/Resources") + install(FILES "${QT_QTSVG_LIBRARY_RELEASE}/Contents/Info.plist" DESTINATION "${CMAKE_BINARY_DIR}/strawberry.app/Contents/Frameworks/QtSvg.framework/Versions/4/Resources") + install(FILES "${QT_QTXML_LIBRARY_RELEASE}/Contents/Info.plist" DESTINATION "${CMAKE_BINARY_DIR}/strawberry.app/Contents/Frameworks/QtXml.framework/Versions/4/Resources") - add_custom_command(TARGET strawberry - POST_BUILD - COMMAND - ${CMAKE_CURRENT_SOURCE_DIR}/../dist/macdeploy.py ${PROJECT_BINARY_DIR}/strawberry.app -f - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} - ) + #add_custom_command(TARGET strawberry + # POST_BUILD + # COMMAND + # ${CMAKE_CURRENT_SOURCE_DIR}/../dist/macos/macdeploy.py ${PROJECT_BINARY_DIR}/strawberry.app -f + # WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + #) - if (APPLE_DEVELOPER_ID) - add_custom_target( - sign - COMMAND - ${PROJECT_SOURCE_DIR}/dist/codesign.py ${APPLE_DEVELOPER_ID} ${PROJECT_BINARY_DIR}/strawberry.app - DEPENDS strawberry - VERBATIM - ) - endif() + #if (APPLE_DEVELOPER_ID) + # add_custom_target( + # sign + # COMMAND + # ${PROJECT_SOURCE_DIR}/dist/macos/codesign.py ${APPLE_DEVELOPER_ID} ${PROJECT_BINARY_DIR}/strawberry.app + # DEPENDS strawberry + # VERBATIM + # ) + #endif() - - add_custom_command( - OUTPUT ${PROJECT_BINARY_DIR}/strawberry-${STRAWBERRY_VERSION_PACKAGE}.dmg - ${CMAKE_COMMAND} -E remove -f ${PROJECT_BINARY_DIR}/strawberry-${STRAWBERRY_VERSION_PACKAGE}.dmg - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../dist/create-dmg.sh ${PROJECT_BINARY_DIR}/strawberry.app - COMMAND ${CMAKE_COMMAND} -E rename - ${PROJECT_BINARY_DIR}/strawberry.dmg - ${PROJECT_BINARY_DIR}/strawberry-${STRAWBERRY_VERSION_PACKAGE}.dmg - DEPENDS strawberry - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} - ) - add_custom_target(dmg - DEPENDS ${PROJECT_BINARY_DIR}/strawberry-${STRAWBERRY_VERSION_PACKAGE}.dmg) + #add_custom_command( + # OUTPUT ${PROJECT_BINARY_DIR}/strawberry-${STRAWBERRY_VERSION_PACKAGE}.dmg ${CMAKE_COMMAND} -E remove -f ${PROJECT_BINARY_DIR}/strawberry-$#{STRAWBERRY_VERSION_PACKAGE}.dmg + # COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../dist/macos/create-dmg.sh ${PROJECT_BINARY_DIR}/strawberry.app + # COMMAND ${CMAKE_COMMAND} -E rename ${PROJECT_BINARY_DIR}/strawberry.dmg ${PROJECT_BINARY_DIR}/strawberry-${STRAWBERRY_VERSION_PACKAGE}.dmg + # DEPENDS strawberry + # WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + #) + #add_custom_target(dmg + # DEPENDS ${PROJECT_BINARY_DIR}/strawberry-${STRAWBERRY_VERSION_PACKAGE}.dmg) else (APPLE) - install(TARGETS strawberry - RUNTIME DESTINATION bin - ) + install(TARGETS strawberry RUNTIME DESTINATION bin ) endif (APPLE) diff --git a/src/analyzer/analyzerbase.h b/src/analyzer/analyzerbase.h index 051d1651d..2f4fe199f 100644 --- a/src/analyzer/analyzerbase.h +++ b/src/analyzer/analyzerbase.h @@ -13,14 +13,6 @@ #include #include -#ifdef Q_OS_MACOS - #include //included for convenience - #include //included for convenience -#else - #include //included for convenience - #include //included for convenience -#endif - #include #include #include diff --git a/src/collection/collection.cpp b/src/collection/collection.cpp index e0e3e2c00..539af4de2 100644 --- a/src/collection/collection.cpp +++ b/src/collection/collection.cpp @@ -38,12 +38,12 @@ #include "collectionmodel.h" #include "playlist/playlistmanager.h" -const char *Collection::kSongsTable = "songs"; -const char *Collection::kDirsTable = "directories"; -const char *Collection::kSubdirsTable = "subdirectories"; -const char *Collection::kFtsTable = "songs_fts"; +const char *SCollection::kSongsTable = "songs"; +const char *SCollection::kDirsTable = "directories"; +const char *SCollection::kSubdirsTable = "subdirectories"; +const char *SCollection::kFtsTable = "songs_fts"; -Collection::Collection(Application *app, QObject *parent) +SCollection::SCollection(Application *app, QObject *parent) : QObject(parent), app_(app), backend_(nullptr), @@ -63,14 +63,14 @@ Collection::Collection(Application *app, QObject *parent) } -Collection::~Collection() { +SCollection::~SCollection() { watcher_->deleteLater(); watcher_thread_->exit(); watcher_thread_->wait(5000 /* five seconds */); } -void Collection::Init() { +void SCollection::Init() { watcher_ = new CollectionWatcher; watcher_thread_ = new Thread(this); @@ -98,26 +98,26 @@ void Collection::Init() { backend_->LoadDirectoriesAsync(); } -void Collection::IncrementalScan() { watcher_->IncrementalScanAsync(); } +void SCollection::IncrementalScan() { watcher_->IncrementalScanAsync(); } -void Collection::FullScan() { watcher_->FullScanAsync(); } +void SCollection::FullScan() { watcher_->FullScanAsync(); } -void Collection::PauseWatcher() { watcher_->SetRescanPausedAsync(true); } +void SCollection::PauseWatcher() { watcher_->SetRescanPausedAsync(true); } -void Collection::ResumeWatcher() { watcher_->SetRescanPausedAsync(false); } +void SCollection::ResumeWatcher() { watcher_->SetRescanPausedAsync(false); } + +void SCollection::ReloadSettings() { -void Collection::ReloadSettings() { - watcher_->ReloadSettingsAsync(); } -void Collection::Stopped() { +void SCollection::Stopped() { CurrentSongChanged(Song()); } -void Collection::CurrentSongChanged(const Song &song) { +void SCollection::CurrentSongChanged(const Song &song) { TagReaderReply *reply = nullptr; diff --git a/src/collection/collection.h b/src/collection/collection.h index 422415c9e..45808ac2f 100644 --- a/src/collection/collection.h +++ b/src/collection/collection.h @@ -36,12 +36,12 @@ class CollectionBackend; class CollectionModel; class CollectionWatcher; -class Collection : public QObject { +class SCollection : public QObject { Q_OBJECT public: - Collection(Application* app, QObject* parent); - ~Collection(); + SCollection(Application *app, QObject *parent); + ~SCollection(); static const char *kSongsTable; static const char *kDirsTable; diff --git a/src/core/application.cpp b/src/core/application.cpp index 267e49f27..529283a6c 100644 --- a/src/core/application.cpp +++ b/src/core/application.cpp @@ -74,7 +74,7 @@ class ApplicationImpl { player_([=]() { return new Player(app, app); }), enginedevice_([=]() { return new EngineDevice(app); }), device_manager_([=]() { return new DeviceManager(app, app); }), - collection_([=]() { return new Collection(app, app); }), + collection_([=]() { return new SCollection(app, app); }), playlist_backend_([=]() { PlaylistBackend *backend = new PlaylistBackend(app, app); app->MoveToThread(backend, database_->thread()); @@ -107,7 +107,7 @@ class ApplicationImpl { Lazy player_; Lazy enginedevice_; Lazy device_manager_; - Lazy collection_; + Lazy collection_; Lazy playlist_backend_; Lazy playlist_manager_; Lazy cover_providers_; @@ -183,7 +183,7 @@ DeviceManager *Application::device_manager() const { return p_->device_manager_.get(); } -Collection *Application::collection() const { return p_->collection_.get(); } +SCollection *Application::collection() const { return p_->collection_.get(); } CollectionBackend *Application::collection_backend() const { return collection()->backend(); diff --git a/src/core/application.h b/src/core/application.h index 4caffdb09..322b8dac2 100644 --- a/src/core/application.h +++ b/src/core/application.h @@ -40,7 +40,7 @@ class Database; class EngineDevice; class Player; class Appearance; -class Collection; +class SCollection; class CollectionBackend; class CollectionModel; class PlaylistBackend; @@ -67,15 +67,15 @@ class Application : public QObject { EngineDevice *enginedevice() const; DeviceManager *device_manager() const; - Collection *collection() const; - + SCollection *collection() const; + PlaylistBackend *playlist_backend() const; PlaylistManager *playlist_manager() const; CoverProviders *cover_providers() const; AlbumCoverLoader *album_cover_loader() const; CurrentArtLoader *current_art_loader() const; - + CollectionBackend *collection_backend() const; CollectionModel *collection_model() const; diff --git a/src/core/commandlineoptions.cpp b/src/core/commandlineoptions.cpp index e47fa0dd7..f1305ec8a 100644 --- a/src/core/commandlineoptions.cpp +++ b/src/core/commandlineoptions.cpp @@ -90,7 +90,7 @@ CommandlineOptions::CommandlineOptions(int argc, char* *argv) toggle_pretty_osd_(false), log_levels_(logging::kDefaultLogLevels) { -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS // Remove -psn_xxx option that Mac passes when opened from Finder. RemoveArg("-psn", 1); #endif diff --git a/src/core/filesystemwatcherinterface.cpp b/src/core/filesystemwatcherinterface.cpp index 304c4665b..420d20913 100644 --- a/src/core/filesystemwatcherinterface.cpp +++ b/src/core/filesystemwatcherinterface.cpp @@ -25,7 +25,7 @@ #include "filesystemwatcherinterface.h" #include "qtfslistener.h" -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS #include "macfslistener.h" #endif @@ -34,7 +34,7 @@ FileSystemWatcherInterface::FileSystemWatcherInterface(QObject *parent) FileSystemWatcherInterface *FileSystemWatcherInterface::Create(QObject *parent) { FileSystemWatcherInterface *ret; -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS ret = new MacFSListener(parent); #else ret = new QtFSListener(parent); diff --git a/src/core/mac_delegate.h b/src/core/mac_delegate.h index 0398502fc..da6f69140 100644 --- a/src/core/mac_delegate.h +++ b/src/core/mac_delegate.h @@ -1,7 +1,7 @@ #import #include "config.h" -#include "macglobalshortcutbackend.h" +#include "globalshortcuts/macglobalshortcutbackend.h" class PlatformInterface; @class SPMediaKeyTap; diff --git a/src/core/mac_startup.mm b/src/core/mac_startup.mm index 92cab46a5..a89d562ab 100644 --- a/src/core/mac_startup.mm +++ b/src/core/mac_startup.mm @@ -43,18 +43,18 @@ #include "config.h" -#include "globalshortcuts.h" #include "mac_delegate.h" #include "mac_startup.h" #include "mac_utilities.h" -#include "macglobalshortcutbackend.h" #include "utilities.h" -#include "core/logging.h" #include "scoped_cftyperef.h" -#include "scoped_nsautorelease_pool.h" +#include "core/logging.h" +#include "core/scoped_nsautorelease_pool.h" +#include "globalshortcuts/globalshortcuts.h" +#include "globalshortcuts/macglobalshortcutbackend.h" #ifdef HAVE_SPARKLE -#import +# import #endif #include diff --git a/src/core/macsystemtrayicon.mm b/src/core/macsystemtrayicon.mm index 6a1df5b8b..0af29abf3 100644 --- a/src/core/macsystemtrayicon.mm +++ b/src/core/macsystemtrayicon.mm @@ -90,7 +90,7 @@ class MacSystemTrayIconPrivate { // This must be called after our custom NSApplicationDelegate has been set. [(AppDelegate*)([NSApp delegate]) setDockMenu:dock_menu_]; - ClearPlaying(); + ClearNowPlaying(); } void AddMenuItem(QAction* action) { @@ -120,8 +120,8 @@ class MacSystemTrayIconPrivate { [dock_menu_ addItem:separator]; } - void ShowPlaying(const QString& artist, const QString& title) { - ClearPlaying(); // Makes sure the order is consistent. + void ShowNowPlaying(const QString& artist, const QString& title) { + ClearNowPlaying(); // Makes sure the order is consistent. [now_playing_artist_ setTitle: [[NSString alloc] initWithUTF8String: artist.toUtf8().constData()]]; [now_playing_title_ setTitle: @@ -131,7 +131,7 @@ class MacSystemTrayIconPrivate { artist.isEmpty() && title.isEmpty() ? HideItem(now_playing_) : ShowItem(now_playing_); } - void ClearPlaying() { + void ClearNowPlaying() { // Hiding doesn't seem to work in the dock menu. HideItem(now_playing_); HideItem(now_playing_artist_); @@ -200,10 +200,10 @@ void MacSystemTrayIcon::ActionChanged() { p_->ActionChanged(action); } -void MacSystemTrayIcon::ClearPlaying() { - p_->ClearPlaying(); +void MacSystemTrayIcon::ClearNowPlaying() { + p_->ClearNowPlaying(); } -void MacSystemTrayIcon::SetPlaying(const Song& song, const QString& image_path) { - p_->ShowPlaying(song.artist(), song.PrettyTitle()); +void MacSystemTrayIcon::SetNowPlaying(const Song& song, const QString& image_path) { + p_->ShowNowPlaying(song.artist(), song.PrettyTitle()); } diff --git a/src/core/main.cpp b/src/core/main.cpp index 42bf54e5c..755bd8e41 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -48,7 +49,7 @@ # include #endif -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS # include # include #endif @@ -90,13 +91,13 @@ int main(int argc, char* argv[]) { -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS // Do Mac specific startup to get media keys working. // This must go before QApplication initialisation. mac::MacMain(); #endif -#if defined(Q_OS_WIN32) || defined(Q_OS_DARWIN) +#if defined(Q_OS_WIN32) || defined(Q_OS_MACOS) QCoreApplication::setApplicationName("Strawberry"); QCoreApplication::setOrganizationName("Strawberry"); #else @@ -142,7 +143,7 @@ int main(int argc, char* argv[]) { } } -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS // Must happen after QCoreApplication::setOrganizationName(). setenv("XDG_CONFIG_HOME", QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation).toLocal8Bit().constData(), 1); #endif @@ -159,8 +160,8 @@ int main(int argc, char* argv[]) { QtSingleApplication a(argc, argv); -#ifdef Q_OS_DARWIN - QCoreApplication::setCollectionPaths(QStringList() << QCoreApplication::applicationDirPath() + "/../PlugIns"); +#ifdef Q_OS_MACOS + QCoreApplication::setLibraryPaths(QStringList() << QCoreApplication::applicationDirPath() + "/../PlugIns"); #endif a.setQuitOnLastWindowClosed(false); @@ -170,7 +171,7 @@ int main(int argc, char* argv[]) { return 0; } -#ifndef Q_OS_DARWIN +#ifndef Q_OS_MACOS // Gnome on Ubuntu has menu icons disabled by default. I think that's a bad idea, and makes some menus in Strawberry look confusing. QCoreApplication::setAttribute(Qt::AA_DontShowIconsInMenus, false); #else @@ -217,9 +218,9 @@ int main(int argc, char* argv[]) { // Window MainWindow w(&app, tray_icon.get(), &osd, options); -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS mac::EnableFullScreen(w); -#endif // Q_OS_DARWIN +#endif // Q_OS_MACOS #ifdef HAVE_GIO ScanGIOModulePath(); #endif diff --git a/src/core/mainwindow.cpp b/src/core/mainwindow.cpp index 07e8e9736..3a5bc374c 100644 --- a/src/core/mainwindow.cpp +++ b/src/core/mainwindow.cpp @@ -84,7 +84,7 @@ #include "dialogs/trackselectiondialog.h" #include "dialogs/edittagdialog.h" #ifdef HAVE_GSTREAMER -#include "dialogs/organisedialog.h" +# include "dialogs/organisedialog.h" #endif #include "widgets/fancytabwidget.h" #include "widgets/playingwidget.h" @@ -127,13 +127,13 @@ #include "settings/playlistsettingspage.h" #include "settings/settingsdialog.h" -#ifdef Q_OS_DARWIN -#include "ui/macsystemtrayicon.h" +#ifdef Q_OS_MACOS +# include "core/macsystemtrayicon.h" #endif -#ifdef Q_OS_DARWIN -// Non exported mac-specific function. -void qt_mac_set_dock_menu(QMenu*); +#ifdef Q_OS_MACOS + // Non exported mac-specific function. + void qt_mac_set_dock_menu(QMenu*); #endif const char *MainWindow::kSettingsGroup = "MainWindow"; @@ -203,7 +203,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co // Initialise the UI ui_->setupUi(this); -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS ui_->menu_help->menuAction()->setVisible(false); #endif @@ -511,7 +511,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co playlist_menu_->addAction(ui_->action_remove_duplicates); playlist_menu_->addAction(ui_->action_remove_unavailable); -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS ui_->action_shuffle->setShortcut(QKeySequence()); #endif @@ -525,7 +525,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co connect(app_->device_manager()->connected_devices_model(), SIGNAL(IsEmptyChanged(bool)), playlist_copy_to_device_, SLOT(setDisabled(bool))); #endif -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS mac::SetApplicationHandler(this); #endif // Tray icon @@ -542,7 +542,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co // Windows 7 thumbbar buttons thumbbar_->SetActions(QList() << ui_->action_previous_track << ui_->action_play_pause << ui_->action_stop << ui_->action_next_track << nullptr); // spacer -#if (defined(Q_OS_DARWIN) && defined(HAVE_SPARKLE)) +#if (defined(Q_OS_MACOS) && defined(HAVE_SPARKLE)) // Add check for updates item to application menu. QAction *check_updates = ui_->menu_tools->addAction(tr("Check for updates...")); check_updates->setMenuRole(QAction::ApplicationSpecificRole); @@ -661,7 +661,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co ui_->playlist->view()->ReloadSettings(); -#ifndef Q_OS_DARWIN +#ifndef Q_OS_MACOS QSettings settings; settings.beginGroup(BehaviourSettingsPage::kSettingsGroup); StartupBehaviour behaviour = StartupBehaviour(settings.value("startupbehaviour", Startup_Remember).toInt()); @@ -682,7 +682,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co settings_.setValue("hidden", false); show(); } -#else // Q_OS_DARWIN +#else // Q_OS_MACOS // Always show mainwindow on startup on OS X. show(); #endif @@ -711,7 +711,7 @@ void MainWindow::ReloadSettings() { QSettings settings; -#ifndef Q_OS_DARWIN +#ifndef Q_OS_MACOS settings.beginGroup(BehaviourSettingsPage::kSettingsGroup); bool showtrayicon = settings.value("showtrayicon", true).toBool(); @@ -1694,7 +1694,7 @@ bool MainWindow::LoadUrl(const QString &url) { } void MainWindow::CheckForUpdates() { -#if defined(Q_OS_DARWIN) +#if defined(Q_OS_MACOS) mac::CheckForUpdates(); #endif } diff --git a/src/core/screensaver.cpp b/src/core/screensaver.cpp index b0fe9b011..241d61d2b 100644 --- a/src/core/screensaver.cpp +++ b/src/core/screensaver.cpp @@ -29,7 +29,7 @@ #include "screensaver.h" -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS #include "macscreensaver.h" #endif @@ -51,7 +51,7 @@ Screensaver *Screensaver::GetScreensaver() { else if (QDBusConnection::sessionBus().interface()->isServiceRegistered(kKdeService)) { screensaver_ = new DBusScreensaver(kKdeService, kKdePath, kKdeInterface); } - #elif defined(Q_OS_DARWIN) + #elif defined(Q_OS_MACOS) screensaver_ = new MacScreensaver(); #endif } diff --git a/src/core/stylesheetloader.cpp b/src/core/stylesheetloader.cpp index a10b4a2a6..b6d9c8058 100644 --- a/src/core/stylesheetloader.cpp +++ b/src/core/stylesheetloader.cpp @@ -87,7 +87,7 @@ void StyleSheetLoader::UpdateStyleSheet(QWidget *widget) { ReplaceColor(&contents, "Link", p, QPalette::Link); ReplaceColor(&contents, "LinkVisited", p, QPalette::LinkVisited); -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS contents.replace("darwin", "*"); #endif diff --git a/src/core/systemtrayicon.cpp b/src/core/systemtrayicon.cpp index be07c6df0..628f97ee6 100644 --- a/src/core/systemtrayicon.cpp +++ b/src/core/systemtrayicon.cpp @@ -30,8 +30,11 @@ #include #include -#include "qtsystemtrayicon.h" #include "systemtrayicon.h" +#include "qtsystemtrayicon.h" +#ifdef Q_OS_MACOS +# include "macsystemtrayicon.h" +#endif SystemTrayIcon::SystemTrayIcon(QObject *parent) : QObject(parent), @@ -103,7 +106,7 @@ void SystemTrayIcon::SetStopped() { } SystemTrayIcon* SystemTrayIcon::CreateSystemTrayIcon(QObject *parent) { -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS return new MacSystemTrayIcon(parent); #else return new QtSystemTrayIcon(parent); diff --git a/src/core/utilities.cpp b/src/core/utilities.cpp index 82d4e319a..24c5eeafa 100644 --- a/src/core/utilities.cpp +++ b/src/core/utilities.cpp @@ -59,26 +59,27 @@ #include #ifdef Q_OS_LINUX - #include - #include +# include +# include #endif -#ifdef Q_OS_DARWIN - #include +#ifdef Q_OS_MACOS +# include +# include +# include #endif #if defined(Q_OS_UNIX) - #include -#elif defined(Q_OS_WIN32) - #include +# include +#elif defined(Q_OS_WIN) +# include #endif -#ifdef Q_OS_DARWIN - #include - - #include "CoreServices/CoreServices.h" - #include "IOKit/ps/IOPSKeys.h" - #include "IOKit/ps/IOPowerSources.h" -#elif defined(Q_OS_WIN32) +#ifdef Q_OS_MACOS +# include +# include "CoreServices/CoreServices.h" +# include "IOKit/ps/IOPSKeys.h" +# include "IOKit/ps/IOPowerSources.h" +#elif defined(Q_OS_WIN) #include #endif @@ -89,10 +90,10 @@ #include "timeconstants.h" #include "application.h" -#ifdef Q_OS_DARWIN - #include "mac_startup.h" - #include "mac_utilities.h" - #include "scoped_cftyperef.h" +#ifdef Q_OS_MACOS +# include "mac_startup.h" +# include "mac_utilities.h" +# include "scoped_cftyperef.h" #endif namespace Utilities { @@ -361,7 +362,7 @@ QString ColorToRgba(const QColor &c) { } -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS qint32 GetMacVersion() { SInt32 minor_version; @@ -374,7 +375,7 @@ qint32 GetMacVersion() { void RevealFileInFinder(QString const &path) { QProcess::execute("/usr/bin/open", QStringList() << "-R" << path); } -#endif // Q_OS_DARWIN +#endif // Q_OS_MACOS #ifdef Q_OS_WIN void ShowFileInExplorer(QString const &path) { @@ -398,7 +399,7 @@ void OpenInFileBrowser(const QList &urls) { if (dirs.contains(directory)) continue; dirs.insert(directory); qLog(Debug) << path; -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS // Revealing multiple files in the finder only opens one window, so it also makes sense to reveal at most one per directory RevealFileInFinder(path); #elif defined(Q_OS_WIN32) @@ -642,7 +643,7 @@ int SetThreadIOPriority(IoPriority priority) { #ifdef Q_OS_LINUX return syscall(SYS_ioprio_set, IOPRIO_WHO_PROCESS, GetThreadId(), 4 | priority << IOPRIO_CLASS_SHIFT); -#elif defined(Q_OS_DARWIN) +#elif defined(Q_OS_MACOS) return setpriority(PRIO_DARWIN_THREAD, 0, priority == IOPRIO_CLASS_IDLE ? PRIO_DARWIN_BG : 0); #else return 0; @@ -752,7 +753,7 @@ void SetEnv(const char *key, const QString &value) { void IncreaseFDLimit() { -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS // Bump the soft limit for the number of file descriptors from the default of 256 to the maximum (usually 10240). struct rlimit limit; getrlimit(RLIMIT_NOFILE, &limit); diff --git a/src/device/cddalister.cpp b/src/device/cddalister.cpp index 7fa203648..88cdd54a9 100644 --- a/src/device/cddalister.cpp +++ b/src/device/cddalister.cpp @@ -105,7 +105,7 @@ void CddaLister::UpdateDeviceFreeSpace(const QString&) {} void CddaLister::Init() { cdio_init(); -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS if (!cdio_have_driver(DRIVER_OSX)) { qLog(Error) << "libcdio was compiled without support for OS X!"; } @@ -121,7 +121,7 @@ void CddaLister::Init() { if (device_info.isSymLink()) { device = device_info.symLinkTarget(); } -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS // Every track is detected as a separate device on Darwin. The raw disk looks like /dev/rdisk1 if (!device.contains(QRegExp("^/dev/rdisk[0-9]$"))) { continue; diff --git a/src/device/devicemanager.cpp b/src/device/devicemanager.cpp index cc7aea8ee..5d80a1231 100644 --- a/src/device/devicemanager.cpp +++ b/src/device/devicemanager.cpp @@ -68,7 +68,7 @@ # include "cddadevice.h" #endif -#if defined(Q_OS_DARWIN) and defined(HAVE_LIBMTP) +#if defined(Q_OS_MACOS) and defined(HAVE_LIBMTP) # include "macdevicelister.h" #endif #ifdef HAVE_LIBGPOD @@ -220,7 +220,7 @@ DeviceManager::DeviceManager(Application *app, QObject *parent) connected_devices_model_->setSourceModel(this); // CD devices are detected via the DiskArbitration framework instead on Darwin. -#if defined(HAVE_AUDIOCD) && defined(HAVE_GSTREAMER) && !defined(Q_OS_DARWIN) +#if defined(HAVE_AUDIOCD) && defined(HAVE_GSTREAMER) && !defined(Q_OS_MACOS) AddLister(new CddaLister); #endif #ifdef HAVE_DEVICEKIT @@ -232,7 +232,7 @@ DeviceManager::DeviceManager(Application *app, QObject *parent) #ifdef HAVE_GIO AddLister(new GioLister); #endif -#if defined(Q_OS_DARWIN) and defined(HAVE_LIBMTP) +#if defined(Q_OS_MACOS) and defined(HAVE_LIBMTP) AddLister(new MacDeviceLister); #endif diff --git a/src/engine/enginedevice.cpp b/src/engine/enginedevice.cpp index 31a0d90e8..9811f2690 100644 --- a/src/engine/enginedevice.cpp +++ b/src/engine/enginedevice.cpp @@ -38,7 +38,7 @@ # include "pulsedevicefinder.h" #endif -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS # include "osxdevicefinder.h" #endif @@ -63,7 +63,7 @@ void EngineDevice::Init() { #ifdef HAVE_LIBPULSE device_finders.append(new PulseDeviceFinder); #endif -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS device_finders.append(new OsxDeviceFinder); #endif #ifdef Q_OS_WIN32 diff --git a/src/engine/gstengine.cpp b/src/engine/gstengine.cpp index ae3a7b561..3261825fc 100644 --- a/src/engine/gstengine.cpp +++ b/src/engine/gstengine.cpp @@ -106,8 +106,8 @@ GstEngine::GstEngine(TaskManager *task_manager) ReloadSettings(); -#ifdef Q_OS_DARWIN - QDir resources_dir(mac::GetResourcesPath()); +#ifdef Q_OS_MACOS___ // FIXME + QDir resources_dir(mac::getResourcesPath()); QString ca_cert_path = resources_dir.filePath("cacert.pem"); GError *error = nullptr; tls_database_ = g_tls_file_database_new(ca_cert_path.toUtf8().data(), &error); @@ -121,7 +121,7 @@ GstEngine::~GstEngine() { current_pipeline_.reset(); -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS g_object_unref(tls_database_); #endif } @@ -428,14 +428,14 @@ void GstEngine::SetEnvironment() { QString registry_filename; // On windows and mac we bundle the gstreamer plugins with strawberry -#if defined(Q_OS_DARWIN) +#if defined(Q_OS_MACOS) scanner_path = QCoreApplication::applicationDirPath() + "/../PlugIns/gst-plugin-scanner"; plugin_path = QCoreApplication::applicationDirPath() + "/../PlugIns/gstreamer"; #elif defined(Q_OS_WIN32) plugin_path = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + "/gstreamer-plugins"); #endif -#if defined(Q_OS_WIN32) || defined(Q_OS_DARWIN) +#if defined(Q_OS_WIN32) || defined(Q_OS_MACOS) registry_filename = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + QString("/gst-registry-%1-bin").arg(QCoreApplication::applicationVersion()); #endif @@ -451,7 +451,7 @@ void GstEngine::SetEnvironment() { Utilities::SetEnv("GST_REGISTRY", registry_filename); } -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS Utilities::SetEnv("GIO_EXTRA_MODULES", QCoreApplication::applicationDirPath() + "/../PlugIns/gio-modules"); #endif diff --git a/src/engine/gstengine.h b/src/engine/gstengine.h index ad577dd49..d52c056d4 100644 --- a/src/engine/gstengine.h +++ b/src/engine/gstengine.h @@ -49,7 +49,7 @@ class TaskManager; class GstEnginePipeline; -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS struct _GTlsDatabase; typedef struct _GTlsDatabase GTlsDatabase; #endif @@ -111,7 +111,7 @@ class GstEngine : public Engine::Base, public GstBufferConsumer { void AddBufferConsumer(GstBufferConsumer *consumer); void RemoveBufferConsumer(GstBufferConsumer *consumer); -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS GTlsDatabase *tls_database() const { return tls_database_; } #endif @@ -202,6 +202,10 @@ class GstEngine : public Engine::Base, public GstBufferConsumer { bool have_new_buffer_; int scope_chunks_; +#ifdef Q_OS_MACOS + GTlsDatabase* tls_database_; +#endif + }; #endif /* GSTENGINE_H */ diff --git a/src/engine/gstenginepipeline.cpp b/src/engine/gstenginepipeline.cpp index c4ba3111f..0b95f06b8 100644 --- a/src/engine/gstenginepipeline.cpp +++ b/src/engine/gstenginepipeline.cpp @@ -513,7 +513,7 @@ void GstEnginePipeline::TaskEnterCallback(GstTask *, GThread *, gpointer) { // Bump the priority of the thread only on OS X -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS sched_param param; memset(¶m, 0, sizeof(param)); @@ -835,7 +835,7 @@ void GstEnginePipeline::SourceSetupCallback(GstPlayBin *bin, GParamSpec *pspec, if (g_object_class_find_property(G_OBJECT_GET_CLASS(element), "user-agent")) { QString user_agent = QString("%1 %2").arg(QCoreApplication::applicationName(), QCoreApplication::applicationVersion()); g_object_set(element, "user-agent", user_agent.toUtf8().constData(), nullptr); -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS g_object_set(element, "tls-database", instance->engine_->tls_database(), nullptr); g_object_set(element, "ssl-use-system-ca-file", false, nullptr); g_object_set(element, "ssl-strict", TRUE, nullptr); diff --git a/src/engine/xineengine.cpp b/src/engine/xineengine.cpp index 79f4b7bc3..2bc0b1b9e 100644 --- a/src/engine/xineengine.cpp +++ b/src/engine/xineengine.cpp @@ -425,7 +425,7 @@ void XineEngine::SetEnvironment() { putenv(QString("XINE_PLUGIN_PATH=" + QCoreApplication::applicationDirPath() + "/xine-plugins").toLatin1().constData()); #endif -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS setenv("XINE_PLUGIN_PATH", QString(QCoreApplication::applicationDirPath() + "/../PlugIns/xine").toLatin1().constData(), 1); #endif diff --git a/src/globalshortcuts/globalshortcutgrabber.cpp b/src/globalshortcuts/globalshortcutgrabber.cpp index 902a257c0..2d1bda43c 100644 --- a/src/globalshortcuts/globalshortcutgrabber.cpp +++ b/src/globalshortcuts/globalshortcutgrabber.cpp @@ -69,14 +69,14 @@ void GlobalShortcutGrabber::hideEvent(QHideEvent *e) { } void GlobalShortcutGrabber::grabKeyboard() { -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS SetupMacEventHandler(); #endif QDialog::grabKeyboard(); } void GlobalShortcutGrabber::releaseKeyboard() { -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS TeardownMacEventHandler(); #endif QDialog::releaseKeyboard(); diff --git a/src/globalshortcuts/globalshortcuts.cpp b/src/globalshortcuts/globalshortcuts.cpp index 938ddb48f..c8c9db098 100644 --- a/src/globalshortcuts/globalshortcuts.cpp +++ b/src/globalshortcuts/globalshortcuts.cpp @@ -33,7 +33,11 @@ #include "globalshortcuts.h" #include "globalshortcutbackend.h" #include "gnomeglobalshortcutbackend.h" -#include "qxtglobalshortcutbackend.h" +#ifndef Q_OS_MACOS +# include "qxtglobalshortcutbackend.h" +#else +# include "macglobalshortcutbackend.h" +#endif #include "settings/shortcutssettingspage.h" GlobalShortcuts::GlobalShortcuts(QWidget *parent) @@ -66,7 +70,7 @@ GlobalShortcuts::GlobalShortcuts(QWidget *parent) // Create backends - these do the actual shortcut registration gnome_backend_ = new GnomeGlobalShortcutBackend(this); -#ifndef Q_OS_DARWIN +#ifndef Q_OS_MACOS system_backend_ = new QxtGlobalShortcutBackend(this); #else system_backend_ = new MacGlobalShortcutBackend(this); diff --git a/src/globalshortcuts/macglobalshortcutbackend.mm b/src/globalshortcuts/macglobalshortcutbackend.mm index b75abd07d..16f821864 100644 --- a/src/globalshortcuts/macglobalshortcutbackend.mm +++ b/src/globalshortcuts/macglobalshortcutbackend.mm @@ -36,13 +36,13 @@ #include #include "config.h" -#include "core/globalshortcuts.h" +#include "globalshortcuts.h" #include "core/logging.h" #include "core/mac_startup.h" #include "core/utilities.h" #import "core/mac_utilities.h" -#import "mac/SBSystemPreferences.h" +#import "core/SBSystemPreferences.h" class MacGlobalShortcutBackendPrivate : boost::noncopyable { public: @@ -88,10 +88,8 @@ bool MacGlobalShortcutBackend::DoRegister() { // Always enable media keys. mac::SetShortcutHandler(this); - for (const GlobalShortcuts::Shortcut& shortcut : - manager_->shortcuts().values()) { - shortcuts_[shortcut.action->shortcut()] = shortcut.action; - } + for (const GlobalShortcuts::Shortcut& shortcut : manager_->shortcuts().values()) { + shortcuts_[shortcut.action->shortcut()] = shortcut.action; } return p_->Register(); @@ -134,29 +132,26 @@ bool MacGlobalShortcutBackend::IsAccessibilityEnabled() const { } void MacGlobalShortcutBackend::ShowAccessibilityDialog() { - NSArray* paths = NSSearchPathForDirectoriesInDomains( - NSPreferencePanesDirectory, NSSystemDomainMask, YES); + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSPreferencePanesDirectory, NSSystemDomainMask, YES); if ([paths count] == 1) { SBSystemPreferencesApplication* system_prefs = [SBApplication applicationWithBundleIdentifier:@"com.apple.systempreferences"]; [system_prefs activate]; - SBElementArray* panes = [system_prefs panes]; - SBSystemPreferencesPane* security_pane = nil; - for (SBSystemPreferencesPane* pane : panes) { - if ([[pane id] isEqualToString:@"com.apple.preference.security"]) { - security_pane = pane; - break; - } + SBElementArray* panes = [system_prefs panes]; + SBSystemPreferencesPane* security_pane = nil; + for (SBSystemPreferencesPane* pane : panes) { + if ([[pane id] isEqualToString:@"com.apple.preference.security"]) { + security_pane = pane; + break; } } [system_prefs setCurrentPane:security_pane]; - SBElementArray* anchors = [security_pane anchors]; - for (SBSystemPreferencesAnchor* anchor : anchors) { - if ([[anchor name] isEqualToString:@"Privacy_Accessibility"]) { - [anchor reveal]; - } + SBElementArray* anchors = [security_pane anchors]; + for (SBSystemPreferencesAnchor* anchor : anchors) { + if ([[anchor name] isEqualToString:@"Privacy_Accessibility"]) { + [anchor reveal]; } } } diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp index 33a4b30b8..084919cec 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlist.cpp @@ -648,7 +648,7 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, int ro if (const SongMimeData *song_data = qobject_cast(data)) { // Dragged from a collection // We want to check if these songs are from the actual local file backend, if they are we treat them differently. - if (song_data->backend && song_data->backend->songs_table() == Collection::kSongsTable) + if (song_data->backend && song_data->backend->songs_table() == SCollection::kSongsTable) InsertSongItems(song_data->songs, row, play_now, enqueue_now); else InsertSongItems(song_data->songs, row, play_now, enqueue_now); @@ -955,7 +955,7 @@ void Playlist::InsertSongsOrCollectionItems(const SongList &songs, int pos, bool } void Playlist::UpdateItems(const SongList &songs) { - + qLog(Debug) << "Updating playlist with new tracks' info"; // We first convert our songs list into a linked list (a 'real' list), because removals are faster with QLinkedList. // Next, we walk through the list of playlist's items then the list of songs diff --git a/src/playlist/playlistdelegates.cpp b/src/playlist/playlistdelegates.cpp index 4851a8b40..ada0a2b51 100644 --- a/src/playlist/playlistdelegates.cpp +++ b/src/playlist/playlistdelegates.cpp @@ -70,9 +70,9 @@ #include "playlist/playlist.h" #include "playlistdelegates.h" -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS #include "core/mac_utilities.h" -#endif // Q_OS_DARWIN +#endif // Q_OS_MACOS const int QueuedItemDelegate::kQueueBoxBorder = 1; const int QueuedItemDelegate::kQueueBoxCornerRadius = 3; @@ -484,7 +484,7 @@ void SongSourceDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op QPixmap pixmap = LookupPixmap(url, option_copy.decorationSize); float device_pixel_ratio = 1.0f; -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS QWidget *parent_widget = reinterpret_cast(parent()); device_pixel_ratio = mac::GetDevicePixelRatio(parent_widget); #endif diff --git a/src/playlist/playlistitem.cpp b/src/playlist/playlistitem.cpp index 7d9f11161..26bcb0aa6 100644 --- a/src/playlist/playlistitem.cpp +++ b/src/playlist/playlistitem.cpp @@ -53,7 +53,7 @@ PlaylistItem* PlaylistItem::NewFromType(const QString &type) { PlaylistItem* PlaylistItem::NewFromSongsTable(const QString &table, const Song &song) { - if (table == Collection::kSongsTable) + if (table == SCollection::kSongsTable) return new CollectionPlaylistItem(song); qLog(Warning) << "Invalid PlaylistItem songs table:" << table; diff --git a/src/playlist/playlistview.cpp b/src/playlist/playlistview.cpp index bf6b04f45..dd0b17183 100644 --- a/src/playlist/playlistview.cpp +++ b/src/playlist/playlistview.cpp @@ -186,7 +186,7 @@ PlaylistView::PlaylistView(QWidget *parent) setAttribute(Qt::WA_MacShowFocusRect, false); -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); #endif // For fading @@ -523,7 +523,7 @@ void PlaylistView::keyPressEvent(QKeyEvent *event) { else if (event == QKeySequence::Delete) { RemoveSelected(false); event->accept(); -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS } else if (event->key() == Qt::Key_Backspace) { RemoveSelected(false); diff --git a/src/settings/behavioursettingspage.cpp b/src/settings/behavioursettingspage.cpp index ee61f6efb..45675bc89 100644 --- a/src/settings/behavioursettingspage.cpp +++ b/src/settings/behavioursettingspage.cpp @@ -43,9 +43,9 @@ BehaviourSettingsPage::BehaviourSettingsPage(SettingsDialog *dialog) : SettingsP connect(ui_->checkbox_showtrayicon, SIGNAL(toggled(bool)), SLOT(ShowTrayIconToggled(bool))); -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS ui_->checkbox_showtrayicon->setEnabled(false); - ui_->startup_group->setEnabled(false); + ui_->groupbox_startup->setEnabled(false); #endif } diff --git a/src/settings/behavioursettingspage.ui b/src/settings/behavioursettingspage.ui index 3b70018af..f92e0d243 100644 --- a/src/settings/behavioursettingspage.ui +++ b/src/settings/behavioursettingspage.ui @@ -52,7 +52,7 @@ - + When Strawberry starts @@ -60,14 +60,14 @@ - Always show the main window + Always show the &main window - Always hide the main window + Alwa&ys hide the main window diff --git a/src/settings/notificationssettingspage.cpp b/src/settings/notificationssettingspage.cpp index 02ce8f6e3..2c152f266 100644 --- a/src/settings/notificationssettingspage.cpp +++ b/src/settings/notificationssettingspage.cpp @@ -175,7 +175,7 @@ void NotificationsSettingsPage::Load() { ui_->notifications_custom_text2->setText(s.value("CustomText2").toString()); s.endGroup(); -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS ui_->notifications_options->setEnabled(ui_->notifications_pretty->isChecked()); #endif @@ -339,7 +339,7 @@ void NotificationsSettingsPage::NotificationTypeChanged() { ui_->notifications_pretty_group->setEnabled(pretty); ui_->notifications_custom_text_group->setEnabled(enabled); -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS ui_->notifications_options->setEnabled(pretty); #endif ui_->notifications_duration->setEnabled(!pretty || (pretty && !ui_->notifications_disable_duration->isChecked())); diff --git a/src/settings/shortcutssettingspage.cpp b/src/settings/shortcutssettingspage.cpp index f7d97012e..a49973982 100644 --- a/src/settings/shortcutssettingspage.cpp +++ b/src/settings/shortcutssettingspage.cpp @@ -38,6 +38,7 @@ #include #include "core/iconloader.h" +#include "core/utilities.h" #include "globalshortcuts/globalshortcutgrabber.h" #include "globalshortcuts/globalshortcuts.h" #include "settingspage.h" @@ -119,11 +120,11 @@ void GlobalShortcutsSettingsPage::Load() { } ui_->mac_container->setVisible(!manager->IsMacAccessibilityEnabled()); -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS qint32 mac_version = Utilities::GetMacVersion(); ui_->mac_label->setVisible(mac_version < 9); ui_->mac_label_mavericks->setVisible(mac_version >= 9); -#endif // Q_OS_DARWIN +#endif // Q_OS_MACOS } diff --git a/src/widgets/osd.cpp b/src/widgets/osd.cpp index 5713a94ea..ffe4f9079 100644 --- a/src/widgets/osd.cpp +++ b/src/widgets/osd.cpp @@ -220,7 +220,7 @@ void OSD::ShowMessage(const QString &summary, const QString &message, const QStr } break; -#ifndef Q_OS_DARWIN +#ifndef Q_OS_MACOS case TrayPopup: tray_icon_->ShowPopup(summary, message, timeout_msec_); break; @@ -324,7 +324,7 @@ QString OSD::ReplaceVariable(const QString &variable, const Song &song) { // We need different strings depending on notification type switch (behaviour_) { case Native: -#ifdef Q_OS_DARWIN +#ifdef Q_OS_MACOS return "\n"; #endif #ifdef Q_OS_LINUX diff --git a/src/widgets/statusview.cpp b/src/widgets/statusview.cpp index 4d2f3c009..d8a6d70e0 100644 --- a/src/widgets/statusview.cpp +++ b/src/widgets/statusview.cpp @@ -297,7 +297,6 @@ void StatusView::UpdateSong() { const QueryOptions opt; CollectionBackend::AlbumList albumlist; - Engine::EngineType enginetype = app_->player()->engine()->type(); label_playing_top_->setText(""); label_playing_text_->setText(""); @@ -314,9 +313,9 @@ void StatusView::UpdateSong() { html += QString("Bitrate: %1 kbps
\n").arg(metadata_.bitrate()); html += QString("Samplerate: %1 hz / %2 bit
\n").arg(metadata_.samplerate()).arg(metadata_.bitdepth()); - if (enginetype != Engine::EngineType::None) { + if (app_->player()->engine() && app_->player()->engine()->type() != Engine::EngineType::None) { html += QString("
"); - html += QString("Engine: %1
").arg(EngineName(enginetype)); + html += QString("Engine: %1
").arg(EngineDescription(app_->player()->engine()->type())); } html += QString("
");