2002-06-19 05:20:29 +00:00
|
|
|
/**
|
2006-04-24 13:48:24 +00:00
|
|
|
* \file qt3/lyx_gui.C
|
2002-09-24 13:57:09 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-06-19 05:20:29 +00:00
|
|
|
*
|
|
|
|
* \author unknown
|
2002-09-24 13:57:09 +00:00
|
|
|
* \author John Levon
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-06-19 05:20:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
2002-07-28 18:13:51 +00:00
|
|
|
|
2002-07-12 01:48:53 +00:00
|
|
|
#include "lyx_gui.h"
|
2002-07-28 18:13:51 +00:00
|
|
|
|
2002-06-19 05:20:29 +00:00
|
|
|
// FIXME: move this stuff out again
|
|
|
|
#include "bufferlist.h"
|
2004-05-20 09:36:28 +00:00
|
|
|
#include "BufferView.h"
|
2006-03-23 20:04:05 +00:00
|
|
|
#include "Color.h"
|
2004-05-20 09:36:28 +00:00
|
|
|
#include "funcrequest.h"
|
|
|
|
#include "LColor.h"
|
2003-10-14 21:30:23 +00:00
|
|
|
#include "lyx_main.h"
|
2003-10-13 00:38:09 +00:00
|
|
|
#include "LyXAction.h"
|
2002-06-19 05:20:29 +00:00
|
|
|
#include "lyxfunc.h"
|
2003-09-06 23:36:02 +00:00
|
|
|
#include "lyxrc.h"
|
2002-06-19 05:20:29 +00:00
|
|
|
#include "lyxserver.h"
|
2003-10-14 11:35:50 +00:00
|
|
|
#include "lyxsocket.h"
|
2002-06-19 05:20:29 +00:00
|
|
|
|
2004-05-20 09:36:28 +00:00
|
|
|
#include "graphics/LoaderQueue.h"
|
|
|
|
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
#include "support/os.h"
|
2005-01-10 19:17:43 +00:00
|
|
|
#include "support/package.h"
|
2004-08-08 22:37:39 +00:00
|
|
|
#include "debug.h"
|
2004-05-20 09:36:28 +00:00
|
|
|
|
|
|
|
// Dear Lord, deliver us from Evil, aka the Qt headers
|
|
|
|
// Qt defines a macro 'signals' that clashes with a boost namespace.
|
|
|
|
// All is well if the namespace is visible first.
|
2004-09-26 14:19:47 +00:00
|
|
|
#include <boost/signal.hpp> // FIXME: Is this needed? (Lgb)
|
2002-11-04 00:15:56 +00:00
|
|
|
#include <boost/bind.hpp>
|
2004-07-21 19:03:21 +00:00
|
|
|
#include <boost/shared_ptr.hpp>
|
2002-07-28 18:13:51 +00:00
|
|
|
|
2002-07-12 01:48:53 +00:00
|
|
|
#include "QtView.h"
|
2003-05-24 15:19:05 +00:00
|
|
|
#include "lcolorcache.h"
|
2004-05-20 09:36:28 +00:00
|
|
|
#include "qfont_loader.h"
|
|
|
|
#include "QLImage.h"
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
#include "socket_callback.h"
|
2002-07-28 18:13:51 +00:00
|
|
|
|
2004-01-07 16:40:30 +00:00
|
|
|
#ifdef Q_WS_MACX
|
|
|
|
#include <Carbon/Carbon.h>
|
|
|
|
#endif
|
|
|
|
|
2002-06-19 05:20:29 +00:00
|
|
|
#include <qapplication.h>
|
2005-05-11 20:09:20 +00:00
|
|
|
#if QT_VERSION >= 0x030100
|
|
|
|
#include <qeventloop.h>
|
|
|
|
#endif
|
2002-10-20 01:48:28 +00:00
|
|
|
#include <qpaintdevicemetrics.h>
|
2004-08-08 22:37:39 +00:00
|
|
|
#include <qtranslator.h>
|
|
|
|
#include <qtextcodec.h>
|
2002-07-28 18:13:51 +00:00
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
using lyx::support::ltrim;
|
2005-01-10 19:17:43 +00:00
|
|
|
using lyx::support::package;
|
2003-06-30 23:56:22 +00:00
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
using lyx::frontend::QtView;
|
|
|
|
|
2003-10-14 11:35:50 +00:00
|
|
|
namespace os = lyx::support::os;
|
|
|
|
|
2004-07-21 19:03:21 +00:00
|
|
|
using boost::shared_ptr;
|
|
|
|
|
2002-06-19 05:20:29 +00:00
|
|
|
#ifndef CXX_GLOBAL_CSTD
|
|
|
|
using std::exit;
|
|
|
|
#endif
|
|
|
|
|
2002-07-31 04:33:03 +00:00
|
|
|
using std::map;
|
2003-09-08 00:33:41 +00:00
|
|
|
using std::vector;
|
2003-10-06 15:43:21 +00:00
|
|
|
using std::string;
|
2003-09-08 00:33:41 +00:00
|
|
|
|
2002-07-28 18:13:51 +00:00
|
|
|
|
2002-06-19 05:20:29 +00:00
|
|
|
extern BufferList bufferlist;
|
2002-07-28 18:13:51 +00:00
|
|
|
|
2006-06-07 20:08:37 +00:00
|
|
|
// FIXME: wrong place !
|
|
|
|
LyXServer * lyxserver;
|
|
|
|
LyXServerSocket * lyxsocket;
|
|
|
|
|
2002-08-25 05:41:42 +00:00
|
|
|
namespace {
|
2002-10-14 20:20:34 +00:00
|
|
|
|
2005-01-05 10:54:31 +00:00
|
|
|
int getDPI()
|
2002-10-20 01:48:28 +00:00
|
|
|
{
|
2002-10-14 20:20:34 +00:00
|
|
|
QWidget w;
|
|
|
|
QPaintDeviceMetrics pdm(&w);
|
2005-01-05 10:54:31 +00:00
|
|
|
return int(0.5 * (pdm.logicalDpiX() + pdm.logicalDpiY()));
|
2002-10-14 20:20:34 +00:00
|
|
|
}
|
|
|
|
|
2004-07-21 19:03:21 +00:00
|
|
|
map<int, shared_ptr<socket_callback> > socket_callbacks;
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2006-06-07 20:08:37 +00:00
|
|
|
void cleanup()
|
|
|
|
{
|
|
|
|
delete lyxsocket;
|
|
|
|
lyxsocket = 0;
|
|
|
|
delete lyxserver;
|
|
|
|
lyxserver = 0;
|
|
|
|
}
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2006-06-07 20:08:37 +00:00
|
|
|
} // namespace anon
|
2002-07-28 18:13:51 +00:00
|
|
|
|
2003-01-05 22:38:42 +00:00
|
|
|
// in QLyXKeySym.C
|
|
|
|
extern void initEncodings();
|
|
|
|
|
2002-11-07 22:46:30 +00:00
|
|
|
#ifdef Q_WS_X11
|
|
|
|
extern bool lyxX11EventFilter(XEvent * xev);
|
|
|
|
#endif
|
|
|
|
|
2004-01-07 16:40:30 +00:00
|
|
|
#ifdef Q_WS_MACX
|
|
|
|
extern pascal OSErr
|
2004-04-03 08:37:12 +00:00
|
|
|
handleOpenDocuments(const AppleEvent* inEvent, AppleEvent* /*reply*/,
|
2004-01-07 16:40:30 +00:00
|
|
|
long /*refCon*/);
|
|
|
|
#endif
|
2003-01-05 22:38:42 +00:00
|
|
|
|
2002-11-07 22:46:30 +00:00
|
|
|
class LQApplication : public QApplication
|
|
|
|
{
|
|
|
|
public:
|
2003-01-23 16:23:43 +00:00
|
|
|
LQApplication(int & argc, char ** argv);
|
2002-11-07 22:46:30 +00:00
|
|
|
#ifdef Q_WS_X11
|
|
|
|
bool x11EventFilter (XEvent * ev) { return lyxX11EventFilter(ev); }
|
|
|
|
#endif
|
2004-01-07 16:40:30 +00:00
|
|
|
#ifdef Q_WS_MACX
|
|
|
|
bool macEventFilter(EventRef event);
|
|
|
|
#endif
|
2002-11-07 22:46:30 +00:00
|
|
|
};
|
|
|
|
|
2002-12-20 01:32:51 +00:00
|
|
|
|
2003-01-23 16:23:43 +00:00
|
|
|
LQApplication::LQApplication(int & argc, char ** argv)
|
|
|
|
: QApplication(argc, argv)
|
2004-01-07 16:40:30 +00:00
|
|
|
{
|
|
|
|
#ifdef Q_WS_MACX
|
|
|
|
AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
|
|
|
|
NewAEEventHandlerUPP(handleOpenDocuments),
|
|
|
|
0, false);
|
|
|
|
#endif
|
|
|
|
}
|
2002-11-07 22:46:30 +00:00
|
|
|
|
2002-12-20 01:32:51 +00:00
|
|
|
|
2004-01-07 16:40:30 +00:00
|
|
|
#ifdef Q_WS_MACX
|
2004-04-03 08:37:12 +00:00
|
|
|
bool LQApplication::macEventFilter(EventRef event)
|
2004-01-07 16:40:30 +00:00
|
|
|
{
|
|
|
|
if (GetEventClass(event) == kEventClassAppleEvent) {
|
|
|
|
EventRecord eventrec;
|
|
|
|
ConvertEventRefToEventRecord(event, &eventrec);
|
|
|
|
AEProcessAppleEvent(&eventrec);
|
2004-04-03 08:37:12 +00:00
|
|
|
|
2004-01-07 16:40:30 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2003-03-31 02:59:34 +00:00
|
|
|
namespace lyx_gui {
|
|
|
|
|
|
|
|
bool use_gui = true;
|
|
|
|
|
2006-06-07 20:08:37 +00:00
|
|
|
|
|
|
|
void exec(int & argc, char * argv[])
|
2002-06-19 05:20:29 +00:00
|
|
|
{
|
2004-10-13 16:14:57 +00:00
|
|
|
// Force adding of font path _before_ QApplication is initialized
|
2005-07-16 15:43:33 +00:00
|
|
|
FontLoader::initFontPath();
|
2004-10-26 21:16:44 +00:00
|
|
|
|
2006-06-07 20:08:37 +00:00
|
|
|
LQApplication app(argc, argv);
|
2004-08-08 22:37:39 +00:00
|
|
|
|
|
|
|
#if QT_VERSION >= 0x030200
|
2004-10-05 10:11:42 +00:00
|
|
|
// install translation file for Qt built-in dialogs
|
2004-08-08 22:37:39 +00:00
|
|
|
// These are only installed since Qt 3.2.x
|
2006-06-07 20:08:37 +00:00
|
|
|
QTranslator qt_trans(0);
|
2004-10-05 10:11:42 +00:00
|
|
|
if (qt_trans.load(QString("qt_") + QTextCodec::locale(),
|
2004-08-08 22:37:39 +00:00
|
|
|
qInstallPathTranslations())) {
|
2006-06-07 20:08:37 +00:00
|
|
|
qApp->installTranslator(&qt_trans);
|
2004-08-08 22:37:39 +00:00
|
|
|
// even if the language calls for RtL, don't do that
|
2006-06-07 20:08:37 +00:00
|
|
|
qApp->setReverseLayout(false);
|
2004-08-08 22:37:39 +00:00
|
|
|
lyxerr[Debug::GUI]
|
|
|
|
<< "Successfully installed Qt translations for locale "
|
|
|
|
<< QTextCodec::locale() << std::endl;
|
|
|
|
} else
|
|
|
|
lyxerr[Debug::GUI]
|
|
|
|
<< "Could not find Qt translations for locale "
|
|
|
|
<< QTextCodec::locale() << std::endl;
|
|
|
|
#endif
|
2002-07-28 18:13:51 +00:00
|
|
|
|
2004-08-14 18:06:10 +00:00
|
|
|
#ifdef Q_WS_MACX
|
|
|
|
// These translations are meant to break Qt/Mac menu merging
|
|
|
|
// algorithm on some entries. It lists the menu names that
|
|
|
|
// should not be moved to the LyX menu
|
2006-06-07 20:08:37 +00:00
|
|
|
QTranslator aqua_trans(0);
|
2004-09-26 14:19:47 +00:00
|
|
|
aqua_trans.insert(QTranslatorMessage("QMenuBar", "Setting", 0,
|
2004-08-14 18:06:10 +00:00
|
|
|
"do_not_merge_me"));
|
2004-09-26 14:19:47 +00:00
|
|
|
aqua_trans.insert(QTranslatorMessage("QMenuBar", "Config", 0,
|
2004-08-14 18:06:10 +00:00
|
|
|
"do_not_merge_me"));
|
2004-09-26 14:19:47 +00:00
|
|
|
aqua_trans.insert(QTranslatorMessage("QMenuBar", "Options", 0,
|
2004-08-14 18:06:10 +00:00
|
|
|
"do_not_merge_me"));
|
2004-09-26 14:19:47 +00:00
|
|
|
aqua_trans.insert(QTranslatorMessage("QMenuBar", "Setup", 0,
|
2004-08-14 18:06:10 +00:00
|
|
|
"do_not_merge_me"));
|
|
|
|
|
2006-06-07 20:08:37 +00:00
|
|
|
qApp->installTranslator(&aqua_trans);
|
2004-08-14 18:06:10 +00:00
|
|
|
#endif
|
|
|
|
|
2003-07-04 08:23:23 +00:00
|
|
|
using namespace lyx::graphics;
|
2002-07-12 16:26:25 +00:00
|
|
|
|
|
|
|
Image::newImage = boost::bind(&QLImage::newImage);
|
|
|
|
Image::loadableFormats = boost::bind(&QLImage::loadableFormats);
|
2002-08-25 05:41:42 +00:00
|
|
|
|
|
|
|
// needs to be done before reading lyxrc
|
|
|
|
lyxrc.dpi = getDPI();
|
2003-01-05 22:38:42 +00:00
|
|
|
|
2003-02-25 11:20:59 +00:00
|
|
|
LoaderQueue::setPriority(10,100);
|
2006-06-07 20:08:37 +00:00
|
|
|
|
|
|
|
LyX::ref().exec2(argc, argv);
|
2002-06-19 05:20:29 +00:00
|
|
|
}
|
2002-07-28 18:13:51 +00:00
|
|
|
|
2002-06-19 05:20:29 +00:00
|
|
|
|
2003-03-31 02:59:34 +00:00
|
|
|
void parse_lyxrc()
|
2003-02-28 09:49:49 +00:00
|
|
|
{}
|
2002-06-19 05:20:29 +00:00
|
|
|
|
2002-07-28 18:13:51 +00:00
|
|
|
|
2006-05-29 15:11:19 +00:00
|
|
|
void start(string const & batch, vector<string> const & files,
|
2006-06-18 09:05:41 +00:00
|
|
|
unsigned int width, unsigned int height, int posx, int posy, bool)
|
2002-06-19 05:20:29 +00:00
|
|
|
{
|
2005-07-16 15:55:36 +00:00
|
|
|
// this can't be done before because it needs the Languages object
|
|
|
|
initEncodings();
|
|
|
|
|
2006-06-14 14:42:24 +00:00
|
|
|
boost::shared_ptr<QtView> view_ptr(new QtView(width, height));
|
2003-10-14 21:30:23 +00:00
|
|
|
LyX::ref().addLyXView(view_ptr);
|
|
|
|
|
|
|
|
QtView & view = *view_ptr.get();
|
2006-04-05 23:56:29 +00:00
|
|
|
|
2006-06-18 09:05:41 +00:00
|
|
|
if (posx != -1 && posy != -1)
|
|
|
|
view.move(QPoint(posx, posy));
|
2006-05-29 15:11:19 +00:00
|
|
|
|
2003-01-05 22:38:42 +00:00
|
|
|
view.show();
|
2006-06-18 09:05:41 +00:00
|
|
|
view.init();
|
2002-06-19 05:20:29 +00:00
|
|
|
|
|
|
|
// FIXME: some code below needs moving
|
|
|
|
|
2002-08-13 14:40:38 +00:00
|
|
|
lyxserver = new LyXServer(&view.getLyXFunc(), lyxrc.lyxpipes);
|
2003-10-14 11:35:50 +00:00
|
|
|
lyxsocket = new LyXServerSocket(&view.getLyXFunc(),
|
2005-01-10 19:17:43 +00:00
|
|
|
os::internal_path(package().temp_dir() + "/lyxsocket"));
|
2002-07-28 18:13:51 +00:00
|
|
|
|
2004-11-06 15:23:12 +00:00
|
|
|
for_each(files.begin(), files.end(),
|
|
|
|
bind(&BufferView::loadLyXFile, view.view(), _1, true));
|
2002-06-19 05:20:29 +00:00
|
|
|
|
|
|
|
// handle the batch commands the user asked for
|
|
|
|
if (!batch.empty()) {
|
2003-10-13 00:38:09 +00:00
|
|
|
view.getLyXFunc().dispatch(lyxaction.lookupFunc(batch));
|
2002-06-19 05:20:29 +00:00
|
|
|
}
|
|
|
|
|
2002-07-22 18:56:04 +00:00
|
|
|
qApp->exec();
|
2002-07-28 18:13:51 +00:00
|
|
|
|
2002-07-22 18:56:04 +00:00
|
|
|
// FIXME
|
2006-06-07 20:08:37 +00:00
|
|
|
cleanup();
|
2002-06-19 05:20:29 +00:00
|
|
|
}
|
2002-07-28 18:13:51 +00:00
|
|
|
|
|
|
|
|
2003-06-03 19:32:08 +00:00
|
|
|
void sync_events()
|
|
|
|
{
|
2005-05-11 07:44:20 +00:00
|
|
|
// This is the ONLY place where processEvents may be called.
|
2005-05-13 08:33:01 +00:00
|
|
|
// During screen update/ redraw, this method is disabled to
|
2005-05-11 07:44:20 +00:00
|
|
|
// prevent keyboard events being handed to the LyX core, where
|
|
|
|
// they could cause re-entrant calls to screen update.
|
2005-05-11 20:09:20 +00:00
|
|
|
#if QT_VERSION >= 0x030100
|
|
|
|
qApp->eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
|
|
|
|
#endif
|
2003-06-03 19:32:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-07 20:08:37 +00:00
|
|
|
void exit(int status)
|
2002-07-22 18:56:04 +00:00
|
|
|
{
|
2006-06-07 20:08:37 +00:00
|
|
|
cleanup();
|
2003-02-07 16:46:40 +00:00
|
|
|
|
2006-06-07 20:08:37 +00:00
|
|
|
// we cannot call QApplication::exit(status) - that could return us
|
2002-12-20 01:32:51 +00:00
|
|
|
// into a static dialog return in the lyx code (for example,
|
|
|
|
// load autosave file QMessageBox. We have to just get the hell
|
|
|
|
// out.
|
2003-02-25 13:35:26 +00:00
|
|
|
|
2006-06-07 20:08:37 +00:00
|
|
|
::exit(status);
|
2002-07-22 18:56:04 +00:00
|
|
|
}
|
|
|
|
|
2002-07-28 18:13:51 +00:00
|
|
|
|
2003-03-31 02:59:34 +00:00
|
|
|
FuncStatus getStatus(FuncRequest const & ev)
|
2002-12-18 14:24:32 +00:00
|
|
|
{
|
|
|
|
FuncStatus flag;
|
|
|
|
switch (ev.action) {
|
2003-06-19 16:49:45 +00:00
|
|
|
case LFUN_DIALOG_SHOW:
|
2004-03-17 21:21:47 +00:00
|
|
|
if (ev.argument == "preamble")
|
2003-06-19 16:49:45 +00:00
|
|
|
flag.unknown(true);
|
|
|
|
break;
|
2006-05-08 18:09:19 +00:00
|
|
|
case LFUN_TOOLTIPS_TOGGLE:
|
2002-12-18 14:24:32 +00:00
|
|
|
flag.unknown(true);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2004-06-23 14:04:09 +00:00
|
|
|
|
2002-12-18 14:24:32 +00:00
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-23 20:04:05 +00:00
|
|
|
bool getRGBColor(LColor_color col, lyx::RGBColor & rgbcol)
|
|
|
|
{
|
|
|
|
QColor const & qcol = lcolorcache.get(col);
|
|
|
|
if (!qcol.isValid()) {
|
|
|
|
rgbcol.r = 0;
|
|
|
|
rgbcol.g = 0;
|
|
|
|
rgbcol.b = 0;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
rgbcol.r = qcol.red();
|
|
|
|
rgbcol.g = qcol.green();
|
|
|
|
rgbcol.b = qcol.blue();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-18 11:48:11 +00:00
|
|
|
string const hexname(LColor_color col)
|
2002-07-11 01:01:38 +00:00
|
|
|
{
|
2003-05-24 15:19:05 +00:00
|
|
|
return ltrim(fromqstr(lcolorcache.get(col).name()), "#");
|
2002-07-11 01:01:38 +00:00
|
|
|
}
|
2002-07-12 02:27:42 +00:00
|
|
|
|
|
|
|
|
2003-09-18 11:48:11 +00:00
|
|
|
void update_color(LColor_color)
|
2002-07-12 02:27:42 +00:00
|
|
|
{
|
2003-05-24 15:19:05 +00:00
|
|
|
// FIXME: Bleh, can't we just clear them all at once ?
|
|
|
|
lcolorcache.clear();
|
2002-07-12 02:27:42 +00:00
|
|
|
}
|
2002-07-12 03:05:13 +00:00
|
|
|
|
|
|
|
|
2003-03-31 02:59:34 +00:00
|
|
|
void update_fonts()
|
2002-07-12 03:05:13 +00:00
|
|
|
{
|
|
|
|
fontloader.update();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-31 02:59:34 +00:00
|
|
|
bool font_available(LyXFont const & font)
|
2002-07-12 03:05:13 +00:00
|
|
|
{
|
|
|
|
return fontloader.available(font);
|
|
|
|
}
|
2002-07-14 01:44:15 +00:00
|
|
|
|
2002-09-24 13:57:09 +00:00
|
|
|
|
2004-07-21 19:03:21 +00:00
|
|
|
void register_socket_callback(int fd, boost::function<void()> func)
|
2003-11-05 10:49:07 +00:00
|
|
|
{
|
2004-07-21 19:03:21 +00:00
|
|
|
socket_callbacks[fd] = shared_ptr<socket_callback>(new socket_callback(fd, func));
|
2003-11-05 10:49:07 +00:00
|
|
|
}
|
2003-10-13 12:25:11 +00:00
|
|
|
|
|
|
|
|
2004-07-21 19:03:21 +00:00
|
|
|
void unregister_socket_callback(int fd)
|
2003-11-05 10:49:07 +00:00
|
|
|
{
|
2004-07-21 19:03:21 +00:00
|
|
|
socket_callbacks.erase(fd);
|
2003-11-05 10:49:07 +00:00
|
|
|
}
|
2003-10-13 12:25:11 +00:00
|
|
|
|
|
|
|
|
2003-03-31 02:59:34 +00:00
|
|
|
string const roman_font_name()
|
|
|
|
{
|
|
|
|
if (!use_gui)
|
|
|
|
return "serif";
|
|
|
|
|
|
|
|
QFont font;
|
|
|
|
font.setStyleHint(QFont::Serif);
|
2003-04-22 23:25:27 +00:00
|
|
|
font.setFamily("serif");
|
2004-06-18 13:31:55 +00:00
|
|
|
|
2004-08-12 07:24:03 +00:00
|
|
|
return fromqstr(QFontInfo(font).family());
|
2003-03-31 02:59:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string const sans_font_name()
|
|
|
|
{
|
|
|
|
if (!use_gui)
|
|
|
|
return "sans";
|
|
|
|
|
|
|
|
QFont font;
|
|
|
|
font.setStyleHint(QFont::SansSerif);
|
2003-04-22 23:25:27 +00:00
|
|
|
font.setFamily("sans");
|
2004-06-18 13:31:55 +00:00
|
|
|
|
2004-08-12 07:24:03 +00:00
|
|
|
return fromqstr(QFontInfo(font).family());
|
2003-03-31 02:59:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string const typewriter_font_name()
|
|
|
|
{
|
|
|
|
if (!use_gui)
|
|
|
|
return "monospace";
|
|
|
|
|
|
|
|
QFont font;
|
|
|
|
font.setStyleHint(QFont::TypeWriter);
|
2003-04-22 23:25:27 +00:00
|
|
|
font.setFamily("monospace");
|
2004-06-18 13:31:55 +00:00
|
|
|
|
2004-08-12 07:24:03 +00:00
|
|
|
return fromqstr(QFontInfo(font).family());
|
2003-03-31 02:59:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}; // namespace lyx_gui
|