3 * Copyright 1995-2002 the LyX Team
4 * Read the file COPYING
6 * \author Lars Gullik Bjornes <larsbj@lyx.org>
7 * \author John Levon <moz@compsoc.man.ac.uk>
13 #pragma implementation
19 #include "support/filetools.h"
20 #include "MenuBackend.h"
21 #include "ToolbarDefaults.h"
23 #include "bufferview_funcs.h"
24 #include "BufferView.h"
26 #include "frontends/Toolbar.h"
27 #include "frontends/Menubar.h"
28 #include "frontends/Dialogs.h"
29 #include "frontends/Timeout.h"
31 #include <boost/bind.hpp>
34 #include "qfont_loader.h"
35 #include "QCommandBuffer.h"
37 #include <qapplication.h>
40 #include <qstatusbar.h>
45 int const idle_timer_value = 3000;
48 // FIXME: this has to go away
49 BufferView * current_view;
51 qfont_loader fontloader;
53 QtView::QtView(unsigned int width, unsigned int height)
54 : QMainWindow(), LyXView()
56 resize(width, height);
58 qApp->setMainWidget(this);
60 bufferview_.reset(new BufferView(this, 0, 0, width, height));
61 ::current_view = bufferview_.get();
63 menubar_.reset(new Menubar(this, menubackend));
64 toolbar_.reset(new Toolbar(this, 0, 0, toolbardefaults));
66 statusBar()->setSizeGripEnabled(false);
68 view_state_changed.connect(boost::bind(&QtView::update_view_state, this));
69 connect(&idle_timer_, SIGNAL(timeout()), this, SLOT(update_view_state_qt()));
71 idle_timer_.start(idle_timer_value);
73 focus_command_buffer.connect(boost::bind(&QtView::focus_command_widget, this));
75 commandbuffer_ = new QCommandBuffer(this, *controlcommand_);
77 addToolBar(commandbuffer_, Bottom, true);
79 // assign an icon to main form
80 string const iconname = LibFileSearch("images", "lyx", "xpm");
81 if (!iconname.empty())
82 setIcon(QPixmap(iconname.c_str()));
84 // make sure the buttons are disabled if needed
94 void QtView::message(string const & str)
96 statusBar()->message(str.c_str());
98 idle_timer_.start(idle_timer_value);
102 void QtView::focus_command_widget()
104 commandbuffer_->focus_command();
108 void QtView::update_view_state_qt()
110 statusBar()->message(currentState(view().get()).c_str());
114 void QtView::update_view_state()
116 statusBar()->message(currentState(view().get()).c_str());
120 void QtView::activated(int id)
122 getLyXFunc().dispatch(id, true);
126 void QtView::closeEvent(QCloseEvent *)
132 void QtView::show(int x, int y, string const & title)
135 setCaption(title.c_str());
140 // it's not at all clear that these are actually
141 // needed anywhere in the source. Something to
142 // check on a rainy day.
143 void QtView::prohibitInput() const
145 //setFocusPolicy(QWidget::NoFocus);
149 void QtView::allowInput() const
151 //setFocusPolicy(QWidget::strongFocus);