-
Notifications
You must be signed in to change notification settings - Fork 583
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a GetInfo like dialog using a Markdown and an MDViewer widget
- Loading branch information
1 parent
40e9c16
commit 533cca1
Showing
6 changed files
with
328 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/************************************************************************ | ||
** | ||
** Copyright (C) 2024 Kevin B. Hendricks, Stratford Ontario Canada | ||
** | ||
** This file is part of Sigil. | ||
** | ||
** Sigil is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 3 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** Sigil is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
** GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with Sigil. If not, see <http://www.gnu.org/licenses/>. | ||
** | ||
*************************************************************************/ | ||
|
||
#include <QLineEdit> | ||
|
||
#include "Dialogs/MDViewer.h" | ||
#include "ResourceObjects/HTMLResource.h" | ||
#include "Misc/SettingsStore.h" | ||
|
||
static QString SETTINGS_GROUP = "markdown_viewer"; | ||
|
||
MDViewer::MDViewer(const QString & mdsrc, QWidget *parent) | ||
: | ||
QDialog(parent) | ||
{ | ||
ui.setupUi(this); | ||
connectSignalsSlots(); | ||
ReadSettings(); | ||
ui.viewer->setMarkdown(mdsrc); | ||
ui.viewer->setReadOnly(true); | ||
} | ||
|
||
void MDViewer::ReadSettings() | ||
{ | ||
SettingsStore settings; | ||
settings.beginGroup(SETTINGS_GROUP); | ||
QByteArray geometry = settings.value("geometry").toByteArray(); | ||
if (!geometry.isNull()) { | ||
restoreGeometry(geometry); | ||
} | ||
settings.endGroup(); | ||
} | ||
|
||
void MDViewer::WriteSettings() | ||
{ | ||
SettingsStore settings; | ||
settings.beginGroup(SETTINGS_GROUP); | ||
settings.setValue("geometry", saveGeometry()); | ||
settings.endGroup(); | ||
} | ||
|
||
void MDViewer::connectSignalsSlots() | ||
{ | ||
connect(this, SIGNAL(accepted()), this, SLOT(WriteSettings())); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/************************************************************************ | ||
** | ||
** Copyright (C) 2024 Kevin B. Hendricks, Stratford Ontario Canada | ||
** | ||
** This file is part of Sigil. | ||
** | ||
** Sigil is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 3 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** Sigil is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
** GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with Sigil. If not, see <http://www.gnu.org/licenses/>. | ||
** | ||
*************************************************************************/ | ||
|
||
#pragma once | ||
#ifndef MDVIEWER_H | ||
#define MDVIEWER_H | ||
|
||
#include <QDialog> | ||
#include <QString> | ||
#include <QTextEdit> | ||
#include "ui_MDViewer.h" | ||
|
||
class MDViewer: public QDialog | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
MDViewer(const QString & mdsrc,QWidget *parent = 0); | ||
|
||
private slots: | ||
void WriteSettings(); | ||
|
||
private: | ||
void ReadSettings(); | ||
void connectSignalsSlots(); | ||
Ui::MDViewer ui; | ||
}; | ||
|
||
#endif // MDVIEWER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>MDViewer</class> | ||
<widget class="QDialog" name="MDViewer"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>504</width> | ||
<height>504</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Information</string> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<item> | ||
<widget class="QTextEdit" name="viewer"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding"> | ||
<horstretch>0</horstretch> | ||
<verstretch>1</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<property name="focusPolicy"> | ||
<enum>Qt::WheelFocus</enum> | ||
</property> | ||
<property name="readOnly"> | ||
<bool>true</bool> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<spacer name="verticalSpacer"> | ||
<property name="orientation"> | ||
<enum>Qt::Vertical</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>20</width> | ||
<height>5</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
<item> | ||
<widget class="QDialogButtonBox" name="buttonBox"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
<property name="standardButtons"> | ||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources/> | ||
<connections> | ||
<connection> | ||
<sender>buttonBox</sender> | ||
<signal>accepted()</signal> | ||
<receiver>MDViewer</receiver> | ||
<slot>accept()</slot> | ||
</connection> | ||
<connection> | ||
<sender>buttonBox</sender> | ||
<signal>rejected()</signal> | ||
<receiver>MDViewer</receiver> | ||
<slot>reject()</slot> | ||
</connection> | ||
</connections> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
533cca1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dougmassay
I created an HTMLResource "GetInfo" dialog using Markdown and a MDViewer widget which uses a QTextEdit in ReadOnly mode.
I tried to include much of the information from Reports widgets but focused on just one file at a time so it will be much faster.
I expanded it to include full Semantic Information as well.
So when you get a free moment, please load an epub2 or epub3 that has semantic info, right click on the file in BookBrowser (just an xhtml file), and select GetInfo.
Take a peak at what output is created.
The code to handle this is in BookBrowser::GetInfo() routine. It is very very simple right now. Basically a list format. I am no Markdown expert but this approach seems quite easy to expand on. So let me know if you think some of this information should go away and others pieces of infomation added. Also feel free to make the Markdown code I generated a lot fancier if you like.
Part of me want to make this a show Semantics only routine and remove all of the extra stuff, but I am unsure if it would be interesting enough on its own.