mirror of
https://github.com/ModOrganizer2/modorganizer-preview_base.git
synced 2026-07-27 14:01:41 -07:00
Compare commits
27
Commits
release_v1.3.5
...
2_3_0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0bdfcb7ae5 | ||
|
|
15f34d3fbd | ||
|
|
9eb356a24b | ||
|
|
1e2c008cab | ||
|
|
886bd07410 | ||
|
|
aaa57ae734 | ||
|
|
c232536d14 | ||
|
|
f661415c23 | ||
|
|
027e07ef09 | ||
|
|
29b8a77baa | ||
|
|
02c564c53c | ||
|
|
e387e6fdb2 | ||
|
|
da3160e088 | ||
|
|
da9ce4a3ba | ||
|
|
0188c4b5e9 | ||
|
|
9934cc4319 | ||
|
|
df3f5458f2 | ||
|
|
1f3a5068f8 | ||
|
|
0eb25c6f75 | ||
|
|
bfbfe2c7da | ||
|
|
0a83590936 | ||
|
|
9c29e470cd | ||
|
|
7a680df548 | ||
|
|
c31c70486f | ||
|
|
1d77e869cd | ||
|
|
72a8636f85 | ||
|
|
f77b5daf9d |
@@ -0,0 +1,5 @@
|
||||
edit
|
||||
CMakeLists.txt.user
|
||||
/msbuild.log
|
||||
/*std*.log
|
||||
/*build
|
||||
@@ -0,0 +1,11 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(preview_base)
|
||||
set(project_type plugin)
|
||||
|
||||
if(DEFINED DEPENDENCIES_DIR)
|
||||
include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/project.cmake)
|
||||
else()
|
||||
include(../cmake_common/project.cmake)
|
||||
endif()
|
||||
add_subdirectory(src)
|
||||
@@ -0,0 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
if(DEFINED DEPENDENCIES_DIR)
|
||||
include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/src.cmake)
|
||||
else()
|
||||
include(../../cmake_common/src.cmake)
|
||||
endif()
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="en_US">
|
||||
<context>
|
||||
<name>PreviewBase</name>
|
||||
<message>
|
||||
<location filename="previewbase.cpp" line="91"/>
|
||||
<source>Supports previewing various types of data files</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="previewbase.cpp" line="107"/>
|
||||
<source>Enable previewing of basic file types, such as images and text files.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="previewbase.cpp" line="108"/>
|
||||
<source>Specify a list of comma separated extensions (without ".") that should not be previewed by this plugin.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
+41
-12
@@ -33,21 +33,46 @@ using namespace MOBase;
|
||||
|
||||
|
||||
PreviewBase::PreviewBase()
|
||||
: m_MOInfo(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
bool PreviewBase::init(IOrganizer *moInfo)
|
||||
{
|
||||
m_MOInfo = moInfo;
|
||||
|
||||
if (!isActive()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const QStringList& blacklist = m_MOInfo->pluginSetting(name(), "blacklisted_extensions").toString().toLower().split(',');
|
||||
|
||||
// set up image reader to be used for all image types qt (the current installation) supports
|
||||
auto imageReader = std::bind(&PreviewBase::genImagePreview, this, std::placeholders::_1, std::placeholders::_2);
|
||||
|
||||
foreach (const QByteArray &fileType, QImageReader::supportedImageFormats()) {
|
||||
m_PreviewGenerators[QString(fileType).toLower()] = imageReader;
|
||||
foreach(const QByteArray & fileType, QImageReader::supportedImageFormats()) {
|
||||
auto strFileType = QString(fileType).toLower();
|
||||
|
||||
// skip dds as that one is handled by the dds preview plugin.
|
||||
if (strFileType == "dds" || blacklist.contains(strFileType))
|
||||
continue;
|
||||
|
||||
m_PreviewGenerators[strFileType] = imageReader;
|
||||
}
|
||||
|
||||
m_PreviewGenerators["txt"]
|
||||
= std::bind(&PreviewBase::genTxtPreview, this, std::placeholders::_1, std::placeholders::_2);
|
||||
const QStringList supportedTextFormats = { "txt", "ini", "json", "log", "cfg" };
|
||||
|
||||
}
|
||||
auto textReader = std::bind(&PreviewBase::genTxtPreview, this, std::placeholders::_1, std::placeholders::_2);
|
||||
|
||||
foreach(const QString fileType, supportedTextFormats) {
|
||||
|
||||
// skip blacklisted ones
|
||||
if (blacklist.contains(fileType))
|
||||
continue;
|
||||
|
||||
m_PreviewGenerators[fileType] = textReader;
|
||||
}
|
||||
|
||||
bool PreviewBase::init(MOBase::IOrganizer*)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -68,23 +93,27 @@ QString PreviewBase::description() const
|
||||
|
||||
MOBase::VersionInfo PreviewBase::version() const
|
||||
{
|
||||
return VersionInfo(1, 0, 0, VersionInfo::RELEASE_FINAL);
|
||||
return VersionInfo(1, 1, 0, VersionInfo::RELEASE_FINAL);
|
||||
}
|
||||
|
||||
bool PreviewBase::isActive() const
|
||||
{
|
||||
return true;
|
||||
return m_MOInfo->pluginSetting(name(), "enabled").toBool();
|
||||
}
|
||||
|
||||
QList<MOBase::PluginSetting> PreviewBase::settings() const
|
||||
{
|
||||
return QList<MOBase::PluginSetting>();
|
||||
QList<PluginSetting> result;
|
||||
result.push_back(PluginSetting("enabled", tr("Enable previewing of basic file types, such as images and text files."), QVariant(true)));
|
||||
result.push_back(PluginSetting("blacklisted_extensions", tr("Specify a list of comma separated extensions (without \".\") "
|
||||
"that should not be previewed by this plugin."), QVariant("")));
|
||||
return result;
|
||||
}
|
||||
|
||||
std::set<QString> PreviewBase::supportedExtensions() const
|
||||
{
|
||||
std::set<QString> extensions;
|
||||
foreach (const auto &generator, m_PreviewGenerators) {
|
||||
for (const auto &generator : m_PreviewGenerators) {
|
||||
extensions.insert(generator.first);
|
||||
}
|
||||
|
||||
@@ -93,7 +122,7 @@ std::set<QString> PreviewBase::supportedExtensions() const
|
||||
|
||||
QWidget *PreviewBase::genFilePreview(const QString &fileName, const QSize &maxSize) const
|
||||
{
|
||||
auto iter = m_PreviewGenerators.find(QFileInfo(fileName).completeSuffix().toLower());
|
||||
auto iter = m_PreviewGenerators.find(QFileInfo(fileName).suffix().toLower());
|
||||
if (iter != m_PreviewGenerators.end()) {
|
||||
return iter->second(fileName, maxSize);
|
||||
} else {
|
||||
|
||||
@@ -57,6 +57,8 @@ private:
|
||||
private:
|
||||
std::map<QString, std::function<QWidget*(const QString&, const QSize&)> > m_PreviewGenerators;
|
||||
|
||||
private:
|
||||
const MOBase::IOrganizer* m_MOInfo;
|
||||
};
|
||||
|
||||
#endif // PREVIEWBASE_H
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#ifndef PREVIEWBASE_GLOBAL_H
|
||||
#define PREVIEWBASE_GLOBAL_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#if defined(PREVIEWBASE_LIBRARY)
|
||||
# define PREVIEWBASESHARED_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
# define PREVIEWBASESHARED_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif // PREVIEWBASE_GLOBAL_H
|
||||
Reference in New Issue
Block a user