From 01f5c6b8f4474726e5e0ba5d65ec02a56ce03198 Mon Sep 17 00:00:00 2001 From: levovix0 Date: Thu, 25 Mar 2021 17:06:03 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=B5=D1=80=D0=BD=D1=83=D0=BB=20=D1=81?= =?UTF-8?q?=D0=B1=D0=BE=D1=80=D0=BA=D1=83=20=D0=BD=D0=B0=20qmake,=20=D1=82?= =?UTF-8?q?=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=D0=B5=D1=82=20=D1=81=D1=82=D0=B0=D1=82=D0=B8=D1=87=D0=B5?= =?UTF-8?q?=D1=81=D0=BA=D0=B0=D1=8F=20=D0=BB=D0=B8=D0=BD=D0=BA=D0=BE=D0=B2?= =?UTF-8?q?=D0=BA=D0=B0=20=D1=81=20=D0=B1=D0=B8=D0=B1=D0=BB=D0=BE=D1=82?= =?UTF-8?q?=D0=B5=D0=BA=D0=B0=D0=BC=D0=B8=20Qt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 6 +-- CMakeLists.txt | 73 ----------------------------- DMusic.pro | 101 ++++++++++++++++++++++++++++++++++++++++ Icon.qml | 2 +- VolumeControlPanel.qml | 1 - main.cpp | 2 +- main.qml | 5 +- qml.qrc | 1 - russian.ts | 23 --------- translations.qrc | 7 +++ translations/russian.ts | 42 +++++++++++++++++ 11 files changed, 158 insertions(+), 105 deletions(-) delete mode 100644 CMakeLists.txt create mode 100644 DMusic.pro delete mode 100644 russian.ts create mode 100644 translations.qrc create mode 100644 translations/russian.ts diff --git a/.gitignore b/.gitignore index b66a82c..dc1d953 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ -/DMusic /.vscode /build-* *.user -/yapi/tests/test1 -/yapi/tests/test1.exe + +# Qt translation binaries +*.qm diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 95b5788..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,73 +0,0 @@ -cmake_minimum_required(VERSION 3.14) - -project(DMusic LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOUIC ON) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -# QtCreator supports the following variables for Android, which are identical to qmake Android variables. -# Check https://doc.qt.io/qt/deployment-android.html for more information. -# They need to be set before the find_package(...) calls below. - -#if(ANDROID) -# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") -# if (ANDROID_ABI STREQUAL "armeabi-v7a") -# set(ANDROID_EXTRA_LIBS -# ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libcrypto.so -# ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libssl.so) -# endif() -#endif() - -find_package(Python3 COMPONENTS Development REQUIRED) - -set(qt_winextras ) -if(WIN32) - set(qt_winextras WinExtras) -endif() - -find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Quick LinguistTools Multimedia DBus ${qt_winextras} REQUIRED) -find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick LinguistTools Multimedia DBus ${qt_winextras} REQUIRED) - -set(TS_FILES russian.ts) - -file(GLOB PROJECT_SOURCES "*.cpp") -file(GLOB project_headers "*.hpp") -file(GLOB project_qml "*.qml") -set(PROJECT_SOURCES ${PROJECT_SOURCES} ${TS_FILES}) - -if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) - qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES}) - - qt_add_executable(${PROJECT_NAME} ${PROJECT_SOURCES} ${project_headers} qml.qrc ${QM_FILES}) -else() - qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES}) - - if(ANDROID) - add_library(${PROJECT_NAME} SHARED ${PROJECT_SOURCES} ${project_headers} qml.qrc ${QM_FILES}) - else() - add_executable(${PROJECT_NAME} ${PROJECT_SOURCES} ${project_headers} qml.qrc ${QM_FILES}) - endif() -endif() - -target_compile_definitions(${PROJECT_NAME} PRIVATE - $<$,$>:QT_QML_DEBUG> -) - -target_link_libraries(${PROJECT_NAME} PRIVATE - ${Python3_LIBRARIES} - Qt${QT_VERSION_MAJOR}::Core - Qt${QT_VERSION_MAJOR}::Quick - Qt${QT_VERSION_MAJOR}::Multimedia - Qt${QT_VERSION_MAJOR}::DBus -) -if(WIN32) - target_link_libraries(${PROJECT_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::WinExtras) -endif() - -target_include_directories(${PROJECT_NAME} PRIVATE ${Python3_INCLUDE_DIRS}) diff --git a/DMusic.pro b/DMusic.pro new file mode 100644 index 0000000..897e458 --- /dev/null +++ b/DMusic.pro @@ -0,0 +1,101 @@ +QT += quick multimedia dbus svg +win32: QT += winextras + +CONFIG += c++17 + +SOURCES += \ + AudioPlayer.cpp \ + IClient.cpp \ + ID.cpp \ + IPlaylist.cpp \ + IPlaylistRadio.cpp \ + IRadio.cpp \ + ITrack.cpp \ + Log.cpp \ + QmlTrack.cpp \ + RemoteMediaController.cpp \ + api.cpp \ + main.cpp \ + mediaplayer.cpp \ + settings.cpp \ + yapi.cpp + +HEADERS += \ + AudioPlayer.hpp \ + IClient.hpp \ + ID.hpp \ + IPlaylist.hpp \ + IPlaylistRadio.hpp \ + IRadio.hpp \ + ITrack.hpp \ + Log.hpp \ + QmlTrack.hpp \ + RemoteMediaController.hpp \ + api.hpp \ + file.hpp \ + mediaplayer.hpp \ + python.hpp \ + settings.hpp \ + types.hpp \ + utils.hpp \ + yapi.hpp + +RESOURCES += qml.qrc translations.qrc +win32:RC_ICONS += resources/application.ico + +TRANSLATIONS += \ + translations/russian.ts + +!isEmpty(TRANSLATIONS): contains(RESOURCES, translations.qrc) { + # generate translations.qrc if TRANSLATIONS changed + _old_translations = $$cat($$OUT_PWD/translations.txt) + _current_translations = $$TRANSLATIONS + _current_translations -= $$_old_translations + _old_translations -= $$TRANSLATIONS + _transaltions_diff = $$_old_translations $$_current_translations + !isEmpty(_transaltions_diff)|!exists($$OUT_PWD/translations.txt)|!exists($$PWD/translations.qrc) { + message(regenerating translations.qrc) + + # create translations.qrc + _translations_qrc += $$escape_expand(\n) + for(_translation_name, TRANSLATIONS) { + _translation_name_qm = $$section(_translation_name,".", 0, 0).qm + _translations_qrc += $$_translation_name_qm$$escape_expand(\n) + + # if *.qm not exist - create dummy + system($$shell_path($$[QT_INSTALL_BINS]/lrelease) $$shell_path($$PWD/$$_translation_name) -qm $$shell_path($$_translation_name_qm)) + } + _translations_qrc += $$escape_expand(\n) + write_file($$PWD/translations.qrc, _translations_qrc) + write_file($$OUT_PWD/translations.txt, TRANSLATIONS); + + QMAKE_CLEAN += $$shell_path($$OUT_PWD/translations.txt) + } + + # run lrelease + QMAKE_EXTRA_COMPILERS += _translations_lrelease + _translations_lrelease.input = TRANSLATIONS + _translations_lrelease.output = $$PWD/translations/${QMAKE_FILE_BASE}.qm + _translations_lrelease.commands = $$[QT_INSTALL_BINS]/lrelease ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_OUT} + _translations_lrelease.CONFIG += no_link +} + +QML_IMPORT_PATH = + +QML_DESIGNER_IMPORT_PATH = + +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target + +win32 { + LIBS += -LC:\Users\levovix\AppData\Local\Programs\Python\Python39\libs -lpython39 + INCLUDEPATH += C:\Users\levovix\AppData\Local\Programs\Python\Python39\include + DEPENDPATH += C:\Users\levovix\AppData\Local\Programs\Python\Python39\include +} + +unix { + LIBS += -L/usr/local/lib/python3.9 -lpython3.9 + INCLUDEPATH += /usr/include/python3.9 + DEPENDPATH += /usr/include/python3.9 +} diff --git a/Icon.qml b/Icon.qml index 374fc79..b4393a6 100644 --- a/Icon.qml +++ b/Icon.qml @@ -1,5 +1,5 @@ import QtQuick 2.0 -import QtGraphicalEffects 1.0 +import QtGraphicalEffects 1.15 Item { id: root diff --git a/VolumeControlPanel.qml b/VolumeControlPanel.qml index 8467931..a0ebfaa 100644 --- a/VolumeControlPanel.qml +++ b/VolumeControlPanel.qml @@ -1,5 +1,4 @@ import QtQuick 2.0 -import QtGraphicalEffects 1.15 import DMusic 1.0 FloatingPanel { diff --git a/main.cpp b/main.cpp index fec629b..4ad1673 100644 --- a/main.cpp +++ b/main.cpp @@ -14,7 +14,7 @@ int main(int argc, char *argv[]) Py_Initialize(); QTranslator translator; - translator.load("russian"); + translator.load(":translations/russian"); QGuiApplication app(argc, argv); app.installTranslator(&translator); diff --git a/main.qml b/main.qml index d44e832..8943de3 100644 --- a/main.qml +++ b/main.qml @@ -93,7 +93,8 @@ Window { anchors.right: root.horizontalCenter anchors.rightMargin: 10 - text: "Прослушать" + //: Play button + text: qsTr("Play") onClick: { _player.player.play(_yapi.track(parseInt(_id_input.text))) @@ -107,7 +108,7 @@ Window { anchors.left: root.horizontalCenter anchors.leftMargin: 10 - text: "Прослушать скачанное" + text: qsTr("Play downloaded") onClick: { _player.player.play(_yapi.downloadsPlaylist()) diff --git a/qml.qrc b/qml.qrc index e0e334a..513cc27 100644 --- a/qml.qrc +++ b/qml.qrc @@ -58,6 +58,5 @@ VolumeSlider.qml FloatingPanel.qml PopupController.qml - russian.ts diff --git a/russian.ts b/russian.ts deleted file mode 100644 index 129f8a8..0000000 --- a/russian.ts +++ /dev/null @@ -1,23 +0,0 @@ - - - - - ThumbnailController - - Play - Играть - - - Next - Следующий - - - Previous - Предыдущий - - - Pause - Пауза - - - diff --git a/translations.qrc b/translations.qrc new file mode 100644 index 0000000..2d3f979 --- /dev/null +++ b/translations.qrc @@ -0,0 +1,7 @@ + + +translations/russian.qm + + + diff --git a/translations/russian.ts b/translations/russian.ts new file mode 100644 index 0000000..2416d99 --- /dev/null +++ b/translations/russian.ts @@ -0,0 +1,42 @@ + + + + + ThumbnailController + + + + Play + Продолжить + + + + Next + Следующий + + + + Previous + Предыдуший + + + + Pause + Пауза + + + + main + + + Play + Play button + Прослушать + + + + Play downloaded + Прослушать скачанное + + +