Make it more clear when the options regarding metered connections are not available
Since this feature will likely not be available in mingw-w64-based builds of the next release (due to missing cppwinrt) it is important to make it clear when those options don't actually work. With this change the checkboxes are completely disabled in case the feature is not available (instead of just providing the information via the tooltip).
This commit is contained in:
parent
274a220c2c
commit
d2dc15fdde
|
@ -91,6 +91,13 @@ static QString meteredToolTip(std::optional<bool> isMetered)
|
|||
: QCoreApplication::translate("QtGui", "Unable to determine whether the network connection is metered; assuming an unmetered connection.");
|
||||
}
|
||||
|
||||
/// \brief Configures the specified \a checkBox for the specified \a isMetered value.
|
||||
static void configureMeteredCheckbox(QCheckBox *checkBox, std::optional<bool> isMetered)
|
||||
{
|
||||
checkBox->setEnabled(isMetered.has_value());
|
||||
checkBox->setToolTip(meteredToolTip(isMetered));
|
||||
}
|
||||
|
||||
// ConnectionOptionPage
|
||||
ConnectionOptionPage::ConnectionOptionPage(Data::SyncthingConnection *connection, QWidget *parentWidget)
|
||||
: ConnectionOptionPageBase(parentWidget)
|
||||
|
@ -143,9 +150,9 @@ QWidget *ConnectionOptionPage::setupWidget()
|
|||
QObject::connect(ui()->removePushButton, &QPushButton::clicked, bind(&ConnectionOptionPage::removeSelectedConfig, this));
|
||||
QObject::connect(ui()->advancedCheckBox, &QCheckBox::toggled, bind(&ConnectionOptionPage::toggleAdvancedSettings, this, std::placeholders::_1));
|
||||
if (const auto *const launcher = SyncthingLauncher::mainInstance()) {
|
||||
handleNetworkConnectionMeteredChanged(launcher->isNetworkConnectionMetered());
|
||||
configureMeteredCheckbox(ui()->pauseOnMeteredConnectionCheckBox, launcher->isNetworkConnectionMetered());
|
||||
QObject::connect(launcher, &SyncthingLauncher::networkConnectionMeteredChanged,
|
||||
bind(&ConnectionOptionPage::handleNetworkConnectionMeteredChanged, this, std::placeholders::_1));
|
||||
bind(&configureMeteredCheckbox, ui()->pauseOnMeteredConnectionCheckBox, std::placeholders::_1));
|
||||
}
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
|
||||
ui()->timeoutSpinBox->setEnabled(false);
|
||||
|
@ -397,11 +404,6 @@ void ConnectionOptionPage::toggleAdvancedSettings(bool show)
|
|||
#endif
|
||||
}
|
||||
|
||||
void ConnectionOptionPage::handleNetworkConnectionMeteredChanged(std::optional<bool> isMetered)
|
||||
{
|
||||
ui()->pauseOnMeteredConnectionCheckBox->setToolTip(meteredToolTip(isMetered));
|
||||
}
|
||||
|
||||
bool ConnectionOptionPage::apply()
|
||||
{
|
||||
if (!cacheCurrentSettings(true)) {
|
||||
|
@ -1164,9 +1166,9 @@ QWidget *LauncherOptionPage::setupWidget()
|
|||
connect(ui()->logLevelComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
&LauncherOptionPage::updateLibSyncthingLogLevel);
|
||||
#endif
|
||||
|
||||
handleNetworkConnectionMeteredChanged(m_launcher->isNetworkConnectionMetered());
|
||||
connect(m_launcher, &SyncthingLauncher::networkConnectionMeteredChanged, this, &LauncherOptionPage::handleNetworkConnectionMeteredChanged);
|
||||
configureMeteredCheckbox(ui()->stopOnMeteredCheckBox, m_launcher->isNetworkConnectionMetered());
|
||||
connect(m_launcher, &SyncthingLauncher::networkConnectionMeteredChanged, this,
|
||||
std::bind(&configureMeteredCheckbox, ui()->stopOnMeteredCheckBox, std::placeholders::_1));
|
||||
|
||||
m_launcher->setEmittingOutput(true);
|
||||
}
|
||||
|
@ -1333,11 +1335,6 @@ void LauncherOptionPage::handleSyncthingError(QProcess::ProcessError error)
|
|||
}
|
||||
}
|
||||
|
||||
void LauncherOptionPage::handleNetworkConnectionMeteredChanged(std::optional<bool> isMetered)
|
||||
{
|
||||
ui()->stopOnMeteredCheckBox->setToolTip(meteredToolTip(isMetered));
|
||||
}
|
||||
|
||||
bool LauncherOptionPage::isRunning() const
|
||||
{
|
||||
return (m_process && m_process->isRunning()) || (m_launcher && m_launcher->isRunning());
|
||||
|
|
|
@ -69,7 +69,6 @@ void moveSelectedConfigDown();
|
|||
void moveSelectedConfigUp();
|
||||
void setCurrentIndex(int currentIndex);
|
||||
void toggleAdvancedSettings(bool show);
|
||||
void handleNetworkConnectionMeteredChanged(std::optional<bool> isMetered);
|
||||
Data::SyncthingConnection *m_connection;
|
||||
Data::SyncthingConnectionSettings m_primarySettings;
|
||||
std::vector<Data::SyncthingConnectionSettings> m_secondarySettings;
|
||||
|
@ -138,7 +137,6 @@ private Q_SLOTS:
|
|||
void handleSyncthingOutputAvailable(const QByteArray &output);
|
||||
void handleSyncthingExited(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void handleSyncthingError(QProcess::ProcessError error);
|
||||
void handleNetworkConnectionMeteredChanged(std::optional<bool> isMetered);
|
||||
void launch();
|
||||
#ifdef SYNCTHINGWIDGETS_USE_LIBSYNCTHING
|
||||
void updateLibSyncthingLogLevel();
|
||||
|
|
Loading…
Reference in New Issue