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
15 #pragma implementation
21 #include "support/filetools.h"
22 #include "MenuBackend.h"
23 #include "ToolbarDefaults.h"
25 #include "bufferview_funcs.h"
26 #include "BufferView.h"
28 #include "frontends/Toolbar.h"
29 #include "frontends/Menubar.h"
30 #include "frontends/Dialogs.h"
31 #include "frontends/Timeout.h"
33 #include <boost/bind.hpp>
36 #include "qfont_loader.h"
37 #include "QCommandBuffer.h"
38 #include "qt_helpers.h"
40 #include <qapplication.h>
43 #include <qstatusbar.h>
49 int const idle_timer_value = 3000;
53 // FIXME: this has to go away
54 BufferView * current_view;
56 qfont_loader fontloader;
59 QtView::QtView(unsigned int width, unsigned int height)
60 : QMainWindow(), LyXView()
62 resize(width, height);
64 qApp->setMainWidget(this);
66 bufferview_.reset(new BufferView(this, 0, 0, width, height));
67 ::current_view = bufferview_.get();
69 menubar_.reset(new Menubar(this, menubackend));
70 toolbar_.reset(new Toolbar(this, 0, 0, toolbardefaults));
72 statusBar()->setSizeGripEnabled(false);
74 view_state_changed.connect(boost::bind(&QtView::update_view_state, this));
75 connect(&idle_timer_, SIGNAL(timeout()), this, SLOT(update_view_state_qt()));
77 idle_timer_.start(idle_timer_value);
79 focus_command_buffer.connect(boost::bind(&QtView::focus_command_widget, this));
81 commandbuffer_ = new QCommandBuffer(this, *controlcommand_);
83 addToolBar(commandbuffer_, Bottom, true);
85 // assign an icon to main form
86 string const iconname = LibFileSearch("images", "lyx", "xpm");
87 if (!iconname.empty())
88 setIcon(QPixmap(toqstr(iconname)));
90 // make sure the buttons are disabled if needed
100 void QtView::setWindowTitle(string const & t, string const & it)
102 setCaption(toqstr(t));
103 setIconText(toqstr(it));
107 void QtView::message(string const & str)
109 statusBar()->message(toqstr(str));
111 idle_timer_.start(idle_timer_value);
115 void QtView::focus_command_widget()
117 commandbuffer_->focus_command();
121 void QtView::update_view_state_qt()
123 statusBar()->message(toqstr(currentState(view().get())));
127 void QtView::update_view_state()
129 statusBar()->message(toqstr(currentState(view().get())));
133 void QtView::activated(int id)
135 getLyXFunc().dispatch(id, true);
139 void QtView::closeEvent(QCloseEvent *)
147 setCaption(qt_("LyX"));
152 // it's not at all clear that these are actually
153 // needed anywhere in the source. Something to
154 // check on a rainy day.
155 void QtView::prohibitInput() const
157 //setFocusPolicy(QWidget::NoFocus);
161 void QtView::allowInput() const
163 //setFocusPolicy(QWidget::strongFocus);