Compare commits

...
7 Commits
Author SHA1 Message Date
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
5 changed files with 58 additions and 79 deletions
+9 -12
View File
@@ -1,14 +1,11 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.16)
ADD_COMPILE_OPTIONS($<$<CXX_COMPILER_ID:MSVC>:/MP> $<$<CXX_COMPILER_ID:MSVC>:$<$<CONFIG:RELEASE>:/O2>> $<$<CXX_COMPILER_ID:MSVC>:$<$<CONFIG:RELWITHDEBINFO>:/O2>>)
project(preview_base)
set(project_type plugin)
SET(PROJ_NAME preview_base)
PROJECT(${PROJ_NAME})
SET(DEPENDENCIES_DIR CACHE PATH "")
# hint to find qt in dependencies path
LIST(APPEND CMAKE_PREFIX_PATH ${QT_ROOT}/lib/cmake)
ADD_SUBDIRECTORY(src)
if(DEFINED DEPENDENCIES_DIR)
include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/project.cmake)
else()
include(../cmake_common/project.cmake)
endif()
add_subdirectory(src)
+6 -54
View File
@@ -1,54 +1,6 @@
CMAKE_MINIMUM_REQUIRED (VERSION 2.8.11)
CMAKE_POLICY(SET CMP0020 NEW)
CMAKE_POLICY(SET CMP0043 NEW)
FILE(GLOB ${PROJ_NAME}_SRCS *.cpp)
FILE(GLOB ${PROJ_NAME}_HDRS *.h)
FILE(GLOB ${PROJ_NAME}_FORMS *.ui)
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
SET(CMAKE_AUTOMOC ON)
SET(CMAKE_AUTOUIC ON)
FIND_PACKAGE(Qt5Widgets REQUIRED)
QT5_WRAP_UI(${PROJ_NAME}_UIHDRS ${${PROJ_NAME}_FORMS})
FIND_PACKAGE(Qt5LinguistTools)
QT5_CREATE_TRANSLATION(${PROJ_NAME}_translations_qm ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/${PROJ_NAME}_en.ts)
SET(Boost_USE_STATIC_LIBS ON)
SET(Boost_USE_MULTITHREADED ON)
SET(Boost_USE_STATIC_RUNTIME OFF)
FIND_PACKAGE(Boost)
IF (Boost_FOUND)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
ENDIF (Boost_FOUND)
SET(default_project_path "${CMAKE_SOURCE_DIR}/..")
GET_FILENAME_COMPONENT(${default_project_path} ${default_project_path} REALPATH)
SET(project_path "${default_project_path}" CACHE PATH "path to the other mo projects")
SET(lib_path "${project_path}/../../install/libs")
INCLUDE_DIRECTORIES(${project_path}/uibase/src)
LINK_DIRECTORIES(${lib_path})
ADD_LIBRARY(${PROJ_NAME} SHARED ${${PROJ_NAME}_HDRS} ${${PROJ_NAME}_SRCS} ${${PROJ_NAME}_UIHDRS} ${${PROJ_NAME}_translations_qm})
TARGET_LINK_LIBRARIES(${PROJ_NAME}
Qt5::Widgets
${Boost_LIBRARIES}
uibase)
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES COMPILE_FLAGS /GL)
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/LTCG /LARGEADDRESSAWARE /OPT:REF /OPT:ICF")
###############
## Installation
INSTALL(TARGETS ${PROJ_NAME}
RUNTIME DESTINATION bin/plugins)
INSTALL(FILES $<TARGET_PDB_FILE:${PROJ_NAME}>
DESTINATION pdb)
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()
+11 -1
View File
@@ -4,9 +4,19 @@
<context>
<name>PreviewBase</name>
<message>
<location filename="previewbase.cpp" line="77"/>
<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 &quot;.&quot;) that should not be previewed by this plugin.</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>
+30 -12
View File
@@ -33,32 +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()) {
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")
if (strFileType == "dds" || blacklist.contains(strFileType))
continue;
m_PreviewGenerators[strFileType] = imageReader;
}
const QStringList supportedTextFormats = { "txt", "ini", "json", "log", "cfg" };
auto textReader = std::bind(&PreviewBase::genTxtPreview, this, std::placeholders::_1, std::placeholders::_2);
m_PreviewGenerators["txt"] = textReader;
m_PreviewGenerators["ini"] = textReader;
m_PreviewGenerators["json"] = textReader;
m_PreviewGenerators["log"] = textReader;
m_PreviewGenerators["cfg"] = textReader;
foreach(const QString fileType, supportedTextFormats) {
}
// skip blacklisted ones
if (blacklist.contains(fileType))
continue;
m_PreviewGenerators[fileType] = textReader;
}
bool PreviewBase::init(MOBase::IOrganizer*)
{
return true;
}
@@ -84,12 +98,16 @@ MOBase::VersionInfo PreviewBase::version() const
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
+2
View File
@@ -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