add some more box settings

This commit is contained in:
Michael Zanetti 2018-10-17 23:33:44 +02:00
parent 91b6a6141d
commit 2278be6c4a
8 changed files with 100 additions and 36 deletions

@ -1 +1 @@
Subproject commit 2990b858e6334fae4dd37a77c770336bd6e1b2d9
Subproject commit 09116a9bf84082688e9f2cd24cfd08788c71650c

View File

@ -103,14 +103,14 @@ void BasicConfiguration::setTcpServerConfiguration(ServerConfiguration *configur
m_client->sendCommand("Configuration.SetTcpServerConfiguration", params);
}
void BasicConfiguration::deleteTcpServerConfiguration(const QString &id) const
void BasicConfiguration::deleteTcpServerConfiguration(const QString &id)
{
QVariantMap params;
params.insert("id", id);
m_client->sendCommand("Configuration.DeleteTcpServerConfiguration", params, this, "deleteTcpConfigReply");
}
void BasicConfiguration::deleteWebsocketServerConfiguration(const QString &id) const
void BasicConfiguration::deleteWebsocketServerConfiguration(const QString &id)
{
QVariantMap params;
params.insert("id", id);
@ -205,6 +205,11 @@ void BasicConfiguration::deleteTcpConfigReply(const QVariantMap &params)
}
}
void BasicConfiguration::deleteWebSocketConfigReply(const QVariantMap &params)
{
}
void BasicConfiguration::notificationReceived(const QVariantMap &notification)
{
QString notif = notification.value("notification").toString();

View File

@ -53,8 +53,8 @@ public:
void setTcpServerConfiguration(ServerConfiguration *configuration) const;
void setWebsocketServerConfiguration(ServerConfiguration *configuration) const;
Q_INVOKABLE void deleteTcpServerConfiguration(const QString &id) const;
Q_INVOKABLE void deleteWebsocketServerConfiguration(const QString &id) const;
Q_INVOKABLE void deleteTcpServerConfiguration(const QString &id);
Q_INVOKABLE void deleteWebsocketServerConfiguration(const QString &id);
void init();

View File

@ -37,14 +37,38 @@ void PluginsProxy::setPlugins(Plugins *plugins)
{
m_plugins = plugins;
setSourceModel(plugins);
setSortRole(Plugins::NameRole);
sort(0);
}
bool PluginsProxy::lessThan(const QModelIndex &left, const QModelIndex &right) const
bool PluginsProxy::showOnlyConfigurable() const
{
QVariant leftName = sourceModel()->data(left);
QVariant rightName = sourceModel()->data(right);
return QString::localeAwareCompare(leftName.toString(), rightName.toString()) < 0;
return m_showOnlyConfigurable;
}
void PluginsProxy::setShowOnlyConfigurable(bool showOnlyConfigurable)
{
if (m_showOnlyConfigurable != showOnlyConfigurable) {
m_showOnlyConfigurable = showOnlyConfigurable;
emit showOnlyConfigurableChanged();
invalidateFilter();
}
}
Plugin *PluginsProxy::get(int index) const
{
return m_plugins->get(mapToSource(this->index(index, 0)).row());
}
bool PluginsProxy::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{
Q_UNUSED(source_parent)
Plugin *plugin = m_plugins->get(source_row);
if (m_showOnlyConfigurable) {
if (plugin->paramTypes()->rowCount() == 0) {
return false;
}
}
return true;
}

View File

@ -31,19 +31,28 @@
class PluginsProxy : public QSortFilterProxyModel
{
Q_OBJECT
Q_PROPERTY(Plugins* plugins READ plugins WRITE setPlugins NOTIFY pluginsChanged)
Q_PROPERTY(bool showOnlyConfigurable READ showOnlyConfigurable WRITE setShowOnlyConfigurable NOTIFY showOnlyConfigurableChanged)
public:
explicit PluginsProxy(QObject *parent = 0);
explicit PluginsProxy(QObject *parent = nullptr);
Plugins *plugins();
void setPlugins(Plugins *plugins);
private:
Plugins *m_plugins;
bool showOnlyConfigurable() const;
void setShowOnlyConfigurable(bool showOnlyConfigurable);
Q_INVOKABLE Plugin* get(int index) const;
protected:
bool lessThan(const QModelIndex &left, const QModelIndex &right) const Q_DECL_OVERRIDE;
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
signals:
void pluginsChanged();
void showOnlyConfigurableChanged();
private:
Plugins *m_plugins = nullptr;
bool m_showOnlyConfigurable = false;
};
#endif // PLUGINSPROXY_H

View File

@ -138,13 +138,6 @@ Page {
}
MeaListItemDelegate {
Layout.fillWidth: true
iconName: "../images/network-vpn.svg"
text: qsTr("Server interfaces")
onClicked: pageStack.push(Qt.resolvedUrl("system/ConnectionInterfacesPage.qml"))
}
MeaListItemDelegate {
Layout.fillWidth: true
iconName: "../images/cloud.svg"
@ -152,24 +145,28 @@ Page {
visible: engine.jsonRpcClient.ensureServerVersion("1.9")
onClicked: pageStack.push(Qt.resolvedUrl("system/CloudSettingsPage.qml"))
}
MeaListItemDelegate {
Layout.fillWidth: true
iconName: "../images/plugin.svg"
text: qsTr("Plugins")
onClicked:pageStack.push(Qt.resolvedUrl("system/PluginsPage.qml"))
}
MeaListItemDelegate {
Layout.fillWidth: true
iconName: "../images/logs.svg"
text: qsTr("Log viewer")
onClicked: pageStack.push(Qt.resolvedUrl("system/LogViewerPage.qml"))
}
MeaListItemDelegate {
Layout.fillWidth: true
iconName: "../images/network-vpn.svg"
text: qsTr("Server interfaces")
onClicked: pageStack.push(Qt.resolvedUrl("system/ConnectionInterfacesPage.qml"))
}
MeaListItemDelegate {
Layout.fillWidth: true
iconName: "../images/info.svg"
text: qsTr("About nymea")
text: qsTr("About %1:core").arg(app.systemName)
onClicked: pageStack.push(Qt.resolvedUrl("system/AboutNymeaPage.qml"))
}
}

View File

@ -8,6 +8,7 @@ MeaListItemDelegate {
text: model.address
subText: model.port
iconName: "../images/network-wifi-symbolic.svg"
progressive: false
iconColor: {
if ((engine.connection.hostAddress === model.address || model.address === "0.0.0.0")
&& engine.connection.port === model.port) {
@ -21,5 +22,5 @@ MeaListItemDelegate {
tertiaryIconName: "../images/network-secure.svg"
tertiaryIconColor: model.sslEnabled ? app.accentColor : tertiaryIconKeyColor
canDelete: true
// canDelete: true
}

View File

@ -11,18 +11,46 @@ Page {
text: qsTr("Plugins")
backButtonVisible: true
onBackPressed: pageStack.pop()
}
ListView {
anchors.fill: parent
model: engine.deviceManager.plugins
clip: true
delegate: MeaListItemDelegate {
width: parent.width
iconName: "../images/plugin.svg"
text: model.name
onClicked: pageStack.push(Qt.resolvedUrl("PluginParamsPage.qml"), {plugin: engine.deviceManager.plugins.get(index)})
HeaderButton {
imageSource: "../images/configure.svg"
color: pluginsProxy.showOnlyConfigurable ? app.accentColor : keyColor
onClicked: {
pluginsProxy.showOnlyConfigurable = !pluginsProxy.showOnlyConfigurable
}
}
}
ColumnLayout {
anchors.fill: parent
Label {
Layout.fillWidth: true
Layout.margins: app.margins
wrapMode: Text.WordWrap
text: qsTr("This list shows the list of installed plugins on this %1 box.").arg(app.systemName)
}
ThinDivider {}
ListView {
Layout.fillWidth: true
Layout.fillHeight: true
model: PluginsProxy {
id: pluginsProxy
plugins: engine.deviceManager.plugins
}
clip: true
delegate: MeaListItemDelegate {
property var plugin: pluginsProxy.get(index)
width: parent.width
iconName: "../images/plugin.svg"
text: model.name
progressive: plugin.paramTypes.count > 0
onClicked: pageStack.push(Qt.resolvedUrl("PluginParamsPage.qml"), {plugin: plugin})
}
}
}
}