3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjornes
9 * Full author contact details are available in file CREDITS
18 #include "support/filetools.h"
19 #include "MenuBackend.h"
20 #include "ToolbarDefaults.h"
22 #include "bufferview_funcs.h"
23 #include "BufferView.h"
25 #include "frontends/Toolbar.h"
26 #include "frontends/Menubar.h"
27 #include "frontends/Dialogs.h"
28 #include "frontends/Timeout.h"
30 #include <boost/bind.hpp>
33 #include "qfont_loader.h"
34 #include "QCommandBuffer.h"
35 #include "qt_helpers.h"
37 #include <qapplication.h>
40 #include <qstatusbar.h>
46 int const idle_timer_value = 3000;
50 // FIXME: this has to go away
51 BufferView * current_view;
53 qfont_loader fontloader;
56 QtView::QtView(unsigned int width, unsigned int height)
57 : QMainWindow(), LyXView()
59 resize(width, height);
61 qApp->setMainWidget(this);
63 bufferview_.reset(new BufferView(this, 0, 0, width, height));
64 ::current_view = bufferview_.get();
66 menubar_.reset(new Menubar(this, menubackend));
67 toolbar_.reset(new Toolbar(this, 0, 0, toolbardefaults));
69 statusBar()->setSizeGripEnabled(false);
71 view_state_changed.connect(boost::bind(&QtView::update_view_state, this));
72 connect(&idle_timer_, SIGNAL(timeout()), this, SLOT(update_view_state_qt()));
74 idle_timer_.start(idle_timer_value);
76 focus_command_buffer.connect(boost::bind(&QtView::focus_command_widget, this));
78 commandbuffer_ = new QCommandBuffer(this, *controlcommand_);
80 addToolBar(commandbuffer_, Bottom, true);
82 // assign an icon to main form
83 string const iconname = LibFileSearch("images", "lyx", "xpm");
84 if (!iconname.empty())
85 setIcon(QPixmap(toqstr(iconname)));
87 // make sure the buttons are disabled if needed
97 void QtView::setWindowTitle(string const & t, string const & it)
99 setCaption(toqstr(t));
100 setIconText(toqstr(it));
104 void QtView::message(string const & str)
106 statusBar()->message(toqstr(str));
108 idle_timer_.start(idle_timer_value);
112 void QtView::focus_command_widget()
114 commandbuffer_->focus_command();
118 void QtView::update_view_state_qt()
120 statusBar()->message(toqstr(currentState(view().get())));
124 void QtView::update_view_state()
126 statusBar()->message(toqstr(currentState(view().get())));
130 void QtView::activated(int id)
132 getLyXFunc().dispatch(id, true);
136 void QtView::closeEvent(QCloseEvent *)
144 setCaption(qt_("LyX"));
149 // it's not at all clear that these are actually
150 // needed anywhere in the source. Something to
151 // check on a rainy day.
152 void QtView::prohibitInput() const
154 //setFocusPolicy(QWidget::NoFocus);
158 void QtView::allowInput() const
160 //setFocusPolicy(QWidget::strongFocus);