19 #include <QPushButton>
20 #include <QStackedWidget>
22 #include <QVBoxLayout>
25 #include "../backend/bookshelfmodel/btbookshelfmodel.h"
26 #include "../backend/bookshelfmodel/btbookshelftreemodel.h"
27 #include "../backend/config/btconfig.h"
28 #include "../backend/drivers/cswordmoduleinfo.h"
29 #include "../backend/managers/cswordbackend.h"
30 #include "../util/btassert.h"
31 #include "../util/btconnect.h"
32 #include "../util/cresmgr.h"
41 QStringLiteral(
"GUI/MainWindow/Docks/Bookshelf/grouping");
71 QVBoxLayout *welcomeLayout =
new QVBoxLayout;
75 welcomeLayout->addWidget(
m_installLabel, 0, Qt::AlignHCenter | Qt::AlignBottom);
77 welcomeLayout->addWidget(
m_installButton, 0, Qt::AlignHCenter | Qt::AlignTop);
84 m_stackedWidget->setCurrentWidget(bookshelfModelPtr->moduleList().empty()
92 if (!module->isLocked()) {
93 Q_EMIT moduleOpenTriggered(module);
102 message::showWarning(
104 tr(
"Warning: Module locked!"),
105 tr(
"You are trying to access an encrypted "
106 "module. Please provide an unlock key in "
107 "the following dialog to open the "
112 auto const moduleName(module->name());
113 if (BibleTime::moduleUnlock(module)) {
115 auto const & backend = CSwordBackend::instance();
116 module = backend.findModuleByName(moduleName);
118 Q_EMIT moduleOpenTriggered(module);
130 Q_EMIT groupingOrderChanged(g);
132 BT_CONNECT(m_bookshelfWidget->showHideAction(), &QAction::toggled,
134 auto modulesChangedSlot =
136 auto const & moduleList =
138 m_stackedWidget->setCurrentWidget(moduleList.empty()
140 : m_bookshelfWidget);
142 BT_CONNECT(bookshelfModelPtr.get(), &BtBookshelfModel::rowsInserted,
143 this, modulesChangedSlot);
144 BT_CONNECT(bookshelfModelPtr.get(), &BtBookshelfModel::rowsRemoved,
145 this, std::move(modulesChangedSlot));
146 BT_CONNECT(m_installButton, &QPushButton::clicked,
156 auto const addMenuAction =
158 auto *
const action =
new QAction(
this);
165 Q_EMIT (this->*signal)(module);
194 tr(
"&Search in %1...").arg(module->
name()));
201 setWindowTitle(tr(
"Bookshelf"));
207 m_installLabel->setText(tr(
"There are currently no works installed. Please "
208 "click the button below to install new works."));
BtConfig & btConfig()
This is a shortchand for BtConfig::getInstance().
void saveTo(BtConfigCore &config, QString const &key) const
void groupingOrderChanged(BtBookshelfTreeModel::Grouping newGrouping)
void setCheckable(bool checkable)
void moduleChecked(CSwordModuleInfo *module, bool checked)
void moduleHovered(CSwordModuleInfo *item)
void moduleActivated(CSwordModuleInfo *item)
QList< CSwordModuleInfo * > const & moduleList() const
static CSwordBackend & instance() noexcept
QString const & name() const
bool setHidden(bool hide)