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>
37 qfont_loader fontloader;
41 using support::LibFileSearch;
47 int const statusbar_timer_value = 3000;
53 QtView::QtView(unsigned int width, unsigned int height)
54 : QMainWindow(), LyXView(), commandbuffer_(0)
56 resize(width, height);
58 qApp->setMainWidget(this);
60 bufferview_.reset(new BufferView(this, width, height));
62 menubar_.reset(new QLMenubar(this, menubackend));
65 statusBar()->setSizeGripEnabled(false);
67 view_state_changed.connect(boost::bind(&QtView::update_view_state, this));
68 connect(&statusbar_timer_, SIGNAL(timeout()), this, SLOT(update_view_state_qt()));
70 // assign an icon to main form
71 string const iconname = LibFileSearch("images", "lyx", "xpm");
72 if (!iconname.empty())
73 setIcon(QPixmap(toqstr(iconname)));
75 // make sure the buttons are disabled if needed
78 // allowing the toolbars to tear off is too easily done,
79 // and we don't save their orientation anyway. Disable the handle.
80 setToolBarsMovable(false);
89 void QtView::setWindowTitle(string const & t, string const & it)
91 setCaption(toqstr(t));
92 setIconText(toqstr(it));
96 void QtView::addCommandBuffer(QWidget * parent)
98 commandbuffer_ = new QCommandBuffer(this, parent, *controlcommand_);
99 focus_command_buffer.connect(boost::bind(&QtView::focus_command_widget, this));
103 void QtView::message(string const & str)
105 statusBar()->message(toqstr(str));
106 statusbar_timer_.stop();
107 statusbar_timer_.start(statusbar_timer_value);
111 void QtView::clearMessage()
113 update_view_state_qt();
117 void QtView::focus_command_widget()
120 commandbuffer_->focus_command();
124 void QtView::update_view_state_qt()
126 statusBar()->message(toqstr(getLyXFunc().viewStatusMessage()));
127 statusbar_timer_.stop();
131 void QtView::update_view_state()
133 // let the user see the explicit message
134 if (statusbar_timer_.isActive())
137 statusBar()->message(toqstr(getLyXFunc().viewStatusMessage()));
141 void QtView::activated(FuncRequest const & func)
143 getLyXFunc().dispatch(func);
147 bool QtView::hasFocus() const
149 return qApp->activeWindow() == this;
153 void QtView::closeEvent(QCloseEvent *)
161 setCaption(qt_("LyX"));
166 void QtView::busy(bool yes) const
169 QApplication::setOverrideCursor(Qt::waitCursor);
171 QApplication::restoreOverrideCursor();
174 } // namespace frontend