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