Skip to content

Commit

Permalink
[16_8] bin/format on src/Plugins/Qt
Browse files Browse the repository at this point in the history
  • Loading branch information
da-liii authored Dec 2, 2023
1 parent f601203 commit e1905d7
Show file tree
Hide file tree
Showing 64 changed files with 9,019 additions and 8,815 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/clang-format-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ on:
- 'src/Graphics/Types/**.hpp'
- 'src/Graphics/Types/**.cpp'
- 'src/Typeset/Boxes/Graphics/**.cpp'
- 'src/Plugins/Pdf/**.cpp'
- 'src/Plugins/Pdf/**.hpp'
- 'src/Plugins/Ghostscript/**.cpp'
- 'src/Plugins/Ghostscript/**.hpp'
- 'src/Plugins/Html/**.cpp'
- 'src/Plugins/Html/**.hpp'
- 'src/Plugins/Metafont/**.cpp'
- 'src/Plugins/Metafont/**.hpp'
- 'src/Plugins/Pdf/**.cpp'
- 'src/Plugins/Pdf/**.hpp'
- 'src/Plugins/Qt/**.cpp'
- 'src/Plugins/Qt/**.hpp'
- 'src/Plugins/Xml/**.cpp'
- 'src/Plugins/Xml/**.hpp'
- 'src/Data/Tree/**.cpp'
Expand Down
10 changes: 6 additions & 4 deletions bin/format
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,18 @@ clang-format -i src/Graphics/Fonts/**.hpp
clang-format -i src/Graphics/Types/**.cpp
clang-format -i src/Graphics/Types/**.hpp
clang-format -i src/Typeset/Boxes/Graphics/**.cpp
clang-format -i src/Plugins/Pdf/**.cpp
clang-format -i src/Plugins/Pdf/**.hpp
clang-format -i src/Plugins/Ghostscript/**.cpp
clang-format -i src/Plugins/Ghostscript/**.hpp
clang-format -i src/Plugins/Html/*.cpp
clang-format -i src/Plugins/Html/*.hpp
clang-format -i src/Plugins/Xml/*.cpp
clang-format -i src/Plugins/Xml/*.hpp
clang-format -i src/Plugins/Metafont/*.cpp
clang-format -i src/Plugins/Metafont/*.hpp
clang-format -i src/Plugins/Pdf/**.cpp
clang-format -i src/Plugins/Pdf/**.hpp
clang-format -i src/Plugins/Qt/**.cpp
clang-format -i src/Plugins/Qt/**.hpp
clang-format -i src/Plugins/Xml/*.cpp
clang-format -i src/Plugins/Xml/*.hpp
clang-format -i src/Mogan/**.cpp
clang-format -i src/Mogan/**.hpp

Expand Down
134 changes: 63 additions & 71 deletions src/Plugins/Qt/QTMApplication.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,24 @@
#ifndef QTMAPPLICATION_HPP
#define QTMAPPLICATION_HPP

#include <QApplication>
#include <QIcon>
#include <QStyle>
#include "renderer.hpp"
#include "string.hpp"
#include "sys_utils.hpp"
#include "url.hpp"
#include "tm_url.hpp"
#include "renderer.hpp"
#include "url.hpp"
#include <QApplication>
#include <QIcon>
#include <QStyle>

#include <QApplication>
#include <QScreen>


void init_palette (QApplication* app);
void init_style_sheet (QApplication* app);
void set_standard_style_sheet (QWidget *w);
void set_standard_style_sheet (QWidget* w);

#ifdef Q_OS_MAC
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QMacPasteboardMime>

// On MacOS we have to register appropriate mime types for PDF files
Expand All @@ -42,43 +41,43 @@ void set_standard_style_sheet (QWidget *w);

// (mg) I'm not sure this is the right place to have this code, but well...

class QMacPasteboardMimePDF : public QMacPasteboardMime
{
class QMacPasteboardMimePDF : public QMacPasteboardMime {
public:
QMacPasteboardMimePDF ()
: QMacPasteboardMime (MIME_QT_CONVERTOR | MIME_ALL)
{}
: QMacPasteboardMime (MIME_QT_CONVERTOR | MIME_ALL) {}

QString convertorName() { return "PDF"; }
QString convertorName () { return "PDF"; }

QString flavorFor (QString const & mime)
{
QString flavorFor (QString const& mime) {
if (mime == QLatin1String ("application/pdf"))
return QLatin1String ("com.adobe.pdf");
return QString();
return QString ();
}

QString mimeFor(QString flav)
{
QString mimeFor (QString flav) {
if (flav == QLatin1String ("com.adobe.pdf"))
return QLatin1String ("application/pdf");
return QString ();
}

bool canConvert(QString const & mime, QString flav)
{ return mimeFor (flav) == mime; }
bool canConvert (QString const& mime, QString flav) {
return mimeFor (flav) == mime;
}

QVariant convertToMime (QString const & mime, QList<QByteArray> data, QString flav)
{
(void) flav; (void) mime;
QVariant convertToMime (QString const& mime, QList<QByteArray> data,
QString flav) {
(void) flav;
(void) mime;
if (data.count () > 1)
debug_qt << "QMacPasteboardMimePDF: Cannot handle multiple member data " << LF;
debug_qt << "QMacPasteboardMimePDF: Cannot handle multiple member data "
<< LF;
return data.first ();
}

QList<QByteArray> convertFromMime (QString const & mime, QVariant data, QString flav)
{
(void) flav; (void) mime;
QList<QByteArray> convertFromMime (QString const& mime, QVariant data,
QString flav) {
(void) flav;
(void) mime;
QList<QByteArray> ret;
ret.append (data.toByteArray ());
return ret;
Expand All @@ -87,54 +86,53 @@ class QMacPasteboardMimePDF : public QMacPasteboardMime
#endif
#endif


/*
FIXME: We would like to do the following
#ifdef USE_EXCEPTIONS
class QTMApplication... blah blah
#else
typedef QApplication QTMApplication;
#endif
But MOC has trouble with conditional compilation.
*/

