]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QtView.C
Compile fixes. Qt2 should now build (and fail immediately when you start it,
[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.h"
25
26 #include "frontends/Toolbar.h"
27 #include "frontends/Menubar.h"
28 #include "frontends/Dialogs.h"
29 #include "frontends/Timeout.h"
30  
31 #include "QtView.h"
32 #include "qfont_loader.h"
33  
34 #include <qapplication.h>
35 #include <qpixmap.h>
36 #include <qmenubar.h>
37  
38 using std::endl;
39
40 // FIXME: this has to go away
41 BufferView * current_view;
42
43 qfont_loader fontloader;
44
45 QtView::QtView(unsigned int width, unsigned int height)
46         : QMainWindow(), LyXView()
47 {
48         resize(width, height);
49  
50         qApp->setMainWidget(this);
51  
52         menubar_.reset(new Menubar(this, menubackend));
53
54         connect(menuBar(), SIGNAL(activated(int)),
55                 this, SLOT(activated(int)));
56  
57         toolbar_.reset(new Toolbar(this, *getDialogs(), 0, 0, toolbardefaults));
58         toolbar_->set(true);
59
60         minibuffer_.reset(new QMiniBuffer(this)); 
61  
62         bufferview_.reset(new BufferView(this, 0, 0, width, height));
63         ::current_view = bufferview_.get();
64
65         // FIXME: move 
66         // FIXME autosave_timeout_->timeout.connect(SigC::slot(this, &QtView::autoSave));
67         
68         //  assign an icon to main form
69         string const iconname = LibFileSearch("images", "lyx", "xpm");
70  
71         if (!iconname.empty())
72                 setIcon(QPixmap(iconname.c_str()));
73
74         // make sure the buttons are disabled if needed
75         updateToolbar();
76 }
77
78
79 QtView::~QtView()
80 {
81 }
82
83
84 void QtView::activated(int id)
85 {
86         getLyXFunc()->verboseDispatch(id, true);
87 }
88  
89  
90 void QtView::closeEvent(QCloseEvent *)
91 {
92         QuitLyX();
93 }
94
95  
96 void QtView::redraw() 
97 {
98         // FIXME: does this make any sense for us ? 
99         repaint();
100 }
101
102
103 void QtView::setPosition(unsigned int x, unsigned int y)
104 {
105         move(x, y);
106 }
107
108
109 void QtView::show(int, int, string const & title)
110 {
111         setCaption(title.c_str());
112         QMainWindow::show();
113 }
114
115
116 void QtView::prohibitInput() const
117 {
118         // FIXME
119         //setFocusPolicy(QWidget::NoFocus);
120 }
121
122
123 void QtView::allowInput() const
124 {
125         // FIXME
126         //setFocusPolicy(QWidget::strongFocus);
127 }