From: Peter Kümmel Date: Thu, 21 Oct 2010 00:07:48 +0000 (+0000) Subject: no QtGui in support X-Git-Tag: 2.0.0~2323 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=f54200b078f285d4c3412a97708b39fc0846370e;p=features.git no QtGui in support git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35740 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt4/GuiAlert.cpp b/src/frontends/qt4/GuiAlert.cpp index e04b301e59..6cc39f179a 100644 --- a/src/frontends/qt4/GuiAlert.cpp +++ b/src/frontends/qt4/GuiAlert.cpp @@ -13,18 +13,18 @@ #include #include "alert.h" +#include "InGuiThread.h" #include "frontends/Application.h" #include "qt_helpers.h" #include "LyX.h" // for lyx::use_gui -#include "support/gettext.h" +#include "support/gettext.h" #include "support/debug.h" #include "support/docstring.h" #include "support/lstrings.h" #include "support/ProgressInterface.h" -#include "support/InGuiThread.h" #include #include diff --git a/src/frontends/qt4/InGuiThread.cpp b/src/frontends/qt4/InGuiThread.cpp new file mode 100644 index 0000000000..f26893f7ac --- /dev/null +++ b/src/frontends/qt4/InGuiThread.cpp @@ -0,0 +1,54 @@ +/** + * \file InGuiThread.cpp + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Peter Kümmel + * + * Full author contact details are available in file CREDITS. + */ + +#include + +#include "InGuiThread.h" + +#include +#include +#include + +namespace lyx { +namespace frontend { + + +IntoGuiThreadMover::IntoGuiThreadMover() +{ + moveToThread(QApplication::instance()->thread()); + connect(this, SIGNAL(triggerCall()), this, SLOT(doFunctionCall()), + Qt::QueuedConnection); +} + + +void IntoGuiThreadMover::callInGuiThread() +{ + if (QThread::currentThread() == QApplication::instance()->thread()) { + synchronousFunctionCall(); + } else { + QEventLoop loop; + connect(this, SIGNAL(called()), &loop, SLOT(quit())); + Q_EMIT triggerCall(); + loop.exec(); + } +} + + +void IntoGuiThreadMover::doFunctionCall() +{ + synchronousFunctionCall(); + Q_EMIT called(); +} + + +} // namespace frontend +} // namespace lyx + + diff --git a/src/frontends/qt4/InGuiThread.h b/src/frontends/qt4/InGuiThread.h new file mode 100644 index 0000000000..6d3b778a04 --- /dev/null +++ b/src/frontends/qt4/InGuiThread.h @@ -0,0 +1,172 @@ +// -*- C++ -*- +/** + * \file InGuiThread.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Peter Kümmel + * + * Full author contact details are available in file CREDITS. + */ + +#ifndef INGUITHREAD_H +#define INGUITHREAD_H + +#include + +#include "support/bind.h" +#include "support/functional.h" + +namespace lyx { +namespace frontend { + + +class IntoGuiThreadMover : public QObject +{ + Q_OBJECT + +protected: + + IntoGuiThreadMover(); + + void callInGuiThread(); + +Q_SIGNALS: + void triggerCall(); + void called(); + +private Q_SLOTS: + void doFunctionCall(); + +private: + virtual void synchronousFunctionCall() = 0; +}; + + +template +class InGuiThread : private IntoGuiThreadMover +{ +public: + + InGuiThread() {} + + template + R call(F f) + { + func_ = f; + callInGuiThread(); + return return_value_; + } + + template + R call(F f, P1 p1) + { + return call(bind(f, p1)); + } + + template + R call(F f, P1 p1, P2 p2) + { + return call(bind(f, p1, p2)); + } + + template + R call(F f, P1 p1, P2 p2, P3 p3) + { + return call(bind(f, p1, p2, p3)); + } + + template + R call(F f, P1 p1, P2 p2, P3 p3, P4 p4) + { + return call(bind(f, p1, p2, p3, p4)); + } + + /* + ... + */ + + template + R call(F f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) + { + return call(bind(f, p1, p2, p3, p4, p5, p6, p7, p8)); + } + +private: + + void synchronousFunctionCall() + { + return_value_ = func_(); + } + +private: + R return_value_; + function func_; +}; + + +// void specialisation +template<> +class InGuiThread : private IntoGuiThreadMover +{ +public: + + InGuiThread() {} + + template + void call(F f) + { + func_ = f; + callInGuiThread(); + } + + template + void call(F f, P1 p1) + { + call(bind(f, p1)); + } + + template + void call(F f, P1 p1, P2 p2) + { + call(bind(f, p1, p2)); + } + + template + void call(F f, P1 p1, P2 p2, P3 p3) + { + call(bind(f, p1, p2, p3)); + } + + template + void call(F f, P1 p1, P2 p2, P3 p3, P4 p4) + { + call(bind(f, p1, p2, p3, p4)); + } + + /* + ... + */ + + template + void call(F f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) + { + call(bind(f, p1, p2, p3, p4, p5, p6, p7, p8)); + } + +private: + + void synchronousFunctionCall() + { + func_(); + } + +private: + function func_; +}; + + +} // namespace frontend +} // namespace lyx + +#endif // GUIABOUT_H diff --git a/src/support/InGuiThread.cpp b/src/support/InGuiThread.cpp deleted file mode 100644 index 17d66d7662..0000000000 --- a/src/support/InGuiThread.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/** - * \file InGuiThread.cpp - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Peter Kümmel - * - * Full author contact details are available in file CREDITS. - */ - -#include - -#include "support/InGuiThread.h" - -#include -#include -#include - -namespace lyx { -namespace frontend { - - -IntoGuiThreadMover::IntoGuiThreadMover() -{ - moveToThread(QApplication::instance()->thread()); - connect(this, SIGNAL(triggerCall()), this, SLOT(doFunctionCall()), - Qt::QueuedConnection); -} - - -void IntoGuiThreadMover::callInGuiThread() -{ - if (QThread::currentThread() == QApplication::instance()->thread()) { - synchronousFunctionCall(); - } else { - QEventLoop loop; - connect(this, SIGNAL(called()), &loop, SLOT(quit())); - Q_EMIT triggerCall(); - loop.exec(); - } -} - - -void IntoGuiThreadMover::doFunctionCall() -{ - synchronousFunctionCall(); - Q_EMIT called(); -} - - -} // namespace frontend -} // namespace lyx - - diff --git a/src/support/InGuiThread.h b/src/support/InGuiThread.h deleted file mode 100644 index 6d3b778a04..0000000000 --- a/src/support/InGuiThread.h +++ /dev/null @@ -1,172 +0,0 @@ -// -*- C++ -*- -/** - * \file InGuiThread.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Peter Kümmel - * - * Full author contact details are available in file CREDITS. - */ - -#ifndef INGUITHREAD_H -#define INGUITHREAD_H - -#include - -#include "support/bind.h" -#include "support/functional.h" - -namespace lyx { -namespace frontend { - - -class IntoGuiThreadMover : public QObject -{ - Q_OBJECT - -protected: - - IntoGuiThreadMover(); - - void callInGuiThread(); - -Q_SIGNALS: - void triggerCall(); - void called(); - -private Q_SLOTS: - void doFunctionCall(); - -private: - virtual void synchronousFunctionCall() = 0; -}; - - -template -class InGuiThread : private IntoGuiThreadMover -{ -public: - - InGuiThread() {} - - template - R call(F f) - { - func_ = f; - callInGuiThread(); - return return_value_; - } - - template - R call(F f, P1 p1) - { - return call(bind(f, p1)); - } - - template - R call(F f, P1 p1, P2 p2) - { - return call(bind(f, p1, p2)); - } - - template - R call(F f, P1 p1, P2 p2, P3 p3) - { - return call(bind(f, p1, p2, p3)); - } - - template - R call(F f, P1 p1, P2 p2, P3 p3, P4 p4) - { - return call(bind(f, p1, p2, p3, p4)); - } - - /* - ... - */ - - template - R call(F f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) - { - return call(bind(f, p1, p2, p3, p4, p5, p6, p7, p8)); - } - -private: - - void synchronousFunctionCall() - { - return_value_ = func_(); - } - -private: - R return_value_; - function func_; -}; - - -// void specialisation -template<> -class InGuiThread : private IntoGuiThreadMover -{ -public: - - InGuiThread() {} - - template - void call(F f) - { - func_ = f; - callInGuiThread(); - } - - template - void call(F f, P1 p1) - { - call(bind(f, p1)); - } - - template - void call(F f, P1 p1, P2 p2) - { - call(bind(f, p1, p2)); - } - - template - void call(F f, P1 p1, P2 p2, P3 p3) - { - call(bind(f, p1, p2, p3)); - } - - template - void call(F f, P1 p1, P2 p2, P3 p3, P4 p4) - { - call(bind(f, p1, p2, p3, p4)); - } - - /* - ... - */ - - template - void call(F f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) - { - call(bind(f, p1, p2, p3, p4, p5, p6, p7, p8)); - } - -private: - - void synchronousFunctionCall() - { - func_(); - } - -private: - function func_; -}; - - -} // namespace frontend -} // namespace lyx - -#endif // GUIABOUT_H