2002-06-19 03:38:44 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file QtView.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 03:38:44 +00:00
|
|
|
|
*
|
2003-06-10 14:39:45 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2002-10-20 01:48:28 +00:00
|
|
|
|
* \author John Levon
|
2002-09-24 13:57:09 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-06-19 03:38:44 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "lyx_cb.h"
|
|
|
|
|
#include "support/filetools.h"
|
|
|
|
|
#include "MenuBackend.h"
|
|
|
|
|
#include "lyxfunc.h"
|
|
|
|
|
#include "BufferView.h"
|
|
|
|
|
|
2002-07-19 23:04:55 +00:00
|
|
|
|
#include <boost/bind.hpp>
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
|
#include "QtView.h"
|
2003-07-25 18:10:34 +00:00
|
|
|
|
#include "QLToolbar.h"
|
2003-07-25 21:34:45 +00:00
|
|
|
|
#include "QLMenubar.h"
|
2002-06-19 03:38:44 +00:00
|
|
|
|
#include "qfont_loader.h"
|
2002-07-19 23:04:55 +00:00
|
|
|
|
#include "QCommandBuffer.h"
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
|
#include <qapplication.h>
|
2002-07-13 01:42:15 +00:00
|
|
|
|
#include <qstatusbar.h>
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
|
using lyx::support::LibFileSearch;
|
2003-06-30 23:56:22 +00:00
|
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
|
|
2002-07-22 18:22:35 +00:00
|
|
|
|
namespace {
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
2003-04-07 05:20:07 +00:00
|
|
|
|
int const statusbar_timer_value = 3000;
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
|
|
|
|
} // namespace anon
|
|
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
|
qfont_loader fontloader;
|
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
|
QtView::QtView(unsigned int width, unsigned int height)
|
2003-04-15 01:06:13 +00:00
|
|
|
|
: QMainWindow(), LyXView(), commandbuffer_(0)
|
2002-06-19 03:38:44 +00:00
|
|
|
|
{
|
|
|
|
|
resize(width, height);
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
|
qApp->setMainWidget(this);
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
2002-07-22 01:53:26 +00:00
|
|
|
|
bufferview_.reset(new BufferView(this, 0, 0, width, height));
|
|
|
|
|
|
2003-07-25 21:34:45 +00:00
|
|
|
|
menubar_.reset(new QLMenubar(this, menubackend));
|
2003-07-25 18:10:34 +00:00
|
|
|
|
toolbar_.reset(new QLToolbar(this));
|
|
|
|
|
toolbar_->init();
|
2002-06-19 03:38:44 +00:00
|
|
|
|
|
2002-07-13 01:42:15 +00:00
|
|
|
|
statusBar()->setSizeGripEnabled(false);
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
2002-07-17 04:13:41 +00:00
|
|
|
|
view_state_changed.connect(boost::bind(&QtView::update_view_state, this));
|
2003-04-07 05:20:07 +00:00
|
|
|
|
connect(&statusbar_timer_, SIGNAL(timeout()), this, SLOT(update_view_state_qt()));
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
|
|
|
|
// assign an icon to main form
|
2002-06-19 03:38:44 +00:00
|
|
|
|
string const iconname = LibFileSearch("images", "lyx", "xpm");
|
|
|
|
|
if (!iconname.empty())
|
2002-12-17 20:37:13 +00:00
|
|
|
|
setIcon(QPixmap(toqstr(iconname)));
|
2002-06-19 03:38:44 +00:00
|
|
|
|
|
|
|
|
|
// make sure the buttons are disabled if needed
|
|
|
|
|
updateToolbar();
|
2003-04-15 01:06:13 +00:00
|
|
|
|
|
|
|
|
|
// allowing the toolbars to tear off is too easily done,
|
|
|
|
|
// and we don't save their orientation anyway. Disable the handle.
|
|
|
|
|
setToolBarsMovable(false);
|
2002-06-19 03:38:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QtView::~QtView()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
|
void QtView::setWindowTitle(string const & t, string const & it)
|
|
|
|
|
{
|
|
|
|
|
setCaption(toqstr(t));
|
|
|
|
|
setIconText(toqstr(it));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-04-15 01:06:13 +00:00
|
|
|
|
void QtView::addCommandBuffer(QWidget * parent)
|
|
|
|
|
{
|
|
|
|
|
commandbuffer_ = new QCommandBuffer(this, parent, *controlcommand_);
|
|
|
|
|
focus_command_buffer.connect(boost::bind(&QtView::focus_command_widget, this));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-19 23:04:55 +00:00
|
|
|
|
void QtView::message(string const & str)
|
|
|
|
|
{
|
2002-12-17 20:37:13 +00:00
|
|
|
|
statusBar()->message(toqstr(str));
|
2003-04-07 05:20:07 +00:00
|
|
|
|
statusbar_timer_.stop();
|
|
|
|
|
statusbar_timer_.start(statusbar_timer_value);
|
2002-07-19 23:04:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
2003-04-07 16:57:38 +00:00
|
|
|
|
void QtView::clearMessage()
|
|
|
|
|
{
|
|
|
|
|
update_view_state_qt();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-19 23:04:55 +00:00
|
|
|
|
void QtView::focus_command_widget()
|
|
|
|
|
{
|
2003-04-15 01:06:13 +00:00
|
|
|
|
if (commandbuffer_)
|
|
|
|
|
commandbuffer_->focus_command();
|
2002-07-19 23:04:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QtView::update_view_state_qt()
|
|
|
|
|
{
|
2003-04-07 16:57:38 +00:00
|
|
|
|
statusBar()->message(toqstr(getLyXFunc().view_status_message()));
|
2003-04-07 05:20:07 +00:00
|
|
|
|
statusbar_timer_.stop();
|
2002-07-19 23:04:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
2002-07-17 04:13:41 +00:00
|
|
|
|
void QtView::update_view_state()
|
|
|
|
|
{
|
2003-04-07 05:20:07 +00:00
|
|
|
|
// let the user see the explicit message
|
|
|
|
|
if (statusbar_timer_.isActive())
|
2003-05-14 09:17:22 +00:00
|
|
|
|
return;
|
2003-04-07 05:20:07 +00:00
|
|
|
|
|
2003-04-07 16:57:38 +00:00
|
|
|
|
statusBar()->message(toqstr(getLyXFunc().view_status_message()));
|
2002-07-17 04:13:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-10-20 01:48:28 +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
|
|
|
|
}
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
|
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
|
void QtView::closeEvent(QCloseEvent *)
|
|
|
|
|
{
|
|
|
|
|
QuitLyX();
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
2003-01-05 22:38:42 +00:00
|
|
|
|
void QtView::show()
|
2002-06-19 03:38:44 +00:00
|
|
|
|
{
|
2003-01-05 22:38:42 +00:00
|
|
|
|
setCaption(qt_("LyX"));
|
2002-06-19 03:38:44 +00:00
|
|
|
|
QMainWindow::show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-02-14 14:49:51 +00:00
|
|
|
|
void QtView::busy(bool yes) const
|
2002-06-19 03:38:44 +00:00
|
|
|
|
{
|
2003-02-14 14:49:51 +00:00
|
|
|
|
if (yes)
|
|
|
|
|
QApplication::setOverrideCursor(Qt::waitCursor);
|
|
|
|
|
else
|
|
|
|
|
QApplication::restoreOverrideCursor();
|
2002-06-19 03:38:44 +00:00
|
|
|
|
}
|