mirror of
https://github.com/ModOrganizer2/modorganizer-preview_base.git
synced 2026-07-27 14:01:41 -07:00
Compare commits
49
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1bfa64842e | ||
|
|
bdd4397c8f | ||
|
|
69fa4b8a3d | ||
|
|
8fe992ed7f | ||
|
|
5597a8eff9 | ||
|
|
02b74362d5 | ||
|
|
d7c6137f29 | ||
|
|
9fc4e63e2d | ||
|
|
247f890396 | ||
|
|
f5318afbdf | ||
|
|
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 | ||
|
|
1dc5a32871 | ||
|
|
db0a791155 | ||
|
|
65ce23f906 | ||
|
|
4fddc311c5 | ||
|
|
c863a94793 | ||
|
|
77f074f59e | ||
|
|
b72216ad8c | ||
|
|
0a8bcff070 | ||
|
|
b8118074c0 | ||
|
|
344965df52 | ||
|
|
ff3b241f6c | ||
|
|
070086d83e |
@@ -0,0 +1,5 @@
|
||||
edit
|
||||
CMakeLists.txt.user
|
||||
/msbuild.log
|
||||
/*std*.log
|
||||
/*build
|
||||
@@ -0,0 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
if(DEFINED DEPENDENCIES_DIR)
|
||||
include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/mo2.cmake)
|
||||
else()
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../cmake_common/mo2.cmake)
|
||||
endif()
|
||||
|
||||
project(preview_base)
|
||||
add_subdirectory(src)
|
||||
@@ -0,0 +1,42 @@
|
||||
version: 1.0.{build}
|
||||
skip_branch_with_pr: true
|
||||
image: Visual Studio 2019
|
||||
environment:
|
||||
WEBHOOK_URL:
|
||||
secure: gOKbXaZM9ImtMD5XrYITvdyZUW/az082G9OIN1EC1Vbg57wBaeLhi49uGjxPw5GVujHku6kxN6ab89zhbS5GVeluR76GM83IbKV4Sh7udXzoYZZdg6YudtYHzdhCgUeiedpswbuczTq9ceIkkfSEWZuh/lMAAVVwvcGsJAnoPFw=
|
||||
build:
|
||||
parallel: true
|
||||
build_script:
|
||||
- pwsh: >-
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
git clone --depth=1 --no-single-branch https://github.com/ModOrganizer2/modorganizer-umbrella.git c:\projects\modorganizer-umbrella
|
||||
|
||||
New-Item -ItemType Directory -Path c:\projects\modorganizer-build
|
||||
|
||||
cd c:\projects\modorganizer-umbrella
|
||||
|
||||
($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH -eq $null) ? ($branch = $env:APPVEYOR_REPO_BRANCH) : ($branch = $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH)
|
||||
|
||||
git checkout $(git show-ref --verify --quiet refs/remotes/origin/${branch} || echo '-b') ${branch}
|
||||
|
||||
C:\Python37-x64\python.exe unimake.py -d c:\projects\modorganizer-build -s Appveyor_Build=True ${env:APPVEYOR_PROJECT_NAME}
|
||||
|
||||
if($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode ) }
|
||||
artifacts:
|
||||
- path: vsbuild\src\RelWithDebInfo\preview_base.dll
|
||||
name: preview_base_dll
|
||||
- path: vsbuild\src\RelWithDebInfo\preview_base.pdb
|
||||
name: preview_base_pdb
|
||||
- path: vsbuild\src\RelWithDebInfo\preview_base.lib
|
||||
name: preview_base_lib
|
||||
on_success:
|
||||
- ps: Set-Location -Path $env:APPVEYOR_BUILD_FOLDER
|
||||
- ps: Invoke-RestMethod https://raw.githubusercontent.com/DiscordHooks/appveyor-discord-webhook/master/send.ps1 -o send.ps1
|
||||
- ps: ./send.ps1 success $env:WEBHOOK_URL
|
||||
on_failure:
|
||||
- ps: Set-Location -Path $env:APPVEYOR_BUILD_FOLDER
|
||||
- ps: Push-AppveyorArtifact ${env:APPVEYOR_BUILD_FOLDER}\stdout.log
|
||||
- ps: Push-AppveyorArtifact ${env:APPVEYOR_BUILD_FOLDER}\stderr.log
|
||||
- ps: Invoke-RestMethod https://raw.githubusercontent.com/DiscordHooks/appveyor-discord-webhook/master/send.ps1 -o send.ps1
|
||||
- ps: ./send.ps1 failure $env:WEBHOOK_URL
|
||||
@@ -0,0 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
add_library(preview_base SHARED)
|
||||
mo2_configure_plugin(preview_base WARNINGS OFF)
|
||||
mo2_install_target(preview_base)
|
||||
@@ -1,20 +0,0 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2014-01-14T19:50:56
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
TARGET = previewBase
|
||||
TEMPLATE = lib
|
||||
|
||||
CONFIG += plugins
|
||||
CONFIG += dll
|
||||
|
||||
DEFINES += PREVIEWBASE_LIBRARY
|
||||
|
||||
SOURCES += previewbase.cpp
|
||||
|
||||
HEADERS += previewbase.h
|
||||
|
||||
|
||||
include(../plugin_template.pri)
|
||||
@@ -0,0 +1,27 @@
|
||||
<?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="82"/>
|
||||
<source>Preview Base</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="previewbase.cpp" line="92"/>
|
||||
<source>Supports previewing various types of data files</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="previewbase.cpp" line="103"/>
|
||||
<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="104"/>
|
||||
<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>
|
||||
+53
-17
@@ -25,31 +25,59 @@ along with Base Preview plugin. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include <QLabel>
|
||||
#include <QTextEdit>
|
||||
#include <QtPlugin>
|
||||
#include <QApplication>
|
||||
#include <QScreen>
|
||||
|
||||
|
||||
using namespace MOBase;
|
||||
|
||||
|
||||
PreviewBase::PreviewBase()
|
||||
: m_MOInfo(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
bool PreviewBase::init(IOrganizer *moInfo)
|
||||
{
|
||||
m_MOInfo = moInfo;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
QString PreviewBase::name() const
|
||||
{
|
||||
return "Preview Base";
|
||||
}
|
||||
|
||||
QString PreviewBase::localizedName() const
|
||||
{
|
||||
return tr("Preview Base");
|
||||
}
|
||||
@@ -66,23 +94,22 @@ QString PreviewBase::description() const
|
||||
|
||||
MOBase::VersionInfo PreviewBase::version() const
|
||||
{
|
||||
return VersionInfo(0, 1, 0, VersionInfo::RELEASE_BETA);
|
||||
}
|
||||
|
||||
bool PreviewBase::isActive() const
|
||||
{
|
||||
return true;
|
||||
return VersionInfo(1, 1, 0, VersionInfo::RELEASE_FINAL);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -91,7 +118,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 {
|
||||
@@ -102,7 +129,16 @@ QWidget *PreviewBase::genFilePreview(const QString &fileName, const QSize &maxSi
|
||||
QWidget *PreviewBase::genImagePreview(const QString &fileName, const QSize&) const
|
||||
{
|
||||
QLabel *label = new QLabel();
|
||||
label->setPixmap(QPixmap(fileName));
|
||||
QPixmap pic = QPixmap(fileName);
|
||||
QSize screenSize = QApplication::primaryScreen()->geometry().size();
|
||||
// ensure the output image is no more than 80% of the screen height.
|
||||
// If the aspect ratio is higher than that of the screen this would still allow the image to extend
|
||||
// beyond the screen but it ensures you can drag the window and close it
|
||||
int maxHeight = static_cast<int>(screenSize.height() * 0.8f);
|
||||
if (pic.size().height() > maxHeight) {
|
||||
pic = pic.scaledToHeight(maxHeight, Qt::SmoothTransformation);
|
||||
}
|
||||
label->setPixmap(pic);
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
+9
-7
@@ -37,13 +37,13 @@ public:
|
||||
PreviewBase();
|
||||
|
||||
public:
|
||||
virtual bool init(MOBase::IOrganizer *moInfo);
|
||||
virtual QString name() const;
|
||||
virtual QString author() const;
|
||||
virtual QString description() const;
|
||||
virtual MOBase::VersionInfo version() const;
|
||||
virtual bool isActive() const;
|
||||
virtual QList<MOBase::PluginSetting> settings() const;
|
||||
virtual bool init(MOBase::IOrganizer *moInfo) override;
|
||||
virtual QString name() const override;
|
||||
virtual QString localizedName() const override;
|
||||
virtual QString author() const override;
|
||||
virtual QString description() const override;
|
||||
virtual MOBase::VersionInfo version() const override;
|
||||
virtual QList<MOBase::PluginSetting> settings() const override;
|
||||
|
||||
public:
|
||||
virtual std::set<QString> supportedExtensions() const;
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -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