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.
14 #include "BufferView.h"
17 #include "MenuBackend.h"
19 #include "frontends/Toolbars.h"
21 #include "support/filetools.h"
23 #include <boost/bind.hpp>
26 #include "QLMenubar.h"
27 #include "qfont_loader.h"
28 #include "QCommandBuffer.h"
29 #include "qt_helpers.h"
31 #include <qapplication.h>
33 #include <qstatusbar.h>
35 using lyx::support::LibFileSearch;
42 int const statusbar_timer_value = 3000;
46 qfont_loader fontloader;
49 QtView::QtView(unsigned int width, unsigned int height)
50 : QMainWindow(), LyXView(), commandbuffer_(0)
52 resize(width, height);
54 qApp->setMainWidget(this);
56 bufferview_.reset(new BufferView(this, width, height));
58 menubar_.reset(new QLMenubar(this, menubackend));
61 statusBar()->setSizeGripEnabled(false);
63 view_state_changed.connect(boost::bind(&QtView::update_view_state, this));
64 connect(&statusbar_timer_, SIGNAL(timeout()), this, SLOT(update_view_state_qt()));
66 // assign an icon to main form
67 string const iconname = LibFileSearch("images", "lyx", "xpm");
68 if (!iconname.empty())
69 setIcon(QPixmap(toqstr(iconname)));
71 // make sure the buttons are disabled if needed
74 // allowing the toolbars to tear off is too easily done,
75 // and we don't save their orientation anyway. Disable the handle.
76 setToolBarsMovable(false);
85 void QtView::setWindowTitle(string const & t, string const & it)
87 setCaption(toqstr(t));
88 setIconText(toqstr(it));
92 void QtView::addCommandBuffer(QWidget * parent)
94 commandbuffer_ = new QCommandBuffer(this, parent, *controlcommand_);
95 focus_command_buffer.connect(boost::bind(&QtView::focus_command_widget, this));
99 void QtView::message(string const & str)
101 statusBar()->message(toqstr(str));
102 statusbar_timer_.stop();
103 statusbar_timer_.start(statusbar_timer_value);
107 void QtView::clearMessage()
109 update_view_state_qt();
113 void QtView::focus_command_widget()
116 commandbuffer_->focus_command();
120 void QtView::update_view_state_qt()
122 statusBar()->message(toqstr(getLyXFunc().viewStatusMessage()));
123 statusbar_timer_.stop();
127 void QtView::update_view_state()
129 // let the user see the explicit message
130 if (statusbar_timer_.isActive())
133 statusBar()->message(toqstr(getLyXFunc().viewStatusMessage()));
137 void QtView::activated(FuncRequest const & func)
139 getLyXFunc().dispatch(func, true);
143 void QtView::closeEvent(QCloseEvent *)
151 setCaption(qt_("LyX"));
156 void QtView::busy(bool yes) const
159 QApplication::setOverrideCursor(Qt::waitCursor);
161 QApplication::restoreOverrideCursor();