From 9d00e2ec0a26dba68b90252b7fe8c02e2e448b28 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Fri, 6 Jun 2008 12:29:58 +0000 Subject: [PATCH] Move loadableImageFormats() to the frontend. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25163 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/scons/scons_manifest.py | 2 - src/frontends/Application.h | 3 ++ src/frontends/qt4/GuiApplication.cpp | 30 +++++++++++++++ src/graphics/GraphicsCache.cpp | 5 ++- src/support/Makefile.am | 2 - src/support/imagetools.cpp | 55 ---------------------------- src/support/imagetools.h | 27 -------------- 7 files changed, 36 insertions(+), 88 deletions(-) delete mode 100644 src/support/imagetools.cpp delete mode 100644 src/support/imagetools.h diff --git a/development/scons/scons_manifest.py b/development/scons/scons_manifest.py index af81ae3ffe..2373f53273 100644 --- a/development/scons/scons_manifest.py +++ b/development/scons/scons_manifest.py @@ -302,7 +302,6 @@ src_support_header_files = Split(''' foreach.h gettext.h gzstream.h - imagetools.h lassert.h limited_stack.h lstrings.h @@ -339,7 +338,6 @@ src_support_files = Split(''' filetools.cpp gettext.cpp gzstream.cpp - imagetools.cpp kill.cpp lassert.cpp lstrings.cpp diff --git a/src/frontends/Application.h b/src/frontends/Application.h index e6450e3c0e..72173ebe16 100644 --- a/src/frontends/Application.h +++ b/src/frontends/Application.h @@ -229,6 +229,9 @@ public: virtual docstring iconName(FuncRequest const & f, bool unknown) = 0; }; +/// Return the list of loadable formats. +std::vector loadableImageFormats(); + } // namespace frontend frontend::Application * theApp(); diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index 161000a5af..fa811307f8 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -61,12 +61,14 @@ #include "support/linkback/LinkBackProxy.h" #endif +#include #include #include #include #include #include #include +#include #include #include #include @@ -129,6 +131,34 @@ frontend::Application * createApplication(int & argc, char * argv[]) namespace frontend { + +/// Return the list of loadable formats. +vector loadableImageFormats() +{ + vector fmts; + + QList qt_formats = QImageReader::supportedImageFormats(); + + LYXERR(Debug::GRAPHICS, + "\nThe image loader can load the following directly:\n"); + + if (qt_formats.empty()) + LYXERR(Debug::GRAPHICS, "\nQt4 Problem: No Format available!"); + + for (QList::const_iterator it = qt_formats.begin(); it != qt_formats.end(); ++it) { + + LYXERR(Debug::GRAPHICS, (const char *) *it << ", "); + + string ext = ascii_lowercase((const char *) *it); + // special case + if (ext == "jpeg") + ext = "jpg"; + fmts.push_back(ext); + } + + return fmts; +} + //////////////////////////////////////////////////////////////////////// // Icon loading support code. //////////////////////////////////////////////////////////////////////// diff --git a/src/graphics/GraphicsCache.cpp b/src/graphics/GraphicsCache.cpp index d36de0fbe2..d508563891 100644 --- a/src/graphics/GraphicsCache.cpp +++ b/src/graphics/GraphicsCache.cpp @@ -17,10 +17,11 @@ #include "Format.h" +#include "frontends/Application.h" + #include "support/debug.h" #include "support/FileName.h" #include "support/filetools.h" -#include "support/imagetools.h" #include @@ -74,7 +75,7 @@ vector const & Cache::loadableFormats() const Formats::const_iterator end = formats.end(); // The formats natively loadable. - vector nformat = loadableImageFormats(); + vector nformat = frontend::loadableImageFormats(); vector::const_iterator it = nformat.begin(); for (; it != nformat.end(); ++it) { diff --git a/src/support/Makefile.am b/src/support/Makefile.am index 983dc36cbf..1c1f8a038d 100644 --- a/src/support/Makefile.am +++ b/src/support/Makefile.am @@ -62,8 +62,6 @@ liblyxsupport_la_SOURCES = \ gettext.h \ gzstream.cpp \ gzstream.h \ - imagetools.cpp \ - imagetools.h \ kill.cpp \ lassert.h \ lassert.cpp \ diff --git a/src/support/imagetools.cpp b/src/support/imagetools.cpp deleted file mode 100644 index 00551d133a..0000000000 --- a/src/support/imagetools.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/** - * \file imagetools.cpp - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Abdelrazak Younes - * - * Full author contact details are available in file CREDITS. - */ - -#include - -#include "support/debug.h" -#include "support/imagetools.h" -#include "support/lstrings.h" - -#include -#include -#include - -using namespace std; - -namespace lyx { -namespace support { - -/// Return the list of loadable formats. -vector loadableImageFormats() -{ - vector fmts; - - QList qt_formats = QImageReader::supportedImageFormats(); - - LYXERR(Debug::GRAPHICS, - "\nThe image loader can load the following directly:\n"); - - if (qt_formats.empty()) - LYXERR(Debug::GRAPHICS, "\nQt4 Problem: No Format available!"); - - for (QList::const_iterator it = qt_formats.begin(); it != qt_formats.end(); ++it) { - - LYXERR(Debug::GRAPHICS, (const char *) *it << ", "); - - string ext = ascii_lowercase((const char *) *it); - // special case - if (ext == "jpeg") - ext = "jpg"; - fmts.push_back(ext); - } - - return fmts; -} - - -} // namespace support -} // namespace lyx diff --git a/src/support/imagetools.h b/src/support/imagetools.h deleted file mode 100644 index c9317ef520..0000000000 --- a/src/support/imagetools.h +++ /dev/null @@ -1,27 +0,0 @@ -// -*- C++ -*- -/** - * \file imagetools.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author João Luis M. Assirati - * - * Full author contact details are available in file CREDITS. - */ - -#ifndef IMAGETOOLS_H -#define IMAGETOOLS_H - -#include -#include - -namespace lyx { -namespace support { - -/// Return the list of loadable formats. -std::vector loadableImageFormats(); - -} // namespace support -} // namespace lyx - -#endif // IMAGETOOLS_H -- 2.39.2