-
Notifications
You must be signed in to change notification settings - Fork 0
/
elmo.cpp
91 lines (80 loc) · 2.87 KB
/
elmo.cpp
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
#include <QDebug>
#include <QFileDialog>
#include <QGraphicsView>
#include <QGraphicsPixmapItem>
#include "elmo.h"
#include "ui_elmo.h"
Elmo::Elmo(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Elmo),
shortcuts(new QList<QShortcut*>),
projects(new QList<Project*>),
lastSaveFilename("")
{
ui->setupUi(this);
QShortcut * shortcut = new QShortcut(QKeySequence(tr("Ctrl+L", "File|actionOpen")), this);
shortcut->setContext(Qt::ApplicationShortcut);
connect(shortcut, SIGNAL(activated()), this, SLOT(on_actionOpen_triggered()));
shortcuts->push_back(shortcut);
shortcut = new QShortcut(QKeySequence(tr("Ctrl+S", "File|actionSave")), this);
shortcut->setContext(Qt::ApplicationShortcut);
connect(shortcut, SIGNAL(activated()), this, SLOT(on_actionSave_triggered()));
shortcuts->push_back(shortcut);
shortcut = new QShortcut(QKeySequence(tr("Ctrl+N", "File|actionNew")), this);
shortcut->setContext(Qt::ApplicationShortcut);
connect(shortcut, SIGNAL(activated()), this, SLOT(on_actionNew_triggered()));
shortcuts->push_back(shortcut);
shortcut = new QShortcut(QKeySequence(tr("Ctrl+Shift+S", "File|actionSave_as")), this);
shortcut->setContext(Qt::ApplicationShortcut);
connect(shortcut, SIGNAL(activated()), this, SLOT(on_actionSaveAs_triggered()));
shortcuts->push_back(shortcut);
shortcut = new QShortcut(QKeySequence(tr("Ctrl+O", "File|actionAdd")), this);
shortcut->setContext(Qt::ApplicationShortcut);
connect(shortcut, SIGNAL(activated()), this, SLOT(on_actionAdd_triggered()));
shortcuts->push_back(shortcut);
QImage image("/home/cerkiewny/test.png");
QGraphicsView* view = findChild<QGraphicsView*>("mainView");
QGraphicsScene* scene = new QGraphicsScene();
QGraphicsPixmapItem * item = new QGraphicsPixmapItem( QPixmap::fromImage(image));
scene->addItem(item);
view->setScene(scene);
view->show();
}
Elmo::~Elmo()
{
delete ui;
delete shortcuts;
}
void Elmo::on_actionOpen_triggered()
{
lastSaveFilename = QFileDialog::getOpenFileName(this, tr("Open File"), "", tr("Files (*.csv)"));
projects->clear();
projects->push_back(new Project(lastSaveFilename));
return;
}
void Elmo::on_actionSave_triggered()
{
if(lastSaveFilename != ""){
lastSaveFilename = QFileDialog::getSaveFileName(this, tr("Open File"), "", tr("Files (*.csv)"));
}
else{
//TODO add save later
}
return;
}
void Elmo::on_actionNew_triggered(){
projects->clear();
lastSaveFilename = "";
return;
}
void Elmo::on_actionAdd_triggered(){
lastSaveFilename = "";
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "", tr("Files (*.csv)"));
return;
}
void Elmo::on_actionSaveAs_triggered()
{
lastSaveFilename = QFileDialog::getSaveFileName(this, tr("Open File"), "", tr("Files (*.csv)"));
qDebug("lulz");
return;
}