Skip to content

Commit

Permalink
Исправил пару ошибок
Browse files Browse the repository at this point in the history
  • Loading branch information
levovix0 committed Mar 24, 2021
1 parent 8de6fa0 commit 06f2211
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 8 deletions.
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Python3 COMPONENTS Development REQUIRED)

find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Quick LinguistTools Multimedia DBus REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick LinguistTools Multimedia DBus 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 ${PROJECT_NAME}_ru_RU.ts)

Expand Down Expand Up @@ -61,5 +66,8 @@ target_link_libraries(${PROJECT_NAME} PRIVATE
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})
3 changes: 2 additions & 1 deletion Log.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include <QString>
#undef log

struct Log
{
Expand All @@ -9,4 +10,4 @@ struct Log
Log& error(QString s);
};

inline static Log log;
inline static Log logging;
2 changes: 1 addition & 1 deletion api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Playlist::Generator DPlaylist::sequenceGenerator(int index)

Playlist::Generator DPlaylist::shuffleGenerator(int index)
{
if (index < 0 || index > size()) return shuffleGenerator(QRandomGenerator::global()->bounded(_tracks.length() - 1));
if (index < 0 || index > size()) return shuffleGenerator(QRandomGenerator::global()->bounded(_tracks.length()));

_history = _tracks;
std::shuffle(_history.begin(), _history.end(), rnd);
Expand Down
4 changes: 2 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QIcon>
#include <QtWinExtras>

int main(int argc, char *argv[])
{
Expand All @@ -21,8 +22,7 @@ int main(int argc, char *argv[])
qmlRegisterType<Settings>("DMusic", 1, 0, "Settings");
qmlRegisterType<RemoteMediaController>("DMusic", 1, 0, "RemoteMediaController");

if (QFileInfo::exists("application.svg"))
QGuiApplication::setWindowIcon(QIcon("application.svg"));
QGuiApplication::setWindowIcon(QIcon(":resources/application.svg"));
app.setApplicationName("DMusic");

QQmlApplicationEngine engine;
Expand Down
2 changes: 1 addition & 1 deletion mediaplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void MediaPlayer::setMedia(QMediaContent media)

void MediaPlayer::onMediaAborted()
{
log.error("media aborted");
logging.error("media aborted");
next();
}

Expand Down
6 changes: 5 additions & 1 deletion yapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "file.hpp"
#include "settings.hpp"
#include "utils.hpp"
#include "Log.hpp"
#include <thread>
#include <functional>
#include <QDebug>
Expand Down Expand Up @@ -309,7 +310,10 @@ QMediaContent YTrack::media()
{
if (_media.isEmpty()) {
if (!_noMedia) _downloadMedia(); // async
else emit mediaAborted();
else {
logging.warning("yandex/" + QString::number(id()) + ": no media");
emit mediaAborted();
}
return {};
}
return QMediaContent("file:" + QDir::cleanPath(Settings::ym_savePath() + QDir::separator() + _media));
Expand Down

0 comments on commit 06f2211

Please sign in to comment.