diff --git a/src/conf/accountpages/codecs.cpp b/src/conf/accountpages/codecs.cpp index 06916c16..c06d00c5 100644 --- a/src/conf/accountpages/codecs.cpp +++ b/src/conf/accountpages/codecs.cpp @@ -1,115 +1,114 @@ /*************************************************************************** * Copyright (C) 2014-2015 by Savoir-Faire Linux * * Author : Emmanuel Lepage Vallee * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * **************************************************************************/ #include "codecs.h" // #include // #include // // // Pages::Codecs::Codecs(QWidget *parent) : PageBase(parent) // { // setupUi(this); // connect(this,&PageBase::accountSet,[this]() { // disconnect(button_audiocodecUp ); // disconnect(button_audiocodecDown); // m_pCodecs->setModel(account()->codecModel()); // m_pCodecs->setSelectionModel(account()->codecModel()->selectionModel()); // connect(button_audiocodecUp , &QToolButton::clicked,account()->codecModel(), &CodecModel::moveUp ); // connect(button_audiocodecDown, &QToolButton::clicked,account()->codecModel(), &CodecModel::moveDown); // }); // // connect(m_pCodecs, &QListView::clicked, this, [this](const QModelIndex& idx) { // m_pSampleRate->setText(idx.data(CodecModel::Role::SAMPLERATE).toString()); // }); // // connect(m_pCodecs, &QListView::clicked, this, [this](const QModelIndex& idx) { // m_pBitrate->setText(idx.data(CodecModel::Role::BITRATE).toString()); // }); // } // Qt #include #include #include #include #include #include #include // Ring #include #include #include Pages::Codecs::Codecs(QWidget* parent) : PageBase(parent),m_pAccount(nullptr) { setupUi(this); m_pWidget = new QQuickWidget(RingApplication::engine(), this); for (auto w : {static_cast(this), static_cast(m_pWidget)}) w->setStyleSheet(QStringLiteral("margin:0px; spacing:0px; padding:0px;")); auto l = new QHBoxLayout(m_pPlaceHolder); l->setContentsMargins(0,0,0,0); l->addWidget(m_pWidget); m_pWidget->setResizeMode(QQuickWidget::SizeRootObjectToView); m_pWidget->setSource(QUrl(QStringLiteral("qrc:/Codecs.qml"))); const auto errors = m_pWidget->errors(); for (auto e : qAsConst(errors)) { qDebug() << e.toString(); } connect(this,&PageBase::accountSet,[this]() { // disconnect(button_audiocodecUp ); // disconnect(button_audiocodecDown); // m_pCodecs->setModel(account()->codecModel()); // m_pCodecs->setSelectionModel(account()->codecModel()->selectionModel()); // connect(button_audiocodecUp , &QToolButton::clicked,account()->codecModel(), &CodecModel::moveUp ); // connect(button_audiocodecDown, &QToolButton::clicked,account()->codecModel(), &CodecModel::moveDown); }); // connect(m_pCodecs, &QListView::clicked, this, [this](const QModelIndex& idx) { // m_pSampleRate->setText(idx.data(CodecModel::Role::SAMPLERATE).toString()); // }); // // connect(m_pCodecs, &QListView::clicked, this, [this](const QModelIndex& idx) { // m_pBitrate->setText(idx.data(CodecModel::Role::BITRATE).toString()); // }); } void Pages::Codecs::setAccount(Account* a) { - const auto errors = m_pWidget->errors(); for (auto e : qAsConst(errors)) { qDebug() << e.toString(); } Q_ASSERT(m_pWidget->rootObject()); if (m_pWidget->rootObject()) m_pWidget->rootObject()->setProperty("account", QVariant::fromValue(a)); m_pAccount = a; } // kate: space-indent on; indent-width 4; replace-tabs on; diff --git a/src/conf/accountpages/credentials.cpp b/src/conf/accountpages/credentials.cpp index 3a1cdc91..09eee9c5 100644 --- a/src/conf/accountpages/credentials.cpp +++ b/src/conf/accountpages/credentials.cpp @@ -1,113 +1,149 @@ /*************************************************************************** * Copyright (C) 2014-2015 by Savoir-Faire Linux * * Author : Emmanuel Lepage Vallee * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * **************************************************************************/ #include "credentials.h" +// Qt +#include +#include +#include +#include +#include +#include + +// LibRingQt #include #include #include +#include Pages::Credentials::Credentials(QWidget *parent) : PageBase(parent) { setupUi(this); + m_pWidget = new QQuickWidget(RingApplication::engine(), this); m_pDelegate = new CategorizedDelegate(m_pCredentials); m_pChildDelegate = new QStyledItemDelegate(); m_pDelegate->setChildDelegate(m_pChildDelegate); m_pCredentials->setItemDelegate(m_pDelegate); + auto l = new QHBoxLayout(m_pQML); + l->setContentsMargins(0,0,0,0); + l->addWidget(m_pWidget); + + m_pWidget->setResizeMode(QQuickWidget::SizeRootObjectToView); + m_pWidget->setSource(QUrl(QStringLiteral("qrc:/Credentials.qml"))); + + const auto errors = m_pWidget->errors(); + + for (auto e : qAsConst(errors)) { + qDebug() << e.toString(); + } + connect(this,&PageBase::accountSet, this, &Pages::Credentials::slotSetAccount); connect(m_pCredentials , &QTreeView::clicked , this, &Pages::Credentials::loadInfo ); connect(button_add_credential , &QToolButton::clicked , this, &Pages::Credentials::slotAddCredential ); connect(button_remove_credential , &QToolButton::clicked , this, &Pages::Credentials::slotRemoveCredential ); connect(edit_credential_realm_2 , &QLineEdit::textChanged, this, &Pages::Credentials::slotRealmChanged ); connect(edit_credential_auth_2 , &QLineEdit::textChanged, this, &Pages::Credentials::slotUserChanged ); connect(edit_credential_password_2 , &QLineEdit::textChanged, this, &Pages::Credentials::slotPasswdChanged ); - } Pages::Credentials::~Credentials() { m_pDelegate->setChildDelegate(nullptr); delete m_pChildDelegate; delete m_pDelegate; } void Pages::Credentials::slotSetAccount() { m_pCredentials->setModel(account()->credentialModel()); loadInfo(); m_pType->bindToModel(account()->credentialModel()->availableTypeModel(),account()->credentialModel()->availableTypeSelectionModel()); connect(account()->credentialModel(), &QAbstractItemModel::rowsInserted, m_pCredentials, &QTreeView::expandAll); m_pCredentials->expandAll(); } void Pages::Credentials::slotAddCredential() { m_pCredentials->setCurrentIndex(account()->credentialModel()->addCredentials()); loadInfo(); } void Pages::Credentials::slotRemoveCredential() { account()->credentialModel()->removeCredentials(m_pCredentials->currentIndex()); m_pCredentials->setCurrentIndex(account()->credentialModel()->index(0,0)); loadInfo(); } void Pages::Credentials::slotRealmChanged(const QString& text) { const QModelIndex current = m_pCredentials->selectionModel()->currentIndex(); account()->credentialModel()->setData(current,text, CredentialModel::Role::REALM); } void Pages::Credentials::slotUserChanged(const QString& text) { const QModelIndex current = m_pCredentials->selectionModel()->currentIndex(); account()->credentialModel()->setData(current,text, CredentialModel::Role::NAME); } void Pages::Credentials::slotPasswdChanged(const QString& text) { const QModelIndex current = m_pCredentials->selectionModel()->currentIndex(); account()->credentialModel()->setData(current,text, CredentialModel::Role::PASSWORD); } void Pages::Credentials::loadInfo() { const QModelIndex idx = m_pCredentials->selectionModel()->currentIndex(); if (idx.isValid()) { edit_credential_password_2->blockSignals(true); edit_credential_auth_2->blockSignals(true); edit_credential_realm_2->blockSignals(true); edit_credential_realm_2->setText ( m_pCredentials->model()->data(idx,CredentialModel::Role::REALM) .toString()); edit_credential_auth_2->setText ( m_pCredentials->model()->data(idx,CredentialModel::Role::NAME) .toString()); edit_credential_password_2->setText ( m_pCredentials->model()->data(idx,CredentialModel::Role::PASSWORD) .toString()); edit_credential_realm_2->blockSignals(false); edit_credential_auth_2->blockSignals(false); edit_credential_password_2->blockSignals(false); } else if (account()->credentialModel()->rowCount()) { m_pCredentials->setCurrentIndex(account()->credentialModel()->index(0,0)); loadInfo(); } } +void Pages::Credentials::setAccount(Account* a) +{ + const auto errors = m_pWidget->errors(); + for (auto e : qAsConst(errors)) { + qDebug() << e.toString(); + } + + Q_ASSERT(m_pWidget->rootObject()); + + if (m_pWidget->rootObject()) + m_pWidget->rootObject()->setProperty("account", QVariant::fromValue(a)); +} + // kate: space-indent on; indent-width 3; replace-tabs on; diff --git a/src/conf/accountpages/credentials.h b/src/conf/accountpages/credentials.h index f68cef6b..d10599b4 100644 --- a/src/conf/accountpages/credentials.h +++ b/src/conf/accountpages/credentials.h @@ -1,56 +1,59 @@ /*************************************************************************** * Copyright (C) 2014-2015 by Savoir-Faire Linux * * Author : Emmanuel Lepage Vallee * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * **************************************************************************/ #ifndef CREDENTIALS_PAGE_H #define CREDENTIALS_PAGE_H #include #include "pagebase.h" #include "ui_credentials.h" class CategorizedDelegate; +class QQuickWidget; class QStyledItemDelegate; namespace Pages { class Credentials final : public PageBase, public Ui_CredentialsPage { Q_OBJECT public: //Constructor explicit Credentials(QWidget *parent = nullptr); virtual ~Credentials(); + void setAccount(Account* a); private: CategorizedDelegate* m_pDelegate; QStyledItemDelegate* m_pChildDelegate; + QQuickWidget* m_pWidget; private Q_SLOTS: void loadInfo(); void slotSetAccount(); void slotAddCredential(); void slotRemoveCredential(); void slotRealmChanged(const QString& text); void slotUserChanged(const QString& text); void slotPasswdChanged(const QString& text); }; } #endif // kate: space-indent on; indent-width 3; replace-tabs on; diff --git a/src/conf/accountpages/credentials.ui b/src/conf/accountpages/credentials.ui index e1a6bbd2..7ba951e7 100644 --- a/src/conf/accountpages/credentials.ui +++ b/src/conf/accountpages/credentials.ui @@ -1,226 +1,220 @@ CredentialsPage 0 0 659 530 - - - - - 0 - 0 - - - - - 32 - 16777215 - - - - - - - - - - - - 0 - 0 - - - - This tab help manage accounts with multiple credentials. If you have multiple accounts. Do not use this feature, just create multiple accounts in Ring-KDE. Nor use this dialog if you only have one set of credentials. In that case, the "Basic" tab will provide everything you need. - - - true - - - - - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - 0 - 0 - - - - Add - - - - ../../../../../../.designer/backup../../../../../../.designer/backup - - - - - - - Remove - - - - ../../../../../../.designer/backup../../../../../../.designer/backup - - - - - - + 0 0 Details Realm Auth. name Password true Usually * true Usually your extension number true true QLineEdit::Password SIP password, ask your network administrator Qt::Vertical QSizePolicy::Minimum 20 40 - + + + + + 0 + 0 + + + + + 32 + 16777215 + + + + + + + + + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + 0 + 0 + + + + Add + + + + ../../../../../../.designer/backup../../../../../../.designer/backup + + + + + + + Remove + + + + ../../../../../../.designer/backup../../../../../../.designer/backup + + + + + + - + 0 0 true Qt::MoveAction 5 false + + + + + 0 + 0 + + + + AutoComboBox QComboBox
widgets/autocombobox.h
CategorizedTree QTreeView
widgets/categorizedtree.h
diff --git a/src/conf/confresources.qrc b/src/conf/confresources.qrc index eec3458a..cb1a3c20 100644 --- a/src/conf/confresources.qrc +++ b/src/conf/confresources.qrc @@ -1,6 +1,7 @@ qml/devices.qml qml/codecs.qml + qml/credentials.qml diff --git a/src/conf/qml/credentials.qml b/src/conf/qml/credentials.qml new file mode 100644 index 00000000..c70d3537 --- /dev/null +++ b/src/conf/qml/credentials.qml @@ -0,0 +1,128 @@ +/*************************************************************************** +* Copyright (C) 2017 by Bluesystems * +* Author : Emmanuel Lepage Vallee * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 3 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program. If not, see . * +**************************************************************************/ +import QtQuick 2.8 +import org.kde.kirigami 2.5 as Kirigami +import org.kde.playground.kquickview 1.0 as KQuickItemViews +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 +import RingQmlWidgets 1.0 + +Rectangle { + property var account: null + + SystemPalette { + id: activePalette + colorGroup: SystemPalette.Active + } + + + SystemPalette { + id: inactivePalette + colorGroup: SystemPalette.Inactive + } + + color: activePalette.window + + ColumnLayout { + anchors.fill: parent + Label { + Layout.fillWidth: true + text: i18n("This tab help manage accounts with multiple credentials. If you have multiple accounts. Do not use this feature, just create multiple accounts in Ring-KDE. Nor use this dialog if you only have one set of credentials. In that case, the \"Basic\" tab will provide everything you need.") + } + + KQuickItemViews.TreeView { + id: gridView + Layout.fillHeight: true + Layout.fillWidth: true + + model: account ? account.credentialModel : null + + delegate: Loader { + Component { + id: categoryDelegate + ColumnLayout { + width: gridView.width + Item { + height: 10 + } + Kirigami.Heading { + text: display + } + } + } + + Component { + id: credentialDelegate + Kirigami.SwipeListItem { + ColumnLayout { + Label { + text: display + } + RowLayout { + Text { + color: inactivePalette.text + text: "Realm: "+realm+"" + } + Item { + Layout.fillWidth: true + } + } + } + actions: [ + Kirigami.Action { + text: i18n("Remove") + iconName: "list-remove" + onTriggered: { + account.credentialModel.removeCredentials( + rootIndex + ) + } + }, + Kirigami.Action { + text: i18n("Edit") + iconName: "document-edit" + onTriggered: print("Action 1 clicked") + }, + Kirigami.Action { + text: i18n("Move up") + iconName: "go-up" + onTriggered: print("Action 1 clicked") + }, + Kirigami.Action { + text: i18n("Move down") + iconName: "go-down" + onTriggered: print("Action 1 clicked") + } + ] + } + } + + sourceComponent: isCategory ? categoryDelegate : credentialDelegate + } + + } + + OutlineButtons { + Layout.fillWidth: true + height: 50 + implicitHeight: 50 + model: account ? account.credentialModel.availableTypeModel : null + } + + } +} diff --git a/src/ringapplication.cpp b/src/ringapplication.cpp index d12e471d..80d086f3 100644 --- a/src/ringapplication.cpp +++ b/src/ringapplication.cpp @@ -1,707 +1,709 @@ /*************************************************************************** * Copyright (C) 2009-2015 by Savoir-Faire Linux * * Author : Emmanuel Lepage Valle * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * **************************************************************************/ //Parent #include "ringapplication.h" //Qt #include #include #include #include #include #include #include #include #include #include #include //KDE #include #include #include #include //LRC #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include