change: some trans logic.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#include "Util.h"
|
||||
#include "Util.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
@@ -45,6 +45,34 @@ void Util::InitLogger(const QString& logPath, const QString& mark)
|
||||
spdlog::register_logger(logger);
|
||||
}
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
|
||||
QString Util::Get2FilePath(const QString& file, const QString& directory)
|
||||
{
|
||||
if (file.isEmpty() || directory.isEmpty()) {
|
||||
return QString();
|
||||
}
|
||||
|
||||
QFileInfo fileInfo(file);
|
||||
QDir dir(directory);
|
||||
|
||||
if (!fileInfo.isFile()) {
|
||||
qWarning() << "Path A is not a file:" << file;
|
||||
return QString();
|
||||
}
|
||||
if (!dir.exists()) {
|
||||
qWarning() << "Path B is not a valid directory:" << directory;
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString fileName = fileInfo.fileName();
|
||||
QString cleanPathB = QDir::cleanPath(directory);
|
||||
QString newPath = cleanPathB + QDir::separator() + fileName;
|
||||
newPath = QDir::cleanPath(newPath);
|
||||
return newPath;
|
||||
}
|
||||
|
||||
void Util::ConsoleMsgHander(QtMsgType type, const QMessageLogContext& context, const QString& msg)
|
||||
{
|
||||
Q_UNUSED(context);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#ifndef UTIL_H
|
||||
#ifndef UTIL_H
|
||||
#define UTIL_H
|
||||
|
||||
#include <QObject>
|
||||
@@ -13,6 +13,7 @@ public:
|
||||
public:
|
||||
static QString GetUserHome();
|
||||
static void InitLogger(const QString& logPath, const QString& mark);
|
||||
static QString Get2FilePath(const QString& file, const QString& directory);
|
||||
static void ConsoleMsgHander(QtMsgType type, const QMessageLogContext& context, const QString& msg);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user