Implemented print dialog, no printing yet
This commit is contained in:
parent
4524cfa76d
commit
3626f72fbd
6 changed files with 47 additions and 16 deletions
|
@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.6)
|
|||
project(ESGRAF48 LANGUAGES CXX)
|
||||
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
find_package(Qt5PrintSupport REQUIRED)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
@ -48,6 +49,7 @@ target_link_libraries(${PROJECT_NAME}
|
|||
LateSkills
|
||||
ResultWidget
|
||||
Qt5::Widgets
|
||||
Qt5::PrintSupport
|
||||
)
|
||||
|
||||
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,6 +10,8 @@
|
|||
#include <QDataWidgetMapper>
|
||||
#include <QCloseEvent>
|
||||
#include <QMessageBox>
|
||||
#include <QtPrintSupport/QPrinter>
|
||||
#include <QtPrintSupport/QPrintDialog>
|
||||
#include <QDebug>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
|
@ -20,10 +22,9 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
|
||||
connect(ui->actionNew, &QAction::triggered, this, &MainWindow::newFile);
|
||||
connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::openFile);
|
||||
connect(ui->actionSave, &QAction::triggered, this,
|
||||
qOverload<>(&MainWindow::saveFile));
|
||||
connect(
|
||||
ui->actionSave_as, &QAction::triggered, this, &MainWindow::saveFileAs);
|
||||
connect(ui->actionSave, &QAction::triggered, this, qOverload<>(&MainWindow::saveFile));
|
||||
connect(ui->actionSave_as, &QAction::triggered, this, &MainWindow::saveFileAs);
|
||||
connect(ui->actionPrint, &QAction::triggered, this, &MainWindow::print);
|
||||
|
||||
newFile();
|
||||
}
|
||||
|
@ -50,8 +51,7 @@ void MainWindow::newFile()
|
|||
|
||||
ui->resultWidget->setModel(&m_dataModel->m_results);
|
||||
|
||||
connect(&*m_dataModel, &DataModel::modelChanged, this,
|
||||
&MainWindow::dataModelChanged);
|
||||
connect(&*m_dataModel, &DataModel::modelChanged, this, &MainWindow::dataModelChanged);
|
||||
|
||||
setWindowModified(false);
|
||||
setWindowTitle("untitled[*]");
|
||||
|
@ -61,8 +61,8 @@ void MainWindow::newFile()
|
|||
|
||||
void MainWindow::openFile()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
this, "Open file", "", "ESGRAF 4-8 (*.esgraf48)");
|
||||
QString filename =
|
||||
QFileDialog::getOpenFileName(this, "Open file", "", "ESGRAF 4-8 (*.esgraf48)");
|
||||
if (filename.isEmpty())
|
||||
{
|
||||
return;
|
||||
|
@ -104,8 +104,8 @@ void MainWindow::saveFile()
|
|||
|
||||
void MainWindow::saveFileAs()
|
||||
{
|
||||
QString filename = QFileDialog::getSaveFileName(
|
||||
this, "Save file", "", "ESGRAF 4-8 (*.esgraf48)");
|
||||
QString filename =
|
||||
QFileDialog::getSaveFileName(this, "Save file", "", "ESGRAF 4-8 (*.esgraf48)");
|
||||
if (filename.isEmpty())
|
||||
{
|
||||
return;
|
||||
|
@ -131,6 +131,14 @@ void MainWindow::closeFile()
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::print() const
|
||||
{
|
||||
QPrinter printer;
|
||||
|
||||
QPrintDialog dialog(&printer);
|
||||
dialog.exec();
|
||||
}
|
||||
|
||||
void MainWindow::dataModelChanged()
|
||||
{
|
||||
m_saveOnClose = true;
|
||||
|
|
|
@ -31,6 +31,7 @@ public slots:
|
|||
void saveFile();
|
||||
void saveFileAs();
|
||||
void closeFile();
|
||||
void print() const;
|
||||
void dataModelChanged();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<RCC>
|
||||
<qresource>
|
||||
<file>images/document-print.png</file>
|
||||
<file>images/document-new.png</file>
|
||||
<file>images/document-open.png</file>
|
||||
<file>images/document-save-as.png</file>
|
||||
|
|
|
@ -132,6 +132,8 @@
|
|||
<addaction name="actionSave"/>
|
||||
<addaction name="actionSave_as"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionPrint"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionQuit"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
|
@ -149,6 +151,8 @@
|
|||
<addaction name="actionNew"/>
|
||||
<addaction name="actionOpen"/>
|
||||
<addaction name="actionSave"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionPrint"/>
|
||||
</widget>
|
||||
<action name="actionSave_as">
|
||||
<property name="icon">
|
||||
|
@ -209,6 +213,21 @@
|
|||
<string>Ctrl+S</string>
|
||||
</property>
|
||||
</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>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
|
Loading…
Reference in a new issue