Merge pull request #191 from monich/logging
Take logging categories into use
This commit is contained in:
commit
10af41eb83
19 changed files with 123 additions and 72 deletions
|
@ -145,6 +145,7 @@ HEADERS += \
|
||||||
src/chatmodel.h \
|
src/chatmodel.h \
|
||||||
src/dbusadaptor.h \
|
src/dbusadaptor.h \
|
||||||
src/dbusinterface.h \
|
src/dbusinterface.h \
|
||||||
|
src/debuglog.h \
|
||||||
src/emojisearchworker.h \
|
src/emojisearchworker.h \
|
||||||
src/fernschreiberutils.h \
|
src/fernschreiberutils.h \
|
||||||
src/notificationmanager.h \
|
src/notificationmanager.h \
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "appsettings.h"
|
#include "appsettings.h"
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#define LOG(x) qDebug() << "[AppSettings]" << x
|
#define DEBUG_MODULE AppSettings
|
||||||
|
#include "debuglog.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const QString KEY_SEND_BY_ENTER("sendByEnter");
|
const QString KEY_SEND_BY_ENTER("sendByEnter");
|
||||||
|
|
|
@ -19,9 +19,9 @@
|
||||||
|
|
||||||
#include "chatlistmodel.h"
|
#include "chatlistmodel.h"
|
||||||
#include "fernschreiberutils.h"
|
#include "fernschreiberutils.h"
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#define LOG(x) qDebug() << "[ChatListModel]" << x
|
#define DEBUG_MODULE ChatListModel
|
||||||
|
#include "debuglog.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const QString ID("id");
|
const QString ID("id");
|
||||||
|
|
|
@ -22,9 +22,9 @@
|
||||||
#include <QListIterator>
|
#include <QListIterator>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QBitArray>
|
#include <QBitArray>
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#define LOG(x) qDebug() << "[ChatModel]" << x
|
#define DEBUG_MODULE ChatModel
|
||||||
|
#include "debuglog.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const QString ID("id");
|
const QString ID("id");
|
||||||
|
|
|
@ -19,22 +19,22 @@
|
||||||
|
|
||||||
#include "dbusadaptor.h"
|
#include "dbusadaptor.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#define DEBUG_MODULE DBusAdaptor
|
||||||
|
#include "debuglog.h"
|
||||||
|
|
||||||
DBusAdaptor::DBusAdaptor(QObject *parent): QDBusAbstractAdaptor(parent)
|
DBusAdaptor::DBusAdaptor(QObject *parent): QDBusAbstractAdaptor(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBusAdaptor::openMessage(const QString &chatId, const QString &messageId)
|
void DBusAdaptor::openMessage(const QString &chatId, const QString &messageId)
|
||||||
{
|
{
|
||||||
qDebug() << "[DBusAdaptor] Open Message " << chatId << messageId;
|
LOG("Open Message" << chatId << messageId);
|
||||||
emit pleaseOpenMessage(chatId, messageId);
|
emit pleaseOpenMessage(chatId, messageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBusAdaptor::openUrl(const QStringList &arguments)
|
void DBusAdaptor::openUrl(const QStringList &arguments)
|
||||||
{
|
{
|
||||||
qDebug() << "[DBusAdaptor] Open Url" << arguments;
|
LOG("Open Url" << arguments);
|
||||||
if (arguments.length() >= 1) {
|
if (arguments.length() >= 1) {
|
||||||
emit pleaseOpenUrl(arguments.first());
|
emit pleaseOpenUrl(arguments.first());
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,27 +19,29 @@
|
||||||
|
|
||||||
#include "dbusinterface.h"
|
#include "dbusinterface.h"
|
||||||
|
|
||||||
|
#define DEBUG_MODULE DBusInterface
|
||||||
|
#include "debuglog.h"
|
||||||
|
|
||||||
DBusInterface::DBusInterface(QObject *parent) : QObject(parent)
|
DBusInterface::DBusInterface(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
qDebug() << "[DBusInterface] Initializing D-BUS connectivity";
|
LOG("Initializing D-BUS connectivity");
|
||||||
this->dbusAdaptor = new DBusAdaptor(this);
|
this->dbusAdaptor = new DBusAdaptor(this);
|
||||||
QDBusConnection sessionBusConnection = QDBusConnection::sessionBus();
|
QDBusConnection sessionBusConnection = QDBusConnection::sessionBus();
|
||||||
|
|
||||||
if (!sessionBusConnection.isConnected()) {
|
if (!sessionBusConnection.isConnected()) {
|
||||||
qDebug() << "[DBusInterface] Error connecting to D-BUS";
|
WARN("Error connecting to D-BUS");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sessionBusConnection.registerObject(PATH_NAME, this)) {
|
if (!sessionBusConnection.registerObject(PATH_NAME, this)) {
|
||||||
qDebug() << "[DBusInterface] Error registering root object to D-BUS" << sessionBusConnection.lastError().message();
|
WARN("Error registering root object to D-BUS" << sessionBusConnection.lastError().message());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sessionBusConnection.registerService(INTERFACE_NAME)) {
|
if (!sessionBusConnection.registerService(INTERFACE_NAME)) {
|
||||||
qDebug() << "[DBusInterface] Error registering interface to D-BUS" << sessionBusConnection.lastError().message();
|
WARN("Error registering interface to D-BUS" << sessionBusConnection.lastError().message());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DBusAdaptor *DBusInterface::getDBusAdaptor()
|
DBusAdaptor *DBusInterface::getDBusAdaptor()
|
||||||
|
|
45
src/debuglog.h
Normal file
45
src/debuglog.h
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2020 Slava Monich et al.
|
||||||
|
|
||||||
|
This file is part of Fernschreiber.
|
||||||
|
|
||||||
|
Fernschreiber is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Fernschreiber 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 General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Fernschreiber. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FERNSCHREIBER_DEBUG_LOG_H
|
||||||
|
#define FERNSCHREIBER_DEBUG_LOG_H
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
#ifndef DEBUG_MODULE
|
||||||
|
# define DEBUG_MODULE Debug
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define LOG_CATEGORY__(x) x##Log
|
||||||
|
#define LOG_CATEGORY_(x) LOG_CATEGORY__(x)
|
||||||
|
#define LOG_CATEGORY LOG_CATEGORY_(DEBUG_MODULE)
|
||||||
|
static const QLoggingCategory LOG_CATEGORY("fernschreiber." QT_STRINGIFY(DEBUG_MODULE));
|
||||||
|
#define LOG(x) qCDebug(LOG_CATEGORY) << "[" QT_STRINGIFY(DEBUG_MODULE) "]" << x
|
||||||
|
#define WARN(x) qCWarning(LOG_CATEGORY) << "[" QT_STRINGIFY(DEBUG_MODULE) "]" << x
|
||||||
|
|
||||||
|
// No VERBOSE in release build
|
||||||
|
#ifndef VERBOSE
|
||||||
|
# if defined (QT_DEBUG) || defined (DEBUG)
|
||||||
|
# define VERBOSE(x) LOG(x)
|
||||||
|
# else
|
||||||
|
# define VERBOSE(x)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // FERNSCHREIBER_DEBUG_LOG_H
|
|
@ -18,7 +18,8 @@
|
||||||
*/
|
*/
|
||||||
#include "emojisearchworker.h"
|
#include "emojisearchworker.h"
|
||||||
|
|
||||||
#define LOG(x) qDebug() << "[EmojiSearchWorker]" << x
|
#define DEBUG_MODULE EmojiSearchWorker
|
||||||
|
#include "debuglog.h"
|
||||||
|
|
||||||
EmojiSearchWorker::~EmojiSearchWorker()
|
EmojiSearchWorker::~EmojiSearchWorker()
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include <QSqlQuery>
|
#include <QSqlQuery>
|
||||||
#include <QSqlError>
|
#include <QSqlError>
|
||||||
#include <QVariantList>
|
#include <QVariantList>
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
class EmojiSearchWorker : public QThread
|
class EmojiSearchWorker : public QThread
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
#include "appsettings.h"
|
#include "appsettings.h"
|
||||||
#include "tdlibfile.h"
|
#include "tdlibfile.h"
|
||||||
|
@ -41,10 +42,20 @@
|
||||||
#include "tgsplugin.h"
|
#include "tgsplugin.h"
|
||||||
#include "fernschreiberutils.h"
|
#include "fernschreiberutils.h"
|
||||||
|
|
||||||
|
// The default filter can be overridden by QT_LOGGING_RULES envinronment variable, e.g.
|
||||||
|
// QT_LOGGING_RULES="fernschreiber.*=true" harbour-fernschreiber
|
||||||
|
#if defined (QT_DEBUG) || defined(DEBUG)
|
||||||
|
# define DEFAULT_LOG_FILTER "fernschreiber.*=true"
|
||||||
|
#else
|
||||||
|
# define DEFAULT_LOG_FILTER "fernschreiber.*=false"
|
||||||
|
#endif
|
||||||
|
|
||||||
Q_IMPORT_PLUGIN(TgsIOPlugin)
|
Q_IMPORT_PLUGIN(TgsIOPlugin)
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
QLoggingCategory::setFilterRules(DEFAULT_LOG_FILTER);
|
||||||
|
|
||||||
QScopedPointer<QGuiApplication> app(SailfishApp::application(argc, argv));
|
QScopedPointer<QGuiApplication> app(SailfishApp::application(argc, argv));
|
||||||
QScopedPointer<QQuickView> view(SailfishApp::createView());
|
QScopedPointer<QQuickView> view(SailfishApp::createView());
|
||||||
|
|
||||||
|
|
|
@ -21,14 +21,14 @@
|
||||||
#include "fernschreiberutils.h"
|
#include "fernschreiberutils.h"
|
||||||
#include "chatmodel.h"
|
#include "chatmodel.h"
|
||||||
#include <sailfishapp.h>
|
#include <sailfishapp.h>
|
||||||
#include <QDebug>
|
|
||||||
#include <QListIterator>
|
#include <QListIterator>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
|
|
||||||
#define LOG(x) qDebug() << "[NotificationManager]" << x
|
#define DEBUG_MODULE NotificationManager
|
||||||
|
#include "debuglog.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const QString _TYPE("@type");
|
const QString _TYPE("@type");
|
||||||
|
|
|
@ -1,18 +1,23 @@
|
||||||
#include "processlauncher.h"
|
#include "processlauncher.h"
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
|
||||||
#define LOG(x) qDebug() << "[ProcessLauncher]" << x
|
#define DEBUG_MODULE ProcessLauncher
|
||||||
|
#include "debuglog.h"
|
||||||
|
|
||||||
ProcessLauncher::ProcessLauncher(QObject *parent) : QObject(parent)
|
ProcessLauncher::ProcessLauncher(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProcessLauncher::launchProgram(const QString &program, const QStringList &arguments)
|
bool ProcessLauncher::launchProgram(const QString &program, const QStringList &arguments)
|
||||||
{
|
{
|
||||||
QString executablePath = QStandardPaths::findExecutable(program);
|
const QString executablePath(QStandardPaths::findExecutable(program));
|
||||||
if(executablePath == "") {
|
if (executablePath.isEmpty()) {
|
||||||
LOG("[ProcessLauncher] Program " + program + "not found");
|
LOG("Program" << program << "not found");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QProcess *externalProcess = new QProcess(this);
|
|
||||||
return externalProcess->startDetached(program, arguments);
|
QProcess *process = new QProcess(this);
|
||||||
|
connect(process, SIGNAL(finished(int)), process, SLOT(deleteLater()));
|
||||||
|
return process->startDetached(program, arguments);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,6 @@
|
||||||
#define PROCESSLAUNCHER_H
|
#define PROCESSLAUNCHER_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QProcess>
|
|
||||||
#include <QStandardPaths>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
class ProcessLauncher : public QObject
|
class ProcessLauncher : public QObject
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,10 +18,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "stickermanager.h"
|
#include "stickermanager.h"
|
||||||
#include <QDebug>
|
|
||||||
#include <QListIterator>
|
#include <QListIterator>
|
||||||
|
|
||||||
#define LOG(x) qDebug() << "[StickerManager]" << x
|
#define DEBUG_MODULE StickerManager
|
||||||
|
#include "debuglog.h"
|
||||||
|
|
||||||
StickerManager::StickerManager(TDLibWrapper *tdLibWrapper, QObject *parent) : QObject(parent)
|
StickerManager::StickerManager(TDLibWrapper *tdLibWrapper, QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tdlibfile.h"
|
#include "tdlibfile.h"
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#define LOG(x) qDebug() << "[TDLibFile]" << x
|
#define DEBUG_MODULE TDLibFile
|
||||||
|
#include "debuglog.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const QString ID("id");
|
const QString ID("id");
|
||||||
|
|
|
@ -18,13 +18,8 @@
|
||||||
*/
|
*/
|
||||||
#include "tdlibreceiver.h"
|
#include "tdlibreceiver.h"
|
||||||
|
|
||||||
#define LOG(x) qDebug() << "[TDLibReceiver]" << x
|
#define DEBUG_MODULE TDLibReceiver
|
||||||
|
#include "debuglog.h"
|
||||||
#if defined (QT_DEBUG) || defined (DEBUG)
|
|
||||||
# define VERBOSE(x) LOG(x)
|
|
||||||
#else
|
|
||||||
# define VERBOSE(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const QString ID("id");
|
const QString ID("id");
|
||||||
|
|
|
@ -19,7 +19,8 @@
|
||||||
#ifndef TDLIBRECEIVER_H
|
#ifndef TDLIBRECEIVER_H
|
||||||
#define TDLIBRECEIVER_H
|
#define TDLIBRECEIVER_H
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QHash>
|
||||||
|
#include <QVariantMap>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
|
@ -25,19 +25,13 @@
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QSysInfo>
|
#include <QSysInfo>
|
||||||
#include <QDebug>
|
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
#include <QDBusInterface>
|
#include <QDBusInterface>
|
||||||
|
|
||||||
#define LOG(x) qDebug() << "[TDLibWrapper]" << x
|
#define DEBUG_MODULE TDLibWrapper
|
||||||
|
#include "debuglog.h"
|
||||||
#if defined (QT_DEBUG) || defined (DEBUG)
|
|
||||||
# define VERBOSE(x) LOG(x)
|
|
||||||
#else
|
|
||||||
# define VERBOSE(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const QString STATUS("status");
|
const QString STATUS("status");
|
||||||
|
@ -199,7 +193,7 @@ void TDLibWrapper::setAuthenticationPassword(const QString &authenticationPasswo
|
||||||
|
|
||||||
void TDLibWrapper::registerUser(const QString &firstName, const QString &lastName)
|
void TDLibWrapper::registerUser(const QString &firstName, const QString &lastName)
|
||||||
{
|
{
|
||||||
qDebug() << "[TDLibWrapper] Register User " << firstName << lastName;
|
LOG("Register User " << firstName << lastName);
|
||||||
QVariantMap requestObject;
|
QVariantMap requestObject;
|
||||||
requestObject.insert("@type", "registerUser");
|
requestObject.insert("@type", "registerUser");
|
||||||
requestObject.insert("first_name", firstName);
|
requestObject.insert("first_name", firstName);
|
||||||
|
@ -890,9 +884,9 @@ void TDLibWrapper::openFileOnDevice(const QString &filePath)
|
||||||
argumentsList.append(filePath);
|
argumentsList.append(filePath);
|
||||||
bool successfullyStarted = QProcess::startDetached("xdg-open", argumentsList);
|
bool successfullyStarted = QProcess::startDetached("xdg-open", argumentsList);
|
||||||
if (successfullyStarted) {
|
if (successfullyStarted) {
|
||||||
qDebug() << "Successfully opened file " << filePath;
|
LOG("Successfully opened file " << filePath);
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Error opening file " << filePath;
|
LOG("Error opening file " << filePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -903,10 +897,10 @@ void TDLibWrapper::controlScreenSaver(bool enabled)
|
||||||
QDBusInterface dbusInterface("com.nokia.mce", "/com/nokia/mce/request", "com.nokia.mce.request", dbusConnection);
|
QDBusInterface dbusInterface("com.nokia.mce", "/com/nokia/mce/request", "com.nokia.mce.request", dbusConnection);
|
||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
qDebug() << "Enabling screensaver";
|
LOG("Enabling screensaver");
|
||||||
dbusInterface.call("req_display_cancel_blanking_pause");
|
dbusInterface.call("req_display_cancel_blanking_pause");
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Disabling screensaver";
|
LOG("Disabling screensaver");
|
||||||
dbusInterface.call("req_display_blanking_pause");
|
dbusInterface.call("req_display_blanking_pause");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1178,21 +1172,21 @@ void TDLibWrapper::setLogVerbosityLevel()
|
||||||
void TDLibWrapper::initializeOpenWith()
|
void TDLibWrapper::initializeOpenWith()
|
||||||
{
|
{
|
||||||
LOG("Initialize open-with");
|
LOG("Initialize open-with");
|
||||||
|
LOG("Checking standard open URL file...");
|
||||||
qDebug() << "Checking standard open URL file...";
|
const QString applicationsLocation(QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation));
|
||||||
QString openUrlFilePath = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation) + "/open-url.desktop";
|
const QString openUrlFilePath(applicationsLocation + "/open-url.desktop");
|
||||||
if (QFile::exists(openUrlFilePath)) {
|
if (QFile::exists(openUrlFilePath)) {
|
||||||
qDebug() << "Standard open URL file exists, good!";
|
LOG("Standard open URL file exists, good!");
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Copying standard open URL file to " << openUrlFilePath;
|
LOG("Copying standard open URL file to " << openUrlFilePath);
|
||||||
QFile::copy("/usr/share/applications/open-url.desktop", openUrlFilePath);
|
QFile::copy("/usr/share/applications/open-url.desktop", openUrlFilePath);
|
||||||
QProcess::startDetached("update-desktop-database " + QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation));
|
QProcess::startDetached("update-desktop-database " + applicationsLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString desktopFilePath = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation) + "/harbour-fernschreiber-open-url.desktop";
|
const QString desktopFilePath(applicationsLocation + "/harbour-fernschreiber-open-url.desktop");
|
||||||
QFile desktopFile(desktopFilePath);
|
QFile desktopFile(desktopFilePath);
|
||||||
if (!desktopFile.exists()) {
|
if (!desktopFile.exists()) {
|
||||||
qDebug() << "Creating Open-With file at " << desktopFile.fileName();
|
LOG("Creating Open-With file at " << desktopFile.fileName());
|
||||||
if (desktopFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
if (desktopFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
QTextStream fileOut(&desktopFile);
|
QTextStream fileOut(&desktopFile);
|
||||||
fileOut.setCodec("UTF-8");
|
fileOut.setCodec("UTF-8");
|
||||||
|
@ -1208,7 +1202,7 @@ void TDLibWrapper::initializeOpenWith()
|
||||||
fileOut << QString("Hidden=true;").toUtf8() << "\n";
|
fileOut << QString("Hidden=true;").toUtf8() << "\n";
|
||||||
fileOut.flush();
|
fileOut.flush();
|
||||||
desktopFile.close();
|
desktopFile.close();
|
||||||
QProcess::startDetached("update-desktop-database " + QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation));
|
QProcess::startDetached("update-desktop-database " + applicationsLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include "tgsplugin.h"
|
#include "tgsplugin.h"
|
||||||
#include "rlottie.h"
|
#include "rlottie.h"
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QImageIOHandler>
|
#include <QImageIOHandler>
|
||||||
|
@ -27,8 +26,9 @@
|
||||||
|
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
#define LOG(x) qDebug() << "[TgsIOHandler]" << qPrintable(fileName) << x
|
#define DEBUG_MODULE TgsIOHandler
|
||||||
#define WARN(x) qWarning() << "[TgsIOHandler]" << qPrintable(fileName) << x
|
#include "debuglog.h"
|
||||||
|
#define LOG_(x) LOG(qPrintable(fileName) << x)
|
||||||
|
|
||||||
class TgsIOHandler : public QImageIOHandler
|
class TgsIOHandler : public QImageIOHandler
|
||||||
{
|
{
|
||||||
|
@ -93,7 +93,7 @@ TgsIOHandler::~TgsIOHandler()
|
||||||
if (currentRender.valid()) {
|
if (currentRender.valid()) {
|
||||||
currentRender.get();
|
currentRender.get();
|
||||||
}
|
}
|
||||||
LOG("Done");
|
LOG_("Done");
|
||||||
}
|
}
|
||||||
|
|
||||||
TgsIOHandler::ByteArray TgsIOHandler::uncompress()
|
TgsIOHandler::ByteArray TgsIOHandler::uncompress()
|
||||||
|
@ -112,7 +112,7 @@ TgsIOHandler::ByteArray TgsIOHandler::uncompress()
|
||||||
unzip.next_out = (Bytef*)unzipped.data();
|
unzip.next_out = (Bytef*)unzipped.data();
|
||||||
unzip.avail_in = zipped.size();
|
unzip.avail_in = zipped.size();
|
||||||
unzip.avail_out = chunk;
|
unzip.avail_out = chunk;
|
||||||
LOG("Compressed size" << zipped.size());
|
LOG_("Compressed size" << zipped.size());
|
||||||
while (unzip.avail_out > 0 && zerr == Z_OK) {
|
while (unzip.avail_out > 0 && zerr == Z_OK) {
|
||||||
zerr = inflate(&unzip, Z_NO_FLUSH);
|
zerr = inflate(&unzip, Z_NO_FLUSH);
|
||||||
if (zerr == Z_OK && unzip.avail_out < chunk) {
|
if (zerr == Z_OK && unzip.avail_out < chunk) {
|
||||||
|
@ -124,7 +124,7 @@ TgsIOHandler::ByteArray TgsIOHandler::uncompress()
|
||||||
}
|
}
|
||||||
if (zerr == Z_STREAM_END) {
|
if (zerr == Z_STREAM_END) {
|
||||||
unzipped.resize(unzip.next_out - (Bytef*)unzipped.data());
|
unzipped.resize(unzip.next_out - (Bytef*)unzipped.data());
|
||||||
LOG("Uncompressed size" << unzipped.size());
|
LOG_("Uncompressed size" << unzipped.size());
|
||||||
} else {
|
} else {
|
||||||
unzipped.clear();
|
unzipped.clear();
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ bool TgsIOHandler::load()
|
||||||
frameRate = animation->frameRate();
|
frameRate = animation->frameRate();
|
||||||
frameCount = (int) animation->totalFrame();
|
frameCount = (int) animation->totalFrame();
|
||||||
size = QSize(width, height);
|
size = QSize(width, height);
|
||||||
LOG(size << frameCount << "frames," << frameRate << "fps");
|
LOG_(size << frameCount << "frames," << frameRate << "fps");
|
||||||
render(0); // Pre-render first frame
|
render(0); // Pre-render first frame
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ void TgsIOHandler::finishRendering()
|
||||||
currentRender.get();
|
currentRender.get();
|
||||||
prevImage = currentImage;
|
prevImage = currentImage;
|
||||||
if (!currentFrame && !firstImage.isNull()) {
|
if (!currentFrame && !firstImage.isNull()) {
|
||||||
LOG("Rendered first frame");
|
LOG_("Rendered first frame");
|
||||||
firstImage = currentImage;
|
firstImage = currentImage;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -192,7 +192,7 @@ bool TgsIOHandler::read(QImage* out)
|
||||||
if (currentFrame && currentRender.valid()) {
|
if (currentFrame && currentRender.valid()) {
|
||||||
std::future_status status = currentRender.wait_for(std::chrono::milliseconds(0));
|
std::future_status status = currentRender.wait_for(std::chrono::milliseconds(0));
|
||||||
if (status != std::future_status::ready) {
|
if (status != std::future_status::ready) {
|
||||||
LOG("Skipping frame" << currentFrame);
|
LOG_("Skipping frame" << currentFrame);
|
||||||
currentFrame = (currentFrame + 1) % frameCount;
|
currentFrame = (currentFrame + 1) % frameCount;
|
||||||
*out = prevImage;
|
*out = prevImage;
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue