3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
9 * Full author contact details are available in file CREDITS.
15 #include "support/filetools.h"
16 #include "MenuBackend.h"
18 #include "BufferView.h"
20 #include <boost/bind.hpp>
23 #include "QLToolbar.h"
24 #include "QLMenubar.h"
25 #include "qfont_loader.h"
26 #include "QCommandBuffer.h"
28 #include <qapplication.h>
29 #include <qstatusbar.h>
31 using lyx::support::LibFileSearch;
38 int const statusbar_timer_value = 3000;
42 qfont_loader fontloader;
45 QtView::QtView(unsigned int width, unsigned int height)
46 : QMainWindow(), LyXView(), commandbuffer_(0)
48 resize(width, height);
50 qApp->setMainWidget(this);
52 bufferview_.reset(new BufferView(this, 0, 0, width, height));
54 menubar_.reset(new QLMenubar(this, menubackend));
55 toolbar_.reset(new QLToolbar(this));
58 statusBar()->setSizeGripEnabled(false);
60 view_state_changed.connect(boost::bind(&QtView::update_view_state, this));
61 connect(&statusbar_timer_, SIGNAL(timeout()), this, SLOT(update_view_state_qt()));
63 // assign an icon to main form
64 string const iconname = LibFileSearch("images", "lyx", "xpm");
65 if (!iconname.empty())
66 setIcon(QPixmap(toqstr(iconname)));
68 // make sure the buttons are disabled if needed
71 // allowing the toolbars to tear off is too easily done,
72 // and we don't save their orientation anyway. Disable the handle.
73 setToolBarsMovable(false);
82 void QtView::setWindowTitle(string const & t, string const & it)
84 setCaption(toqstr(t));
85 setIconText(toqstr(it));
89 void QtView::addCommandBuffer(QWidget * parent)
91 commandbuffer_ = new QCommandBuffer(this, parent, *controlcommand_);
92 focus_command_buffer.connect(boost::bind(&QtView::focus_command_widget, this));
96 void QtView::message(string const & str)
98 statusBar()->message(toqstr(str));
99 statusbar_timer_.stop();
100 statusbar_timer_.start(statusbar_timer_value);
104 void QtView::clearMessage()
106 update_view_state_qt();
110 void QtView::focus_command_widget()
113 commandbuffer_->focus_command();
117 void QtView::update_view_state_qt()
119 statusBar()->message(toqstr(getLyXFunc().view_status_message()));
120 statusbar_timer_.stop();
124 void QtView::update_view_state()
126 // let the user see the explicit message
127 if (statusbar_timer_.isActive())
130 statusBar()->message(toqstr(getLyXFunc().view_status_message()));
134 void QtView::activated(FuncRequest const & func)
136 getLyXFunc().dispatch(func, true);
140 void QtView::closeEvent(QCloseEvent *)
148 setCaption(qt_("LyX"));
153 void QtView::busy(bool yes) const
156 QApplication::setOverrideCursor(Qt::waitCursor);
158 QApplication::restoreOverrideCursor();