diff --git a/src/main.cpp b/src/main.cpp index b3277db5..aece1784 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,182 +1,182 @@ /* * Copyright 2015-2018 Matthieu Gallien * * This program is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "config-upnp-qt.h" #include "elisa-version.h" #include "elisaapplication.h" #include "elisa_settings.h" //#define QT_QML_DEBUG #if defined KF5Declarative_FOUND && KF5Declarative_FOUND #include #endif #include #include #include #if defined KF5Crash_FOUND && KF5Crash_FOUND #include #endif #if defined KF5DBusAddons_FOUND && KF5DBusAddons_FOUND #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined Qt5AndroidExtras_FOUND && Qt5AndroidExtras_FOUND #include #endif #include #if defined Qt5AndroidExtras_FOUND && Qt5AndroidExtras_FOUND #include #include #endif #if defined Q_OS_ANDROID int __attribute__((visibility("default"))) main(int argc, char *argv[]) #else int main(int argc, char *argv[]) #endif { #if defined Q_OS_ANDROID if(argc > 1 && strcmp(argv[1], "-service") == 0){ QAndroidService app(argc, argv); qInfo() << "Service starting..."; // My service stuff return app.exec(); } qInfo() << "Application starting..."; #endif QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); qputenv("QT_GSTREAMER_USE_PLAYBIN_VOLUME", "true"); QApplication app(argc, argv); #if defined Qt5AndroidExtras_FOUND && Qt5AndroidExtras_FOUND qInfo() << QCoreApplication::arguments(); QAndroidJniObject::callStaticMethod("org/kde/elisa/ElisaService", "startMyService", "(Landroid/content/Context;)V", QtAndroid::androidContext().object()); #endif #if defined KF5Crash_FOUND && KF5Crash_FOUND KCrash::initialize(); #endif QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("elisa"))); KLocalizedString::setApplicationDomain("elisa"); KAboutData aboutData( QStringLiteral("elisa"), i18n("Elisa"), QStringLiteral(ELISA_VERSION_STRING), i18n("A Simple Music Player written with KDE Frameworks"), KAboutLicense::LGPL_V3, i18n("(c) 2015-2019, Elisa contributors")); aboutData.addAuthor(QStringLiteral("Matthieu Gallien"),i18n("Creator"), QStringLiteral("mgallien@mgallien.fr")); aboutData.addAuthor(QStringLiteral("Alexander Stippich"), i18n("Author"), QStringLiteral("a.stippich@gmx.net")); aboutData.addCredit(QStringLiteral("Andrew Lake"), i18n("Concept and design work"), QStringLiteral("jamboarder@gmail.com")); aboutData.addCredit(QStringLiteral("Luigi Toscano"), i18n("Localization support"), QStringLiteral("luigi.toscano@tiscali.it")); aboutData.addCredit(QStringLiteral("Safa Alfulaij"), i18n("Right to left support in interface"), QStringLiteral("safa1996alfulaij@gmail.com")); aboutData.addCredit(QStringLiteral("Diego Gangl"), i18n("Various improvements to the interface"), QStringLiteral("diego@sinestesia.co")); KAboutData::setApplicationData(aboutData); KLocalizedString::setApplicationDomain("elisa"); QCommandLineParser parser; parser.addHelpOption(); parser.addVersionOption(); aboutData.setupCommandLine(&parser); parser.process(app); aboutData.processCommandLine(&parser); QQuickStyle::setStyle(QStringLiteral("org.kde.desktop")); QQuickStyle::setFallbackStyle(QStringLiteral("Fusion")); QQmlApplicationEngine engine; engine.addImportPath(QStringLiteral("qrc:/imports")); QQmlFileSelector selector(&engine); #if defined KF5Declarative_FOUND && KF5Declarative_FOUND KDeclarative::KDeclarative decl; decl.setDeclarativeEngine(&engine); decl.setupEngine(&engine); decl.setupContext(); #endif engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); - engine.rootContext()->setContextProperty(QStringLiteral("logicalDpi"), QGuiApplication::primaryScreen()->logicalDotsPerInch()); #if defined KF5DBusAddons_FOUND && KF5DBusAddons_FOUND KDBusService elisaService(KDBusService::Unique); #endif std::unique_ptr myApp = std::make_unique(); #if defined KF5DBusAddons_FOUND && KF5DBusAddons_FOUND QObject::connect(&elisaService, &KDBusService::activateActionRequested, myApp.get(), &ElisaApplication::activateActionRequested); QObject::connect(&elisaService, &KDBusService::activateRequested, myApp.get(), &ElisaApplication::activateRequested); QObject::connect(&elisaService, &KDBusService::openRequested, myApp.get(), &ElisaApplication::openRequested); #endif auto arguments = ElisaUtils::EntryDataList{}; auto realArgumentsList = parser.positionalArguments(); for (auto oneArgument : realArgumentsList) { arguments.push_back(ElisaUtils::EntryData{0, oneArgument}); } myApp->setArguments(arguments); engine.rootContext()->setContextProperty(QStringLiteral("elisa"), myApp.release()); engine.load(QUrl(QStringLiteral("qrc:/qml/ElisaMainWindow.qml"))); return app.exec(); } diff --git a/src/qml/BaseTheme.qml b/src/qml/BaseTheme.qml index b45f2e13..e2dd5a93 100644 --- a/src/qml/BaseTheme.qml +++ b/src/qml/BaseTheme.qml @@ -1,120 +1,115 @@ /* * Copyright 2017 Matthieu Gallien * * This program is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ import QtQuick 2.7 import QtQuick.Controls 2.2 Item { - function dp(pixel) { - // 96 - common, "base" DPI value - return Math.round(pixel * logicalDpi / 96); - } - property string defaultAlbumImage: 'image://icon/media-optical-audio' property string defaultArtistImage: 'image://icon/view-media-artist' property string defaultBackgroundImage: 'qrc:///background.png' property string nowPlayingIcon: 'image://icon/view-media-lyrics' property string artistIcon: 'image://icon/view-media-artist' property string albumIcon: 'image://icon/view-media-album-cover' property string albumCoverIcon: 'image://icon/media-optical-audio' property string playlistIcon: 'image://icon/view-media-playlist' property string tracksIcon: 'image://icon/view-media-track' property string genresIcon: 'image://icon/view-media-genre' property string clearIcon: 'image://icon/edit-clear' property string recentlyPlayedTracksIcon: 'image://icon/media-playlist-play' property string frequentlyPlayedTracksIcon: 'image://icon/view-media-playcount' property string pausedIndicatorIcon: 'image://icon/media-playback-paused' property string playingIndicatorIcon: 'image://icon/media-playback-playing' property string ratingIcon: 'image://icon/rating' property string ratingUnratedIcon: 'image://icon/rating-unrated' property string errorIcon: 'image://icon/error' property string folderIcon: 'image://icon/document-open-folder' - property int layoutHorizontalMargin: dp(8) - property int layoutVerticalMargin: dp(6) + property int layoutHorizontalMargin: 8 + property int layoutVerticalMargin: 6 - property int delegateHeight: dp(28) + property int delegateHeight: 28 FontMetrics { id: playListAuthorTextHeight font.weight: Font.Light } FontMetrics { id: playListAlbumTextHeight font.weight: Font.Bold font.pointSize: Math.round(elisaTheme.defaultFontPointSize * 1.4) } FontMetrics { id: playListTrackTextHeight font.weight: Font.Bold } - property int playListDelegateHeight: (playListTrackTextHeight.height > dp(28)) ? playListTrackTextHeight.height : dp(28) + property int playListDelegateHeight: (playListTrackTextHeight.height > 28) ? playListTrackTextHeight.height : 28 property int playListHeaderHeight: elisaTheme.layoutVerticalMargin * 5 + playListAuthorTextHeight.height + playListAlbumTextHeight.height - property int trackDelegateHeight: dp(45) + property int trackDelegateHeight: 45 - property int coverImageSize: dp(180) - property int contextCoverImageSize: dp(100) - property int smallImageSize: dp(32) + property int coverImageSize: 180 + property int contextCoverImageSize: 100 + property int smallImageSize: 32 - property int maximumMetadataWidth: dp(300) + property int maximumMetadataWidth: 300 - property int tooltipRadius: dp(3) - property int shadowOffset: dp(2) + property int tooltipRadius: 3 + property int shadowOffset: 2 - property int delegateToolButtonSize: dp(34) - property int smallDelegateToolButtonSize: dp(20) + property int delegateToolButtonSize: 34 + property int smallDelegateToolButtonSize: 20 - property int ratingStarSize: dp(15) + property int ratingStarSize: 15 - property int mediaPlayerControlHeight: dp(42) - property int mediaPlayerHorizontalMargin: dp(10) + property int mediaPlayerControlHeight: 42 + property int mediaPlayerHorizontalMargin: 10 property real mediaPlayerControlOpacity: 0.6 - property int smallControlButtonSize: dp(22) - property int volumeSliderWidth: dp(100) + property int smallControlButtonSize: 22 + property int volumeSliderWidth: 100 - property int dragDropPlaceholderHeight: dp(28) + property int dragDropPlaceholderHeight: 28 - property int navigationBarHeight: dp(100) - property int navigationBarFilterHeight: dp(44) + property int navigationBarHeight: 100 + property int navigationBarFilterHeight: 44 - property int gridDelegateHeight: dp(170) + layoutVerticalMargin + fontSize.height * 2 - property int gridDelegateWidth: dp(170) + property int gridDelegateHeight: 170 + layoutVerticalMargin + fontSize.height * 2 + property int gridDelegateWidth: 170 - property int viewSelectorDelegateHeight: dp(24) + property int viewSelectorDelegateHeight: 24 property int filterClearButtonMargin: layoutVerticalMargin property alias defaultFontPointSize: fontSize.font.pointSize property int headerTitleFontSize: defaultFontPointSize * 2 - property int headerToolbarHeight: dp(48) - property int footerToolbarHeight: dp(30) + property int headerToolbarHeight: 48 + property int footerToolbarHeight: 30 property int viewSelectorSmallSizeThreshold: 800 Label { id: fontSize } } diff --git a/src/qml/ViewSelector.qml b/src/qml/ViewSelector.qml index 06a28b8b..59e292a3 100644 --- a/src/qml/ViewSelector.qml +++ b/src/qml/ViewSelector.qml @@ -1,143 +1,143 @@ /* * Copyright 2016-2017 Matthieu Gallien * * This program is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ import QtQuick 2.7 import QtQuick.Controls 2.2 import QtQml.Models 2.2 import QtGraphicalEffects 1.0 import org.kde.elisa 1.0 FocusScope { id: rootFocusScope readonly property alias currentIndex: viewModeView.currentIndex property double textOpacity property alias model: pageDelegateModel.model signal switchView(var viewType) function setCurrentIndex(index) { viewModeView.ignoreCurrentItemChanges = true viewModeView.currentIndex = index viewModeView.ignoreCurrentItemChanges = false } - implicitWidth: elisaTheme.dp(225) + implicitWidth: 225 ScrollView { focus: true anchors.fill: parent z: 2 clip: true ScrollBar.horizontal.policy: ScrollBar.AlwaysOff ListView { id: viewModeView Accessible.role: Accessible.List focus: true activeFocusOnTab: true keyNavigationEnabled: true property bool ignoreCurrentItemChanges: false z: 2 anchors.topMargin: elisaTheme.layoutHorizontalMargin * 2 model: DelegateModel { id: pageDelegateModel delegate: ViewSelectorDelegate { id: entry height: Math.round(elisaTheme.viewSelectorDelegateHeight * 1.4) width: viewModeView.width focus: true isSelected: viewModeView.currentIndex === index onClicked: { viewModeView.currentIndex = index entry.forceActiveFocus() } } } footer: MouseArea { width: viewModeView.width height: viewModeView.height - y acceptedButtons: Qt.LeftButton onClicked: { rootFocusScope.focus = true } } onCurrentItemChanged: if (!ignoreCurrentItemChanges) switchView(currentItem.viewType) } } Connections { target: elisa onInitializationDone: { viewModeView.currentIndex = 3 } } Behavior on implicitWidth { NumberAnimation { duration: 150 } } Behavior on width { NumberAnimation { duration: 150 } } states: [ State { name: 'iconsAndText' when: mainWindow.width >= elisaTheme.viewSelectorSmallSizeThreshold PropertyChanges { target: rootFocusScope textOpacity: 1 - implicitWidth: elisaTheme.dp(225) + implicitWidth: 225 } }, State { name: 'iconsOnly' when: mainWindow.width < elisaTheme.viewSelectorSmallSizeThreshold PropertyChanges { target: rootFocusScope textOpacity: 0 implicitWidth: elisaTheme.viewSelectorDelegateHeight + 2 * elisaTheme.layoutHorizontalMargin } } ] }