Skip to content

Commit

Permalink
Merge pull request nextcloud#7941 from Pabarino/more/2792
Browse files Browse the repository at this point in the history
Added hiding remotePollInterval selector in settings if notify push available
  • Loading branch information
claucambra authored Feb 28, 2025
2 parents 756bdbe + c1a5eaa commit d1d3b7b
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 50 deletions.
28 changes: 22 additions & 6 deletions src/gui/generalsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "owncloudsetupwizard.h"
#include "accountmanager.h"
#include "guiutility.h"
#include "capabilities.h"

#if defined(BUILD_UPDATER)
#include "updater/updater.h"
Expand Down Expand Up @@ -187,12 +188,9 @@ GeneralSettings::GeneralSettings(QWidget *parent)
, _ui(new Ui::GeneralSettings)
{
_ui->setupUi(this);

_ui->labelInterval->setText("seconds (if <a href=\"https://github.com/nextcloud/notify_push\">Client Push</a> is unavailable)");
_ui->labelInterval->setTextFormat(Qt::RichText);
_ui->labelInterval->setTextInteractionFlags(Qt::TextBrowserInteraction);
_ui->labelInterval->setOpenExternalLinks(true);

updatePollIntervalVisibility();

connect(_ui->serverNotificationsCheckBox, &QAbstractButton::toggled,
this, &GeneralSettings::slotToggleOptionalServerNotifications);
_ui->serverNotificationsCheckBox->setToolTip(tr("Server notifications that require attention."));
Expand Down Expand Up @@ -330,7 +328,8 @@ void GeneralSettings::loadMiscSettings()
_ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons());

const auto interval = cfgFile.remotePollInterval();
_ui->remotePollIntervalSpinBox->setValue(static_cast<int>(interval.count() / 1000));
_ui->remotePollIntervalSpinBox->setValue(static_cast<int>(interval.count() / 1000));
updatePollIntervalVisibility();
}

#if defined(BUILD_UPDATER)
Expand Down Expand Up @@ -660,4 +659,21 @@ void GeneralSettings::slotRemotePollIntervalChanged(int seconds)
cfgFile.setRemotePollInterval(interval);
}

void GeneralSettings::updatePollIntervalVisibility()

Check warning on line 662 in src/gui/generalsettings.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/generalsettings.cpp:662:23 [readability-convert-member-functions-to-static]

method 'updatePollIntervalVisibility' can be made static
{
const auto accounts = AccountManager::instance()->accounts();
const auto pushAvailable = std::any_of(accounts.cbegin(), accounts.cend(), [](const AccountStatePtr &accountState) -> bool {
if (!accountState) {
return false;
}
const auto accountPtr = accountState->account();
if (!accountPtr) {
return false;
}
return accountPtr->capabilities().availablePushNotifications().testFlag(PushNotificationType::Files);
});

_ui->horizontalLayoutWidget_remotePollInterval->setVisible(!pushAvailable);
}

} // namespace OCC
1 change: 1 addition & 0 deletions src/gui/generalsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ private slots:
void loadMiscSettings();
void slotShowLegalNotice();
void slotRemotePollIntervalChanged(int seconds);
void updatePollIntervalVisibility();
#if defined(BUILD_UPDATER)
void slotUpdateInfo();
void slotUpdateChannelChanged();
Expand Down
99 changes: 55 additions & 44 deletions src/gui/generalsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -197,50 +197,6 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_remotePollInterval">
<item>
<widget class="QLabel" name="remotePollIntervalLabel">
<property name="text">
<string>Server poll interval</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="remotePollIntervalSpinBox">
<property name="minimum">
<number>30</number>
</property>
<property name="maximum">
<number>999999</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelInterval">
<property name="text">
<string extracomment="Trailing part of &quot;Server poll interval&quot; ">seconds (if Client Push is unavailable)</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_remotePollInterval">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
Expand Down Expand Up @@ -269,6 +225,61 @@
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="horizontalLayoutWidget_remotePollInterval">
<layout class="QHBoxLayout" name="horizontalLayout_remotePollInterval">
<item>
<widget class="QLabel" name="remotePollIntervalLabel">
<property name="text">
<string>Server poll interval</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="remotePollIntervalSpinBox">
<property name="minimum">
<number>30</number>
</property>
<property name="maximum">
<number>999999</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelInterval">
<property name="text">
<string>seconds (if &lt;a href=&quot;https://github.com/nextcloud/notify_push&quot;&gt;Client Push&lt;/a&gt; is unavailable)</string>
</property>
<property name="textFormat">
<enum>Qt::TextFormat::RichText</enum>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextInteractionFlag::LinksAccessibleByKeyboard|Qt::TextInteractionFlag::LinksAccessibleByMouse</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_remotePollInterval">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
Expand Down

0 comments on commit d1d3b7b

Please sign in to comment.