1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
#include "tikzit.h"
#include <QFileDialog>
#include <QSettings>
// application-level instance of Tikzit
Tikzit *tikzit;
// font to use for node labels
QFont Tikzit::LABEL_FONT("Courrier", 9);
Tikzit::Tikzit()
{
_mainMenu = new MainMenu();
_activeWindow = 0;
QMainWindow *dummy = new QMainWindow();
_toolPalette = new ToolPalette(dummy);
_propertyPalette = new PropertyPalette(dummy);
loadStyles();
_toolPalette->show();
_propertyPalette->show();
_windows << new MainWindow();
_windows[0]->show();
}
//QMenuBar *Tikzit::mainMenu() const
//{
// return _mainMenu;
//}
ToolPalette *Tikzit::toolPalette() const
{
return _toolPalette;
}
PropertyPalette *Tikzit::propertyPalette() const
{
return _propertyPalette;
}
void Tikzit::loadStyles()
{
_nodeStyles << new NodeStyle("black dot", NodeShape::Circle, Qt::black, Qt::black, 1);
_nodeStyles << new NodeStyle("white dot", NodeShape::Circle, Qt::white, Qt::black, 1);
_nodeStyles << new NodeStyle("gray dot", NodeShape::Circle, Qt::gray, Qt::black, 1);
}
void Tikzit::newDoc()
{
MainWindow *w = new MainWindow();
w->show();
_windows << w;
}
MainWindow *Tikzit::activeWindow() const
{
return _activeWindow;
}
void Tikzit::setActiveWindow(MainWindow *activeWindow)
{
_activeWindow = activeWindow;
}
void Tikzit::removeWindow(MainWindow *w)
{
_windows.removeAll(w);
if (_activeWindow == w) {
if (_windows.isEmpty()) _activeWindow = 0;
else _activeWindow = _windows[0];
}
}
NodeStyle *Tikzit::nodeStyle(QString name)
{
foreach (NodeStyle *s , _nodeStyles)
if (s->name == name) return s;
return noneStyle; //NodeStyle(name, NodeShape::Circle, Qt::white);
}
void Tikzit::open()
{
QSettings settings("tikzit", "tikzit");
QString fileName = QFileDialog::getOpenFileName(0,
tr("Open File"),
settings.value("previous-file-path").toString(),
tr("TiKZ Files (*.tikz)"));
if (!fileName.isEmpty()) {
if (_windows.size() == 1 && _windows[0]->pristine()) {
_windows[0]->open(fileName);
_windows[0]->show();
} else {
MainWindow *w = new MainWindow();
w->show();
w->open(fileName);
_windows << w;
}
}
}
|