Compare commits

...
60 Commits
Author SHA1 Message Date
pre-commit-ci[bot] cfd985876e [pre-commit.ci] Pre-commit autoupdate. (#19)
updates:
- [github.com/pre-commit/mirrors-clang-format: v22.1.2 → v22.1.5](https://github.com/pre-commit/mirrors-clang-format/compare/v22.1.2...v22.1.5)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-07-09 08:13:30 +02:00
pre-commit-ci[bot] b89b52296a [pre-commit.ci] Pre-commit autoupdate. (#17)
updates:
- [github.com/pre-commit/mirrors-clang-format: v21.1.8 → v22.1.2](https://github.com/pre-commit/mirrors-clang-format/compare/v21.1.8...v22.1.2)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-04-07 09:02:02 +02:00
pre-commit-ci[bot] 11b4d13da8 [pre-commit.ci] Pre-commit autoupdate. (#16)
updates:
- [github.com/pre-commit/mirrors-clang-format: v21.1.2 → v21.1.8](https://github.com/pre-commit/mirrors-clang-format/compare/v21.1.2...v21.1.8)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-01-05 19:26:46 +01:00
pre-commit-ci[bot] be7c5f0d0b [pre-commit.ci] Pre-commit autoupdate. (#15)
updates:
- [github.com/pre-commit/pre-commit-hooks: v5.0.0 → v6.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v5.0.0...v6.0.0)
- [github.com/pre-commit/mirrors-clang-format: v20.1.7 → v21.1.2](https://github.com/pre-commit/mirrors-clang-format/compare/v20.1.7...v21.1.2)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-10-07 15:00:43 +02:00
pre-commit-ci[bot] 27718aecc2 [pre-commit.ci] Pre-commit autoupdate. (#14)
updates:
- [github.com/pre-commit/mirrors-clang-format: v19.1.5 → v20.1.7](https://github.com/pre-commit/mirrors-clang-format/compare/v19.1.5...v20.1.7)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-07-07 20:31:09 +02:00
Mikaël Capelle 4deb451f14 Merge pull request #12 from ModOrganizer2/dev/vcpkg 2025-05-29 11:02:09 +02:00
Mikaël Capelle f6c7a516d3 Merge pull request #13 from ModOrganizer2/dev/update-translations
Update translations.
2024-07-21 17:04:55 +02:00
Mikaël Capelle 32399c01a2 Update translations. 2024-07-21 16:48:31 +02:00
Mikaël Capelle 23c4ce331a Merge pull request #11 from ModOrganizer2/dev/modernize_repo
Formatting + CI
2024-07-11 11:48:54 +02:00
Mikaël Capelle ed9f6d9b63 Add .git-blame-ignore-revs. 2024-07-11 11:34:57 +02:00
Jeremy Rimpo 01daa7e9c9 Modernize repo 2024-07-11 11:34:04 +02:00
Jeremy Rimpo f47d910bd2 Add raw data preview support (#10)
- Also adds psc as valid text preview
2024-07-11 11:28:24 +02:00
Mikaël Capelle 1bfa64842e Merge pull request #9 from ModOrganizer2/update-cmake-common-qt6
Update following cmake_common changes.
2022-04-28 17:50:08 +02:00
Mikaël Capelle bdd4397c8f Update following cmake_common changes. 2022-04-19 23:56:03 +02:00
Jeremy Rimpo 69fa4b8a3d Changes to compile with Qt6 + Boost 1.77 2021-12-05 03:42:49 -06:00
Mikaël Capelle 8fe992ed7f Update translation file. 2021-02-02 20:39:14 +01:00
Jeremy Rimpo 5597a8eff9 [ci skip] Update artifacts paths for msbuild 2021-01-29 10:53:43 -06:00
Mikaël Capelle 02b74362d5 Merge pull request #8 from Holt59/iplugin-isactive-refactoring
IPlugin::isActive refactoring
2020-11-18 10:01:33 +01:00
Mikaël Capelle d7c6137f29 Update following removal of IPlugin::isActive(). 2020-11-11 15:12:26 +01:00
Jeremy Rimpo 9fc4e63e2d [skip ci] Use PR branch for umbrella repo (if it exists) 2020-09-25 00:34:24 -05:00
Jeremy Rimpo 247f890396 Fix artifacts 2020-09-23 19:44:13 -05:00
Jeremy Rimpo f5318afbdf Add appveyor config 2020-09-23 19:36:37 -05:00
Silarn 0bdfcb7ae5 Appveyor CMAKE fix 2020-05-01 04:59:08 -05:00
isanae 15f34d3fbd Merge pull request #7 from isanae/new-cmakefiles
New cmakefiles
2020-04-26 02:54:54 -04:00
isanae 9eb356a24b now using new cmakefiles 2020-04-23 21:01:59 -04:00
Al 1e2c008cab Merge pull request #5 from Al12rs/blacklist
Added "enabled" and "blacklisted_extensions" settings.
2020-01-31 21:53:14 +01:00
Chris Bessent 886bd07410 Merge pull request #6 from ModOrganizer2/2_2_2
Pull in 2.2.2.1 changes
2020-01-13 23:08:38 -07:00
AL aaa57ae734 Update translations. 2020-01-13 13:56:29 +01:00
AL c232536d14 Added "enabled" and "blacklisted_extensions" settings. 2020-01-13 13:56:06 +01:00
Chris Bessent f661415c23 Merge pull request #4 from ModOrganizer2/Develop
Stage for release 2.2.2
2020-01-06 05:12:31 -07:00
LostDragonist 027e07ef09 Update version to 1.1.0.0 2019-12-07 01:53:03 -07:00
Al 29b8a77baa Add support for json, log and cfg txt files previews 2019-10-02 23:52:17 +02:00
Al 02c564c53c Add support for ini files and remove support for dds files as preview_dds plugin will handle those from now on. 2019-10-02 23:41:27 +02:00
Jeremy Rimpo e387e6fdb2 Merge pull request #3 from ModOrganizer2/Develop
Stage for release 2.2.1
2019-07-14 18:02:45 -05:00
Silarn da3160e088 Set optimization for release builds 2019-05-22 02:04:30 -05:00
Brian Munro da9ce4a3ba Merge pull request #2 from Modorganizer2/Develop
Stage for 2.1.3 release
2018-05-08 12:33:09 +02:00
Silarn 0188c4b5e9 Updating gitignore 2018-05-04 00:28:44 -05:00
Brian Munro 9934cc4319 Merge pull request #1 from Modorganizer2/Develop
Merge to Master for Release
2018-04-13 08:51:13 +02:00
Jeremy Rimpo df3f5458f2 Remove extraneous search code 2018-04-13 00:38:23 -05:00
Silarn 1f3a5068f8 Prep for Qt 5.11 (backward-compatible) 2018-04-10 23:28:33 -05:00
Silarn 0eb25c6f75 Fix up CMAKE to use /MP and allow building through umbrella 2018-04-07 17:12:22 -05:00
LePresidente bfbfe2c7da Updated cmakelists to get the QT5 location from the QT_ROOT variable, instead of expecting it in DEPENDENCIES_DIR. 2017-09-21 16:47:16 +02:00
Tannin 0a83590936 translation 2016-06-04 19:47:34 +02:00
Tannin 9c29e470cd updated build scripts 2015-11-16 21:39:53 +01:00
Tannin 7a680df548 more work on build system 2015-10-09 19:58:14 +02:00
Tannin c31c70486f fixed build system 2015-09-26 23:59:50 +02:00
Tannin 1d77e869cd updated build system 2015-09-26 12:13:27 +02:00
convert-repo 72a8636f85 update tags 2015-09-07 17:41:42 +00:00
Tannin f77b5daf9d incorrect use of "complete" file suffixes 2015-06-09 20:40:13 +02:00
Tannin 1dc5a32871 Merge 2015-05-09 21:46:40 +02:00
Tannin db0a791155 Merge in changes by Tom Tanner 2015-03-27 18:24:37 +01:00
Tom Tanner 65ce23f906 Fixed Scons build for existing bits.
Changed pynedit.pro to fetch from 'standard' install location
Changed saveas code to use organizer report rather than uibase - this way it's
not dependant on the vagaries of the include path, and works the same as the
rest of the organiser directory
2015-03-20 10:34:30 +00:00
Tom Tanner 4fddc311c5 Merge with branch1.2 2015-03-18 17:40:29 +00:00
Tom Tanner c863a94793 Refactoring and cleanup. 2015-03-18 14:16:04 +00:00
Tom Tanner 77f074f59e Every plugin now built 2015-03-17 16:31:15 +00:00
Tannin b72216ad8c extended the game-plugin interface 2015-01-29 19:26:42 +01:00
Tannin 0a8bcff070 Merge with branch1.2 2015-01-03 15:58:52 +01:00
Tannin b8118074c0 - archive library can now query for password during extraction (seems to be necessary for rars)
- process blacklist is now taken from a file if there is one, not hardcoded
- removed workaround for the papyrus compiler
- updated loot client to work with the actual api
- loot client now links with loot32.dll at runtime
- loot client now produces its output in a (json-)file which includes all plugin messages and dirty flags
- fomod installer now tries to parse the xml with several encodings
- fomod installer will now display a diagnostics warning if the jpg imageformat isn't supported
- base preview plugin now tries to be a bit smarter about resizing images to fit the screen
- bugfix: fomod installer no longer tries to open an image even after detecting its invalid
- bugfix: potential null-pointer dereferentiation in getprivateprofile... hooks
- bugfix: potential null-pointer dereferentiation in download manager
- bugfix: internal origin name showed up in one more place
- bugfix: ToString function produced strings that were one (zero-termination-)character too long
2014-11-05 23:48:06 +01:00
Tannin 344965df52 - re-enabled building of loot_cli and started developing against the new api
- extended set of default categories
- more tolerand bbcode parser
- added a few colors for the bbcode parser
- more fixes to qt5 compatibility
- started work on ability to unloading (and thus re-loading) of plugins
- names of plugins are no longer localizable (because those names are also used to store settings)
- added settings to disable individual diagnosis settings
- path of dependencies is now configured in a .pri file instead of environment variablees
- bugfix: if the modid-input is canceled, the id was saved as -1 and wasn't re-requested from the user
- bugfix: moving files with the SHFileOperation-Api didn't update the vfs correctly (still not perfect but better)
- bugfix: attempt to remove the deleter-file seems to have caused error messages for some users
- bugfix: fixed a couple of cases that might have caused the tutorial to hang
2014-09-08 20:37:23 +02:00
TheBloke ff3b241f6c .pro files - formatting/consistency fixes
Many small formatting changes to the majority of .pro files
 Consistent style for Qt version checking, using greaterThan(QT_MAJOR_VERSION, 4)
  This seems safest, as would continue to work for a future Qt 6 etc.
  Note that this makes redudundant the commit before this one, to organizer.pro
 Consistent indenting
 Moved some file configuration sections to be together with related sections
 Moved some installation-related sections (e.g. OUTDIR/DSTDIR) to be at the bottom,
  immediately before the related POST_LINK install lines.
 Similarly, in some cases separated out CONFIG(debug,.. checks into separate
  LIB/INCLUDE sections (high in file) and installation directory sections (low
   in file)
2014-07-07 23:32:18 +01:00
17 changed files with 494 additions and 223 deletions
+41
View File
@@ -0,0 +1,41 @@
---
# We'll use defaults from the LLVM style, but with 4 columns indentation.
BasedOnStyle: LLVM
IndentWidth: 2
---
Language: Cpp
DeriveLineEnding: false
UseCRLF: true
DerivePointerAlignment: false
PointerAlignment: Left
AlignConsecutiveAssignments: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Empty
AlwaysBreakTemplateDeclarations: Yes
AccessModifierOffset: -2
AlignTrailingComments: true
SpacesBeforeTrailingComments: 2
NamespaceIndentation: Inner
MaxEmptyLinesToKeep: 1
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: false
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: true
ColumnLimit: 88
ForEachMacros: ['Q_FOREACH', 'foreach']
+1
View File
@@ -0,0 +1 @@
01daa7e9c9f396f83451703fc6cdc046a4e87b16
+7
View File
@@ -0,0 +1,7 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.cpp text eol=crlf
*.h text eol=crlf
+20
View File
@@ -0,0 +1,20 @@
name: Build Preview Base
on:
push:
branches: [master]
pull_request:
types: [opened, synchronize, reopened]
env:
VCPKG_BINARY_SOURCES: clear;x-azblob,${{ vars.AZ_BLOB_VCPKG_URL }},${{ secrets.AZ_BLOB_SAS }},readwrite
jobs:
build:
runs-on: windows-2022
steps:
- name: Build Preview Base
id: build-preview-base
uses: ModOrganizer2/build-with-mob-action@master
with:
mo2-dependencies: uibase
+16
View File
@@ -0,0 +1,16 @@
name: Lint Preview Base Plugin
on:
push:
pull_request:
types: [opened, synchronize, reopened]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check format
uses: ModOrganizer2/check-formatting-action@master
with:
check-path: "."
+5
View File
@@ -0,0 +1,5 @@
edit
CMakeLists.txt.user
/msbuild.log
/*std*.log
/*build
+20
View File
@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-merge-conflict
- id: check-case-conflict
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v22.1.5
hooks:
- id: clang-format
'types_or': [c++, c]
ci:
autofix_commit_msg: "[pre-commit.ci] Auto fixes from pre-commit.com hooks."
autofix_prs: true
autoupdate_commit_msg: "[pre-commit.ci] Pre-commit autoupdate."
autoupdate_schedule: quarterly
submodules: false
+5
View File
@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.16)
project(preview_base)
add_subdirectory(src)
+67
View File
@@ -0,0 +1,67 @@
{
"configurePresets": [
{
"errors": {
"deprecated": true
},
"hidden": true,
"name": "cmake-dev",
"warnings": {
"deprecated": true,
"dev": true
}
},
{
"cacheVariables": {
"VCPKG_MANIFEST_NO_DEFAULT_FEATURES": {
"type": "BOOL",
"value": "ON"
}
},
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"hidden": true,
"name": "vcpkg"
},
{
"hidden": true,
"inherits": ["vcpkg"],
"name": "vcpkg-dev"
},
{
"binaryDir": "${sourceDir}/vsbuild",
"architecture": {
"strategy": "set",
"value": "x64"
},
"cacheVariables": {
"CMAKE_CXX_FLAGS": "/EHsc /MP /W4",
"VCPKG_TARGET_TRIPLET": {
"type": "STRING",
"value": "x64-windows-static-md"
}
},
"generator": "Visual Studio 17 2022",
"inherits": ["cmake-dev", "vcpkg-dev"],
"name": "vs2022-windows",
"toolset": "v143"
},
{
"cacheVariables": {
"VCPKG_MANIFEST_FEATURES": {
"type": "STRING",
"value": "standalone"
}
},
"inherits": "vs2022-windows",
"name": "vs2022-windows-standalone"
}
],
"buildPresets": [
{
"name": "vs2022-windows",
"resolvePackageReferences": "on",
"configurePreset": "vs2022-windows"
}
],
"version": 4
}
+9
View File
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.16)
find_package(mo2-cmake CONFIG REQUIRED)
find_package(mo2-uibase CONFIG REQUIRED)
add_library(preview_base SHARED previewbase.cpp previewbase.h)
mo2_configure_plugin(preview_base NO_SOURCES WARNINGS 4)
target_link_libraries(preview_base PRIVATE mo2::uibase)
mo2_install_plugin(preview_base)
-27
View File
@@ -1,27 +0,0 @@
#-------------------------------------------------
#
# Project created by QtCreator 2014-01-14T19:50:56
#
#-------------------------------------------------
TARGET = previewBase
TEMPLATE = lib
CONFIG += plugins
CONFIG += dll
contains(QT_VERSION, "^5.*") {
QT += widgets
}
DEFINES += PREVIEWBASE_LIBRARY
SOURCES += previewbase.cpp
HEADERS += previewbase.h
include(../plugin_template.pri)
OTHER_FILES += \
previewbase.json
+27
View File
@@ -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="86"/>
<source>Preview Base</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="previewbase.cpp" line="96"/>
<source>Supports previewing various types of data files</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="previewbase.cpp" line="109"/>
<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="113"/>
<source>Specify a list of comma separated extensions (without &quot;.&quot;) that should not be previewed by this plugin.</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>
+185 -121
View File
@@ -1,121 +1,185 @@
/*
Copyright (C) 2014 Sebastian Herbord. All rights reserved.
This file is part of Base Preview plugin for MO
Base Preview plugin is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Base Preview plugin is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Base Preview plugin. If not, see <http://www.gnu.org/licenses/>.
*/
#include "previewbase.h"
#include <utility.h>
#include <QImageReader>
#include <QFileInfo>
#include <QLabel>
#include <QTextEdit>
#include <QtPlugin>
using namespace MOBase;
PreviewBase::PreviewBase()
{
// 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;
}
m_PreviewGenerators["txt"]
= std::bind(&PreviewBase::genTxtPreview, this, std::placeholders::_1, std::placeholders::_2);
}
bool PreviewBase::init(MOBase::IOrganizer*)
{
return true;
}
QString PreviewBase::name() const
{
return tr("Preview Base");
}
QString PreviewBase::author() const
{
return "Tannin";
}
QString PreviewBase::description() const
{
return tr("Supports previewing various types of data files");
}
MOBase::VersionInfo PreviewBase::version() const
{
return VersionInfo(0, 1, 0, VersionInfo::RELEASE_BETA);
}
bool PreviewBase::isActive() const
{
return true;
}
QList<MOBase::PluginSetting> PreviewBase::settings() const
{
return QList<MOBase::PluginSetting>();
}
std::set<QString> PreviewBase::supportedExtensions() const
{
std::set<QString> extensions;
foreach (const auto &generator, m_PreviewGenerators) {
extensions.insert(generator.first);
}
return extensions;
}
QWidget *PreviewBase::genFilePreview(const QString &fileName, const QSize &maxSize) const
{
auto iter = m_PreviewGenerators.find(QFileInfo(fileName).completeSuffix().toLower());
if (iter != m_PreviewGenerators.end()) {
return iter->second(fileName, maxSize);
} else {
return nullptr;
}
}
QWidget *PreviewBase::genImagePreview(const QString &fileName, const QSize&) const
{
QLabel *label = new QLabel();
label->setPixmap(QPixmap(fileName));
return label;
}
QWidget *PreviewBase::genTxtPreview(const QString &fileName, const QSize&) const
{
QTextEdit *edit = new QTextEdit();
edit->setText(MOBase::readFileText(fileName));
edit->setReadOnly(true);
return edit;
}
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
Q_EXPORT_PLUGIN2(previewBase, PreviewBase)
#endif
/*
Copyright (C) 2014 Sebastian Herbord. All rights reserved.
This file is part of Base Preview plugin for MO
Base Preview plugin is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Base Preview plugin is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Base Preview plugin. If not, see <http://www.gnu.org/licenses/>.
*/
#include "previewbase.h"
#include <QApplication>
#include <QFileInfo>
#include <QImageReader>
#include <QLabel>
#include <QScreen>
#include <QTextEdit>
#include <QtPlugin>
#include <uibase/utility.h>
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, std::placeholders::_3);
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;
}
const QStringList supportedTextFormats = {"txt", "ini", "json", "log", "cfg", "psc"};
auto textReader = std::bind(&PreviewBase::genTxtPreview, this, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3);
foreach (const QString fileType, supportedTextFormats) {
// skip blacklisted ones
if (blacklist.contains(fileType))
continue;
m_PreviewGenerators[fileType] = textReader;
}
return true;
}
QString PreviewBase::name() const
{
return "Preview Base";
}
QString PreviewBase::localizedName() const
{
return tr("Preview Base");
}
QString PreviewBase::author() const
{
return "Tannin";
}
QString PreviewBase::description() const
{
return tr("Supports previewing various types of data files");
}
MOBase::VersionInfo PreviewBase::version() const
{
return VersionInfo(1, 1, 0, VersionInfo::RELEASE_FINAL);
}
QList<MOBase::PluginSetting> PreviewBase::settings() const
{
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;
for (const auto& generator : m_PreviewGenerators) {
extensions.insert(generator.first);
}
return extensions;
}
QWidget* PreviewBase::genFilePreview(const QString& fileName,
const QSize& maxSize) const
{
return genDataPreview(nullptr, fileName, maxSize);
}
QWidget* PreviewBase::genDataPreview(const QByteArray& fileData,
const QString& fileName,
const QSize& maxSize) const
{
auto iter = m_PreviewGenerators.find(QFileInfo(fileName).suffix().toLower());
if (iter != m_PreviewGenerators.end()) {
return iter->second(fileName, maxSize, fileData);
} else {
return nullptr;
}
}
QWidget* PreviewBase::genImagePreview(const QString& fileName, const QSize&,
const QByteArray& fileData) const
{
QLabel* label = new QLabel();
QPixmap pic;
if (fileData == nullptr) {
pic = QPixmap(fileName);
} else {
pic.loadFromData(fileData);
}
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;
}
QWidget* PreviewBase::genTxtPreview(const QString& fileName, const QSize&,
const QByteArray& fileData) const
{
QTextEdit* edit = new QTextEdit();
if (fileData == nullptr) {
edit->setText(MOBase::readFileText(fileName));
} else {
edit->setText(MOBase::decodeTextData(fileData));
}
edit->setReadOnly(true);
return edit;
}
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
Q_EXPORT_PLUGIN2(previewBase, PreviewBase)
#endif
+68 -62
View File
@@ -1,62 +1,68 @@
/*
Copyright (C) 2014 Sebastian Herbord. All rights reserved.
This file is part of Base Preview plugin for MO
Base Preview plugin is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Base Preview plugin is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Base Preview plugin. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PREVIEWBASE_H
#define PREVIEWBASE_H
#include <ipluginpreview.h>
#include <functional>
class PreviewBase : public MOBase::IPluginPreview
{
Q_OBJECT
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginPreview)
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
Q_PLUGIN_METADATA(IID "org.tannin.PreviewBase" FILE "previewbase.json")
#endif
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;
public:
virtual std::set<QString> supportedExtensions() const;
virtual QWidget *genFilePreview(const QString &fileName, const QSize &maxSize) const;
private:
QWidget *genImagePreview(const QString &fileName, const QSize &maxSize) const;
QWidget *genTxtPreview(const QString &fileName, const QSize &maxSize) const;
private:
std::map<QString, std::function<QWidget*(const QString&, const QSize&)> > m_PreviewGenerators;
};
#endif // PREVIEWBASE_H
/*
Copyright (C) 2014 Sebastian Herbord. All rights reserved.
This file is part of Base Preview plugin for MO
Base Preview plugin is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Base Preview plugin is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Base Preview plugin. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PREVIEWBASE_H
#define PREVIEWBASE_H
#include <functional>
#include <uibase/ipluginpreview.h>
class PreviewBase : public MOBase::IPluginPreview
{
Q_OBJECT
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginPreview)
Q_PLUGIN_METADATA(IID "org.tannin.PreviewBase")
public:
PreviewBase();
public:
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;
virtual bool supportsArchives() const override { return true; }
virtual QWidget* genFilePreview(const QString& fileName, const QSize& maxSize) const;
virtual QWidget* genDataPreview(const QByteArray& fileData, const QString& fileName,
const QSize& maxSize) const override;
private:
QWidget* genImagePreview(const QString& fileName, const QSize& maxSize,
const QByteArray& fileData) const;
QWidget* genTxtPreview(const QString& fileName, const QSize& maxSize,
const QByteArray& fileData) const;
private:
std::map<QString,
std::function<QWidget*(const QString&, const QSize&, const QByteArray&)>>
m_PreviewGenerators;
private:
const MOBase::IOrganizer* m_MOInfo;
};
#endif // PREVIEWBASE_H
-1
View File
@@ -1 +0,0 @@
{}
-12
View File
@@ -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
+23
View File
@@ -0,0 +1,23 @@
{
"features": {
"standalone": {
"description": "Build Standalone.",
"dependencies": ["mo2-cmake", "mo2-uibase"]
}
},
"vcpkg-configuration": {
"default-registry": {
"kind": "git",
"repository": "https://github.com/Microsoft/vcpkg",
"baseline": "294f76666c3000630d828703e675814c05a4fd43"
},
"registries": [
{
"kind": "git",
"repository": "https://github.com/ModOrganizer2/vcpkg-registry",
"baseline": "8beb2e0efa9c17dd6d17bb05288dd1e40727f673",
"packages": ["mo2-*"]
}
]
}
}