summaryrefslogtreecommitdiffstats
path: root/examples/webenginewidgets/markdowneditor
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2016-03-21 18:09:08 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2016-03-21 18:09:08 +0100
commitb1153753221513aa5687001c84a1c9ed69925dc6 (patch)
tree3569ad54e433fee8244effe558ca52e567b6890d /examples/webenginewidgets/markdowneditor
parent4d6b2dc88bda15ade9d04e54d80b7e4693d59832 (diff)
parentc2687689ba42d6021ae3f220d9fd240609489d3a (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: src/3rdparty src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc Change-Id: I90728e965399e51b626d538924de955f9abab5fe
Diffstat (limited to 'examples/webenginewidgets/markdowneditor')
-rw-r--r--examples/webenginewidgets/markdowneditor/doc/src/markdowneditor.qdoc3
-rw-r--r--examples/webenginewidgets/markdowneditor/mainwindow.cpp25
-rw-r--r--examples/webenginewidgets/markdowneditor/mainwindow.h2
3 files changed, 20 insertions, 10 deletions
diff --git a/examples/webenginewidgets/markdowneditor/doc/src/markdowneditor.qdoc b/examples/webenginewidgets/markdowneditor/doc/src/markdowneditor.qdoc
index 7909aaddd..3a9908ea6 100644
--- a/examples/webenginewidgets/markdowneditor/doc/src/markdowneditor.qdoc
+++ b/examples/webenginewidgets/markdowneditor/doc/src/markdowneditor.qdoc
@@ -116,7 +116,8 @@
\printto connect
The constructor first calls \c setupUi to construct the widgets and menu
- actions according to the UI file. It then makes sure our custom
+ actions according to the UI file. The text editor font is set to one
+ with a fixed character width. It then makes sure our custom
\c PreviewPage is used by the QWebEngineView instance in \c{ui->preview}.
\printto ui->preview
diff --git a/examples/webenginewidgets/markdowneditor/mainwindow.cpp b/examples/webenginewidgets/markdowneditor/mainwindow.cpp
index 34d436cc2..417858d8d 100644
--- a/examples/webenginewidgets/markdowneditor/mainwindow.cpp
+++ b/examples/webenginewidgets/markdowneditor/mainwindow.cpp
@@ -54,6 +54,7 @@
#include <QFile>
#include <QFileDialog>
+#include <QFontDatabase>
#include <QMessageBox>
#include <QTextStream>
#include <QWebChannel>
@@ -63,6 +64,7 @@ MainWindow::MainWindow(QWidget *parent) :
ui(new Ui::MainWindow)
{
ui->setupUi(this);
+ ui->editor->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
PreviewPage *page = new PreviewPage(this);
ui->preview->setPage(page);
@@ -95,6 +97,19 @@ MainWindow::~MainWindow()
delete ui;
}
+void MainWindow::openFile(const QString &path)
+{
+ QFile f(path);
+ if (!f.open(QIODevice::ReadOnly)) {
+ QMessageBox::warning(this, windowTitle(),
+ tr("Could not open file %1: %2").arg(
+ QDir::toNativeSeparators(path), f.errorString()));
+ return;
+ }
+ m_filePath = path;
+ ui->editor->setPlainText(f.readAll());
+}
+
bool MainWindow::isModified() const
{
return ui->editor->document()->isModified();
@@ -128,15 +143,7 @@ void MainWindow::onFileOpen()
if (path.isEmpty())
return;
- QFile f(path);
- if (!f.open(QIODevice::ReadOnly)) {
- QMessageBox::warning(this, windowTitle(),
- tr("Could not open file %1: %2").arg(
- QDir::toNativeSeparators(path), f.errorString()));
- return;
- }
- m_filePath = path;
- ui->editor->setPlainText(f.readAll());
+ openFile(path);
}
void MainWindow::onFileSave()
diff --git a/examples/webenginewidgets/markdowneditor/mainwindow.h b/examples/webenginewidgets/markdowneditor/mainwindow.h
index 19b6cb036..ad0320373 100644
--- a/examples/webenginewidgets/markdowneditor/mainwindow.h
+++ b/examples/webenginewidgets/markdowneditor/mainwindow.h
@@ -70,6 +70,8 @@ public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
+ void openFile(const QString &path);
+
private slots:
void onFileNew();
void onFileOpen();