]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QtView.C
dispatch changes ...
[lyx.git] / src / frontends / qt2 / QtView.C
1 /**
2  * \file QtView.C
3  * Copyright 1995-2002 the LyX Team
4  * Read the file COPYING
5  *
6  * \author Lars Gullik Bjornes <larsbj@lyx.org>
7  * \author John Levon <moz@compsoc.man.ac.uk>
8  */
9
10 #include <config.h>
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include "debug.h"
17 #include "intl.h"
18 #include "lyx_cb.h"
19 #include "support/filetools.h"
20 #include "MenuBackend.h"
21 #include "QMiniBuffer.h"
22 #include "ToolbarDefaults.h"
23 #include "lyxfunc.h"
24 #include "bufferview_funcs.h"
25 #include "BufferView.h"
26
27 #include "frontends/Toolbar.h"
28 #include "frontends/Menubar.h"
29 #include "frontends/Dialogs.h"
30 #include "frontends/Timeout.h"
31  
32 #include "QtView.h"
33 #include "qfont_loader.h"
34  
35 #include <qapplication.h>
36 #include <qpixmap.h>
37 #include <qmenubar.h>
38 #include <qstatusbar.h>
39  
40 #include <boost/bind.hpp>
41  
42 using std::endl;
43
44 // FIXME: this has to go away
45 BufferView * current_view;
46
47 qfont_loader fontloader;
48
49 QtView::QtView(unsigned int width, unsigned int height)
50         : QMainWindow(), LyXView()
51 {
52         resize(width, height);
53  
54         qApp->setMainWidget(this);
55  
56         menubar_.reset(new Menubar(this, menubackend));
57
58         connect(menuBar(), SIGNAL(activated(int)),
59                 this, SLOT(activated(int)));
60  
61         toolbar_.reset(new Toolbar(this, *getDialogs(), 0, 0, toolbardefaults));
62         toolbar_->set(true);
63
64         statusBar()->setSizeGripEnabled(false);
65  
66         minibuffer_.reset(new QMiniBuffer(this)); 
67  
68         bufferview_.reset(new BufferView(this, 0, 0, width, height));
69         ::current_view = bufferview_.get();
70
71         view_state_changed.connect(boost::bind(&QtView::update_view_state, this));
72  
73         // FIXME: move 
74         // FIXME autosave_timeout_->timeout.connect(SigC::slot(this, &QtView::autoSave));
75         
76         //  assign an icon to main form
77         string const iconname = LibFileSearch("images", "lyx", "xpm");
78  
79         if (!iconname.empty())
80                 setIcon(QPixmap(iconname.c_str()));
81
82         // make sure the buttons are disabled if needed
83         updateToolbar();
84 }
85
86
87 QtView::~QtView()
88 {
89 }
90
91
92 void QtView::update_view_state()
93 {
94         statusBar()->message(currentState(view()).c_str()); 
95 }
96
97  
98 void QtView::activated(int id)
99 {
100         getLyXFunc()->dispatch(id, true);
101 }
102  
103  
104 void QtView::closeEvent(QCloseEvent *)
105 {
106         QuitLyX();
107 }
108
109  
110 void QtView::show(int x, int y, string const & title)
111 {
112         move(x, y);
113         setCaption(title.c_str());
114         QMainWindow::show();
115 }
116
117
118 void QtView::prohibitInput() const
119 {
120         // FIXME
121         //setFocusPolicy(QWidget::NoFocus);
122 }
123
124
125 void QtView::allowInput() const
126 {
127         // FIXME
128         //setFocusPolicy(QWidget::strongFocus);
129 }