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
18 #include "support/filetools.h"
19 #include "MenuBackend.h"
20 #include "ToolbarBackend.h"
22 #include "BufferView.h"
24 #include "frontends/Toolbar.h"
25 #include "frontends/Menubar.h"
26 #include "frontends/Dialogs.h"
27 #include "frontends/Timeout.h"
29 #include <boost/bind.hpp>
32 #include "qfont_loader.h"
33 #include "QCommandBuffer.h"
34 #include "qt_helpers.h"
36 #include <qapplication.h>
40 #include <qstatusbar.h>
46 int const statusbar_timer_value = 3000;
50 #warning FIXME Current_view is used here!
51 BufferView * current_view;
53 qfont_loader fontloader;
56 QtView::QtView(unsigned int width, unsigned int height)
57 : QMainWindow(), LyXView(), commandbuffer_(0)
59 resize(width, height);
61 qApp->setMainWidget(this);
63 bufferview_.reset(new BufferView(this, 0, 0, width, height));
64 #warning FIXME Current_view is used here!
65 ::current_view = bufferview_.get();
67 menubar_.reset(new Menubar(this, menubackend));
68 toolbar_.reset(new Toolbar(this, 0, 0));
70 statusBar()->setSizeGripEnabled(false);
72 view_state_changed.connect(boost::bind(&QtView::update_view_state, this));
73 connect(&statusbar_timer_, SIGNAL(timeout()), this, SLOT(update_view_state_qt()));
75 // assign an icon to main form
76 string const iconname = LibFileSearch("images", "lyx", "xpm");
77 if (!iconname.empty())
78 setIcon(QPixmap(toqstr(iconname)));
80 // make sure the buttons are disabled if needed
83 // allowing the toolbars to tear off is too easily done,
84 // and we don't save their orientation anyway. Disable the handle.
85 setToolBarsMovable(false);
94 void QtView::setWindowTitle(string const & t, string const & it)
96 setCaption(toqstr(t));
97 setIconText(toqstr(it));
101 void QtView::addCommandBuffer(QWidget * parent)
103 commandbuffer_ = new QCommandBuffer(this, parent, *controlcommand_);
104 focus_command_buffer.connect(boost::bind(&QtView::focus_command_widget, this));
108 void QtView::message(string const & str)
110 statusBar()->message(toqstr(str));
111 statusbar_timer_.stop();
112 statusbar_timer_.start(statusbar_timer_value);
116 void QtView::clearMessage()
118 update_view_state_qt();
122 void QtView::focus_command_widget()
125 commandbuffer_->focus_command();
129 void QtView::update_view_state_qt()
131 statusBar()->message(toqstr(getLyXFunc().view_status_message()));
132 statusbar_timer_.stop();
136 void QtView::update_view_state()
138 // let the user see the explicit message
139 if (statusbar_timer_.isActive())
142 statusBar()->message(toqstr(getLyXFunc().view_status_message()));
146 void QtView::activated(int id)
148 getLyXFunc().dispatch(id, true);
152 void QtView::closeEvent(QCloseEvent *)
160 setCaption(qt_("LyX"));
165 void QtView::busy(bool yes) const
168 QApplication::setOverrideCursor(Qt::waitCursor);
170 QApplication::restoreOverrideCursor();