mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-23 03:58:56 -04:00
Merge pull request #989 from kiwix/autoOnline
This commit is contained in:
commit
81593431cf
@ -16,6 +16,7 @@ class ContentManager : public QObject
|
||||
Q_PROPERTY(QStringList bookIds READ getBookIds NOTIFY booksChanged)
|
||||
Q_PROPERTY(QStringList downloadIds READ getDownloadIds NOTIFY downloadsChanged)
|
||||
Q_PROPERTY(QString currentLanguage MEMBER m_currentLanguage WRITE setCurrentLanguage NOTIFY currentLangChanged)
|
||||
Q_PROPERTY(bool isLocal MEMBER m_local READ isLocal WRITE setLocal NOTIFY localChanged)
|
||||
|
||||
public:
|
||||
typedef QList<QPair<QString, QString>> LanguageList;
|
||||
@ -66,6 +67,7 @@ signals:
|
||||
void pendingRequest(const bool);
|
||||
void categoriesLoaded(QStringList);
|
||||
void languagesLoaded(LanguageList);
|
||||
void localChanged(const bool);
|
||||
|
||||
public slots:
|
||||
QStringList getTranslations(const QStringList &keys);
|
||||
|
@ -12,17 +12,19 @@ ContentManagerSide::ContentManagerSide(QWidget *parent) :
|
||||
mp_ui(new Ui::contentmanagerside)
|
||||
{
|
||||
mp_ui->setupUi(this);
|
||||
connect(mp_ui->allFileButton, &QRadioButton::toggled,
|
||||
this, [=](bool checked) { this->mp_contentManager->setLocal(!checked); });
|
||||
connect(mp_ui->localFileButton, &QRadioButton::toggled,
|
||||
this, [=](bool checked) { this->mp_contentManager->setLocal(checked); });
|
||||
mp_ui->buttonGroup->setId(mp_ui->allFileButton, CatalogButtonId::ALL);
|
||||
mp_ui->buttonGroup->setId(mp_ui->localFileButton, CatalogButtonId::LOCAL);
|
||||
connect(mp_ui->buttonGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked), [=](QAbstractButton *btn) {
|
||||
const auto id = mp_ui->buttonGroup->id(btn);
|
||||
mp_contentManager->setLocal(id == CatalogButtonId::LOCAL);
|
||||
});
|
||||
|
||||
connect(mp_ui->allFileButton, &QRadioButton::toggled,
|
||||
this, [=](bool checked) { mp_ui->allFileButton->setStyleSheet(
|
||||
checked ? "*{font-weight: bold}" : "");});
|
||||
connect(mp_ui->localFileButton, &QRadioButton::toggled,
|
||||
this, [=](bool checked) { mp_ui->localFileButton->setStyleSheet(
|
||||
checked ?"*{font-weight: bold}" : "");});
|
||||
mp_ui->localFileButton->setStyleSheet("*{font-weight: bold}");
|
||||
|
||||
mp_ui->allFileButton->setText(gt("online-files"));
|
||||
mp_ui->localFileButton ->setText(gt("local-files"));
|
||||
@ -105,6 +107,10 @@ ContentManagerSide::~ContentManagerSide()
|
||||
void ContentManagerSide::setContentManager(ContentManager *contentManager)
|
||||
{
|
||||
mp_contentManager = contentManager;
|
||||
const auto isLocal = mp_contentManager->isLocal();
|
||||
const auto checkedButton = mp_ui->buttonGroup->button(isLocal == CatalogButtonId::LOCAL);
|
||||
checkedButton->setChecked(true);
|
||||
checkedButton->setStyleSheet("*{font-weight: bold}");
|
||||
connect(mp_languageSelector, &QListWidget::itemSelectionChanged,
|
||||
this, [=]() {
|
||||
auto item = mp_languageSelector->selectedItems().at(0);
|
||||
|
@ -16,6 +16,10 @@ class ContentManagerSide : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum CatalogButtonId {
|
||||
ALL = 0,
|
||||
LOCAL = 1
|
||||
};
|
||||
explicit ContentManagerSide(QWidget *parent = 0);
|
||||
~ContentManagerSide();
|
||||
|
||||
|
@ -79,6 +79,9 @@
|
||||
<property name="text">
|
||||
<string>All Files</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">buttonGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -95,6 +98,9 @@
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">buttonGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -258,4 +264,7 @@
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
<buttongroups>
|
||||
<buttongroup name="buttonGroup"/>
|
||||
</buttongroups>
|
||||
</ui>
|
||||
|
@ -64,6 +64,7 @@ void KiwixApp::init()
|
||||
gt("error-downloader-launch-message") + "<br><br>" + e.what());
|
||||
}
|
||||
mp_manager = new ContentManager(&m_library, mp_downloader);
|
||||
mp_manager->setLocal(!m_library.getBookIds().isEmpty());
|
||||
|
||||
auto icon = QIcon();
|
||||
icon.addFile(":/icons/kiwix-app-icons-square.svg");
|
||||
|
Loading…
x
Reference in New Issue
Block a user