2002-06-19 03:38:44 +00:00
|
|
|
/**
|
|
|
|
* \file QtView.C
|
|
|
|
* Copyright 1995-2002 the LyX Team
|
|
|
|
* Read the file COPYING
|
|
|
|
*
|
|
|
|
* \author Lars Gullik Bjornes <larsbj@lyx.org>
|
|
|
|
* \author John Levon <moz@compsoc.man.ac.uk>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "debug.h"
|
|
|
|
#include "intl.h"
|
|
|
|
#include "lyx_cb.h"
|
|
|
|
#include "support/filetools.h"
|
|
|
|
#include "MenuBackend.h"
|
|
|
|
#include "ToolbarDefaults.h"
|
|
|
|
#include "lyxfunc.h"
|
2002-07-17 04:13:41 +00:00
|
|
|
#include "bufferview_funcs.h"
|
2002-06-19 03:38:44 +00:00
|
|
|
#include "BufferView.h"
|
|
|
|
|
|
|
|
#include "frontends/Toolbar.h"
|
|
|
|
#include "frontends/Menubar.h"
|
|
|
|
#include "frontends/Dialogs.h"
|
|
|
|
#include "frontends/Timeout.h"
|
|
|
|
|
2002-07-19 23:04:55 +00:00
|
|
|
#include <boost/bind.hpp>
|
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
#include "QtView.h"
|
|
|
|
#include "qfont_loader.h"
|
2002-07-19 23:04:55 +00:00
|
|
|
#include "QCommandBuffer.h"
|
2002-06-19 03:38:44 +00:00
|
|
|
|
|
|
|
#include <qapplication.h>
|
|
|
|
#include <qpixmap.h>
|
|
|
|
#include <qmenubar.h>
|
2002-07-13 01:42:15 +00:00
|
|
|
#include <qstatusbar.h>
|
2002-06-19 03:38:44 +00:00
|
|
|
|
|
|
|
using std::endl;
|
|
|
|
|
2002-07-22 18:22:35 +00:00
|
|
|
namespace {
|
|
|
|
int const idle_timer_value = 3000;
|
|
|
|
}
|
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
// FIXME: this has to go away
|
|
|
|
BufferView * current_view;
|
|
|
|
|
|
|
|
qfont_loader fontloader;
|
|
|
|
|
|
|
|
QtView::QtView(unsigned int width, unsigned int height)
|
|
|
|
: QMainWindow(), LyXView()
|
|
|
|
{
|
|
|
|
resize(width, height);
|
|
|
|
|
|
|
|
qApp->setMainWidget(this);
|
|
|
|
|
2002-07-22 01:53:26 +00:00
|
|
|
bufferview_.reset(new BufferView(this, 0, 0, width, height));
|
|
|
|
::current_view = bufferview_.get();
|
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
menubar_.reset(new Menubar(this, menubackend));
|
|
|
|
|
|
|
|
connect(menuBar(), SIGNAL(activated(int)),
|
|
|
|
this, SLOT(activated(int)));
|
|
|
|
|
2002-08-12 14:28:43 +00:00
|
|
|
toolbar_.reset(new Toolbar(this, 0, 0, toolbardefaults));
|
2002-06-19 03:38:44 +00:00
|
|
|
|
2002-07-13 01:42:15 +00:00
|
|
|
statusBar()->setSizeGripEnabled(false);
|
|
|
|
|
2002-07-17 04:13:41 +00:00
|
|
|
view_state_changed.connect(boost::bind(&QtView::update_view_state, this));
|
2002-07-19 23:04:55 +00:00
|
|
|
connect(&idle_timer_, SIGNAL(timeout()), this, SLOT(update_view_state_qt()));
|
|
|
|
|
2002-07-22 18:22:35 +00:00
|
|
|
idle_timer_.start(idle_timer_value);
|
2002-07-19 23:04:55 +00:00
|
|
|
|
|
|
|
focus_command_buffer.connect(boost::bind(&QtView::focus_command_widget, this));
|
|
|
|
|
|
|
|
commandbuffer_ = new QCommandBuffer(this, *controlcommand_);
|
|
|
|
|
|
|
|
addToolBar(commandbuffer_, Bottom, true);
|
2002-07-17 04:13:41 +00:00
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
// assign an icon to main form
|
|
|
|
string const iconname = LibFileSearch("images", "lyx", "xpm");
|
|
|
|
if (!iconname.empty())
|
|
|
|
setIcon(QPixmap(iconname.c_str()));
|
|
|
|
|
|
|
|
// make sure the buttons are disabled if needed
|
|
|
|
updateToolbar();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QtView::~QtView()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-19 23:04:55 +00:00
|
|
|
void QtView::message(string const & str)
|
|
|
|
{
|
|
|
|
statusBar()->message(str.c_str());
|
2002-07-21 01:38:24 +00:00
|
|
|
idle_timer_.stop();
|
2002-07-22 18:22:35 +00:00
|
|
|
idle_timer_.start(idle_timer_value);
|
2002-07-19 23:04:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QtView::focus_command_widget()
|
|
|
|
{
|
|
|
|
commandbuffer_->focus_command();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QtView::update_view_state_qt()
|
|
|
|
{
|
2002-08-06 00:54:20 +00:00
|
|
|
statusBar()->message(currentState(view().get()).c_str());
|
2002-07-19 23:04:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-17 04:13:41 +00:00
|
|
|
void QtView::update_view_state()
|
|
|
|
{
|
2002-08-06 00:54:20 +00:00
|
|
|
statusBar()->message(currentState(view().get()).c_str());
|
2002-07-17 04:13:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
void QtView::activated(int id)
|
|
|
|
{
|
2002-08-13 14:40:38 +00:00
|
|
|
getLyXFunc().dispatch(id, true);
|
2002-06-19 03:38:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QtView::closeEvent(QCloseEvent *)
|
|
|
|
{
|
|
|
|
QuitLyX();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-12 01:59:01 +00:00
|
|
|
void QtView::show(int x, int y, string const & title)
|
2002-06-19 03:38:44 +00:00
|
|
|
{
|
|
|
|
move(x, y);
|
|
|
|
setCaption(title.c_str());
|
|
|
|
QMainWindow::show();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QtView::prohibitInput() const
|
|
|
|
{
|
|
|
|
// FIXME
|
|
|
|
//setFocusPolicy(QWidget::NoFocus);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QtView::allowInput() const
|
|
|
|
{
|
|
|
|
// FIXME
|
|
|
|
//setFocusPolicy(QWidget::strongFocus);
|
|
|
|
}
|