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>
44 // FIXME: this has to go away
45 BufferView * current_view;
47 qfont_loader fontloader;
49 QtView::QtView(unsigned int width, unsigned int height)
50 : QMainWindow(), LyXView()
52 resize(width, height);
54 qApp->setMainWidget(this);
56 menubar_.reset(new Menubar(this, menubackend));
58 connect(menuBar(), SIGNAL(activated(int)),
59 this, SLOT(activated(int)));
61 toolbar_.reset(new Toolbar(this, *getDialogs(), 0, 0, toolbardefaults));
64 statusBar()->setSizeGripEnabled(false);
66 bufferview_.reset(new BufferView(this, 0, 0, width, height));
67 ::current_view = bufferview_.get();
69 view_state_changed.connect(boost::bind(&QtView::update_view_state, this));
70 connect(&idle_timer_, SIGNAL(timeout()), this, SLOT(update_view_state_qt()));
72 idle_timer_.start(3000);
74 focus_command_buffer.connect(boost::bind(&QtView::focus_command_widget, this));
76 commandbuffer_ = new QCommandBuffer(this, *controlcommand_);
78 addToolBar(commandbuffer_, Bottom, true);
81 // FIXME autosave_timeout_->timeout.connect(SigC::slot(this, &QtView::autoSave));
83 // assign an icon to main form
84 string const iconname = LibFileSearch("images", "lyx", "xpm");
86 if (!iconname.empty())
87 setIcon(QPixmap(iconname.c_str()));
89 // make sure the buttons are disabled if needed
99 void QtView::message(string const & str)
101 statusBar()->message(str.c_str());
105 void QtView::focus_command_widget()
107 commandbuffer_->focus_command();
111 void QtView::update_view_state_qt()
113 message(currentState(view()));
117 void QtView::update_view_state()
119 message(currentState(view()));
123 void QtView::activated(int id)
125 getLyXFunc()->dispatch(id, true);
129 void QtView::closeEvent(QCloseEvent *)
135 void QtView::show(int x, int y, string const & title)
138 setCaption(title.c_str());
143 void QtView::prohibitInput() const
146 //setFocusPolicy(QWidget::NoFocus);
150 void QtView::allowInput() const
153 //setFocusPolicy(QWidget::strongFocus);