commit
aa6bddb0e4
@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.6)
|
|||||||
project(ESGRAF48 LANGUAGES CXX)
|
project(ESGRAF48 LANGUAGES CXX)
|
||||||
|
|
||||||
find_package(Qt5Widgets REQUIRED)
|
find_package(Qt5Widgets REQUIRED)
|
||||||
|
find_package(Qt5PrintSupport REQUIRED)
|
||||||
|
|
||||||
set(CMAKE_AUTOMOC ON)
|
set(CMAKE_AUTOMOC ON)
|
||||||
set(CMAKE_AUTORCC ON)
|
set(CMAKE_AUTORCC ON)
|
||||||
@ -45,9 +46,10 @@ target_link_libraries(${PROJECT_NAME}
|
|||||||
Genus
|
Genus
|
||||||
AkkusativDativ
|
AkkusativDativ
|
||||||
V2Svk
|
V2Svk
|
||||||
LateSkills
|
LateSkills
|
||||||
ResultWidget
|
ResultWidget
|
||||||
Qt5::Widgets
|
Qt5::Widgets
|
||||||
|
Qt5::PrintSupport
|
||||||
)
|
)
|
||||||
|
|
||||||
add_subdirectory(CheckableItem)
|
add_subdirectory(CheckableItem)
|
||||||
|
BIN
source/images/document-print.png
Normal file
BIN
source/images/document-print.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 818 B |
@ -10,20 +10,21 @@
|
|||||||
#include <QDataWidgetMapper>
|
#include <QDataWidgetMapper>
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QtPrintSupport/QPrinter>
|
||||||
|
#include <QtPrintSupport/QPrintDialog>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
, ui(new Ui::MainWindow)
|
, ui(new Ui::MainWindow)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
connect(ui->actionNew, &QAction::triggered, this, &MainWindow::newFile);
|
connect(ui->actionNew, &QAction::triggered, this, &MainWindow::newFile);
|
||||||
connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::openFile);
|
connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::openFile);
|
||||||
connect(ui->actionSave, &QAction::triggered, this,
|
connect(ui->actionSave, &QAction::triggered, this, qOverload<>(&MainWindow::saveFile));
|
||||||
qOverload<>(&MainWindow::saveFile));
|
connect(ui->actionSave_as, &QAction::triggered, this, &MainWindow::saveFileAs);
|
||||||
connect(
|
connect(ui->actionPrint, &QAction::triggered, this, &MainWindow::print);
|
||||||
ui->actionSave_as, &QAction::triggered, this, &MainWindow::saveFileAs);
|
|
||||||
|
|
||||||
newFile();
|
newFile();
|
||||||
}
|
}
|
||||||
@ -50,8 +51,7 @@ void MainWindow::newFile()
|
|||||||
|
|
||||||
ui->resultWidget->setModel(&m_dataModel->m_results);
|
ui->resultWidget->setModel(&m_dataModel->m_results);
|
||||||
|
|
||||||
connect(&*m_dataModel, &DataModel::modelChanged, this,
|
connect(&*m_dataModel, &DataModel::modelChanged, this, &MainWindow::dataModelChanged);
|
||||||
&MainWindow::dataModelChanged);
|
|
||||||
|
|
||||||
setWindowModified(false);
|
setWindowModified(false);
|
||||||
setWindowTitle("untitled[*]");
|
setWindowTitle("untitled[*]");
|
||||||
@ -61,8 +61,8 @@ void MainWindow::newFile()
|
|||||||
|
|
||||||
void MainWindow::openFile()
|
void MainWindow::openFile()
|
||||||
{
|
{
|
||||||
QString filename = QFileDialog::getOpenFileName(
|
QString filename =
|
||||||
this, "Open file", "", "ESGRAF 4-8 (*.esgraf48)");
|
QFileDialog::getOpenFileName(this, "Open file", "", "ESGRAF 4-8 (*.esgraf48)");
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -104,8 +104,8 @@ void MainWindow::saveFile()
|
|||||||
|
|
||||||
void MainWindow::saveFileAs()
|
void MainWindow::saveFileAs()
|
||||||
{
|
{
|
||||||
QString filename = QFileDialog::getSaveFileName(
|
QString filename =
|
||||||
this, "Save file", "", "ESGRAF 4-8 (*.esgraf48)");
|
QFileDialog::getSaveFileName(this, "Save file", "", "ESGRAF 4-8 (*.esgraf48)");
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -131,6 +131,14 @@ void MainWindow::closeFile()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::print() const
|
||||||
|
{
|
||||||
|
QPrinter printer;
|
||||||
|
|
||||||
|
QPrintDialog dialog(&printer);
|
||||||
|
dialog.exec();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::dataModelChanged()
|
void MainWindow::dataModelChanged()
|
||||||
{
|
{
|
||||||
m_saveOnClose = true;
|
m_saveOnClose = true;
|
||||||
|
@ -18,7 +18,7 @@ class MainWindow : public QMainWindow
|
|||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
std::unique_ptr<DataModel> m_dataModel;
|
std::unique_ptr<DataModel> m_dataModel;
|
||||||
QString m_filename;
|
QString m_filename;
|
||||||
bool m_saveOnClose = false;
|
bool m_saveOnClose = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -28,14 +28,15 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void newFile();
|
void newFile();
|
||||||
void openFile();
|
void openFile();
|
||||||
void saveFile();
|
void saveFile();
|
||||||
void saveFileAs();
|
void saveFileAs();
|
||||||
void closeFile();
|
void closeFile();
|
||||||
|
void print() const;
|
||||||
void dataModelChanged();
|
void dataModelChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void saveFile(const QString &filename);
|
void saveFile(const QString &filename);
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource>
|
<qresource>
|
||||||
|
<file>images/document-print.png</file>
|
||||||
<file>images/document-new.png</file>
|
<file>images/document-new.png</file>
|
||||||
<file>images/document-open.png</file>
|
<file>images/document-open.png</file>
|
||||||
<file>images/document-save-as.png</file>
|
<file>images/document-save-as.png</file>
|
||||||
|
@ -132,6 +132,8 @@
|
|||||||
<addaction name="actionSave"/>
|
<addaction name="actionSave"/>
|
||||||
<addaction name="actionSave_as"/>
|
<addaction name="actionSave_as"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionPrint"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
<addaction name="actionQuit"/>
|
<addaction name="actionQuit"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="menuFile"/>
|
<addaction name="menuFile"/>
|
||||||
@ -149,6 +151,8 @@
|
|||||||
<addaction name="actionNew"/>
|
<addaction name="actionNew"/>
|
||||||
<addaction name="actionOpen"/>
|
<addaction name="actionOpen"/>
|
||||||
<addaction name="actionSave"/>
|
<addaction name="actionSave"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionPrint"/>
|
||||||
</widget>
|
</widget>
|
||||||
<action name="actionSave_as">
|
<action name="actionSave_as">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
@ -209,6 +213,21 @@
|
|||||||
<string>Ctrl+S</string>
|
<string>Ctrl+S</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionPrint">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="mainwindow.qrc">
|
||||||
|
<normaloff>:/images/document-print.png</normaloff>:/images/document-print.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Print</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Print</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+P</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
Reference in New Issue
Block a user