diff --git a/CMakeLists.txt b/CMakeLists.txt index 9507f9e46..3efbea21c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -203,8 +203,12 @@ SET( CANTATA_UIS widgets/itemview.ui ) -set(TAGLIB_MIN_VERSION "1.6") -find_package(Taglib) +IF (ANDROID) + SET(CANTATA_SRCS ${CANTATA_SRCS} androidmain.cpp) +ELSE (ANDROID) + set(TAGLIB_MIN_VERSION "1.6") + find_package(Taglib) +ENDIF (ANDROID) if (TAGLIB_FOUND) SET( CANTATA_SRCS ${CANTATA_SRCS} @@ -276,17 +280,24 @@ include_directories( ${CMAKE_SOURCE_DIR}/libmaia ${CMAKE_BINARY_DIR} ) +IF (ANDROID) + INCLUDE_DIRECTORIES(${ANDROID_NDK_TOOLCHAIN_ROOT}/sysroot/usr/include) +ENDIF (ANDROID) + # this command finds Qt4 libraries and sets all required variables FIND_PACKAGE( Qt4 REQUIRED QtCore QtGui QtXml QtNetwork ) -FIND_PACKAGE( Phonon ) -if(NOT WIN32) +IF (NOT ANDROID) + FIND_PACKAGE( Phonon ) +ENDIF (NOT ANDROID) + +if(NOT WIN32 AND NOT ANDROID) qt4_add_dbus_adaptor(CANTATA_SRCS dbus/org.mpris.MediaPlayer2.Player.xml dbus/mpris.h Mpris) qt4_add_dbus_adaptor(CANTATA_SRCS dbus/org.mpris.MediaPlayer2.root.xml dbus/mpris.h Mpris) qt4_add_dbus_adaptor(CANTATA_SRCS dbus/org.kde.cantata.xml gui/mainwindow.h MainWindow) qt4_add_dbus_interfaces(CANTATA_SRCS dbus/net.launchpad.DockItem.xml ) qt4_add_dbus_interfaces(CANTATA_SRCS dbus/net.launchpad.DockManager.xml) -endif(NOT WIN32) +endif(NOT WIN32 AND NOT ANDROID) IF( NOT DEFINED WANT_KDE_SUPPORT ) SET( WANT_KDE_SUPPORT ON ) @@ -453,34 +464,37 @@ ELSE( ENABLE_KDE_SUPPORT ) INCLUDE( ${QT_USE_FILE} ) QT4_WRAP_CPP( CANTATA_MOC_SRCS ${CANTATA_MOC_HDRS} ) - if (WIN32) - IF( MINGW ) - # resource compilation for MinGW - ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cantataico.o - COMMAND windres.exe -I${CMAKE_CURRENT_SOURCE_DIR} -i${CMAKE_SOURCE_DIR}/icons/cantataico.rc - -o ${CMAKE_CURRENT_BINARY_DIR}/cantataico.o ) - SET(CANTATA_SRCS ${CANTATA_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/cantataico.o) - ELSE( MINGW ) - SET(CANTATA_SRCS ${CANTATA_SRCS} icons/cantataico.rc) - ENDIF( MINGW ) - ADD_EXECUTABLE( cantata WIN32 ${CANTATA_SRCS} ${CANTATA_MOC_SRCS} ${CANTATA_RC_SRCS} ${CANTATA_UI_HDRS} ) - else (WIN32) - ADD_EXECUTABLE( cantata ${CANTATA_SRCS} ${CANTATA_MOC_SRCS} ${CANTATA_RC_SRCS} ${CANTATA_UI_HDRS} ) - install( PROGRAMS dynamic/cantata-dynamic DESTINATION bin) - endif (WIN32) + IF (ANDROID) + ADD_LIBRARY(cantata SHARED ${CANTATA_SRCS} ${CANTATA_MOC_SRCS} ${CANTATA_RC_SRCS} ${CANTATA_UI_HDRS} ) + ELSE (ANDROID) + if (WIN32) + IF( MINGW ) + # resource compilation for MinGW + ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cantataico.o + COMMAND windres.exe -I${CMAKE_CURRENT_SOURCE_DIR} -i${CMAKE_SOURCE_DIR}/icons/cantataico.rc + -o ${CMAKE_CURRENT_BINARY_DIR}/cantataico.o ) + SET(CANTATA_SRCS ${CANTATA_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/cantataico.o) + ELSE( MINGW ) + SET(CANTATA_SRCS ${CANTATA_SRCS} icons/cantataico.rc) + ENDIF( MINGW ) + ADD_EXECUTABLE( cantata WIN32 ${CANTATA_SRCS} ${CANTATA_MOC_SRCS} ${CANTATA_RC_SRCS} ${CANTATA_UI_HDRS} ) + else (WIN32) + ADD_EXECUTABLE( cantata ${CANTATA_SRCS} ${CANTATA_MOC_SRCS} ${CANTATA_RC_SRCS} ${CANTATA_UI_HDRS} ) + install( PROGRAMS dynamic/cantata-dynamic DESTINATION bin) + endif (WIN32) - install( TARGETS cantata RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) - ADD_DEFINITIONS( -DQT_NO_STL -DQT_NO_CAST_TO_ASCII -Wall -Wextra ) - SET( XDG_APPS_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/applications" ) + install( TARGETS cantata RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) + ADD_DEFINITIONS( -DQT_NO_STL -DQT_NO_CAST_TO_ASCII -Wall -Wextra ) + SET( XDG_APPS_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/applications" ) - add_subdirectory(qtsingleapplication) - TARGET_LINK_LIBRARIES(cantata qtsingleapplication) - include_directories(${CMAKE_BINARY_DIR}/qtsingleapplication) + add_subdirectory(qtsingleapplication) + TARGET_LINK_LIBRARIES(cantata qtsingleapplication) + include_directories(${CMAKE_BINARY_DIR}/qtsingleapplication) + ENDIF (ANDROID) ENDIF( ENABLE_KDE_SUPPORT ) ADD_SUBDIRECTORY( icons ) - TARGET_LINK_LIBRARIES(cantata ${QT_QTWEBKIT_LIBRARY} ${QT_QTXML_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTDBUS_LIBRARY}) include_directories( ${QT_INCLUDES}) @@ -521,9 +535,9 @@ endif (ENABLE_WEBKIT) # enable warnings ADD_DEFINITIONS( -DQT_NO_DEBUG_OUTPUT ) -IF( UNIX AND NOT APPLE ) +IF( UNIX AND NOT APPLE AND NOT ANDROID) install(FILES cantata.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) -ENDIF( UNIX AND NOT APPLE ) +ENDIF( UNIX AND NOT APPLE AND NOT ANDROID) configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h) @@ -567,7 +581,7 @@ IF( ENABLE_KDE_SUPPORT ) endif( NOT TAGLIB_FOUND OR NOT MTP_FOUND OR NOT FFMPEG_FOUND OR NOT MPG123_FOUND ) endif (TAGLIB_FOUND) ELSE( ENABLE_KDE_SUPPORT ) - if (NOT WIN32) + if (NOT WIN32 AND NOT ANDROID) message("INFO: Building WITHOUT KDE support - Device sync support DISABLED") if( NOT TAGLIB_FOUND OR NOT FFMPEG_FOUND OR NOT MPG123_FOUND ) message(" Disabled features:") @@ -579,7 +593,7 @@ ELSE( ENABLE_KDE_SUPPORT ) endif (NOT TAGLIB_FOUND) message(" - ReplayGain calculation (taglib, ffmpeg, and mpg123 required)") endif( NOT TAGLIB_FOUND OR NOT FFMPEG_FOUND OR NOT MPG123_FOUND ) - endif (NOT WIN32) + endif (NOT WIN32 AND NOT ANDROID) message("") message("*************************************************************") message("*************************************************************") diff --git a/android/androidmain.cpp b/android/androidmain.cpp new file mode 100644 index 000000000..0517a4572 --- /dev/null +++ b/android/androidmain.cpp @@ -0,0 +1,169 @@ +/* +Copyright (c) 2009-2011, BogDan Vatra +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: +* Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. +* Neither the name of the BogDan Vatra nor the +names of its contributors may be used to endorse or promote products +derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY BogDan Vatra ''AS IS'' AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL BogDan Vatra BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +static JavaVM *m_javaVM = NULL; +static JNIEnv *m_env = NULL; +static jobject objptr; +static QSemaphore m_quitAppSemaphore; +static QList m_applicationParams; +static const char * const QtNativeClassPathName = "org/kde/necessitas/industrius/QtNative"; + +extern "C" int main(int, char **); //use the standard main method to start the application +static void * startMainMethod(void * /*data*/) +{ + + char ** params; + params=(char**)malloc(sizeof(char*)*m_applicationParams.length()); + for (int i=0;iAttachCurrentThread(&env, NULL)<0) + { + qCritical()<<"AttachCurrentThread failed"; + return false; + } + jclass applicationClass = env->GetObjectClass(objptr); + if (applicationClass){ + jmethodID quitApp = env->GetStaticMethodID(applicationClass, "quitApp", "()V"); + env->CallStaticVoidMethod(applicationClass, quitApp); + } + m_javaVM->DetachCurrentThread(); + return NULL; +} + +static jboolean startQtApp(JNIEnv* env, jobject /*object*/, jstring paramsString, jstring environmentString) +{ + qDebug()<<"startQtApp"; + const char * nativeString = env->GetStringUTFChars(environmentString, 0); + QByteArray string=nativeString; + env->ReleaseStringUTFChars(environmentString, nativeString); + m_applicationParams=string.split('\t'); + qDebug()<<"environmentString"<GetStringUTFChars(paramsString, 0); + string=nativeString; + env->ReleaseStringUTFChars(paramsString, nativeString); + + qDebug()<<"paramsString"<FindClass(className); + if (clazz == NULL) + { + __android_log_print(ANDROID_LOG_FATAL,"Qt", "Native registration unable to find class '%s'", className); + return JNI_FALSE; + } + jmethodID constr = env->GetMethodID(clazz, "", "()V"); + if(!constr) { + __android_log_print(ANDROID_LOG_FATAL,"Qt", "Native registration unable to find constructor for class '%s'", className); + return JNI_FALSE;; + } + jobject obj = env->NewObject(clazz, constr); + objptr = env->NewGlobalRef(obj); + if (env->RegisterNatives(clazz, gMethods, numMethods) < 0) + { + __android_log_print(ANDROID_LOG_FATAL,"Qt", "RegisterNatives failed for '%s'", className); + return JNI_FALSE; + } + return JNI_TRUE; +} + +/* +* Register native methods for all classes we know about. +*/ +static int registerNatives(JNIEnv* env) +{ + if (!registerNativeMethods(env, QtNativeClassPathName, methods, sizeof(methods) / sizeof(methods[0]))) + return JNI_FALSE; + + return JNI_TRUE; +} + +typedef union { + JNIEnv* nativeEnvironment; + void* venv; +} UnionJNIEnvToVoid; + +Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* /*reserved*/) +{ + __android_log_print(ANDROID_LOG_INFO,"Qt", "qt start"); + UnionJNIEnvToVoid uenv; + uenv.venv = NULL; + m_javaVM = 0; + + if (vm->GetEnv(&uenv.venv, JNI_VERSION_1_4) != JNI_OK) + { + __android_log_print(ANDROID_LOG_FATAL,"Qt","GetEnv failed"); + return -1; + } + m_env = uenv.nativeEnvironment; + if (!registerNatives(m_env)) + { + __android_log_print(ANDROID_LOG_FATAL, "Qt", "registerNatives failed"); + return -1; + } + m_javaVM = vm; + return JNI_VERSION_1_4; +} + diff --git a/android/cantata.pro b/android/cantata.pro new file mode 100644 index 000000000..533248e3f --- /dev/null +++ b/android/cantata.pro @@ -0,0 +1,170 @@ +QT += core gui xml network + +TARGET = cantata +TEMPLATE = app + +# androidmain.cpp +SOURCES += \ + ../application.cpp \ + ../main.cpp \ + ../gui/mainwindow.cpp \ + ../gui/preferencesdialog.cpp \ + ../gui/settings.cpp \ + ../gui/covers.cpp \ + ../gui/interfacesettings.cpp \ + ../gui/externalsettings.cpp \ + ../gui/playbacksettings.cpp \ + ../gui/serverplaybacksettings.cpp \ + ../gui/serversettings.cpp \ + ../gui/streamspage.cpp \ + ../gui/streamdialog.cpp \ + ../gui/streamcategorydialog.cpp \ + ../gui/librarypage.cpp \ + ../gui/albumspage.cpp \ + ../gui/folderpage.cpp \ + ../gui/serverinfopage.cpp \ + ../gui/playlistspage.cpp \ + ../models/musiclibraryitemroot.cpp \ + ../models/musiclibraryitemartist.cpp \ + ../models/musiclibraryitemalbum.cpp \ + ../models/musiclibrarymodel.cpp \ + ../models/musiclibraryproxymodel.cpp \ + ../models/playlistsmodel.cpp \ + ../models/playlistsproxymodel.cpp \ + ../models/playqueuemodel.cpp \ + ../models/playqueueproxymodel.cpp \ + ../models/dirviewmodel.cpp \ + ../models/dirviewproxymodel.cpp \ + ../models/dirviewitem.cpp \ + ../models/dirviewitemdir.cpp \ + ../models/streamsmodel.cpp \ + ../models/streamsproxymodel.cpp \ + ../models/albumsmodel.cpp \ + ../models/albumsproxymodel.cpp \ + ../models/streamfetcher.cpp \ + ../models/proxymodel.cpp \ + ../mpd/mpdconnection.cpp \ + ../mpd/mpdparseutils.cpp \ + ../mpd/mpdstatus.cpp \ + ../mpd/song.cpp \ + ../widgets/treeview.cpp \ + ../widgets/fancytabwidget.cpp \ + ../widgets/listview.cpp \ + ../widgets/itemview.cpp \ + ../widgets/timeslider.cpp \ + ../widgets/actionlabel.cpp \ + ../widgets/playqueueview.cpp \ + ../widgets/groupedview.cpp \ + ../widgets/messagewidget.cpp \ + ../widgets/actionitemdelegate.cpp \ + ../widgets/textbrowser.cpp \ + ../widgets/coverwidget.cpp \ + ../lyrics/lyricspage.cpp \ + ../lyrics/lyricsettings.cpp \ + ../lyrics/ultimatelyricsprovider.cpp \ + ../lyrics/ultimatelyricsreader.cpp \ + ../lyrics/songinfoprovider.cpp \ + ../lyrics/lyricsdialog.cpp \ + ../network/networkaccessmanager.cpp \ + ../network/network.cpp \ + ../libmaia/maiaObject.cpp \ + ../libmaia/maiaFault.cpp \ + ../libmaia/maiaXmlRpcClient.cpp \ + ../devices/utils.cpp \ + ../widgets/dirrequester.cpp \ + ../widgets/lineedit.cpp \ + ../network/networkproxyfactory.cpp \ + ../widgets/kmessagewidget.cpp \ + ../widgets/dialog.cpp \ + ../widgets/messagebox.cpp + +HEADERS+= \ + ../gui/mainwindow.h \ + ../gui/settings.h \ + ../gui/covers.h \ + ../gui/folderpage.h \ + ../gui/librarypage.h \ + ../gui/albumspage.h \ + ../gui/playlistspage.h \ + ../gui/streamspage.h \ + ../gui/serverinfopage.h \ + ../gui/streamdialog.h \ + ../gui/streamcategorydialog.h \ + ../gui/serverplaybacksettings.h \ + ../gui/serversettings.h \ + ../gui/preferencesdialog.h \ + ../gui/interfacesettings.h \ + ../gui/externalsettings.h \ + ../models/musiclibrarymodel.h \ + ../models/musiclibraryproxymodel.h \ + ../models/playlistsmodel.h \ + ../models/playlistsproxymodel.h \ + ../models/playqueuemodel.h \ + ../models/playqueueproxymodel.h \ + ../models/dirviewmodel.h \ + ../models/dirviewproxymodel.h \ + ../models/albumsmodel.h \ + ../models/streamfetcher.h \ + ../models/streamsmodel.h \ + ../mpd/mpdconnection.h \ + ../mpd/mpdstatus.h \ + ../widgets/fancytabwidget.h \ + ../widgets/treeview.h \ + ../widgets/listview.h \ + ../widgets/itemview.h \ + ../widgets/timeslider.h \ + ../widgets/actionlabel.h \ + ../widgets/playqueueview.h \ + ../widgets/groupedview.h \ + ../widgets/messagewidget.h \ + ../widgets/coverwidget.h \ + ../lyrics/lyricspage.h \ + ../lyrics/lyricsettings.h \ + ../lyrics/ultimatelyricsprovider.h \ + ../lyrics/songinfoprovider.h \ + ../lyrics/lyricsdialog.h \ + ../network/networkaccessmanager.h \ + ../network/network.h \ + ../libmaia/maiaObject.h \ + ../libmaia/maiaFault.h \ + ../libmaia/maiaXmlRpcClient.h \ + ../application.h \ + ../widgets/dirrequester.h \ + ../widgets/lineedit.h \ + ../widgets/kmessagewidget.h \ + ../widgets/urllabel.h \ + ../widgets/dialog.h + +FORMS+= \ + ../gui/mainwindow.ui \ + ../gui/folderpage.ui \ + ../gui/librarypage.ui \ + ../gui/albumspage.ui \ + ../gui/playlistspage.ui \ + ../gui/streamspage.ui \ + ../gui/serverinfopage.ui \ + ../gui/interfacesettings.ui \ + ../gui/externalsettings.ui \ + ../gui/playbacksettings.ui \ + ../gui/serverplaybacksettings.ui \ + ../gui/serversettings.ui \ + ../lyrics/lyricspage.ui \ + ../lyrics/lyricsettings.ui \ + ../widgets/itemview.ui + +INCLUDEPATH += \ + .. \ + ../devices \ + ../libmaia \ + ../gui \ + ../mpd \ + ../models \ + ../widgets \ + ../lyrics \ + ../network + +RESOURCES += \ + ../cantata_qt.qrc + +DEFINES += \ + QT_NO_DEBUG_OUTPUT diff --git a/android/config.h b/android/config.h new file mode 100644 index 000000000..992c6bfcc --- /dev/null +++ b/android/config.h @@ -0,0 +1,15 @@ +#ifndef _CONFIG_H +#define _CONFIG_H + +#define PACKAGE_NAME "cantata" +#define PACKAGE_VERSION "0.8.0" +#define PACKAGE_STRING PACKAGE_NAME" "PACKAGE_VERSION +#define DEFAULT_ALBUM_ICON "media-optical" +#define DEFAULT_STREAM_ICON "applications-internet" +#define CANTATA_ANDROID +#ifdef ENABLE_WEBKIT +#undef ENABLE_WEBKIT +#endif + +#endif + diff --git a/application.cpp b/application.cpp index 9ff8dc825..b6e553582 100644 --- a/application.cpp +++ b/application.cpp @@ -87,9 +87,13 @@ int Application::newInstance() { } #else // ENABLE_KDE_SUPPORT Application::Application(int &argc, char **argv) + #ifdef CANTATA_ANDROID + : QApplication(argc, argv) + #else : QtSingleApplication(argc, argv) + #endif { - #ifdef TAGLIB_FOUND + #if defined TAGLIB_FOUND && !defined CANTATA_ANDROID connect(this, SIGNAL(messageReceived(const QString &)), SLOT(message(const QString &))); #endif } @@ -100,6 +104,7 @@ Application::~Application() bool Application::start() { + #if !defined CANTATA_ANDROID if (isRunning()) { #ifdef TAGLIB_FOUND QStringList args(arguments()); @@ -110,12 +115,13 @@ bool Application::start() #endif return false; } + #endif setupIconTheme(); return true; } -#ifdef TAGLIB_FOUND +#if defined TAGLIB_FOUND && !defined CANTATA_ANDROID void Application::loadFiles() { QStringList args(arguments()); @@ -153,7 +159,7 @@ void Application::setupIconTheme() } } -#ifdef TAGLIB_FOUND +#if defined TAGLIB_FOUND && !defined CANTATA_ANDROID void Application::message(const QString &msg) { load(msg.split("\n")); diff --git a/application.h b/application.h index 4d090b806..4e3357c25 100644 --- a/application.h +++ b/application.h @@ -42,6 +42,17 @@ public: private: MainWindow *w; }; +#elif defined CANTATA_ANDROID +#include +class Application : public QApplication +{ +public: + Application(int &argc, char **argv); + virtual ~Application(); + bool start(); +private: + void setupIconTheme(); +}; #else #include "qtsingleapplication/qtsingleapplication.h" class Application : public QtSingleApplication @@ -53,17 +64,17 @@ public: virtual ~Application(); bool start(); - #ifdef TAGLIB_FOUND + #if defined TAGLIB_FOUND void loadFiles(); #endif private: void setupIconTheme(); - #ifdef TAGLIB_FOUND + #if defined TAGLIB_FOUND void load(const QStringList &files); #endif -#ifdef TAGLIB_FOUND +#if defined TAGLIB_FOUND private Q_SLOTS: void message(const QString &m); #endif diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index b40cf4cd3..a32fc53c8 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -98,7 +98,7 @@ #include "playlistspage.h" #include "fancytabwidget.h" #include "timeslider.h" -#ifndef Q_OS_WIN +#if !defined Q_OS_WIN && !defined CANTATA_ANDROID #include "mpris.h" #include "dockmanager.h" #include "dynamicpage.h" @@ -289,6 +289,7 @@ void VolumeControl::setValue(int v) slider->setValue(v); } +#ifndef CANTATA_ANDROID CoverEventHandler::CoverEventHandler(MainWindow *w) : QObject(w), window(w) { @@ -313,6 +314,7 @@ bool CoverEventHandler::eventFilter(QObject *obj, QEvent *event) } return QObject::eventFilter(obj, event); } +#endif static int nextKey(int &key) { int k=key; @@ -340,7 +342,9 @@ MainWindow::MainWindow(QWidget *parent) , lastSongId(-1) , autoScrollPlayQueue(true) , draggingPositionSlider(false) + #ifndef CANTATA_ANDROID , trayItem(0) + #endif #ifdef ENABLE_KDE_SUPPORT , notification(0) #endif @@ -348,7 +352,7 @@ MainWindow::MainWindow(QWidget *parent) #ifdef ENABLE_WEBKIT , infoNeedsUpdating(false) #endif - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID , dock(0) , mpris(0) #endif @@ -364,7 +368,7 @@ MainWindow::MainWindow(QWidget *parent) , phononStream(0) #endif { - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID new CantataAdaptor(this); QDBusConnection::sessionBus().registerObject("/cantata", this); #endif @@ -389,11 +393,13 @@ MainWindow::MainWindow(QWidget *parent) prefAction=KStandardAction::preferences(this, SLOT(showPreferencesDialog()), actionCollection()); quitAction=KStandardAction::quit(kapp, SLOT(quit()), actionCollection()); + #ifndef CANTATA_ANDROID smallPlaybackButtonsAction = actionCollection()->addAction("smallplaybackbuttons"); smallPlaybackButtonsAction->setText(i18n("Small Playback Buttons")); smallControlButtonsAction = actionCollection()->addAction("smallcontrolbuttons"); smallControlButtonsAction->setText(i18n("Small Control Buttons")); + #endif connectAction = actionCollection()->addAction("connect"); connectAction->setText(i18n("Connect")); @@ -474,8 +480,10 @@ MainWindow::MainWindow(QWidget *parent) clearPlayQueueAction = actionCollection()->addAction("clearplaylist"); clearPlayQueueAction->setText(i18n("Clear")); + #ifndef CANTATA_ANDROID expandInterfaceAction = actionCollection()->addAction("expandinterface"); expandInterfaceAction->setText(i18n("Expanded Interface")); + #endif randomPlayQueueAction = actionCollection()->addAction("randomplaylist"); randomPlayQueueAction->setText(i18n("Random")); @@ -555,7 +563,7 @@ MainWindow::MainWindow(QWidget *parent) playlistsTabAction = actionCollection()->addAction("showplayliststab"); playlistsTabAction->setText(i18n("Playlists")); - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID dynamicTabAction = actionCollection()->addAction("showdynamictab"); dynamicTabAction->setText(i18n("Dynamic")); #endif @@ -592,8 +600,10 @@ MainWindow::MainWindow(QWidget *parent) connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); quitAction->setIcon(Icon("application-exit")); quitAction->setShortcut(QKeySequence::Quit); + #ifndef CANTATA_ANDROID smallPlaybackButtonsAction = new QAction(tr("Small Playback Buttons"), this); smallControlButtonsAction = new QAction(tr("Small Control Buttons"), this); + #endif refreshAction = new QAction(tr("Refresh"), this); connectAction = new QAction(tr("Connect"), this); connectionsAction = new QAction(tr("Connections"), this); @@ -618,7 +628,9 @@ MainWindow::MainWindow(QWidget *parent) shufflePlayQueueAction = new QAction(tr("Shuffle"), this); savePlayQueueAction = new QAction(tr("Save As"), this); clearPlayQueueAction = new QAction(tr("Clear"), this); + #ifndef CANTATA_ANDROID expandInterfaceAction = new QAction(tr("Expanded Interface"), this); + #endif randomPlayQueueAction = new QAction(tr("Random"), this); repeatPlayQueueAction = new QAction(tr("Repeat"), this); singlePlayQueueAction = new QAction(tr("Single"), this); @@ -653,7 +665,7 @@ MainWindow::MainWindow(QWidget *parent) albumsTabAction = new QAction(tr("Albums"), this); foldersTabAction = new QAction(tr("Folders"), this); playlistsTabAction = new QAction(tr("Playlists"), this); - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID dynamicTabAction = new QAction(tr("Dynamic"), this); #endif lyricsTabAction = new QAction(tr("Lyrics"), this); @@ -673,7 +685,7 @@ MainWindow::MainWindow(QWidget *parent) albumsTabAction->setShortcut(Qt::AltModifier+nextKey(pageKey)); foldersTabAction->setShortcut(Qt::AltModifier+nextKey(pageKey)); playlistsTabAction->setShortcut(Qt::AltModifier+nextKey(pageKey)); - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID dynamicTabAction->setShortcut(Qt::AltModifier+nextKey(pageKey)); #endif streamsTabAction->setShortcut(Qt::AltModifier+nextKey(pageKey)); @@ -755,7 +767,9 @@ MainWindow::MainWindow(QWidget *parent) removeFromPlayQueueAction->setIcon(Icon("list-remove")); clearPlayQueueAction->setIcon(Icon("edit-clear-list")); savePlayQueueAction->setIcon(Icon("document-save-as")); + #ifndef CANTATA_ANDROID expandInterfaceAction->setIcon(Icon("view-media-playlist")); + #endif refreshAction->setIcon(Icon("view-refresh")); connectAction->setIcon(Icon("network-connect")); connectionsAction->setIcon(Icon("network-server")); @@ -775,7 +789,7 @@ MainWindow::MainWindow(QWidget *parent) albumsTabAction->setIcon(Icon(DEFAULT_ALBUM_ICON)); foldersTabAction->setIcon(Icon("inode-directory")); playlistsTabAction->setIcon(Icon("view-media-playlist")); - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID dynamicTabAction->setIcon(Icon("media-playlist-shuffle")); #endif lyricsTabAction->setIcon(Icon("view-media-lyrics")); @@ -819,7 +833,7 @@ MainWindow::MainWindow(QWidget *parent) albumsPage = new AlbumsPage(this); folderPage = new FolderPage(this); playlistsPage = new PlaylistsPage(this); - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID dynamicPage = new DynamicPage(this); #endif streamsPage = new StreamsPage(this); @@ -864,7 +878,7 @@ MainWindow::MainWindow(QWidget *parent) tabWidget->AddTab(albumsPage, TAB_ACTION(albumsTabAction), !hiddenPages.contains(albumsPage->metaObject()->className())); tabWidget->AddTab(folderPage, TAB_ACTION(foldersTabAction), !hiddenPages.contains(folderPage->metaObject()->className())); tabWidget->AddTab(playlistsPage, TAB_ACTION(playlistsTabAction), !hiddenPages.contains(playlistsPage->metaObject()->className())); - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID tabWidget->AddTab(dynamicPage, TAB_ACTION(dynamicTabAction), !hiddenPages.contains(dynamicPage->metaObject()->className())); #endif tabWidget->AddTab(streamsPage, TAB_ACTION(streamsTabAction), !hiddenPages.contains(streamsPage->metaObject()->className())); @@ -884,7 +898,9 @@ MainWindow::MainWindow(QWidget *parent) tabWidget->SetMode(FancyTabWidget::Mode_LargeSidebar); + #ifndef CANTATA_ANDROID expandInterfaceAction->setCheckable(true); + #endif randomPlayQueueAction->setCheckable(true); repeatPlayQueueAction->setCheckable(true); singlePlayQueueAction->setCheckable(true); @@ -905,35 +921,47 @@ MainWindow::MainWindow(QWidget *parent) initButton(b); } + #ifndef CANTATA_ANDROID smallControlButtonsAction->setCheckable(true); smallControlButtonsAction->setChecked(Settings::self()->smallControlButtons()); controlBtnsMenu = new QMenu(this); controlBtnsMenu->addAction(smallControlButtonsAction); connect(smallControlButtonsAction, SIGNAL(triggered(bool)), SLOT(setControlButtonsSize(bool))); + #endif foreach (QToolButton *b, controlBtns) { b->setAutoRaise(true); + #ifndef CANTATA_ANDROID b->setContextMenuPolicy(Qt::CustomContextMenu); connect(b, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(controlButtonsMenu())); + #endif } + #ifndef CANTATA_ANDROID smallPlaybackButtonsAction->setCheckable(true); smallPlaybackButtonsAction->setChecked(Settings::self()->smallPlaybackButtons()); playbackBtnsMenu = new QMenu(this); playbackBtnsMenu->addAction(smallPlaybackButtonsAction); connect(smallPlaybackButtonsAction, SIGNAL(triggered(bool)), SLOT(setPlaybackButtonsSize(bool))); + #endif foreach (QToolButton *b, playbackBtns) { b->setAutoRaise(true); + #ifndef CANTATA_ANDROID b->setContextMenuPolicy(Qt::CustomContextMenu); connect(b, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(playbackButtonsMenu())); + #endif } + #ifndef CANTATA_ANDROID setPlaybackButtonsSize(Settings::self()->smallPlaybackButtons()); setControlButtonsSize(Settings::self()->smallControlButtons()); + #endif trackLabel->setText(QString()); artistLabel->setText(QString()); + #ifndef CANTATA_ANDROID expandInterfaceAction->setChecked(Settings::self()->showPlaylist()); + #endif randomPlayQueueAction->setChecked(false); repeatPlayQueueAction->setChecked(false); singlePlayQueueAction->setChecked(false); @@ -947,6 +975,7 @@ MainWindow::MainWindow(QWidget *parent) AlbumsModel::setCoverSize((MusicLibraryItemAlbum::CoverSize)Settings::self()->albumsCoverSize()); tabWidget->SetMode((FancyTabWidget::Mode)Settings::self()->sidebar()); + #ifndef CANTATA_ANDROID setupTrayIcon(); expandedSize=Settings::self()->mainWindowSize(); collapsedSize=Settings::self()->mainWindowCollapsedSize(); @@ -963,12 +992,15 @@ MainWindow::MainWindow(QWidget *parent) resize(collapsedSize); } } + #endif #ifdef ENABLE_KDE_SUPPORT setupGUI(KXmlGuiWindow::Keys | KXmlGuiWindow::Save | KXmlGuiWindow::Create); menuBar()->setVisible(false); #endif + #ifndef CANTATA_ANDROID mainMenu->addAction(expandInterfaceAction); + #endif mainMenu->addAction(connectionsAction); mainMenu->addAction(outputsAction); QAction *menuAct=mainMenu->addAction(tr("Configure Cantata..."), this, SLOT(showPreferencesDialog())); @@ -990,7 +1022,9 @@ MainWindow::MainWindow(QWidget *parent) mainMenu->addSeparator(); mainMenu->addAction(quitAction); + #ifndef CANTATA_ANDROID coverWidget->installEventFilter(new CoverEventHandler(this)); + #endif dynamicLabel->setVisible(false); addWithPriorityAction->setIcon(QIcon::fromTheme("favorites")); @@ -1073,7 +1107,7 @@ MainWindow::MainWindow(QWidget *parent) connect(MPDConnection::self(), SIGNAL(stateChanged(bool)), SLOT(mpdConnectionStateChanged(bool))); connect(MPDConnection::self(), SIGNAL(error(const QString &, bool)), SLOT(showError(const QString &, bool))); connect(MPDConnection::self(), SIGNAL(dirChanged()), SLOT(checkMpdDir())); - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID connect(Dynamic::self(), SIGNAL(error(const QString &)), SLOT(showError(const QString &))); connect(Dynamic::self(), SIGNAL(running(bool)), dynamicLabel, SLOT(setVisible(bool))); #endif @@ -1113,7 +1147,9 @@ MainWindow::MainWindow(QWidget *parent) connect(copyTrackInfoAction, SIGNAL(activated()), this, SLOT(copyTrackInfo())); connect(cropPlayQueueAction, SIGNAL(activated()), this, SLOT(cropPlayQueue())); connect(shufflePlayQueueAction, SIGNAL(activated()), MPDConnection::self(), SLOT(shuffle())); + #ifndef CANTATA_ANDROID connect(expandInterfaceAction, SIGNAL(activated()), this, SLOT(togglePlayQueue())); + #endif connect(positionSlider, SIGNAL(valueChanged(int)), this, SLOT(updatePosition())); connect(volumeButton, SIGNAL(clicked()), SLOT(showVolumeControl())); // connect(createDataCdAction, SIGNAL(activated()), this, SLOT(createDataCd())); @@ -1129,7 +1165,7 @@ MainWindow::MainWindow(QWidget *parent) connect(albumsTabAction, SIGNAL(activated()), this, SLOT(showAlbumsTab())); connect(foldersTabAction, SIGNAL(activated()), this, SLOT(showFoldersTab())); connect(playlistsTabAction, SIGNAL(activated()), this, SLOT(showPlaylistsTab())); - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID connect(dynamicTabAction, SIGNAL(activated()), this, SLOT(showDynamicTab())); #endif connect(lyricsTabAction, SIGNAL(activated()), this, SLOT(showLyricsTab())); @@ -1163,6 +1199,7 @@ MainWindow::MainWindow(QWidget *parent) connect(playlistsPage, SIGNAL(add(const QStringList &, bool, quint8)), &playQueueModel, SLOT(addItems(const QStringList &, bool, quint8))); connect(coverWidget, SIGNAL(coverImage(const QImage &)), lyricsPage, SLOT(setImage(const QImage &))); + #ifndef CANTATA_ANDROID if (!playQueueInSidebar) { QByteArray state=Settings::self()->splitterState(); @@ -1175,6 +1212,7 @@ MainWindow::MainWindow(QWidget *parent) splitter->restoreState(Settings::self()->splitterState()); } } + #endif playQueueItemsSelected(false); playQueue->setFocus(); @@ -1197,24 +1235,28 @@ MainWindow::MainWindow(QWidget *parent) } } + #ifndef CANTATA_ANDROID autoHideSplitterAction=new QAction(i18n("Auto Hide"), this); autoHideSplitterAction->setCheckable(true); autoHideSplitterAction->setChecked(Settings::self()->splitterAutoHide()); + connect(autoHideSplitterAction, SIGNAL(toggled(bool)), this, SLOT(toggleSplitterAutoHide())); + #endif connect(tabWidget, SIGNAL(CurrentChanged(int)), this, SLOT(currentTabChanged(int))); connect(tabWidget, SIGNAL(TabToggled(int)), this, SLOT(tabToggled(int))); - connect(autoHideSplitterAction, SIGNAL(toggled(bool)), this, SLOT(toggleSplitterAutoHide())); connect(tabWidget, SIGNAL(ModeChanged(FancyTabWidget::Mode)), this, SLOT(sidebarModeChanged())); connect(messageWidget, SIGNAL(visible(bool)), this, SLOT(messageWidgetVisibility(bool))); if (playQueueInSidebar) { tabToggled(PAGE_PLAYQUEUE); } + #ifndef CANTATA_ANDROID toggleSplitterAutoHide(); + #endif readSettings(); updateConnectionsMenu(); fadeStop=Settings::self()->stopFadeDuration()>Settings::MinFade; playlistsPage->refresh(); - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID toggleMpris(); if (Settings::self()->dockManager()) { QTimer::singleShot(250, this, SLOT(toggleDockManager())); @@ -1225,28 +1267,33 @@ MainWindow::MainWindow(QWidget *parent) MainWindow::~MainWindow() { - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID if (dock) { dock->setIcon(QString()); } #endif + #ifndef CANTATA_ANDROID Settings::self()->saveMainWindowSize(splitter->isVisible() ? size() : expandedSize); Settings::self()->saveMainWindowCollapsedSize(splitter->isVisible() ? collapsedSize : size()); + #endif #if defined ENABLE_REMOTE_DEVICES && defined ENABLE_DEVICES_SUPPORT DevicesModel::self()->unmountRemote(); #endif #ifdef PHONON_FOUND Settings::self()->savePlayStream(streamPlayAction->isChecked()); #endif + #ifndef CANTATA_ANDROID Settings::self()->saveShowPlaylist(expandInterfaceAction->isChecked()); if (!tabWidget->isEnabled(PAGE_PLAYQUEUE)) { Settings::self()->saveSplitterState(splitter->saveState()); } + Settings::self()->saveSplitterAutoHide(autoHideSplitterAction->isChecked()); Settings::self()->saveSidebar((int)(tabWidget->mode())); Settings::self()->savePage(tabWidget->currentWidget()->metaObject()->className()); Settings::self()->saveSmallPlaybackButtons(smallPlaybackButtonsAction->isChecked()); Settings::self()->saveSmallControlButtons(smallControlButtonsAction->isChecked()); - Settings::self()->saveSplitterAutoHide(autoHideSplitterAction->isChecked()); + #endif + playQueue->saveHeader(); QStringList hiddenPages; for (int i=0; icount(); ++i) { @@ -1265,7 +1312,7 @@ MainWindow::~MainWindow() #endif Settings::self()->save(true); disconnect(MPDConnection::self(), 0, 0, 0); - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID if (Settings::self()->stopDynamizerOnExit() || Settings::self()->stopOnExit()) { Dynamic::self()->stop(); } @@ -1394,7 +1441,7 @@ void MainWindow::songLoaded() void MainWindow::showError(const QString &message, bool showActions) { - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID if (QLatin1String("NO_SONGS")==message) { messageWidget->setError(i18n("Failed to locate any songs matching the dynamic playlist rules.")); } else @@ -1420,9 +1467,13 @@ void MainWindow::showInformation(const QString &message) void MainWindow::messageWidgetVisibility(bool v) { + #ifdef CANTATA_ANDROID + Q_UNUSED(v) + #else if (v && !splitter->isVisible()) { expandInterfaceAction->trigger(); } + #endif } void MainWindow::mpdConnectionStateChanged(bool connected) @@ -1466,6 +1517,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event) } } +#ifndef CANTATA_ANDROID void MainWindow::closeEvent(QCloseEvent *event) { if (trayItem) { @@ -1478,6 +1530,7 @@ void MainWindow::closeEvent(QCloseEvent *event) close(); } } +#endif void MainWindow::showVolumeControl() { @@ -1512,7 +1565,7 @@ void MainWindow::connectToMpd(const MPDConnectionDetails &details) playQueueModel.clear(); lyricsPage->text->clear(); serverInfoPage->clear(); - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID Dynamic::self()->stop(); #endif showInformation(i18n("Connecting to %1").arg(details.description())); @@ -1590,7 +1643,7 @@ void MainWindow::checkMpdDir() case PAGE_ALBUMS: albumsPage->controlActions(); break; case PAGE_FOLDERS: folderPage->controlActions(); break; case PAGE_PLAYLISTS: playlistsPage->controlActions(); break; - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID case PAGE_DYNAMIC: dynamicPage->controlActions(); break; #endif case PAGE_STREAMS: streamsPage->controlActions(); break; @@ -1715,11 +1768,13 @@ void MainWindow::readSettings() #ifdef ENABLE_DEVICES_SUPPORT devicesPage->setView(0==Settings::self()->devicesView()); #endif + #ifndef CANTATA_ANDROID setupTrayIcon(); - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN toggleDockManager(); toggleMpris(); #endif + #endif autoScrollPlayQueue=Settings::self()->playQueueScroll(); updateWindowTitle(); } @@ -2187,6 +2242,7 @@ void MainWindow::updateCurrentSong(const Song &song) } #endif + #ifndef CANTATA_ANDROID if (Settings::self()->showPopups() || trayItem) { if (!current.title.isEmpty() && !current.artist.isEmpty() && !current.album.isEmpty()) { #ifdef ENABLE_KDE_SUPPORT @@ -2241,6 +2297,7 @@ void MainWindow::updateCurrentSong(const Song &song) #endif } } + #endif } void MainWindow::scrollPlayQueue() @@ -2351,6 +2408,7 @@ void MainWindow::updateStatus() } positionSlider->startTimer(); + #ifndef CANTATA_ANDROID if (trayItem) { #ifdef ENABLE_KDE_SUPPORT trayItem->setIconByName("media-playback-start"); @@ -2358,7 +2416,7 @@ void MainWindow::updateStatus() trayItem->setIcon(playbackPlay); #endif } - + #endif break; case MPDState_Inactive: case MPDState_Stopped: @@ -2381,6 +2439,7 @@ void MainWindow::updateStatus() current.id=0; updateWindowTitle(); + #ifndef CANTATA_ANDROID if (trayItem) { #ifdef ENABLE_KDE_SUPPORT trayItem->setIconByName("cantata"); @@ -2389,7 +2448,7 @@ void MainWindow::updateStatus() trayItem->setIcon(windowIcon()); #endif } - + #endif positionSlider->stopTimer(); break; case MPDState_Paused: @@ -2403,6 +2462,7 @@ void MainWindow::updateStatus() stopTrackAction->setEnabled(0!=playQueueModel.rowCount()); nextTrackAction->setEnabled(playQueueModel.rowCount()>1); prevTrackAction->setEnabled(playQueueModel.rowCount()>1); + #ifndef CANTATA_ANDROID if (trayItem) { #ifdef ENABLE_KDE_SUPPORT trayItem->setIconByName("media-playback-pause"); @@ -2410,7 +2470,7 @@ void MainWindow::updateStatus() trayItem->setIcon(playbackPause); #endif } - + #endif positionSlider->stopTimer(); break; default: @@ -2637,6 +2697,7 @@ int MainWindow::calcMinHeight() return 256; } +#ifndef CANTATA_ANDROID void MainWindow::togglePlayQueue() { if (!expandInterfaceAction->isChecked() && messageWidget->isVisible()) { @@ -2702,12 +2763,15 @@ void MainWindow::togglePlayQueue() move(p); } } +#endif void MainWindow::sidebarModeChanged() { + #ifndef CANTATA_ANDROID if (splitter->isVisible()) { setMinimumHeight(calcMinHeight()); } + #endif } /* @@ -2733,6 +2797,7 @@ void MainWindow::cropPlayQueue() emit removeSongs(toBeRemoved); } +#ifndef CANTATA_ANDROID // Tray Icon // void MainWindow::setupTrayIcon() { @@ -2823,6 +2888,7 @@ void MainWindow::trayItemClicked(QSystemTrayIcon::ActivationReason reason) } } #endif +#endif // CANTATA_ANDROID void MainWindow::currentTabChanged(int index) { @@ -2855,7 +2921,7 @@ void MainWindow::currentTabChanged(int index) case PAGE_PLAYLISTS: playlistsPage->controlActions(); break; - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID case PAGE_DYNAMIC: dynamicPage->controlActions(); break; @@ -2896,14 +2962,18 @@ void MainWindow::tabToggled(int index) playQueueWidget->setParent(playQueuePage); playQueuePage->layout()->addWidget(playQueueWidget); playQueueWidget->setVisible(true); + #ifndef CANTATA_ANDROID tabWidget->removeMenuAction(autoHideSplitterAction); toggleSplitterAutoHide(); + #endif } else { playQueuePage->layout()->removeWidget(playQueueWidget); playQueueWidget->setParent(splitter); playQueueWidget->setVisible(true); + #ifndef CANTATA_ANDROID tabWidget->addMenuAction(autoHideSplitterAction); toggleSplitterAutoHide(); + #endif } break; case PAGE_LIBRARY: @@ -2930,12 +3000,14 @@ void MainWindow::tabToggled(int index) sidebarModeChanged(); } +#ifndef CANTATA_ANDROID void MainWindow::toggleSplitterAutoHide() { bool ah=autoHideSplitterAction->isChecked() && !tabWidget->isEnabled(PAGE_PLAYQUEUE); splitter->setAutoHideEnabled(ah); splitter->setAutohidable(0, ah); } +#endif void MainWindow::locateTrack() { @@ -2957,7 +3029,7 @@ void MainWindow::showPage(const QString &page, bool focusSearch) } else if (QLatin1String("playlists")==p) { showTab(MainWindow::PAGE_PLAYLISTS); } - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID else if (QLatin1String("dynamic")==p) { showTab(MainWindow::PAGE_DYNAMIC); } @@ -2966,9 +3038,13 @@ void MainWindow::showPage(const QString &page, bool focusSearch) showTab(MainWindow::PAGE_STREAMS); } else if (QLatin1String("lyrics")==p) { showTab(MainWindow::PAGE_LYRICS); - } else if (QLatin1String("info")==p) { + } + #ifdef ENABLE_WEBKIT + else if (QLatin1String("info")==p) { showTab(MainWindow::PAGE_INFO); - } else if (QLatin1String("serverinfo")==p) { + } + #endif + else if (QLatin1String("serverinfo")==p) { showTab(MainWindow::PAGE_SERVER_INFO); } #if defined ENABLE_KDE_SUPPORT && defined TAGLIB_FOUND @@ -2981,7 +3057,7 @@ void MainWindow::showPage(const QString &page, bool focusSearch) } } -#ifndef Q_OS_WIN +#if !defined Q_OS_WIN && !defined CANTATA_ANDROID void MainWindow::dynamicStatus(const QString &message) { Dynamic::self()->helperMessage(message); @@ -3031,7 +3107,7 @@ void MainWindow::focusTabSearch() } else if (playlistsPage->isVisible()) { playlistsPage->focusSearch(); } - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID else if (dynamicPage->isVisible()) { dynamicPage->focusSearch(); } @@ -3067,7 +3143,7 @@ void MainWindow::collapseAll() } } -#ifndef Q_OS_WIN +#if !defined Q_OS_WIN && !defined CANTATA_ANDROID void MainWindow::toggleMpris() { bool on=Settings::self()->mpris(); diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 9ffbd0b34..0a013608a 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -68,7 +68,7 @@ class LibraryPage; class AlbumsPage; class FolderPage; class PlaylistsPage; -#ifndef Q_OS_WIN +#if !defined Q_OS_WIN && !defined CANTATA_ANDROID class DynamicPage; #endif class LyricsPage; @@ -80,7 +80,7 @@ class DevicesPage; #endif class QThread; class QAbstractItemView; -#ifndef Q_OS_WIN +#if !defined Q_OS_WIN && !defined CANTATA_ANDROID class DockManager; class Mpris; #endif @@ -141,6 +141,7 @@ private: QSlider *slider; }; +#ifndef CANTATA_ANDROID class CoverEventHandler : public QObject { Q_OBJECT @@ -155,6 +156,7 @@ private: MainWindow * const window; bool pressed; }; +#endif #ifdef ENABLE_KDE_SUPPORT class MainWindow : public KXmlGuiWindow, private Ui::MainWindow @@ -173,12 +175,14 @@ public: PAGE_ALBUMS, PAGE_FOLDERS, PAGE_PLAYLISTS, - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID PAGE_DYNAMIC, #endif PAGE_STREAMS, PAGE_LYRICS, + #ifdef ENABLE_WEBKIT PAGE_INFO, + #endif PAGE_SERVER_INFO #if defined ENABLE_KDE_SUPPORT && defined TAGLIB_FOUND , PAGE_DEVICES @@ -206,11 +210,15 @@ public: protected: void keyPressEvent(QKeyEvent *event); + #ifndef CANTATA_ANDROID void closeEvent(QCloseEvent *event); + #endif private: void initSizes(); + #ifndef CANTATA_ANDROID void setupTrayIcon(); + #endif Q_SIGNALS: // These are for communicating with MPD object (which is in its own thread, so need to talk via signal/slots) @@ -235,7 +243,7 @@ public Q_SLOTS: void showError(const QString &message, bool showActions=false); void showInformation(const QString &message); void showPage(const QString &page, bool focusSearch); - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID void dynamicStatus(const QString &message); #endif @@ -289,13 +297,15 @@ private Q_SLOTS: #ifdef ENABLE_KDE_SUPPORT void trayItemScrollRequested(int delta, Qt::Orientation orientation); void notificationClosed(); - #else + #elif !defined CANTATA_ANDROID void trayItemClicked(QSystemTrayIcon::ActivationReason reason); #endif void cropPlayQueue(); void updatePlayQueueStats(int artists, int albums, int songs, quint32 time); void copyTrackInfo(); + #ifndef CANTATA_ANDROID void togglePlayQueue(); + #endif void sidebarModeChanged(); void currentTabChanged(int index); void tabToggled(int index); @@ -304,19 +314,23 @@ private Q_SLOTS: void showAlbumsTab() { showTab(PAGE_ALBUMS); } void showFoldersTab() { showTab(PAGE_FOLDERS); } void showPlaylistsTab() { showTab(PAGE_PLAYLISTS); } - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID void showDynamicTab() { showTab(PAGE_DYNAMIC); } #endif void showStreamsTab() { showTab(PAGE_STREAMS); } void showLyricsTab() { showTab(PAGE_LYRICS); } + #ifdef ENABLE_WEBKIT void showInfoTab() { showTab(PAGE_INFO); } + #endif void showServerInfoTab() { showTab(PAGE_SERVER_INFO); } + #ifndef CANTATA_ANDROID void toggleSplitterAutoHide(); + #endif void locateTrack(); #if defined ENABLE_KDE_SUPPORT && defined TAGLIB_FOUND void showDevicesTab() { showTab(PAGE_DEVICES); } #endif - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID void toggleMpris(); void toggleDockManager(); #endif @@ -408,7 +422,9 @@ private: #ifdef PHONON_FOUND Action *streamPlayAction; #endif + #ifndef CANTATA_ANDROID Action *expandInterfaceAction; + #endif Action *quitAction; Action *locateTrackAction; Action *showPlayQueueAction; @@ -416,7 +432,7 @@ private: Action *albumsTabAction; Action *foldersTabAction; Action *playlistsTabAction; - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID Action *dynamicTabAction; #endif Action *lyricsTabAction; @@ -447,14 +463,16 @@ private: Action *searchAction; Action *expandAllAction; Action *collapseAllAction; + #ifndef CANTATA_ANDROID Action *smallPlaybackButtonsAction; Action *smallControlButtonsAction; QAction *autoHideSplitterAction; + #endif #ifdef ENABLE_KDE_SUPPORT KStatusNotifierItem *trayItem; KMenu *trayItemMenu; KNotification *notification; - #else + #elif !defined CANTATA_ANDROID QSystemTrayIcon *trayItem; QMenu *trayItemMenu; #endif @@ -473,7 +491,7 @@ private: AlbumsPage *albumsPage; FolderPage *folderPage; PlaylistsPage *playlistsPage; - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID DynamicPage *dynamicPage; #endif LyricsPage *lyricsPage; @@ -486,7 +504,7 @@ private: #endif ServerInfoPage *serverInfoPage; QThread *mpdThread; - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID DockManager *dock; Mpris *mpris; #endif @@ -519,12 +537,14 @@ private: #endif friend class VolumeSliderEventHandler; + #ifndef CANTATA_ANDROID friend class CoverEventHandler; + #endif friend class LibraryPage; friend class AlbumsPage; friend class FolderPage; friend class PlaylistsPage; - #ifndef Q_OS_WIN + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID friend class DynamicPage; #endif friend class StreamsPage; diff --git a/gui/playbacksettings.cpp b/gui/playbacksettings.cpp index d3a5f263b..b752036a2 100644 --- a/gui/playbacksettings.cpp +++ b/gui/playbacksettings.cpp @@ -33,7 +33,11 @@ PlaybackSettings::PlaybackSettings(QWidget *p) stopFadeDuration->setSuffix(i18n(" ms")); stopFadeDuration->setRange(Settings::MinFade, Settings::MaxFade); stopFadeDuration->setSingleStep(100); - #ifdef Q_OS_WIN + #ifdef CANTATA_ANDROID + stopOnExit->setVisible(false); + stopOnExitLabel->setVisible(false); + #endif + #if defined Q_OS_WIN || defined CANTATA_ANDROID stopDynamizerOnExit->setVisible(false); stopDynamizerOnExitLabel->setVisible(false); #endif @@ -42,8 +46,10 @@ PlaybackSettings::PlaybackSettings(QWidget *p) void PlaybackSettings::load() { stopOnExit->setChecked(Settings::self()->stopOnExit()); + #ifndef CANTATA_ANDROID stopFadeDuration->setValue(Settings::self()->stopFadeDuration()); - #ifndef Q_OS_WIN + #endif + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID stopDynamizerOnExit->setChecked(Settings::self()->stopDynamizerOnExit()); #endif } @@ -51,8 +57,10 @@ void PlaybackSettings::load() void PlaybackSettings::save() { Settings::self()->saveStopOnExit(stopOnExit->isChecked()); + #ifndef CANTATA_ANDROID Settings::self()->saveStopFadeDuration(stopFadeDuration->value()); - #ifndef Q_OS_WIN + #endif + #if !defined Q_OS_WIN && !defined CANTATA_ANDROID Settings::self()->saveStopDynamizerOnExit(stopDynamizerOnExit->isChecked()); #endif } diff --git a/gui/playbacksettings.ui b/gui/playbacksettings.ui index f54897823..a8f120d1e 100644 --- a/gui/playbacksettings.ui +++ b/gui/playbacksettings.ui @@ -31,7 +31,7 @@ - + Stop playback on exit: diff --git a/gui/preferencesdialog.cpp b/gui/preferencesdialog.cpp index 99f2c2a95..f5e2f12df 100644 --- a/gui/preferencesdialog.cpp +++ b/gui/preferencesdialog.cpp @@ -24,8 +24,10 @@ #include "preferencesdialog.h" #include "mainwindow.h" #include "settings.h" +#ifndef CANTATA_ANDROID #include "interfacesettings.h" #include "externalsettings.h" +#endif #include "serversettings.h" #include "serverplaybacksettings.h" #include "playbacksettings.h" @@ -41,8 +43,10 @@ #include #else #include "fancytabwidget.h" +#ifndef CANTATA_ANDROID #include "proxysettings.h" #endif +#endif #ifndef ENABLE_KDE_SUPPORT class ConfigPage : public QWidget @@ -84,20 +88,24 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, LyricsPage *lp) server = new ServerSettings(widget); serverplayback = new ServerPlaybackSettings(widget); playback = new PlaybackSettings(widget); + #ifndef CANTATA_ANDROID interface = new InterfaceSettings(widget); ext = new ExternalSettings(widget); #ifdef TAGLIB_FOUND http = new HttpServerSettings(widget); #endif + #endif lyrics = new LyricSettings(widget); server->load(); serverplayback->load(); playback->load(); + #ifndef CANTATA_ANDROID interface->load(); ext->load(); #ifdef TAGLIB_FOUND http->load(); #endif + #endif const QList &lprov=lp->getProviders(); lyrics->Load(lprov); #ifdef ENABLE_KDE_SUPPORT @@ -110,6 +118,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, LyricsPage *lp) page=widget->addPage(playback, i18n("Playback")); page->setHeader(i18n("Playback Settings")); page->setIcon(KIcon("media-playback-start")); + #ifndef CANTATA_ANDROID page=widget->addPage(interface, i18n("Interface")); page->setHeader(i18n("Interface Settings")); page->setIcon(KIcon("view-choose")); @@ -121,6 +130,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, LyricsPage *lp) page->setHeader(i18n("HTTP Server Settings")); #endif page->setIcon(KIcon("network-server")); + #endif page=widget->addPage(lyrics, i18n("Lyrics")); page->setHeader(i18n("Lyrics Settings")); page->setIcon(KIcon("view-media-lyrics")); @@ -131,6 +141,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, LyricsPage *lp) QIcon::fromTheme("speaker"), tr("Output")); widget->AddTab(new ConfigPage(this, tr("Playback Settings"), QIcon::fromTheme("media-playback-start"), playback), QIcon::fromTheme("media-playback-start"), tr("Playback")); + #ifndef CANTATA_ANDROID widget->AddTab(new ConfigPage(this, tr("Interface Settings"), QIcon::fromTheme("view-choose"), interface), QIcon::fromTheme("view-choose"), tr("Interface")); widget->AddTab(new ConfigPage(this, tr("External Settings"), QIcon::fromTheme("video-display"), ext), @@ -139,12 +150,15 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, LyricsPage *lp) widget->AddTab(new ConfigPage(this, tr("HTTP Server Settings"), QIcon::fromTheme("network-server"), http), QIcon::fromTheme("network-server"), tr("HTTP Server")); #endif + #endif widget->AddTab(new ConfigPage(this, tr("Lyrics Settings"), QIcon::fromTheme("view-media-lyrics"), lyrics), QIcon::fromTheme("view-media-lyrics"), tr("Lyrics")); + #ifndef CANTATA_ANDROID proxy = new ProxySettings(this); proxy->load(); widget->AddTab(new ConfigPage(this, tr("Proxy Settings"), QIcon::fromTheme("preferences-system-network"), proxy), QIcon::fromTheme("preferences-system-network"), tr("Proxy")); + #endif widget->SetMode(FancyTabWidget::Mode_LargeSidebar); #endif setCaption(i18n("Configure")); @@ -160,6 +174,7 @@ void PreferencesDialog::writeSettings() server->save(); serverplayback->save(); playback->save(); + #ifndef CANTATA_ANDROID interface->save(); ext->save(); #ifdef TAGLIB_FOUND @@ -168,6 +183,7 @@ void PreferencesDialog::writeSettings() #ifndef ENABLE_KDE_SUPPORT proxy->save(); #endif + #endif Settings::self()->saveLyricProviders(lyrics->EnabledProviders()); Settings::self()->save(); emit settingsSaved(); diff --git a/gui/preferencesdialog.h b/gui/preferencesdialog.h index b02bd45bf..94cff35d4 100644 --- a/gui/preferencesdialog.h +++ b/gui/preferencesdialog.h @@ -63,15 +63,19 @@ private: ServerSettings *server; ServerPlaybackSettings *serverplayback; PlaybackSettings *playback; + #ifndef CANTATA_ANDROID InterfaceSettings *interface; ExternalSettings *ext; + #endif LyricSettings *lyrics; + #ifndef CANTATA_ANDROID #ifdef TAGLIB_FOUND HttpServerSettings *http; #endif #ifndef ENABLE_KDE_SUPPORT ProxySettings *proxy; #endif + #endif // CANTATA_ANDROID }; #endif diff --git a/gui/serversettings.cpp b/gui/serversettings.cpp index e6570f58c..cf5e42140 100644 --- a/gui/serversettings.cpp +++ b/gui/serversettings.cpp @@ -35,7 +35,11 @@ ServerSettings::ServerSettings(QWidget *p) : QWidget(p) { setupUi(this); - #ifdef ENABLE_DEVICES_SUPPORT + #ifdef CANTATA_ANDROID + dir->setVisible(false); + dirLabel->setVisible(false); + musicFolderNoteLabel->setVisible(false); + #elif defined ENABLE_DEVICES_SUPPORT musicFolderNoteLabel->setText(musicFolderNoteLabel->text()+ i18n(" This folder will also be used to locate music files " "for transferring to (and from) devices.")); @@ -48,7 +52,7 @@ ServerSettings::ServerSettings(QWidget *p) saveButton->setIcon(QIcon::fromTheme("document-save-as")); removeButton->setIcon(QIcon::fromTheme("edit-delete")); - #ifdef Q_OS_WIN + #if defined Q_OS_WIN || defined CANTATA_ANDROID hostLabel->setText(i18n("Host:")); socketNoteLabel->setVisible(false); #endif diff --git a/gui/settings.cpp b/gui/settings.cpp index 054255082..c164a2d80 100644 --- a/gui/settings.cpp +++ b/gui/settings.cpp @@ -339,27 +339,47 @@ bool Settings::storeLyricsInMpdDir() int Settings::libraryView() { + #ifdef CANTATA_ANDROID + return ItemView::Mode_List; + #else return GET_INT("libraryView", (int)(version()>=CANTATA_MAKE_VERSION(0, 5, 0) ? ItemView::Mode_Tree : ItemView::Mode_List)); + #endif } int Settings::albumsView() { + #ifdef CANTATA_ANDROID + return ItemView::Mode_IconTop; + #else return GET_INT("albumsView", (int)ItemView::Mode_IconTop); + #endif } int Settings::folderView() { + #ifdef CANTATA_ANDROID + return ItemView::Mode_List; + #else return GET_INT("folderView", (int)ItemView::Mode_Tree); + #endif } int Settings::playlistsView() { + #ifdef CANTATA_ANDROID + return ItemView::Mode_List; + #else return GET_INT("playlistsView", (int)(version()>=CANTATA_MAKE_VERSION(0, 5, 0) ? ItemView::Mode_Tree : ItemView::Mode_List)); + #endif } int Settings::streamsView() { + #ifdef CANTATA_ANDROID + return ItemView::Mode_List; + #else return GET_INT("streamsView", (int)(version()>=CANTATA_MAKE_VERSION(0, 5, 0) ? ItemView::Mode_Tree : ItemView::Mode_List)); + #endif } bool Settings::libraryArtistImage() @@ -369,12 +389,20 @@ bool Settings::libraryArtistImage() int Settings::libraryCoverSize() { + #ifdef CANTATA_ANDROID + return MusicLibraryItemAlbum::CoverAuto; + #else return GET_INT("libraryCoverSize", (int)(MusicLibraryItemAlbum::CoverMedium)); + #endif } int Settings::albumsCoverSize() { + #ifdef CANTATA_ANDROID + return MusicLibraryItemAlbum::CoverAuto; + #else return GET_INT("albumsCoverSize", (int)(MusicLibraryItemAlbum::CoverMedium)); + #endif } int Settings::albumSort() diff --git a/main.cpp b/main.cpp index 70b56fefe..0d350602f 100644 --- a/main.cpp +++ b/main.cpp @@ -61,7 +61,7 @@ int main(int argc, char *argv[]) exit(0); Application app; - #else + #else // ENABLE_KDE_SUPPORT QCoreApplication::setApplicationName(PACKAGE_NAME); #ifdef Q_OS_WIN QCoreApplication::setOrganizationName("mpd"); @@ -74,11 +74,13 @@ int main(int argc, char *argv[]) return 0; } MainWindow mw; + #if !defined CANTATA_ANDROID app.setActivationWindow(&mw); #ifdef TAGLIB_FOUND app.loadFiles(); - #endif - #endif + #endif // TAGLIB_FOUND + #endif // CANTATA_ANDROID + #endif // ENABLE_KDE_SUPPORT return app.exec(); } diff --git a/widgets/autohidingsplitter.h b/widgets/autohidingsplitter.h index 3d7f72a82..ae41af68f 100644 --- a/widgets/autohidingsplitter.h +++ b/widgets/autohidingsplitter.h @@ -25,14 +25,21 @@ #ifndef AUTOHIDINGSPLITTER_H #define AUTOHIDINGSPLITTER_H +#include "config.h" #include + +#ifdef CANTATA_ANDROID + +#define AutohidingSplitter QSplitter + +#else + #include #include #include #include #include - Q_DECLARE_METATYPE(QList) class SplitterSizeAnimation; @@ -118,3 +125,5 @@ private: }; #endif + +#endif diff --git a/widgets/playqueueview.cpp b/widgets/playqueueview.cpp index e8676a14d..a4824dd6e 100644 --- a/widgets/playqueueview.cpp +++ b/widgets/playqueueview.cpp @@ -28,7 +28,6 @@ #include "treeview.h" #include "settings.h" #include "mpdstatus.h" -#include "httpserver.h" #include "localize.h" #include #include