-
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.
allow more than one semantic per file
- Loading branch information
1 parent
e1e7280
commit 81dfbcd
Showing
12 changed files
with
497 additions
and
111 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
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,90 @@ | ||
/************************************************************************ | ||
** | ||
** 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/SemanticTargetID.h" | ||
#include "ResourceObjects/HTMLResource.h" | ||
#include "Misc/SettingsStore.h" | ||
|
||
static QString SETTINGS_GROUP = "semantic_target_id"; | ||
|
||
SemanticTargetID::SemanticTargetID(HTMLResource *html_resource, QWidget *parent) | ||
: | ||
QDialog(parent), | ||
m_SelectedText(""), | ||
m_HTMLResource(html_resource) | ||
{ | ||
ui.setupUi(this); | ||
connectSignalsSlots(); | ||
ReadSettings(); | ||
SetList(); | ||
} | ||
|
||
void SemanticTargetID::SetList() | ||
{ | ||
QString BookPath = m_HTMLResource->GetRelativePath(); | ||
QString xhtmlsrc = m_HTMLResource->GetText(); | ||
QStringList ids = XhtmlDoc::GetAllDescendantIDs(xhtmlsrc); | ||
ui.id->addItem(BookPath); | ||
foreach(QString id, ids) { | ||
ui.id->addItem(id); | ||
} | ||
ui.id->setEditText(BookPath); | ||
} | ||
|
||
|
||
QString SemanticTargetID::GetID() | ||
{ | ||
return m_SelectedText; | ||
} | ||
|
||
void SemanticTargetID::SetSelectedText() | ||
{ | ||
QString tgt = ui.id->currentText(); | ||
if (tgt == m_HTMLResource->GetRelativePath()) tgt = ""; | ||
m_SelectedText = tgt; | ||
} | ||
|
||
void SemanticTargetID::ReadSettings() | ||
{ | ||
SettingsStore settings; | ||
settings.beginGroup(SETTINGS_GROUP); | ||
QByteArray geometry = settings.value("geometry").toByteArray(); | ||
if (!geometry.isNull()) { | ||
restoreGeometry(geometry); | ||
} | ||
settings.endGroup(); | ||
} | ||
|
||
void SemanticTargetID::WriteSettings() | ||
{ | ||
SetSelectedText(); | ||
SettingsStore settings; | ||
settings.beginGroup(SETTINGS_GROUP); | ||
settings.setValue("geometry", saveGeometry()); | ||
settings.endGroup(); | ||
} | ||
|
||
void SemanticTargetID::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,59 @@ | ||
/************************************************************************ | ||
** | ||
** 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 SEMANTICTARGETID_H | ||
#define SEMANTICTARGETID_H | ||
|
||
#include <QDialog> | ||
|
||
#include "ResourceObjects/Resource.h" | ||
#include "ResourceObjects/HTMLResource.h" | ||
#include "ui_SemanticTargetID.h" | ||
|
||
class SemanticTargetID: public QDialog | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
SemanticTargetID(HTMLResource *html_resource, QWidget *parent = 0); | ||
|
||
void SetList(); | ||
|
||
QString GetID(); | ||
|
||
private slots: | ||
void WriteSettings(); | ||
|
||
private: | ||
void SetSelectedText(); | ||
|
||
void ReadSettings(); | ||
void connectSignalsSlots(); | ||
|
||
QString m_SelectedText; | ||
|
||
HTMLResource *m_HTMLResource; | ||
|
||
Ui::SemanticTargetID ui; | ||
}; | ||
|
||
#endif // SEMANTICTARGETID_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,107 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>SemanticTargetID</class> | ||
<widget class="QDialog" name="SemanticTargetID"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>504</width> | ||
<height>106</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Target for Semantic</string> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<item> | ||
<layout class="QHBoxLayout" name="horizontalLayout"> | ||
<item> | ||
<widget class="QLabel" name="label"> | ||
<property name="toolTip"> | ||
<string>Select an ID or use the default file level target for this Semantic setting.</string> | ||
</property> | ||
<property name="text"> | ||
<string>ID:</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QComboBox" name="id"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<property name="focusPolicy"> | ||
<enum>Qt::WheelFocus</enum> | ||
</property> | ||
<property name="editable"> | ||
<bool>false</bool> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
<item> | ||
<spacer name="verticalSpacer"> | ||
<property name="orientation"> | ||
<enum>Qt::Vertical</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>20</width> | ||
<height>40</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>SemanticTargetID</receiver> | ||
<slot>accept()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>248</x> | ||
<y>254</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>157</x> | ||
<y>274</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
<connection> | ||
<sender>buttonBox</sender> | ||
<signal>rejected()</signal> | ||
<receiver>SemanticTargetID</receiver> | ||
<slot>reject()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>316</x> | ||
<y>260</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>286</x> | ||
<y>274</y> | ||
</hint> | ||
</hints> | ||
</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.
81dfbcd
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.
I'll try to build and test a bit in the next few days. If not I'll do it this weekend.
81dfbcd
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.
Thanks! It is hard to find epubs with more than one semantic set in the same file in the wild. Normally landmarks/guides items standalone as separate files since they typically start on a new page. Technically it is possible but I have never actualky seen one before.
I will try to concoct a test case from the bug report and post it for testing.
We will also need to better handle this case in the "Reports". I have ignored Reports for the time being.
Also we need to add a GetInfo command for xhtml files in BookBrowser to show all manifest properties, and all semantics for the selected file. Maybe include all images, all footnotes, all ids, etc.