Program Listing for File maestrodrawingareadialog.cpp¶
↰ Return to documentation for file (src/dialog/maestrodrawingareadialog.cpp
)
#include "maestrodrawingareadialog.h"
#include "ui_maestrodrawingareadialog.h"
#include <QEvent>
#include <QKeyEvent>
using namespace PixelMaestro;
namespace PixelMaestroStudio {
MaestroDrawingAreaDialog::MaestroDrawingAreaDialog(QWidget *parent, MaestroController& maestro_controller) :
QDialog(parent),
ui(new Ui::MaestroDrawingAreaDialog),
maestro_controller_(maestro_controller) {
setWindowIcon(QIcon("qrc:/../../../docsrc/images/logo.png"));
// Capture button key presses
qApp->installEventFilter(this);
ui->setupUi(this);
QLayout* layout = this->findChild<QLayout*>("maestroLayout");
drawing_area_ = QSharedPointer<MaestroDrawingArea>(new MaestroDrawingArea(layout->widget(), maestro_controller_));
drawing_area_->set_maestro_control_widget(dynamic_cast<MaestroControlWidget*>(parent));
layout->addWidget(drawing_area_.data());
this->setWindowFlags(Qt::Window);
}
bool MaestroDrawingAreaDialog::eventFilter(QObject *watched, QEvent *event) {
if (event->type() == QEvent::KeyPress) {
QKeyEvent* key_event = dynamic_cast<QKeyEvent*>(event);
if (key_event->key() == Qt::Key_F11) {
if (this->isFullScreen()) {
this->showNormal();
}
else {
this->showFullScreen();
}
return true;
}
}
return QObject::eventFilter(watched, event);
}
MaestroDrawingArea& MaestroDrawingAreaDialog::get_maestro_drawing_area() {
return *this->drawing_area_.get();
}
MaestroDrawingAreaDialog::~MaestroDrawingAreaDialog() {
qApp->removeEventFilter(this);
delete ui;
}
}