-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapplication_window.cpp
87 lines (69 loc) · 2.21 KB
/
application_window.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
#include <QPushButton>
#include <QVBoxLayout>
#include <QFileDialog>
#include <QTextCursor>
#include <QTextStream>
#include <QApplication>
#include <QFile>
#include <QIODevice>
#include "application_window.h"
#include "controls_menu.h"
#include "menubar.h"
ApplicationWindow::ApplicationWindow(QWidget *parent)
: QWidget(parent)
{
teleWindow = new TeleprompterWindow(0,this);
teleWindow->setWindowTitle("JoyPrompter - Full Screen");
this->setAcceptDrops(true);
QPushButton *fullScreen = new QPushButton("Start Prompt", this);
fullScreen->setGeometry(50,40,75,30);
QVBoxLayout *layout = new QVBoxLayout(this);
optionBar = new ControlsMenu();
edit = new EditorWindow(this);
layout->addLayout(optionBar,0);
layout->addWidget(edit, 0);
layout->addWidget(fullScreen, 0);
MenuBar *menu = new MenuBar(this);
layout->setMenuBar(menu);
connect(fullScreen, SIGNAL(clicked()), this, SLOT(goToPrompt()));
}
void ApplicationWindow::goToPrompt()
{
teleWindow->setFontPointSize(this->optionBar->sizebox->currentText().toInt());
teleWindow->setPlainText(this->edit->toPlainText());
teleWindow->setPadding(this->optionBar->padding->value());
teleWindow->selectAll();
teleWindow->setAlignment(Qt::AlignCenter);
QTextCursor cursor = teleWindow->textCursor();
cursor.clearSelection();
cursor.setPosition(0,QTextCursor::MoveAnchor);
teleWindow->setTextCursor(cursor);
teleWindow->setReadOnly(true);
//teleWindow->show();
teleWindow->showFullScreen();
teleWindow->setFocus();
teleWindow->setCursor(QCursor(Qt::BlankCursor));
this->hide();
}
void ApplicationWindow::getFile()
{
QFileDialog::getOpenFileName(this, tr("Open File"), ".", tr("Image Files (*.png *.jpg *.bmp)"));
}
void ApplicationWindow::saveFile()
{
QString filename = QFileDialog::getSaveFileName(this, tr("Save File"), ".", tr("Text File (*.jyp)"));
QFile file( filename );
file.open(QIODevice::WriteOnly | QFile::Text);
QTextStream out(&file);
QApplication::setOverrideCursor(Qt::WaitCursor);
out << this->edit->toPlainText();
QApplication::restoreOverrideCursor();
file.close();
}
void ApplicationWindow::dragEnterEvent(QDragEnterEvent *event)
{
event->accept();
}
void ApplicationWindow::dropEvent(QDropEvent *event){
this->edit->dropEvent(event);
}