/*! QTMApplication
Reimplements notify() in order to catch exceptions thrown from event handlers
and slots.
NOTE: see http://qt-project.org/forums/viewthread/17731 for the reason why
the constructor takes an int&
*/
class QTMApplication: public QApplication {
class QTMApplication : public QApplication {
Q_OBJECT

#ifdef Q_OS_MAC
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QMacPasteboardMimePDF mac_pasteboard_mime_pdf;
#endif
#endif

public:
QTMApplication (int& argc, char** argv) :
QApplication (argc, argv) {
init_palette (this);
init_style_sheet (this);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor);
QTMApplication (int& argc, char** argv) : QApplication (argc, argv) {
init_palette (this);
init_style_sheet (this);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QGuiApplication::setHighDpiScaleFactorRoundingPolicy (
Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor);
#endif
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
if (!retina_manual) {
qreal ratio = QApplication::primaryScreen ()->devicePixelRatio ();
retina_factor= qRound (ratio - 0.1);
}
#endif
if (!retina_manual) {
qreal ratio = QApplication::primaryScreen ()->devicePixelRatio ();
retina_factor= qRound (ratio - 0.1);
}
#endif
}

void set_window_icon (string icon_path) {
url icon_url= url_system (get_env ("TEXMACS_PATH") * icon_path);
Expand All @@ -143,7 +141,8 @@ class QTMApplication: public QApplication {
setWindowIcon (QIcon ((const char*) _icon));
}
else
std_warning << "Could not find TeXmacs icon file: " << as_string (icon_url) << LF;
std_warning << "Could not find TeXmacs icon file: "
<< as_string (icon_url) << LF;
}

/*
Expand All @@ -157,44 +156,37 @@ class QTMApplication: public QApplication {
return QApplication::event(event);
}
*/

virtual bool notify (QObject* receiver, QEvent* event)
{

virtual bool notify (QObject* receiver, QEvent* event) {
try {
return QApplication::notify (receiver, event);
}
catch (string s) {
//c_string cs (s);
//tm_failure (cs);
//qt_error << "Thrown " << s << LF;
} catch (string s) {
// c_string cs (s);
// tm_failure (cs);
// qt_error << "Thrown " << s << LF;
the_exception= s;
}
return false;
}
};

class QTMCoreApplication: public QCoreApplication {
class QTMCoreApplication : public QCoreApplication {
Q_OBJECT

public:
QTMCoreApplication (int& argc, char** argv) :
QCoreApplication (argc, argv) {}
QTMCoreApplication (int& argc, char** argv) : QCoreApplication (argc, argv) {}

void set_window_icon (string icon_path) {
(void) icon_path;
}
void set_window_icon (string icon_path) { (void) icon_path; }

virtual bool notify (QObject* receiver, QEvent* event)
{
virtual bool notify (QObject* receiver, QEvent* event) {
try {
return QCoreApplication::notify (receiver, event);
}
catch (string s) {
} catch (string s) {
qt_error << "Thrown " << s << LF;
the_exception= s;
}
return false;
}
};

#endif // QTMAPPLICATION_HPP
#endif // QTMAPPLICATION_HPP
Loading

0 comments on commit e1905d7

Please sign in to comment.