20 #include <QVBoxLayout>
21 #include <QtAlgorithms>
23 #include "../backend/config/btconfig.h"
24 #include "../backend/drivers/cswordmoduleinfo.h"
25 #include "../backend/keys/cswordkey.h"
26 #include "../backend/managers/colormanager.h"
27 #include "../backend/managers/referencemanager.h"
28 #include "../util/btassert.h"
29 #include "../util/btconnect.h"
34 using namespace sword;
40 , m_mainWindow(parent)
42 QVBoxLayout *
const layout =
new QVBoxLayout(
this);
43 layout->setContentsMargins(2, 2, 2, 2);
44 setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
49 QAction selectAllAction(tr(
"Select all"));
50 selectAllAction.setShortcut(QKeySequence::SelectAll);
51 BT_CONNECT(&selectAllAction, &QAction::triggered,
55 copyAction.setShortcut(QKeySequence(Qt::CTRL | Qt::Key_C));
60 menu.addAction(&selectAllAction);
61 menu.addAction(©Action);
62 menu.exec(QCursor::pos());
65 [
this](QUrl
const & url) {
66 auto const decodedLink(
69 if (!decodedLink && !decodedLink->module)
72 auto const *
const m = decodedLink->module;
73 std::unique_ptr<CSwordKey> key(m->createKey());
74 key->setKey(decodedLink->key);
76 setInfo(key->renderedText(), m->language()->abbrev());
83 setInfo(tr(
"<small>This is the Mag viewer area. Hover the mouse over links "
84 "or other items which include some data and the contents appear "
85 "in the Mag after a short delay. Move the mouse into Mag "
86 "rapidly or lock the view by pressing and holding Shift while "
87 "moving the mouse.</small>"));
99 text.replace(QStringLiteral(
"#CHAPTERTITLE#"), QString());
100 text.replace(QStringLiteral(
"#TEXT_ALIGN#"), QStringLiteral(
"left"));
114 if (list.isEmpty()) {
129 setInfo(tr(
"<div class=\"moduleinfo\"><h3>%1</h3><p>%2</p><p>Version: %3</p></div>")
130 .arg(module->
name().toHtmlEscaped())
140 auto const lang = module->
language();
148 return QSize(100, 150);
BtConfig & btConfig()
This is a shortchand for BtConfig::getInstance().
QList< CSwordModuleInfo const * > BtConstModuleList
CSwordModuleInfo const * getCurrentModule()
A QTextBrowser subclass which adds the ability to start drags for references.
QString config(const CSwordModuleInfo::ConfigEntry entry) const
std::shared_ptr< Language const > language() const
QString const & name() const
void setInfo(const QString &renderedData, const QString &lang=QString())
QSize sizeHint() const override
void setBrowserFont(const CSwordModuleInfo *const module)
BtTextBrowser * m_textBrowser
QString getForegroundColor()
QString getBackgroundColor()
QString replaceColors(QString content)
std::optional< DecodedHyperlink > decodeHyperlink(QString const &hyperlink)
QString formatInfo(const ListInfoData &list, BtConstModuleList const &modules)