From 086f7e004fe041158f40d2541dc51dd11e884cc9 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Sat, 24 Apr 2021 17:39:47 +0300 Subject: [PATCH] UI: Rename AppUtil to AppInfoUtil. --- src/ui/FortFirewallUI.pro | 4 ++-- src/ui/model/applistmodel.cpp | 4 ++-- src/ui/util/app/appinfo.cpp | 2 +- src/ui/util/app/appinfocache.cpp | 2 +- src/ui/util/app/appinfocache.h | 2 +- src/ui/util/app/appinfomanager.cpp | 8 ++++---- src/ui/util/app/appinfomanager.h | 2 +- .../util/app/{apputil.cpp => appinfoutil.cpp} | 14 +++++++++----- src/ui/util/app/appinfoutil.h | 19 +++++++++++++++++++ src/ui/util/app/appinfoworker.cpp | 6 +++--- src/ui/util/app/apputil.h | 19 ------------------- 11 files changed, 43 insertions(+), 39 deletions(-) rename src/ui/util/app/{apputil.cpp => appinfoutil.cpp} (95%) create mode 100644 src/ui/util/app/appinfoutil.h delete mode 100644 src/ui/util/app/apputil.h diff --git a/src/ui/FortFirewallUI.pro b/src/ui/FortFirewallUI.pro index c0624fef..8468ee48 100644 --- a/src/ui/FortFirewallUI.pro +++ b/src/ui/FortFirewallUI.pro @@ -102,8 +102,8 @@ SOURCES += \ util/app/appinfocache.cpp \ util/app/appinfojob.cpp \ util/app/appinfomanager.cpp \ + util/app/appinfoutil.cpp \ util/app/appinfoworker.cpp \ - util/app/apputil.cpp \ util/conf/addressrange.cpp \ util/conf/confutil.cpp \ util/dateutil.cpp \ @@ -236,8 +236,8 @@ HEADERS += \ util/app/appinfocache.h \ util/app/appinfojob.h \ util/app/appinfomanager.h \ + util/app/appinfoutil.h \ util/app/appinfoworker.h \ - util/app/apputil.h \ util/conf/addressrange.h \ util/conf/confappswalker.h \ util/conf/confutil.h \ diff --git a/src/ui/model/applistmodel.cpp b/src/ui/model/applistmodel.cpp index eff1c6b6..75928329 100644 --- a/src/ui/model/applistmodel.cpp +++ b/src/ui/model/applistmodel.cpp @@ -11,7 +11,7 @@ #include "../conf/firewallconf.h" #include "../log/logentryblocked.h" #include "../util/app/appinfocache.h" -#include "../util/app/apputil.h" +#include "../util/app/appinfoutil.h" #include "../util/fileutil.h" #include "../util/iconcache.h" #include "../util/guiutil.h" @@ -374,7 +374,7 @@ void AppListModel::purgeApps() const auto appPath = appRow.appPath; if (!FileUtil::fileExists(appPath)) { AppInfo appInfo; - if (!AppUtil::getInfo(appPath, appInfo)) { + if (!AppInfoUtil::getInfo(appPath, appInfo)) { deleteApp(appRow.appId, appPath, row); } } diff --git a/src/ui/util/app/appinfo.cpp b/src/ui/util/app/appinfo.cpp index 5ea5c0be..a8dda50d 100644 --- a/src/ui/util/app/appinfo.cpp +++ b/src/ui/util/app/appinfo.cpp @@ -1,7 +1,7 @@ #include "appinfo.h" #include "../fileutil.h" -#include "apputil.h" +#include "appinfoutil.h" bool AppInfo::isFileModified(const QString &appPath) const { diff --git a/src/ui/util/app/appinfocache.cpp b/src/ui/util/app/appinfocache.cpp index 20d2535f..85deb78e 100644 --- a/src/ui/util/app/appinfocache.cpp +++ b/src/ui/util/app/appinfocache.cpp @@ -78,7 +78,7 @@ AppInfo AppInfoCache::appInfo(const QString &appPath) return *appInfo; } -void AppInfoCache::handleFinishedLookup(const QString &appPath, const AppInfo info) +void AppInfoCache::handleFinishedLookup(const QString &appPath, const AppInfo &info) { AppInfo *appInfo = m_cache.object(appPath); if (!appInfo) diff --git a/src/ui/util/app/appinfocache.h b/src/ui/util/app/appinfocache.h index 5a89627b..bd9fd625 100644 --- a/src/ui/util/app/appinfocache.h +++ b/src/ui/util/app/appinfocache.h @@ -30,7 +30,7 @@ signals: void cacheChanged(); private slots: - void handleFinishedLookup(const QString &appPath, const AppInfo info); + void handleFinishedLookup(const QString &appPath, const AppInfo &info); private: void emitCacheChanged(); diff --git a/src/ui/util/app/appinfomanager.cpp b/src/ui/util/app/appinfomanager.cpp index dfa7ac7e..54cfbc97 100644 --- a/src/ui/util/app/appinfomanager.cpp +++ b/src/ui/util/app/appinfomanager.cpp @@ -7,8 +7,8 @@ #include #include "appinfojob.h" +#include "appinfoutil.h" #include "appinfoworker.h" -#include "apputil.h" Q_DECLARE_LOGGING_CATEGORY(CLOG_APPINFO_MANAGER) Q_LOGGING_CATEGORY(CLOG_APPINFO_MANAGER, "appInfo") @@ -97,7 +97,7 @@ void AppInfoManager::lookupAppInfo(const QString &appPath) void AppInfoManager::handleWorkerResult(WorkerJob *workerJob) { if (!aborted()) { - auto job = static_cast(workerJob); + const auto job = static_cast(workerJob); emit lookupFinished(job->appPath(), job->appInfo); } @@ -107,12 +107,12 @@ void AppInfoManager::handleWorkerResult(WorkerJob *workerJob) bool AppInfoManager::loadInfoFromFs(const QString &appPath, AppInfo &appInfo) { - return AppUtil::getInfo(appPath, appInfo); + return AppInfoUtil::getInfo(appPath, appInfo); } QImage AppInfoManager::loadIconFromFs(const QString &appPath) { - return AppUtil::getIcon(appPath); + return AppInfoUtil::getIcon(appPath); } bool AppInfoManager::loadInfoFromDb(const QString &appPath, AppInfo &appInfo) diff --git a/src/ui/util/app/appinfomanager.h b/src/ui/util/app/appinfomanager.h index 68e588be..e350c415 100644 --- a/src/ui/util/app/appinfomanager.h +++ b/src/ui/util/app/appinfomanager.h @@ -35,7 +35,7 @@ public: void deleteOldApps(int limitCount = 0); signals: - void lookupFinished(const QString &appPath, const AppInfo appInfo); + void lookupFinished(const QString &appPath, const AppInfo &appInfo); public slots: void lookupAppInfo(const QString &appPath); diff --git a/src/ui/util/app/apputil.cpp b/src/ui/util/app/appinfoutil.cpp similarity index 95% rename from src/ui/util/app/apputil.cpp rename to src/ui/util/app/appinfoutil.cpp index 7469f4ec..77f8e4d9 100644 --- a/src/ui/util/app/apputil.cpp +++ b/src/ui/util/app/appinfoutil.cpp @@ -1,4 +1,4 @@ -#include "apputil.h" +#include "appinfoutil.h" #include #include @@ -121,7 +121,9 @@ bool extractVersionInfo(const QString &appPath, AppInfo &appInfo) } -bool AppUtil::getInfo(const QString &appPath, AppInfo &appInfo) +namespace AppInfoUtil { + +bool getInfo(const QString &appPath, AppInfo &appInfo) { if (appPath.isEmpty()) return false; @@ -142,7 +144,7 @@ bool AppUtil::getInfo(const QString &appPath, AppInfo &appInfo) return true; } -QImage AppUtil::getIcon(const QString &appPath) +QImage getIcon(const QString &appPath) { if (appPath.isEmpty()) return {}; @@ -155,12 +157,14 @@ QImage AppUtil::getIcon(const QString &appPath) return extractShellIcon(appPath).toImage(); } -void AppUtil::initThread() +void initThread() { CoInitialize(nullptr); } -void AppUtil::doneThread() +void doneThread() { CoUninitialize(); } + +} diff --git a/src/ui/util/app/appinfoutil.h b/src/ui/util/app/appinfoutil.h new file mode 100644 index 00000000..f4a8e715 --- /dev/null +++ b/src/ui/util/app/appinfoutil.h @@ -0,0 +1,19 @@ +#ifndef APPINFOUTIL_H +#define APPINFOUTIL_H + +#include +#include + +class AppInfo; + +namespace AppInfoUtil { + +bool getInfo(const QString &appPath, AppInfo &appInfo); +QImage getIcon(const QString &appPath); + +void initThread(); +void doneThread(); + +} + +#endif // APPINFOUTIL_H diff --git a/src/ui/util/app/appinfoworker.cpp b/src/ui/util/app/appinfoworker.cpp index f9cbcb61..a4ab6b52 100644 --- a/src/ui/util/app/appinfoworker.cpp +++ b/src/ui/util/app/appinfoworker.cpp @@ -5,7 +5,7 @@ #include "appinfo.h" #include "appinfomanager.h" #include "appinfojob.h" -#include "apputil.h" +#include "appinfoutil.h" AppInfoWorker::AppInfoWorker(AppInfoManager *manager) : WorkerObject(manager) { } @@ -16,11 +16,11 @@ AppInfoManager *AppInfoWorker::manager() const void AppInfoWorker::run() { - AppUtil::initThread(); + AppInfoUtil::initThread(); WorkerObject::run(); - AppUtil::doneThread(); + AppInfoUtil::doneThread(); } void AppInfoWorker::doJob(WorkerJob *workerJob) diff --git a/src/ui/util/app/apputil.h b/src/ui/util/app/apputil.h deleted file mode 100644 index 8a511e57..00000000 --- a/src/ui/util/app/apputil.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef APPUTIL_H -#define APPUTIL_H - -#include -#include - -class AppInfo; - -class AppUtil -{ -public: - static bool getInfo(const QString &appPath, AppInfo &appInfo); - static QImage getIcon(const QString &appPath); - - static void initThread(); - static void doneThread(); -}; - -#endif // APPUTIL_H