migrate to Qt6
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,3 +4,4 @@ qcma.pro.user*
|
|||||||
*.bundle
|
*.bundle
|
||||||
org.qcma.*.xml
|
org.qcma.*.xml
|
||||||
buildscripts/windows/driver/QcmaDriver_*.exe
|
buildscripts/windows/driver/QcmaDriver_*.exe
|
||||||
|
build/
|
||||||
|
@@ -67,11 +67,9 @@ static void cleanOutput(QtMsgType type, const QMessageLogContext &, const QStrin
|
|||||||
case QtFatalMsg:
|
case QtFatalMsg:
|
||||||
__android_log_print(ANDROID_LOG_FATAL, "qcma", "%s", message);
|
__android_log_print(ANDROID_LOG_FATAL, "qcma", "%s", message);
|
||||||
abort();
|
abort();
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
|
|
||||||
case QtInfoMsg:
|
case QtInfoMsg:
|
||||||
__android_log_print(ANDROID_LOG_INFO, "qcma", "%s", message);
|
__android_log_print(ANDROID_LOG_INFO, "qcma", "%s", message);
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -61,7 +61,7 @@ void HeadlessManager::refreshDatabase()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextStream(stdout) << "Database scan has started" << endl;
|
QTextStream(stdout) << "Database scan has started" << Qt::endl;
|
||||||
|
|
||||||
if(!m_db->rescan()) {
|
if(!m_db->rescan()) {
|
||||||
qWarning("No PS Vita system has been registered");
|
qWarning("No PS Vita system has been registered");
|
||||||
@@ -136,7 +136,7 @@ void HeadlessManager::start()
|
|||||||
|
|
||||||
void HeadlessManager::receiveMessage(QString message)
|
void HeadlessManager::receiveMessage(QString message)
|
||||||
{
|
{
|
||||||
QTextStream(stdout) << message << endl;
|
QTextStream(stdout) << message << Qt::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeadlessManager::stop()
|
void HeadlessManager::stop()
|
||||||
|
@@ -25,7 +25,6 @@
|
|||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QTextCodec>
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
|
|
||||||
@@ -35,15 +34,10 @@
|
|||||||
#include "singlecoreapplication.h"
|
#include "singlecoreapplication.h"
|
||||||
#include "headlessmanager.h"
|
#include "headlessmanager.h"
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
|
||||||
static void noDebugOutput(QtMsgType type, const QMessageLogContext &, const QString & msg)
|
static void noDebugOutput(QtMsgType type, const QMessageLogContext &, const QString & msg)
|
||||||
{
|
{
|
||||||
QByteArray localMsg = msg.toLocal8Bit();
|
QByteArray localMsg = msg.toLocal8Bit();
|
||||||
const char *message = localMsg.constData();
|
const char *message = localMsg.constData();
|
||||||
#else
|
|
||||||
static void noDebugOutput(QtMsgType type, const char *message)
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QtDebugMsg:
|
case QtDebugMsg:
|
||||||
break;
|
break;
|
||||||
@@ -57,11 +51,9 @@ static void noDebugOutput(QtMsgType type, const char *message)
|
|||||||
fprintf(stderr, "Fatal: %s\n", message);
|
fprintf(stderr, "Fatal: %s\n", message);
|
||||||
abort();
|
abort();
|
||||||
break;
|
break;
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
|
|
||||||
case QtInfoMsg:
|
case QtInfoMsg:
|
||||||
fprintf(stderr, "Info: %s\n", message);
|
fprintf(stderr, "Info: %s\n", message);
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +97,7 @@ int main(int argc, char *argv[])
|
|||||||
Q_INIT_RESOURCE(translations);
|
Q_INIT_RESOURCE(translations);
|
||||||
|
|
||||||
if(SingleCoreApplication::sendMessage("Another instance of Qcma tried to start")) {
|
if(SingleCoreApplication::sendMessage("Another instance of Qcma tried to start")) {
|
||||||
QTextStream(stdout) << "An instance of Qcma is already running" << endl;
|
QTextStream(stdout) << "An instance of Qcma is already running" << Qt::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,18 +117,10 @@ int main(int argc, char *argv[])
|
|||||||
VitaMTP_Set_Logging(VitaMTP_VERBOSE);
|
VitaMTP_Set_Logging(VitaMTP_VERBOSE);
|
||||||
} else {
|
} else {
|
||||||
VitaMTP_Set_Logging(VitaMTP_NONE);
|
VitaMTP_Set_Logging(VitaMTP_NONE);
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
|
||||||
qInstallMessageHandler(noDebugOutput);
|
qInstallMessageHandler(noDebugOutput);
|
||||||
#else
|
|
||||||
qInstallMsgHandler(noDebugOutput);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
QTextStream(stdout) << "Starting Qcma " << QCMA_VER << Qt::endl;
|
||||||
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QTextStream(stdout) << "Starting Qcma " << QCMA_VER << endl;
|
|
||||||
|
|
||||||
QTranslator translator;
|
QTranslator translator;
|
||||||
QString locale = QLocale().system().name();
|
QString locale = QLocale().system().name();
|
||||||
@@ -157,8 +141,11 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
QTranslator system_translator;
|
QTranslator system_translator;
|
||||||
system_translator.load("qt_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
if(!system_translator.load("qt_" + locale, QLibraryInfo::path(QLibraryInfo::TranslationsPath))) {
|
||||||
|
qWarning() << "Cannot load system translation for locale:" << locale;
|
||||||
|
} else {
|
||||||
app.installTranslator(&system_translator);
|
app.installTranslator(&system_translator);
|
||||||
|
}
|
||||||
|
|
||||||
qDebug("Starting main thread: 0x%016" PRIxPTR, (uintptr_t)QThread::currentThreadId());
|
qDebug("Starting main thread: 0x%016" PRIxPTR, (uintptr_t)QThread::currentThreadId());
|
||||||
|
|
||||||
|
@@ -128,11 +128,7 @@ void AVDecoder::getVideoMetadata(metadata_t &metadata)
|
|||||||
|
|
||||||
AVFrame *AVDecoder::getDecodedFrame(AVCodecContext *codec_ctx, int frame_stream_index)
|
AVFrame *AVDecoder::getDecodedFrame(AVCodecContext *codec_ctx, int frame_stream_index)
|
||||||
{
|
{
|
||||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
|
|
||||||
AVFrame *pFrame = av_frame_alloc();
|
AVFrame *pFrame = av_frame_alloc();
|
||||||
#else
|
|
||||||
AVFrame *pFrame = avcodec_alloc_frame();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
AVPacket packet;
|
AVPacket packet;
|
||||||
int frame_finished = 0;
|
int frame_finished = 0;
|
||||||
@@ -141,21 +137,13 @@ AVFrame *AVDecoder::getDecodedFrame(AVCodecContext *codec_ctx, int frame_stream_
|
|||||||
if(packet.stream_index == frame_stream_index) {
|
if(packet.stream_index == frame_stream_index) {
|
||||||
avcodec_decode_video2(codec_ctx, pFrame, &frame_finished, &packet);
|
avcodec_decode_video2(codec_ctx, pFrame, &frame_finished, &packet);
|
||||||
}
|
}
|
||||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57,7,0)
|
|
||||||
av_packet_unref(&packet);
|
av_packet_unref(&packet);
|
||||||
#else
|
|
||||||
av_free_packet(&packet);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(frame_finished) {
|
if(frame_finished) {
|
||||||
return pFrame;
|
return pFrame;
|
||||||
} else {
|
} else {
|
||||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
|
|
||||||
av_frame_free(&pFrame);
|
av_frame_free(&pFrame);
|
||||||
#else
|
|
||||||
avcodec_free_frame(&pFrame);
|
|
||||||
#endif
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -215,11 +203,7 @@ QByteArray AVDecoder::getThumbnail(int &width, int &height)
|
|||||||
width, height);
|
width, height);
|
||||||
|
|
||||||
data = WriteJPEG(pCodecCtx, pFrame, width, height);
|
data = WriteJPEG(pCodecCtx, pFrame, width, height);
|
||||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
|
|
||||||
av_frame_free(&pFrame);
|
av_frame_free(&pFrame);
|
||||||
#else
|
|
||||||
avcodec_free_frame(&pFrame);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
@@ -249,44 +233,24 @@ QByteArray AVDecoder::WriteJPEG(AVCodecContext *pCodecCtx, AVFrame *pFrame, int
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
|
|
||||||
AVFrame *pFrameRGB = av_frame_alloc();
|
AVFrame *pFrameRGB = av_frame_alloc();
|
||||||
#else
|
|
||||||
AVFrame *pFrameRGB = avcodec_alloc_frame();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(pFrameRGB == NULL) {
|
if(pFrameRGB == NULL) {
|
||||||
sws_freeContext(sws_ctx);
|
sws_freeContext(sws_ctx);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// detect ffmpeg (>= 100) or libav (< 100)
|
|
||||||
#if (LIBAVUTIL_VERSION_MICRO >= 100 && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,63,100)) || \
|
|
||||||
(LIBAVUTIL_VERSION_MICRO < 100 && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(54,6,0))
|
|
||||||
int numBytes = av_image_get_buffer_size(AV_PIX_FMT_YUV420P, width, height, 16);
|
int numBytes = av_image_get_buffer_size(AV_PIX_FMT_YUV420P, width, height, 16);
|
||||||
#else
|
|
||||||
int numBytes = avpicture_get_size(PIX_FMT_YUVJ420P, width, height);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint8_t *buffer = (uint8_t *)av_malloc(numBytes);
|
uint8_t *buffer = (uint8_t *)av_malloc(numBytes);
|
||||||
|
|
||||||
if(!buffer) {
|
if(!buffer) {
|
||||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
|
|
||||||
av_frame_free(&pFrameRGB);
|
av_frame_free(&pFrameRGB);
|
||||||
#else
|
|
||||||
avcodec_free_frame(&pFrameRGB);
|
|
||||||
#endif
|
|
||||||
sws_freeContext(sws_ctx);
|
sws_freeContext(sws_ctx);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// detect ffmpeg (>= 100) or libav (< 100)
|
|
||||||
#if (LIBAVUTIL_VERSION_MICRO >= 100 && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,63,100)) || \
|
|
||||||
(LIBAVUTIL_VERSION_MICRO < 100 && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(54,6,0))
|
|
||||||
av_image_fill_arrays(pFrameRGB->data, pFrameRGB->linesize, buffer, AV_PIX_FMT_YUV420P, width, height, 1);
|
av_image_fill_arrays(pFrameRGB->data, pFrameRGB->linesize, buffer, AV_PIX_FMT_YUV420P, width, height, 1);
|
||||||
#else
|
|
||||||
avpicture_fill((AVPicture *)pFrameRGB, buffer, PIX_FMT_YUVJ420P, width, height);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
sws_scale(
|
sws_scale(
|
||||||
sws_ctx,
|
sws_ctx,
|
||||||
@@ -301,18 +265,9 @@ QByteArray AVDecoder::WriteJPEG(AVCodecContext *pCodecCtx, AVFrame *pFrame, int
|
|||||||
pOCodecCtx = avcodec_alloc_context3(pOCodec);
|
pOCodecCtx = avcodec_alloc_context3(pOCodec);
|
||||||
|
|
||||||
if(pOCodecCtx == NULL) {
|
if(pOCodecCtx == NULL) {
|
||||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,52,0)
|
|
||||||
avcodec_free_context(&pOCodecCtx);
|
avcodec_free_context(&pOCodecCtx);
|
||||||
#else
|
|
||||||
avcodec_close(pOCodecCtx);
|
|
||||||
av_free(pOCodecCtx);
|
|
||||||
#endif
|
|
||||||
av_free(buffer);
|
av_free(buffer);
|
||||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
|
|
||||||
av_frame_free(&pFrameRGB);
|
av_frame_free(&pFrameRGB);
|
||||||
#else
|
|
||||||
avcodec_free_frame(&pFrameRGB);
|
|
||||||
#endif
|
|
||||||
sws_freeContext(sws_ctx);
|
sws_freeContext(sws_ctx);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -329,18 +284,9 @@ QByteArray AVDecoder::WriteJPEG(AVCodecContext *pCodecCtx, AVFrame *pFrame, int
|
|||||||
|
|
||||||
AVDictionary *opts = NULL;
|
AVDictionary *opts = NULL;
|
||||||
if(avcodec_open2(pOCodecCtx, pOCodec, &opts) < 0) {
|
if(avcodec_open2(pOCodecCtx, pOCodec, &opts) < 0) {
|
||||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,52,0)
|
|
||||||
avcodec_free_context(&pOCodecCtx);
|
avcodec_free_context(&pOCodecCtx);
|
||||||
#else
|
|
||||||
avcodec_close(pOCodecCtx);
|
|
||||||
av_free(pOCodecCtx);
|
|
||||||
#endif
|
|
||||||
av_free(buffer);
|
av_free(buffer);
|
||||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
|
|
||||||
av_frame_free(&pFrameRGB);
|
av_frame_free(&pFrameRGB);
|
||||||
#else
|
|
||||||
avcodec_free_frame(&pFrameRGB);
|
|
||||||
#endif
|
|
||||||
sws_freeContext(sws_ctx);
|
sws_freeContext(sws_ctx);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -367,18 +313,9 @@ QByteArray AVDecoder::WriteJPEG(AVCodecContext *pCodecCtx, AVFrame *pFrame, int
|
|||||||
|
|
||||||
QByteArray buffer2(reinterpret_cast<char *>(pkt.data), pkt.size);
|
QByteArray buffer2(reinterpret_cast<char *>(pkt.data), pkt.size);
|
||||||
|
|
||||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,52,0)
|
|
||||||
avcodec_free_context(&pOCodecCtx);
|
avcodec_free_context(&pOCodecCtx);
|
||||||
#else
|
|
||||||
avcodec_close(pOCodecCtx);
|
|
||||||
av_free(pOCodecCtx);
|
|
||||||
#endif
|
|
||||||
av_free(buffer);
|
av_free(buffer);
|
||||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
|
|
||||||
av_frame_free(&pFrameRGB);
|
av_frame_free(&pFrameRGB);
|
||||||
#else
|
|
||||||
avcodec_free_frame(&pFrameRGB);
|
|
||||||
#endif
|
|
||||||
avcodec_close(pOCodecCtx);
|
avcodec_close(pOCodecCtx);
|
||||||
sws_freeContext(sws_ctx);
|
sws_freeContext(sws_ctx);
|
||||||
|
|
||||||
|
@@ -72,7 +72,6 @@ public:
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AvInit() {
|
AvInit() {
|
||||||
av_register_all();
|
|
||||||
// hide warning logs
|
// hide warning logs
|
||||||
av_log_set_level(AV_LOG_ERROR);
|
av_log_set_level(AV_LOG_ERROR);
|
||||||
}
|
}
|
||||||
@@ -87,7 +86,7 @@ private:
|
|||||||
AVFormatContext *pFormatCtx;
|
AVFormatContext *pFormatCtx;
|
||||||
AVCodecContext *pCodecCtx;
|
AVCodecContext *pCodecCtx;
|
||||||
AVStream *av_stream;
|
AVStream *av_stream;
|
||||||
AVCodec *av_codec;
|
const AVCodec *av_codec;
|
||||||
int stream_index;
|
int stream_index;
|
||||||
bool codec_loaded;
|
bool codec_loaded;
|
||||||
};
|
};
|
||||||
|
@@ -62,11 +62,7 @@ CmaBroadcast::CmaBroadcast(QObject *obj_parent) :
|
|||||||
socket = new QUdpSocket(this);
|
socket = new QUdpSocket(this);
|
||||||
connect(socket, SIGNAL(readyRead()), this, SLOT(readPendingDatagrams()));
|
connect(socket, SIGNAL(readyRead()), this, SLOT(readPendingDatagrams()));
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
|
||||||
QHostAddress host_address(QHostAddress::Any);
|
|
||||||
#else
|
|
||||||
QHostAddress host_address(QHostAddress::AnyIPv4);
|
QHostAddress host_address(QHostAddress::AnyIPv4);
|
||||||
#endif
|
|
||||||
|
|
||||||
if(!socket->bind(host_address, QCMA_REQUEST_PORT, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint)) {
|
if(!socket->bind(host_address, QCMA_REQUEST_PORT, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint)) {
|
||||||
qCritical() << "Failed to bind address for UDP broadcast";
|
qCritical() << "Failed to bind address for UDP broadcast";
|
||||||
@@ -88,7 +84,7 @@ void CmaBroadcast::readPendingDatagrams()
|
|||||||
QMutexLocker locker(&mutex);
|
QMutexLocker locker(&mutex);
|
||||||
socket->writeDatagram(reply, cma_sender, senderPort);
|
socket->writeDatagram(reply, cma_sender, senderPort);
|
||||||
} else {
|
} else {
|
||||||
qWarning("Unknown request: %.*s\n", datagram.length(), datagram.constData());
|
qWarning() << "Unknown request, length: " << datagram.length() << "data: " << datagram.constData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,7 +99,7 @@ void CmaBroadcast::setAvailable()
|
|||||||
.arg(broadcast_ok, uuid, "win", hostname)
|
.arg(broadcast_ok, uuid, "win", hostname)
|
||||||
.arg(protocol_version, 8, 10, QChar('0'))
|
.arg(protocol_version, 8, 10, QChar('0'))
|
||||||
.arg(QCMA_REQUEST_PORT)
|
.arg(QCMA_REQUEST_PORT)
|
||||||
.arg(VITAMTP_WIRELESS_MAX_VERSION, 8, 10, QChar('0')));
|
.arg(VITAMTP_WIRELESS_MAX_VERSION, 8, 10, QChar('0')).toStdString());
|
||||||
reply.append('\0');
|
reply.append('\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,6 +113,6 @@ void CmaBroadcast::setUnavailable()
|
|||||||
.arg(broadcast_unavailable, uuid, "win", hostname)
|
.arg(broadcast_unavailable, uuid, "win", hostname)
|
||||||
.arg(protocol_version, 8, 10, QChar('0'))
|
.arg(protocol_version, 8, 10, QChar('0'))
|
||||||
.arg(QCMA_REQUEST_PORT)
|
.arg(QCMA_REQUEST_PORT)
|
||||||
.arg(VITAMTP_WIRELESS_MAX_VERSION, 8, 10, QChar('0')));
|
.arg(VITAMTP_WIRELESS_MAX_VERSION, 8, 10, QChar('0')).toStdString());
|
||||||
reply.append('\0');
|
reply.append('\0');
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,8 @@
|
|||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
|
#include <random>
|
||||||
|
|
||||||
QMutex CmaClient::mutex;
|
QMutex CmaClient::mutex;
|
||||||
QMutex CmaClient::runner;
|
QMutex CmaClient::runner;
|
||||||
QWaitCondition CmaClient::usbcondition;
|
QWaitCondition CmaClient::usbcondition;
|
||||||
@@ -92,9 +94,6 @@ void CmaClient::connectWireless()
|
|||||||
wireless_host_info_t host = {NULL, NULL, NULL, QCMA_REQUEST_PORT};
|
wireless_host_info_t host = {NULL, NULL, NULL, QCMA_REQUEST_PORT};
|
||||||
typedef CmaClient CC;
|
typedef CmaClient CC;
|
||||||
|
|
||||||
QTime now = QTime::currentTime();
|
|
||||||
qsrand(now.msec());
|
|
||||||
|
|
||||||
qDebug("Starting wireless_thread: 0x%016" PRIxPTR, (uintptr_t)QThread::currentThreadId());
|
qDebug("Starting wireless_thread: 0x%016" PRIxPTR, (uintptr_t)QThread::currentThreadId());
|
||||||
|
|
||||||
setActive(true);
|
setActive(true);
|
||||||
@@ -132,7 +131,7 @@ void CmaClient::processNewConnection(vita_device_t *device)
|
|||||||
QMutexLocker locker(&mutex);
|
QMutexLocker locker(&mutex);
|
||||||
in_progress = true;
|
in_progress = true;
|
||||||
|
|
||||||
QTextStream(stdout) << "Vita connected, id: " << VitaMTP_Get_Identification(device) << endl;
|
QTextStream(stdout) << "Vita connected, id: " << VitaMTP_Get_Identification(device) << Qt::endl;
|
||||||
DeviceCapability vita_info;
|
DeviceCapability vita_info;
|
||||||
|
|
||||||
if(!vita_info.exchangeInfo(device)) {
|
if(!vita_info.exchangeInfo(device)) {
|
||||||
@@ -189,6 +188,10 @@ int CmaClient::generatePin(wireless_vita_info_t *info, int *p_err)
|
|||||||
|
|
||||||
QString staticPin = QSettings().value("staticPin").toString();
|
QString staticPin = QSettings().value("staticPin").toString();
|
||||||
|
|
||||||
|
static std::mt19937 rng(std::random_device{}());
|
||||||
|
|
||||||
|
std::uniform_int_distribution<int> dist(0, 99999999);
|
||||||
|
|
||||||
int pin;
|
int pin;
|
||||||
|
|
||||||
if(!staticPin.isNull() && staticPin.length() == 8) {
|
if(!staticPin.isNull() && staticPin.length() == 8) {
|
||||||
@@ -196,17 +199,17 @@ int CmaClient::generatePin(wireless_vita_info_t *info, int *p_err)
|
|||||||
pin = staticPin.toInt(&ok);
|
pin = staticPin.toInt(&ok);
|
||||||
|
|
||||||
if(!ok) {
|
if(!ok) {
|
||||||
pin = rand() % 10000 * 10000 | rand() % 10000;
|
pin = dist(rng);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pin = rand() % 10000 * 10000 | rand() % 10000;
|
pin = dist(rng);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextStream out(stdout);
|
QTextStream out(stdout);
|
||||||
out << "Your registration PIN for " << info->name << " is: ";
|
out << "Your registration PIN for " << info->name << " is: ";
|
||||||
out.setFieldWidth(8);
|
out.setFieldWidth(8);
|
||||||
out.setPadChar('0');
|
out.setPadChar('0');
|
||||||
out << pin << endl;
|
out << pin << Qt::endl;
|
||||||
|
|
||||||
qDebug("PIN: %08i", pin);
|
qDebug("PIN: %08i", pin);
|
||||||
|
|
||||||
@@ -262,7 +265,7 @@ void CmaClient::enterEventLoop(vita_device_t *device)
|
|||||||
|
|
||||||
int CmaClient::stop()
|
int CmaClient::stop()
|
||||||
{
|
{
|
||||||
QTextStream(stdout) << "Stopping Qcma" << endl;
|
QTextStream(stdout) << "Stopping Qcma" << Qt::endl;
|
||||||
|
|
||||||
if(!isActive()) {
|
if(!isActive()) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@@ -649,7 +649,7 @@ void CmaEvent::vitaEventSendHttpObjectFromURL(vita_event_t *cma_event, int event
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("Sending %i bytes of data for HTTP request %s", data.size(), url);
|
qDebug() << "Sending " << data.size() << " bytes of data for HTTP request" << url;
|
||||||
|
|
||||||
if(VitaMTP_SendHttpObjectFromURL(m_device, eventId, data.data(), data.size()) != PTP_RC_OK) {
|
if(VitaMTP_SendHttpObjectFromURL(m_device, eventId, data.data(), data.size()) != PTP_RC_OK) {
|
||||||
qWarning("Failed to send HTTP object");
|
qWarning("Failed to send HTTP object");
|
||||||
|
@@ -99,7 +99,7 @@ void CMAObject::loadSfoMetadata(const QString &path)
|
|||||||
title.chop(1);
|
title.chop(1);
|
||||||
}
|
}
|
||||||
metadata.data.saveData.savedataTitle = strdup(title.toStdString().c_str());
|
metadata.data.saveData.savedataTitle = strdup(title.toStdString().c_str());
|
||||||
metadata.data.saveData.dateTimeUpdated = QFileInfo(sfo).created().toUTC().toTime_t();
|
metadata.data.saveData.dateTimeUpdated = QFileInfo(sfo).birthTime().toUTC().toSecsSinceEpoch();
|
||||||
} else {
|
} else {
|
||||||
metadata.data.saveData.title = strdup(metadata.name);
|
metadata.data.saveData.title = strdup(metadata.name);
|
||||||
metadata.data.saveData.detail = strdup("");
|
metadata.data.saveData.detail = strdup("");
|
||||||
@@ -115,7 +115,7 @@ void CMAObject::initObject(const QFileInfo &file, int obj_file_type)
|
|||||||
metadata.ohfi = ohfi_count++;
|
metadata.ohfi = ohfi_count++;
|
||||||
|
|
||||||
metadata.type = VITA_DIR_TYPE_MASK_REGULAR; // ignored for files
|
metadata.type = VITA_DIR_TYPE_MASK_REGULAR; // ignored for files
|
||||||
metadata.dateTimeCreated = file.created().toUTC().toTime_t();
|
metadata.dateTimeCreated = file.birthTime().toUTC().toSecsSinceEpoch();
|
||||||
metadata.size = 0;
|
metadata.size = 0;
|
||||||
DataType type = file.isFile() ? File : Folder;
|
DataType type = file.isFile() ? File : Folder;
|
||||||
metadata.dataType = (DataType)(type | (parent->metadata.dataType & ~Folder));
|
metadata.dataType = (DataType)(type | (parent->metadata.dataType & ~Folder));
|
||||||
@@ -142,7 +142,7 @@ void CMAObject::initObject(const QFileInfo &file, int obj_file_type)
|
|||||||
Database::loadMusicMetadata(file.absoluteFilePath(), metadata);
|
Database::loadMusicMetadata(file.absoluteFilePath(), metadata);
|
||||||
} else if(MASK_SET(metadata.dataType, Video | File)) {
|
} else if(MASK_SET(metadata.dataType, Video | File)) {
|
||||||
metadata.data.video.fileName = strdup(metadata.name);
|
metadata.data.video.fileName = strdup(metadata.name);
|
||||||
metadata.data.video.dateTimeUpdated = file.created().toUTC().toTime_t();
|
metadata.data.video.dateTimeUpdated = file.birthTime().toUTC().toSecsSinceEpoch();
|
||||||
metadata.data.video.statusType = 1;
|
metadata.data.video.statusType = 1;
|
||||||
metadata.data.video.fileFormatType = FILE_FORMAT_MP4;
|
metadata.data.video.fileFormatType = FILE_FORMAT_MP4;
|
||||||
metadata.data.video.parentalLevel = 0;
|
metadata.data.video.parentalLevel = 0;
|
||||||
@@ -160,7 +160,7 @@ void CMAObject::initObject(const QFileInfo &file, int obj_file_type)
|
|||||||
metadata.data.photo.fileName = strdup(metadata.name);
|
metadata.data.photo.fileName = strdup(metadata.name);
|
||||||
metadata.data.photo.fileFormatType = photo_list[obj_file_type].file_format;
|
metadata.data.photo.fileFormatType = photo_list[obj_file_type].file_format;
|
||||||
metadata.data.photo.statusType = 1;
|
metadata.data.photo.statusType = 1;
|
||||||
metadata.data.photo.dateTimeOriginal = file.created().toUTC().toTime_t();
|
metadata.data.photo.dateTimeOriginal = file.birthTime().toUTC().toSecsSinceEpoch();
|
||||||
metadata.data.photo.numTracks = 1;
|
metadata.data.photo.numTracks = 1;
|
||||||
metadata.data.photo.tracks = new media_track();
|
metadata.data.photo.tracks = new media_track();
|
||||||
metadata.data.photo.tracks->type = VITA_TRACK_TYPE_PHOTO;
|
metadata.data.photo.tracks->type = VITA_TRACK_TYPE_PHOTO;
|
||||||
|
@@ -70,31 +70,7 @@ bool removeRecursively(const QString &path)
|
|||||||
QFileInfo file_info(path);
|
QFileInfo file_info(path);
|
||||||
|
|
||||||
if(file_info.isDir()) {
|
if(file_info.isDir()) {
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
|
||||||
return QDir(path).removeRecursively();
|
return QDir(path).removeRecursively();
|
||||||
#else
|
|
||||||
bool result = false;
|
|
||||||
QDir dir(path);
|
|
||||||
|
|
||||||
QDir::Filters filter = QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files;
|
|
||||||
|
|
||||||
if(dir.exists(path)) {
|
|
||||||
foreach(QFileInfo info, dir.entryInfoList(filter, QDir::DirsFirst)) {
|
|
||||||
if(info.isDir()) {
|
|
||||||
result = removeRecursively(info.absoluteFilePath());
|
|
||||||
} else {
|
|
||||||
result = QFile::remove(info.absoluteFilePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!result) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result = dir.rmdir(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
return QFile::remove(path);
|
return QFile::remove(path);
|
||||||
}
|
}
|
||||||
|
@@ -26,24 +26,7 @@
|
|||||||
|
|
||||||
#include <vitamtp.h>
|
#include <vitamtp.h>
|
||||||
|
|
||||||
// Qt4 doesn't have public methods for Thread::*sleep
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
|
||||||
typedef QThread Sleeper;
|
typedef QThread Sleeper;
|
||||||
#else
|
|
||||||
class Sleeper : QThread
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void sleep(unsigned long secs) {
|
|
||||||
QThread::sleep(secs);
|
|
||||||
}
|
|
||||||
static void msleep(unsigned long msecs) {
|
|
||||||
QThread::msleep(msecs);
|
|
||||||
}
|
|
||||||
static void usleep(unsigned long usecs) {
|
|
||||||
QThread::usleep(usecs);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool removeRecursively(const QString &path);
|
bool removeRecursively(const QString &path);
|
||||||
QString readable_size(qint64 size, bool use_gib = false);
|
QString readable_size(qint64 size, bool use_gib = false);
|
||||||
|
@@ -52,7 +52,7 @@ const file_type video_list[] = {
|
|||||||
|
|
||||||
Database::Database(QObject *obj_parent) :
|
Database::Database(QObject *obj_parent) :
|
||||||
QObject(obj_parent),
|
QObject(obj_parent),
|
||||||
mutex(QMutex::Recursive)
|
mutex()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ void Database::process()
|
|||||||
cancel_operation = false;
|
cancel_operation = false;
|
||||||
int count = create();
|
int count = create();
|
||||||
cancel_operation = false;
|
cancel_operation = false;
|
||||||
QTextStream(stdout) << "Total entries added to the database: " << count << endl;
|
QTextStream(stdout) << "Total entries added to the database: " << count << Qt::endl;
|
||||||
if(count < 0) {
|
if(count < 0) {
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
@@ -88,7 +88,7 @@ public:
|
|||||||
static void loadPhotoMetadata(const QString &path, metadata_t &metadata);
|
static void loadPhotoMetadata(const QString &path, metadata_t &metadata);
|
||||||
static void loadVideoMetadata(const QString &path, metadata_t &metadata);
|
static void loadVideoMetadata(const QString &path, metadata_t &metadata);
|
||||||
|
|
||||||
QMutex mutex;
|
QRecursiveMutex mutex;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool continueOperation();
|
bool continueOperation();
|
||||||
|
@@ -253,7 +253,7 @@ int QListDB::recursiveScanRootDirectory(root_list &list, CMAObject *obj_parent,
|
|||||||
QFileInfoList qsl = dir.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot, QDir::Time);
|
QFileInfoList qsl = dir.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot, QDir::Time);
|
||||||
|
|
||||||
if(obj_parent && !obj_parent->parent) {
|
if(obj_parent && !obj_parent->parent) {
|
||||||
qSort(qsl.begin(), qsl.end(), nameLessThan);
|
std::sort(qsl.begin(), qsl.end(), nameLessThan);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(const QFileInfo &info, qsl) {
|
foreach(const QFileInfo &info, qsl) {
|
||||||
@@ -325,7 +325,7 @@ bool QListDB::findInternal(const root_list &list, int ohfi, find_data &data)
|
|||||||
} else {
|
} else {
|
||||||
CMAObject obj;
|
CMAObject obj;
|
||||||
obj.setOhfi(ohfi);
|
obj.setOhfi(ohfi);
|
||||||
data.it = qBinaryFind(list.begin(), list.end(), &obj, QListDB::lessThanComparator);
|
data.it = std::lower_bound(list.begin(), list.end(), &obj, QListDB::lessThanComparator);
|
||||||
}
|
}
|
||||||
data.end = list.end();
|
data.end = list.end();
|
||||||
return data.it != data.end;
|
return data.it != data.end;
|
||||||
@@ -565,7 +565,7 @@ int QListDB::insertObjectEntry(const QString &path, const QString &name, int par
|
|||||||
|
|
||||||
for(map_list::iterator root = object_list.begin(); root != object_list.end(); ++root) {
|
for(map_list::iterator root = object_list.begin(); root != object_list.end(); ++root) {
|
||||||
root_list *cat_list = &(*root);
|
root_list *cat_list = &(*root);
|
||||||
root_list::const_iterator it = qBinaryFind(cat_list->begin(), cat_list->end(), parent_obj, QListDB::lessThanComparator);
|
root_list::iterator it = std::lower_bound(cat_list->begin(), cat_list->end(), parent_obj, QListDB::lessThanComparator);
|
||||||
|
|
||||||
if(it != cat_list->end()) {
|
if(it != cat_list->end()) {
|
||||||
CMAObject *newobj = new CMAObject(parent_obj);
|
CMAObject *newobj = new CMAObject(parent_obj);
|
||||||
|
@@ -29,15 +29,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#else
|
|
||||||
#include <QDesktopServices>
|
|
||||||
#define QStandardPaths QDesktopServices
|
|
||||||
#define writableLocation storageLocation
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QSqlQuery>
|
#include <QSqlQuery>
|
||||||
|
|
||||||
@@ -160,7 +152,7 @@ SQLiteDB::SQLiteDB(QObject *obj_parent) :
|
|||||||
connect(timer, SIGNAL(timeout()), this, SLOT(process()));
|
connect(timer, SIGNAL(timeout()), this, SLOT(process()));
|
||||||
|
|
||||||
// fetch a configured database path if it exists
|
// fetch a configured database path if it exists
|
||||||
QString db_path = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
|
QString db_path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||||
db_path = QSettings().value("databasePath", db_path).toString();
|
db_path = QSettings().value("databasePath", db_path).toString();
|
||||||
QDir(QDir::root()).mkpath(db_path);
|
QDir(QDir::root()).mkpath(db_path);
|
||||||
|
|
||||||
@@ -226,7 +218,7 @@ void SQLiteDB::clear()
|
|||||||
{
|
{
|
||||||
db.close();
|
db.close();
|
||||||
//QSqlDatabase::removeDatabase("QSQLITE");
|
//QSqlDatabase::removeDatabase("QSQLITE");
|
||||||
QString db_path = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
|
QString db_path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||||
db_path = QSettings().value("databasePath", db_path).toString();
|
db_path = QSettings().value("databasePath", db_path).toString();
|
||||||
QFile(db_path + QDir::separator() + "qcma.sqlite").remove();
|
QFile(db_path + QDir::separator() + "qcma.sqlite").remove();
|
||||||
load();
|
load();
|
||||||
@@ -529,13 +521,13 @@ bool SQLiteDB::insertSourceEntry(uint object_id, const QString &path, const QStr
|
|||||||
QFileInfo info(path, name);
|
QFileInfo info(path, name);
|
||||||
if(info.isFile()) {
|
if(info.isFile()) {
|
||||||
size = QVariant(info.size());
|
size = QVariant(info.size());
|
||||||
date_created = QVariant(info.created().toUTC().toTime_t());
|
date_created = QVariant(info.birthTime().toUTC().toSecsSinceEpoch());
|
||||||
} else {
|
} else {
|
||||||
size = QVariant(QVariant::LongLong);
|
size = QVariant(static_cast<qint64>(0));
|
||||||
date_created = QVariant(QVariant::UInt);
|
date_created = QVariant(static_cast<qint64>(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
date_modified = QVariant(info.lastModified().toUTC().toTime_t());
|
date_modified = QVariant(info.lastModified().toUTC().toSecsSinceEpoch());
|
||||||
|
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
query.prepare("REPLACE INTO sources (object_id, path, size, date_created, date_modified)"
|
query.prepare("REPLACE INTO sources (object_id, path, size, date_created, date_modified)"
|
||||||
@@ -662,10 +654,10 @@ uint SQLiteDB::insertMusicEntry(const QString &path, const QString &name, int id
|
|||||||
query.bindValue(2, audio_codec);
|
query.bindValue(2, audio_codec);
|
||||||
query.bindValue(3, audio_bitrate);
|
query.bindValue(3, audio_bitrate);
|
||||||
query.bindValue(4, duration);
|
query.bindValue(4, duration);
|
||||||
query.bindValue(5, genre_id ? genre_id : QVariant(QVariant::Int));
|
query.bindValue(5, genre_id ? genre_id : QVariant(static_cast<int>(0)));
|
||||||
query.bindValue(6, artist_id ? artist_id : QVariant(QVariant::Int));
|
query.bindValue(6, artist_id ? artist_id : QVariant(static_cast<int>(0)));
|
||||||
query.bindValue(7, album_id ? album_id : QVariant(QVariant::Int));
|
query.bindValue(7, album_id ? album_id : QVariant(static_cast<int>(0)));
|
||||||
query.bindValue(8, track_id ? track_id : QVariant(QVariant::Int));
|
query.bindValue(8, track_id ? track_id : QVariant(static_cast<int>(0)));
|
||||||
query.bindValue(9, artist);
|
query.bindValue(9, artist);
|
||||||
query.bindValue(10, album);
|
query.bindValue(10, album);
|
||||||
query.bindValue(11, track_number);
|
query.bindValue(11, track_number);
|
||||||
@@ -775,8 +767,8 @@ uint SQLiteDB::insertPhotoEntry(const QString &path, const QString &name, int id
|
|||||||
// return 0;
|
// return 0;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
QDateTime date = QFileInfo(path + "/" + name).created();
|
QDateTime date = QFileInfo(path + "/" + name).birthTime();
|
||||||
date_created = date.toUTC().toTime_t();
|
date_created = date.toUTC().toSecsSinceEpoch();
|
||||||
QString month_created = date.toString("yyyy/MM");
|
QString month_created = date.toString("yyyy/MM");
|
||||||
|
|
||||||
width = 0; //img.width();
|
width = 0; //img.width();
|
||||||
@@ -826,7 +818,7 @@ uint SQLiteDB::insertSavedataEntry(const QString &path, const QString &name, int
|
|||||||
title = reader.value("TITLE", utf8name.constData());
|
title = reader.value("TITLE", utf8name.constData());
|
||||||
savedata_detail = reader.value("SAVEDATA_DETAIL", "");
|
savedata_detail = reader.value("SAVEDATA_DETAIL", "");
|
||||||
savedata_directory = reader.value("SAVEDATA_DIRECTORY", utf8name.constData());
|
savedata_directory = reader.value("SAVEDATA_DIRECTORY", utf8name.constData());
|
||||||
date_updated = QFileInfo(path + "/" + name).lastModified().toUTC().toTime_t();
|
date_updated = QFileInfo(path + "/" + name).lastModified().toUTC().toSecsSinceEpoch();
|
||||||
}
|
}
|
||||||
|
|
||||||
if((ohfi = insertDefaultEntry(path, name, title, id_parent, type)) == 0) {
|
if((ohfi = insertDefaultEntry(path, name, title, id_parent, type)) == 0) {
|
||||||
|
@@ -62,7 +62,7 @@ void BackupItem::removeEntry()
|
|||||||
emit deleteEntry(this);
|
emit deleteEntry(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QPixmap *BackupItem::getIconPixmap()
|
const QPixmap BackupItem::getIconPixmap()
|
||||||
{
|
{
|
||||||
return ui->itemPicture->pixmap();
|
return ui->itemPicture->pixmap();
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,7 @@ public:
|
|||||||
void setItemInfo(const QString &name, const QString &size, const QString &extra);
|
void setItemInfo(const QString &name, const QString &size, const QString &extra);
|
||||||
void setItemIcon(const QString &m_path, int width = 48, bool try_dds = false);
|
void setItemIcon(const QString &m_path, int width = 48, bool try_dds = false);
|
||||||
void setDirectory(const QString &m_path);
|
void setDirectory(const QString &m_path);
|
||||||
const QPixmap *getIconPixmap();
|
const QPixmap getIconPixmap();
|
||||||
int getIconWidth();
|
int getIconWidth();
|
||||||
QString getPath();
|
QString getPath();
|
||||||
QString getSize();
|
QString getSize();
|
||||||
|
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
#include "backupmanagerform.h"
|
#include "backupmanagerform.h"
|
||||||
#include "ui_backupmanagerform.h"
|
#include "ui_backupmanagerform.h"
|
||||||
#include "cmaobject.h"
|
|
||||||
#include "sforeader.h"
|
#include "sforeader.h"
|
||||||
#include "confirmdialog.h"
|
#include "confirmdialog.h"
|
||||||
#include "cmautils.h"
|
#include "cmautils.h"
|
||||||
@@ -90,7 +89,7 @@ void BackupManagerForm::removeEntry(BackupItem *item)
|
|||||||
ConfirmDialog msgBox;
|
ConfirmDialog msgBox;
|
||||||
|
|
||||||
msgBox.setMessageText(tr("Are you sure to remove the backup of the following entry?"), item->title);
|
msgBox.setMessageText(tr("Are you sure to remove the backup of the following entry?"), item->title);
|
||||||
msgBox.setMessagePixmap(*item->getIconPixmap(), item->getIconWidth());
|
msgBox.setMessagePixmap(item->getIconPixmap(), item->getIconWidth());
|
||||||
|
|
||||||
if(msgBox.exec() == 0) {
|
if(msgBox.exec() == 0) {
|
||||||
return;
|
return;
|
||||||
@@ -190,11 +189,7 @@ void BackupManagerForm::loadBackupListing(int index)
|
|||||||
// adjust the table item width to fill all the widget
|
// adjust the table item width to fill all the widget
|
||||||
QHeaderView *vert_header = ui->tableWidget->verticalHeader();
|
QHeaderView *vert_header = ui->tableWidget->verticalHeader();
|
||||||
QHeaderView *horiz_header = ui->tableWidget->horizontalHeader();
|
QHeaderView *horiz_header = ui->tableWidget->horizontalHeader();
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
|
||||||
horiz_header->setSectionResizeMode(QHeaderView::Stretch);
|
horiz_header->setSectionResizeMode(QHeaderView::Stretch);
|
||||||
#else
|
|
||||||
horiz_header->setResizeMode(QHeaderView::Stretch);
|
|
||||||
#endif
|
|
||||||
qint64 backup_size = m_db->getObjectSize(ohfi);
|
qint64 backup_size = m_db->getObjectSize(ohfi);
|
||||||
setBackupUsage(backup_size);
|
setBackupUsage(backup_size);
|
||||||
QString path = m_db->getAbsolutePath(ohfi);
|
QString path = m_db->getAbsolutePath(ohfi);
|
||||||
@@ -254,7 +249,7 @@ void BackupManagerForm::loadBackupListing(int index)
|
|||||||
|
|
||||||
m_db->freeMetadata(first);
|
m_db->freeMetadata(first);
|
||||||
|
|
||||||
qSort(item_list.begin(), item_list.end(), BackupItem::lessThan);
|
std::sort(item_list.begin(), item_list.end(), BackupItem::lessThan);
|
||||||
|
|
||||||
int row;
|
int row;
|
||||||
QList<BackupItem *>::iterator it;
|
QList<BackupItem *>::iterator it;
|
||||||
|
@@ -26,14 +26,7 @@ extern "C" {
|
|||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#else
|
|
||||||
#include <QDesktopServices>
|
|
||||||
#define QStandardPaths QDesktopServices
|
|
||||||
#define writableLocation storageLocation
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ConfigWidget::ConfigWidget(QWidget *obj_parent) :
|
ConfigWidget::ConfigWidget(QWidget *obj_parent) :
|
||||||
QDialog(obj_parent),
|
QDialog(obj_parent),
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
#include "ui_pinform.h"
|
#include "ui_pinform.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDesktopWidget>
|
#include <QScreen>
|
||||||
|
|
||||||
const QString PinForm::pinFormat =
|
const QString PinForm::pinFormat =
|
||||||
"<html><head/><body>"
|
"<html><head/><body>"
|
||||||
@@ -33,7 +33,10 @@ PinForm::PinForm(QWidget *obj_parent) :
|
|||||||
ui(new Ui::PinForm)
|
ui(new Ui::PinForm)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
move(QApplication::desktop()->screen()->rect().center() - rect().center());
|
if (QScreen *screen = QGuiApplication::primaryScreen()) {
|
||||||
|
QRect screenGeometry = screen->geometry();
|
||||||
|
move(screenGeometry.center() - rect().center());
|
||||||
|
}
|
||||||
setFixedSize(size());
|
setFixedSize(size());
|
||||||
setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint);
|
setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint);
|
||||||
connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(hide()));
|
connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(hide()));
|
||||||
|
@@ -20,15 +20,18 @@
|
|||||||
#include "progressform.h"
|
#include "progressform.h"
|
||||||
#include "ui_progressform.h"
|
#include "ui_progressform.h"
|
||||||
|
|
||||||
#include <QDesktopWidget>
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QScreen>
|
||||||
|
|
||||||
ProgressForm::ProgressForm(QWidget *obj_parent) :
|
ProgressForm::ProgressForm(QWidget *obj_parent) :
|
||||||
QWidget(obj_parent),
|
QWidget(obj_parent),
|
||||||
ui(new Ui::ProgressForm)
|
ui(new Ui::ProgressForm)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
move(QApplication::desktop()->screen()->rect().center() - rect().center());
|
if (QScreen *screen = QGuiApplication::primaryScreen()) {
|
||||||
|
QRect screenGeometry = screen->geometry();
|
||||||
|
move(screenGeometry.center() - rect().center());
|
||||||
|
}
|
||||||
setFixedSize(size());
|
setFixedSize(size());
|
||||||
setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint);
|
setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint);
|
||||||
connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(cancelConfirm()));
|
connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(cancelConfirm()));
|
||||||
|
21
gui/main.cpp
21
gui/main.cpp
@@ -24,7 +24,6 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QTextCodec>
|
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
@@ -34,14 +33,9 @@
|
|||||||
#include "singleapplication.h"
|
#include "singleapplication.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
|
||||||
static void noMessageOutput(QtMsgType type, const QMessageLogContext &, const QString & str)
|
static void noMessageOutput(QtMsgType type, const QMessageLogContext &, const QString & str)
|
||||||
{
|
{
|
||||||
const char * msg = str.toStdString().c_str();
|
const char * msg = str.toStdString().c_str();
|
||||||
#else
|
|
||||||
static void noMessageOutput(QtMsgType type, const char *msg)
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
Q_UNUSED(type);
|
Q_UNUSED(type);
|
||||||
Q_UNUSED(msg);
|
Q_UNUSED(msg);
|
||||||
}
|
}
|
||||||
@@ -102,18 +96,10 @@ int main(int argc, char *argv[])
|
|||||||
VitaMTP_Set_Logging(VitaMTP_VERBOSE);
|
VitaMTP_Set_Logging(VitaMTP_VERBOSE);
|
||||||
} else {
|
} else {
|
||||||
VitaMTP_Set_Logging(VitaMTP_NONE);
|
VitaMTP_Set_Logging(VitaMTP_NONE);
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
|
||||||
qInstallMessageHandler(noMessageOutput);
|
qInstallMessageHandler(noMessageOutput);
|
||||||
#else
|
|
||||||
qInstallMsgHandler(noMessageOutput);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
QTextStream(stdout) << "Starting Qcma " << QCMA_VER << Qt::endl;
|
||||||
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QTextStream(stdout) << "Starting Qcma " << QCMA_VER << endl;
|
|
||||||
|
|
||||||
QTranslator translator;
|
QTranslator translator;
|
||||||
QString locale = QLocale().system().name();
|
QString locale = QLocale().system().name();
|
||||||
@@ -134,8 +120,11 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
QTranslator system_translator;
|
QTranslator system_translator;
|
||||||
system_translator.load("qt_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
if(!system_translator.load("qt_" + locale, QLibraryInfo::path(QLibraryInfo::TranslationsPath))) {
|
||||||
|
qWarning() << "Cannot load system translation for locale:" << locale;
|
||||||
|
} else {
|
||||||
app.installTranslator(&system_translator);
|
app.installTranslator(&system_translator);
|
||||||
|
}
|
||||||
|
|
||||||
qDebug("Starting main thread: 0x%016" PRIxPTR, (uintptr_t)QThread::currentThreadId());
|
qDebug("Starting main thread: 0x%016" PRIxPTR, (uintptr_t)QThread::currentThreadId());
|
||||||
|
|
||||||
|
@@ -25,12 +25,6 @@
|
|||||||
|
|
||||||
#include "trayindicator_global.h"
|
#include "trayindicator_global.h"
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
|
||||||
// in Qt4 signals are protected
|
|
||||||
#undef signals
|
|
||||||
#define signals public
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class TrayIndicator : public QWidget
|
class TrayIndicator : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Reference in New Issue
Block a user