summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Grulich <[email protected]>2018-11-14 14:43:42 +0100
committerJan Grulich <[email protected]>2018-11-14 14:43:42 +0100
commit4b549b2d37d8f942b6f821077b87baede447f791 (patch)
tree3ddc7bc883747aa87f8296c8b69a116fd7e5d2a0
parent99af6a8a5b64ccefe6534bf458d8278298e2c941 (diff)
Add metered property to general configuration
BUG: 401020 FIXED-IN: 5.15.0
-rw-r--r--libs/editor/settings/connectionwidget.cpp17
-rw-r--r--libs/editor/settings/ui/connectionwidget.ui318
2 files changed, 161 insertions, 174 deletions
diff --git a/libs/editor/settings/connectionwidget.cpp b/libs/editor/settings/connectionwidget.cpp
index 365a018..02b3285 100644
--- a/libs/editor/settings/connectionwidget.cpp
+++ b/libs/editor/settings/connectionwidget.cpp
@@ -58,14 +58,6 @@ ConnectionWidget::ConnectionWidget(const NetworkManager::ConnectionSettings::Ptr
connect(m_widget->autoconnectVpn, &QCheckBox::toggled, this, &ConnectionWidget::autoVpnToggled);
- if (NetworkManager::compareVersion(QLatin1String("1.0.0")) >= 0) {
- m_widget->prioritySpin->setEnabled(true);
- m_widget->nmVersionWarning->setVisible(false);
- } else {
- m_widget->prioritySpin->setEnabled(false);
- m_widget->nmVersionWarning->setVisible(true);
- }
-
if (settings) {
loadConfig(settings);
}
@@ -83,6 +75,7 @@ ConnectionWidget::ConnectionWidget(const NetworkManager::ConnectionSettings::Ptr
connect(m_widget->vpnCombobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ConnectionWidget::settingChanged);
connect(m_widget->vpnCombobox, &QComboBox::currentTextChanged, this, &ConnectionWidget::settingChanged);
connect(m_widget->prioritySpin, QOverload<int>::of(&QSpinBox::valueChanged), this, &ConnectionWidget::settingChanged);
+ connect(m_widget->metered, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ConnectionWidget::settingChanged);
connect(m_widget->pushButtonPermissions, &QPushButton::clicked, this, &ConnectionWidget::openAdvancedPermissions);
}
@@ -119,11 +112,11 @@ void ConnectionWidget::loadConfig(const NetworkManager::ConnectionSettings::Ptr
m_widget->autoconnect->setChecked(settings->autoconnect());
-#if NM_CHECK_VERSION(1, 0, 0)
if (m_widget->prioritySpin->isEnabled()) {
m_widget->prioritySpin->setValue(settings->autoconnectPriority());
}
-#endif
+
+ m_widget->metered->setCurrentIndex(settings->metered());
}
NMVariantMapMap ConnectionWidget::setting() const
@@ -154,11 +147,11 @@ NMVariantMapMap ConnectionWidget::setting() const
settings.setZone(zone);
}
-#if NM_CHECK_VERSION(1, 0, 0)
if (m_widget->prioritySpin->isEnabled()) {
settings.setAutoconnectPriority(m_widget->prioritySpin->value());
}
-#endif
+
+ settings.setMetered(static_cast<NetworkManager::ConnectionSettings::Metered>(m_widget->metered->currentIndex()));
return settings.toMap();
}
diff --git a/libs/editor/settings/ui/connectionwidget.ui b/libs/editor/settings/ui/connectionwidget.ui
index d95d04f..38d7cda 100644
--- a/libs/editor/settings/ui/connectionwidget.ui
+++ b/libs/editor/settings/ui/connectionwidget.ui
@@ -6,203 +6,181 @@
<rect>
<x>0</x>
<y>0</y>
- <width>586</width>
- <height>441</height>
+ <width>471</width>
+ <height>262</height>
</rect>
</property>
- <layout class="QVBoxLayout" name="verticalLayout_4">
- <item>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
<widget class="QCheckBox" name="autoconnect">
<property name="text">
- <string>Automatically connect to this network when it is available</string>
+ <string>Connect automatically with priority</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_3">
- <item>
- <widget class="QCheckBox" name="allUsers">
- <property name="text">
- <string>All users may connect to this network</string>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="pushButtonPermissions">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="toolTip">
- <string>Edit advanced permissions for this connection</string>
- </property>
- <property name="whatsThis">
- <string>Fine-grained permissions editor for this connection. It lets you choose which users can activate/modify/delete this connection.</string>
- </property>
- <property name="text">
- <string>Advanced...</string>
- </property>
- <property name="icon">
- <iconset theme="preferences-desktop-user">
- <normaloff/>
- </iconset>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <spacer name="verticalSpacer_2">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
+ <item row="0" column="1">
+ <widget class="QSpinBox" name="prioritySpin">
+ <property name="enabled">
+ <bool>true</bool>
</property>
- <property name="sizeType">
- <enum>QSizePolicy::Minimum</enum>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
+ <property name="toolTip">
+ <string>If the connection is set to autoconnect, connections with higher priority will be preferred. Defaults to 0.
+The higher number means higher priority. An negative number can be used to indicate priority lower than the default.
+ </string>
</property>
- </spacer>
+ <property name="minimum">
+ <number>-100</number>
+ </property>
+ </widget>
</item>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QCheckBox" name="autoconnectVpn">
- <property name="text">
- <string>Automatically connect to VPN when using this connection</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KComboBox" name="vpnCombobox">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
+ <item row="1" column="0">
+ <widget class="QCheckBox" name="allUsers">
+ <property name="text">
+ <string>All users may connect to this network</string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ </widget>
</item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
+ <item row="1" column="1">
+ <widget class="QPushButton" name="pushButtonPermissions">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- <property name="sizeType">
- <enum>QSizePolicy::Minimum</enum>
+ <property name="toolTip">
+ <string>Edit advanced permissions for this connection</string>
</property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
+ <property name="whatsThis">
+ <string>Fine-grained permissions editor for this connection. It lets you choose which users can activate/modify/delete this connection.</string>
</property>
- </spacer>
+ <property name="text">
+ <string>Advanced...</string>
+ </property>
+ <property name="icon">
+ <iconset theme="preferences-desktop-user">
+ <normaloff>.</normaloff>.</iconset>
+ </property>
+ </widget>
</item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <layout class="QVBoxLayout" name="verticalLayout_3">
- <item>
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Firewall zone:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="buddy">
- <cstring>firewallZone</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Priority:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="KComboBox" name="firewallZone">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="editable">
- <bool>true</bool>
- </property>
- <property name="insertPolicy">
- <enum>QComboBox::InsertAlphabetically</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QSpinBox" name="prioritySpin">
- <property name="toolTip">
- <string>If the connection is set to autoconnect, connections with higher priority will be preferred. Defaults to 0.
-The higher number means higher priority. An negative number can be used to indicate priority lower than the default.
- </string>
- </property>
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimum">
- <number>-100</number>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
+ <item row="2" column="0">
+ <widget class="QCheckBox" name="autoconnectVpn">
+ <property name="text">
+ <string>Automatically connect to VPN</string>
+ </property>
+ </widget>
</item>
- <item>
- <widget class="QLabel" name="nmVersionWarning">
+ <item row="2" column="1">
+ <widget class="KComboBox" name="vpnCombobox">
<property name="enabled">
<bool>false</bool>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="firewallZoneLabel">
+ <property name="text">
+ <string>Firewall zone:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="buddy">
+ <cstring>firewallZone</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="KComboBox" name="firewallZone">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ <property name="insertPolicy">
+ <enum>QComboBox::InsertAlphabetically</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="meteredLabel">
<property name="text">
- <string>(Priority property requires newer version of NetworkManager)</string>
+ <string>Metered:</string>
</property>
<property name="alignment">
- <set>Qt::AlignCenter</set>
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="buddy">
+ <cstring>firewallZone</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="KComboBox" name="metered">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>NetworkManager indicates to applications whether the connection is metered and therefore
+data usage should be restricted.</string>
+ </property>
+ <property name="editable">
+ <bool>false</bool>
+ </property>
+ <property name="insertPolicy">
+ <enum>QComboBox::InsertAlphabetically</enum>
</property>
+ <item>
+ <property name="text">
+ <string>Automatic</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Yes</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>No</string>
+ </property>
+ </item>
</widget>
</item>
- <item>
- <spacer name="verticalSpacer_3">
+ <item row="5" column="0">
+ <spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
- <height>118</height>
+ <height>40</height>
</size>
</property>
</spacer>
@@ -242,5 +220,21 @@ The higher number means higher priority. An negative number can be used to indic
</hint>
</hints>
</connection>
+ <connection>
+ <sender>autoconnect</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>prioritySpin</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>150</x>
+ <y>16</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>375</x>
+ <y>21</y>
+ </hint>
+ </hints>
+ </connection>
</connections>
</ui>