Merge lp:~b-eltzner/qpdfview/searchable-help into lp:qpdfview

Proposed by Benjamin Eltzner
Status: Merged
Merged at revision: 1258
Proposed branch: lp:~b-eltzner/qpdfview/searchable-help
Merge into: lp:qpdfview
Diff against target: 163 lines (+98/-15)
4 files modified
qpdfview-application.pro (+4/-2)
sources/helpdialog.cpp (+43/-0)
sources/helpdialog.h (+48/-0)
sources/mainwindow.cpp (+3/-13)
To merge this branch: bzr merge lp:~b-eltzner/qpdfview/searchable-help
Reviewer Review Type Date Requested Status
Adam Reichold Approve
Review via email: mp+184346@code.launchpad.net

Description of the change

The help dialog is now treated as a separate class to facilitate extension. This was done in a very simplistic way, so the code might need some additional care.

To post a comment you must log in.
Revision history for this message
Adam Reichold (adamreichold) wrote :

Hello Benjamin,

Thanks for the change! Will fix a few empty lines and then merge it. Afterwards, we can discuss extending the help dialog.

Best regards, Adam.

review: Approve
Revision history for this message
Adam Reichold (adamreichold) wrote :

By the way, there seems to be the small issue of the accidentally added binary file which I'll just remove...

Revision history for this message
Benjamin Eltzner (b-eltzner) wrote :

> By the way, there seems to be the small issue of the accidentally added binary
> file which I'll just remove...

Oh, sorry about that. Thanks for cleaning it up.

1258. By Adam Reichold

merge help dialog that was refactored for further extension

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'qpdfview'
2Binary files qpdfview 1970-01-01 00:00:00 +0000 and qpdfview 2013-09-06 16:42:02 +0000 differ
3=== modified file 'qpdfview-application.pro'
4--- qpdfview-application.pro 2013-09-02 09:25:38 +0000
5+++ qpdfview-application.pro 2013-09-06 16:42:02 +0000
6@@ -24,7 +24,8 @@
7 sources/recentlyusedmenu.h \
8 sources/bookmarkmenu.h \
9 sources/database.h \
10- sources/mainwindow.h
11+ sources/mainwindow.h \
12+ sources/helpdialog.h
13
14 SOURCES += \
15 sources/settings.cpp \
16@@ -42,7 +43,8 @@
17 sources/bookmarkmenu.cpp \
18 sources/database.cpp \
19 sources/mainwindow.cpp \
20- sources/main.cpp
21+ sources/main.cpp \
22+ sources/helpdialog.cpp
23
24 DEFINES += APPLICATION_VERSION=\\\"$${APPLICATION_VERSION}\\\"
25
26
27=== added file 'sources/helpdialog.cpp'
28--- sources/helpdialog.cpp 1970-01-01 00:00:00 +0000
29+++ sources/helpdialog.cpp 2013-09-06 16:42:02 +0000
30@@ -0,0 +1,43 @@
31+/*
32+
33+Copyright 2013 Benjamin Eltzner
34+Copyright 2013 Adam Reichold
35+
36+This file is part of qpdfview.
37+
38+qpdfview is free software: you can redistribute it and/or modify
39+it under the terms of the GNU General Public License as published by
40+the Free Software Foundation, either version 2 of the License, or
41+(at your option) any later version.
42+
43+qpdfview is distributed in the hope that it will be useful,
44+but WITHOUT ANY WARRANTY; without even the implied warranty of
45+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46+GNU General Public License for more details.
47+
48+You should have received a copy of the GNU General Public License
49+along with qpdfview. If not, see <http://www.gnu.org/licenses/>.
50+
51+*/
52+
53+#include "helpdialog.h"
54+
55+#include <QApplication>
56+#include <QDir>
57+#include <QVBoxLayout>
58+
59+HelpDialog::HelpDialog(QWidget* parent) : QDialog(parent)
60+{
61+ m_textBrowser = new QTextBrowser(this);
62+ m_textBrowser->setSearchPaths(QStringList() << QDir(QApplication::applicationDirPath()).filePath("data") << DATA_INSTALL_PATH);
63+ m_textBrowser->setSource(QUrl("help.html"));
64+
65+ m_dialogButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, this);
66+ connect(m_dialogButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
67+ connect(m_dialogButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
68+
69+ this->setLayout(new QVBoxLayout(this));
70+ this->layout()->addWidget(m_textBrowser);
71+ this->layout()->addWidget(m_dialogButtonBox);
72+
73+}
74
75=== added file 'sources/helpdialog.h'
76--- sources/helpdialog.h 1970-01-01 00:00:00 +0000
77+++ sources/helpdialog.h 2013-09-06 16:42:02 +0000
78@@ -0,0 +1,48 @@
79+/*
80+
81+Copyright 2013 Benjamin Eltzner
82+Copyright 2013 Adam Reichold
83+
84+This file is part of qpdfview.
85+
86+qpdfview is free software: you can redistribute it and/or modify
87+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 2 of the License, or
89+(at your option) any later version.
90+
91+qpdfview is distributed in the hope that it will be useful,
92+but WITHOUT ANY WARRANTY; without even the implied warranty of
93+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
94+GNU General Public License for more details.
95+
96+You should have received a copy of the GNU General Public License
97+along with qpdfview. If not, see <http://www.gnu.org/licenses/>.
98+
99+*/
100+
101+#ifndef HELPDIALOG_H
102+#define HELPDIALOG_H
103+
104+#include <QDialog>
105+#include <QTextBrowser>
106+#include <QDialogButtonBox>
107+
108+class HelpDialog : public QDialog
109+{
110+ Q_OBJECT
111+
112+public:
113+ explicit HelpDialog(QWidget* parent = 0);
114+
115+signals:
116+
117+public slots:
118+
119+private:
120+ QTextBrowser* m_textBrowser;
121+
122+ QDialogButtonBox* m_dialogButtonBox;
123+
124+};
125+
126+#endif // HELPDIALOG_H
127
128=== modified file 'sources/mainwindow.cpp'
129--- sources/mainwindow.cpp 2013-09-06 14:26:01 +0000
130+++ sources/mainwindow.cpp 2013-09-06 16:42:02 +0000
131@@ -59,6 +59,7 @@
132 #include "pageitem.h"
133 #include "documentview.h"
134 #include "miscellaneous.h"
135+#include "helpdialog.h"
136 #include "printdialog.h"
137 #include "settingsdialog.h"
138 #include "recentlyusedmenu.h"
139@@ -1485,22 +1486,11 @@
140
141 void MainWindow::on_contents_triggered()
142 {
143- QDialog* dialog = new QDialog(this);
144-
145- QTextBrowser* textBrowser = new QTextBrowser(dialog);
146- textBrowser->setSearchPaths(QStringList() << QDir(QApplication::applicationDirPath()).filePath("data") << DATA_INSTALL_PATH);
147- textBrowser->setSource(QUrl("help.html"));
148-
149- QDialogButtonBox* dialogButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, dialog);
150- connect(dialogButtonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
151- connect(dialogButtonBox, SIGNAL(rejected()), dialog, SLOT(reject()));
152-
153- dialog->setLayout(new QVBoxLayout(dialog));
154- dialog->layout()->addWidget(textBrowser);
155- dialog->layout()->addWidget(dialogButtonBox);
156+ HelpDialog* dialog = new HelpDialog(this);
157
158 dialog->resize(s_settings->mainWindow().contentsDialogSize(dialog->sizeHint()));
159 dialog->exec();
160+
161 s_settings->mainWindow().setContentsDialogSize(dialog->size());
162
163 delete dialog;

Subscribers

People subscribed via source and target branches