BibleTime
btbookshelftaskpage.cpp
Go to the documentation of this file.
1 /*********
2 *
3 * In the name of the Father, and of the Son, and of the Holy Spirit.
4 *
5 * This file is part of BibleTime's source code, https://bibletime.info/
6 *
7 * Copyright 1999-2021 by the BibleTime developers.
8 * The BibleTime source code is licensed under the GNU General Public License
9 * version 2.0.
10 *
11 **********/
12 
13 #include "btbookshelftaskpage.h"
14 
15 #include <QApplication>
16 #include <QGroupBox>
17 #include <QLabel>
18 #include <QRadioButton>
19 #include <QSizePolicy>
20 #include <QSpacerItem>
21 #include <QStringLiteral>
22 #include <QVBoxLayout>
23 #include "../../backend/managers/cswordbackend.h"
24 #include "btbookshelfwizard.h"
25 
26 
28  : BtBookshelfWizardPage(parent)
29 {
30  m_verticalLayout = new QVBoxLayout(this);
31 
32  m_warningLabel = new QLabel(this);
33  m_warningLabel->setWordWrap(true);
34 
35  m_verticalLayout->addWidget(m_warningLabel);
36  m_verticalLayout->addItem(
37  new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding));
38 
39  m_groupBox = new QGroupBox(this);
40  { // Setup radio buttons:
41  QVBoxLayout * const vLayout = new QVBoxLayout(m_groupBox);
42 
43  m_installRadioButton = new QRadioButton(m_groupBox);
44  QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
45  sizePolicy.setHorizontalStretch(0);
46  sizePolicy.setVerticalStretch(0);
47  sizePolicy.setHeightForWidth(
48  m_installRadioButton->sizePolicy().hasHeightForWidth());
49  m_installRadioButton->setSizePolicy(sizePolicy);
50  m_installRadioButton->setChecked(true);
51  vLayout->addWidget(m_installRadioButton);
52 
53  m_updateRadioButton = new QRadioButton(m_groupBox);
54  sizePolicy.setHeightForWidth(
55  m_updateRadioButton->sizePolicy().hasHeightForWidth());
56  m_updateRadioButton->setSizePolicy(sizePolicy);
57  vLayout->addWidget(m_updateRadioButton);
58 
59  m_removeRadioButton = new QRadioButton(m_groupBox);
60  vLayout->addWidget(m_removeRadioButton);
61  }
62  m_verticalLayout->addWidget(m_groupBox);
63 
64  m_verticalLayout->addItem(
65  new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding));
66  m_verticalLayout->setStretch(0, 1);
67  m_verticalLayout->setStretch(1, 1);
68  m_verticalLayout->setStretch(2, 1);
69  m_verticalLayout->setStretch(3, 3);
70 
71  retranslateUi();
72 }
73 
75  setTitle(QApplication::translate("BookshelfWizard",
76  "Bookshelf Manager"));
77  setSubTitle(QApplication::translate("BookshelfWizard",
78  "Install, update, or remove works on your bookshelf."));
79  m_warningLabel->setText(
80  QApplication::translate(
81  "BookshelfWizard",
82  "<html><head/><body><p><span style=\" font-weight:600;\">"
83  "WARNING</span>: Installing or updating works uses the "
84  "internet. If you live in a persecuted country you may not "
85  "want to do this.</p></body></html>"));
86  m_groupBox->setTitle(QApplication::translate("BookshelfWizard",
87  "Bookshelf task"));
88  m_installRadioButton->setText(
89  QApplication::translate(
90  "BookshelfWizard",
91  "Install additional works (uses internet)"));
92  m_updateRadioButton->setText(
93  QApplication::translate("BookshelfWizard",
94  "Update installed works (uses internet)"));
95  m_removeRadioButton->setText(
96  QApplication::translate("BookshelfWizard",
97  "Remove installed works"));
98 }
99 
101  if (CSwordBackend::instance().moduleList().empty())
102  return true;
103 
105 }
106 
108  if (m_installRadioButton->isChecked()) {
109  if (timeToUpdate())
112  } else if (m_updateRadioButton->isChecked()) {
113  if (timeToUpdate())
116  } else if (m_removeRadioButton->isChecked()) {
118  } else {
119  return -1;
120  }
121 }
122 
124  if (m_installRadioButton->isChecked())
126  if (m_updateRadioButton->isChecked())
129 }
@ installWorks
@ removeWorksPage
@ updateWorksPage
@ sourcesProgressPage
QVBoxLayout * m_verticalLayout
QRadioButton * m_removeRadioButton
QRadioButton * m_installRadioButton
BtBookshelfTaskPage(QWidget *parent=nullptr)
QRadioButton * m_updateRadioButton
WizardTaskType taskType() const
int nextId() const final override
static bool autoUpdateSources()
static CSwordBackend & instance() noexcept
Definition: cswordbackend.h:98