]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QtView.C
minor 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.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 #include <qstatusbar.h>
38  
39 using std::endl;
40
41 // FIXME: this has to go away
42 BufferView * current_view;
43
44 qfont_loader fontloader;
45
46 QtView::QtView(unsigned int width, unsigned int height)
47         : QMainWindow(), LyXView()
48 {
49         resize(width, height);
50  
51         qApp->setMainWidget(this);
52  
53         menubar_.reset(new Menubar(this, menubackend));
54
55         connect(menuBar(), SIGNAL(activated(int)),
56                 this, SLOT(activated(int)));
57  
58         toolbar_.reset(new Toolbar(this, *getDialogs(), 0, 0, toolbardefaults));
59         toolbar_->set(true);
60
61         statusBar()->setSizeGripEnabled(false);
62  
63         minibuffer_.reset(new QMiniBuffer(this)); 
64  
65         bufferview_.reset(new BufferView(this, 0, 0, width, height));
66         ::current_view = bufferview_.get();
67
68         // FIXME: move 
69         // FIXME autosave_timeout_->timeout.connect(SigC::slot(this, &QtView::autoSave));
70         
71         //  assign an icon to main form
72         string const iconname = LibFileSearch("images", "lyx", "xpm");
73  
74         if (!iconname.empty())
75                 setIcon(QPixmap(iconname.c_str()));
76
77         // make sure the buttons are disabled if needed
78         updateToolbar();
79 }
80
81
82 QtView::~QtView()
83 {
84 }
85
86
87 void QtView::activated(int id)
88 {
89         getLyXFunc()->verboseDispatch(id, true);
90 }
91  
92  
93 void QtView::closeEvent(QCloseEvent *)
94 {
95         QuitLyX();
96 }
97
98  
99 void QtView::show(int x, int y, string const & title)
100 {
101         move(x, y);
102         setCaption(title.c_str());
103         QMainWindow::show();
104 }
105
106
107 void QtView::prohibitInput() const
108 {
109         // FIXME
110         //setFocusPolicy(QWidget::NoFocus);
111 }
112
113
114 void QtView::allowInput() const
115 {
116         // FIXME
117         //setFocusPolicy(QWidget::strongFocus);
118 }