[SCM] ktp-accounts-kcm packaging branch, master, updated. debian/15.12.1-1-1157-gc4589c5
Maximiliano Curia
maxy at moszumanska.debian.org
Fri May 27 23:58:12 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-accounts-kcm.git;a=commitdiff;h=d2328a6
The following commit has been merged in the master branch:
commit d2328a62a7e901797226c127251737b0ff432c5f
Author: Dariusz Mikulski <dariusz.mikulski at gmail.com>
Date: Tue Dec 15 23:59:55 2009 +0000
Allow in interface setting a title for custom tabs, setting sensible titles for gabble pages
svn path=/trunk/playground/network/telepathy-accounts-kcm/; revision=1062786
---
src/account-item.cpp | 9 ++
src/account-item.h | 15 ++-
src/accounts-list-model.cpp | 12 +++
src/accounts-list-model.h | 7 ++
src/add-account-assistant.cpp | 55 ++++++++--
src/add-account-assistant.h | 5 +
src/edit-account-dialog.cpp | 235 +++++++++++++++++++++++------------------
src/edit-account-dialog.h | 7 ++
src/kcm-telepathy-accounts.cpp | 26 +++++
src/kcm-telepathy-accounts.h | 4 +
10 files changed, 259 insertions(+), 116 deletions(-)
diff --git a/src/account-item.cpp b/src/account-item.cpp
index d514370..2bc43c1 100644
--- a/src/account-item.cpp
+++ b/src/account-item.cpp
@@ -98,6 +98,10 @@ void AccountItem::edit()
connect(m_editAccountDialog,
SIGNAL(finished()),
SLOT(onAccountEdited()));
+ connect(m_editAccountDialog, SIGNAL(protocolSelected(QString, QString)),
+ this, SIGNAL(protocolSelected(QString, QString)));
+ connect(this, SIGNAL(setTitleForCustomPages(QString, QList<QString>)),
+ m_editAccountDialog, SLOT(onTitleForCustomPages(QString, QList<QString>)));
m_editAccountDialog->show();
}
@@ -183,6 +187,11 @@ void AccountItem::onAccountEdited()
Q_EMIT updated();
}
+void AccountItem::onTitleForCustomPages(QString mandatoryPage, QList<QString> optionalPage)
+{
+ kDebug();
+ emit setTitleForCustomPages(mandatoryPage, optionalPage);
+}
#include "account-item.moc"
diff --git a/src/account-item.h b/src/account-item.h
index b197505..e6c37e4 100644
--- a/src/account-item.h
+++ b/src/account-item.h
@@ -47,16 +47,21 @@ public:
void remove();
const KIcon& icon() const;
-private Q_SLOTS:
- void generateIcon();
- void onAccountReady(Tp::PendingOperation *op);
- void onAccountRemoved(Tp::PendingOperation *op);
- void onAccountEdited();
+public Q_SLOTS:
+ void onTitleForCustomPages(QString, QList<QString>);
Q_SIGNALS:
void ready();
void removed();
void updated();
+ void protocolSelected(QString, QString);
+ void setTitleForCustomPages(QString, QList<QString>);
+
+private Q_SLOTS:
+ void generateIcon();
+ void onAccountReady(Tp::PendingOperation *op);
+ void onAccountRemoved(Tp::PendingOperation *op);
+ void onAccountEdited();
private:
Tp::AccountPtr m_account;
diff --git a/src/accounts-list-model.cpp b/src/accounts-list-model.cpp
index 9641330..0f607f2 100644
--- a/src/accounts-list-model.cpp
+++ b/src/accounts-list-model.cpp
@@ -156,6 +156,11 @@ void AccountsListModel::editAccount(const QModelIndex &index)
return;
}
+ connect(accountItem, SIGNAL(protocolSelected(QString, QString)),
+ this, SIGNAL(protocolSelected(QString, QString)));
+ connect(this, SIGNAL(setTitleForCustomPages(QString, QList<QString>)),
+ accountItem, SLOT(onTitleForCustomPages(QString, QList<QString>)));
+
accountItem->edit();
}
@@ -249,6 +254,13 @@ void AccountsListModel::onAccountItemUpdated()
emit dataChanged(index, index);
}
+void AccountsListModel::onTitleForCustomPages(QString mandatoryPage, QList<QString> optionalPage)
+{
+ kDebug();
+
+ emit setTitleForCustomPages(mandatoryPage, optionalPage);
+}
+
#include "accounts-list-model.moc"
diff --git a/src/accounts-list-model.h b/src/accounts-list-model.h
index 6beefea..9325b5d 100644
--- a/src/accounts-list-model.h
+++ b/src/accounts-list-model.h
@@ -43,6 +43,13 @@ public:
void editAccount(const QModelIndex &index);
void removeAccount(const QModelIndex &index);
+Q_SIGNALS:
+ void protocolSelected(QString, QString);
+ void setTitleForCustomPages(QString, QList<QString>);
+
+public Q_SLOTS:
+ void onTitleForCustomPages(QString, QList<QString>);
+
private Q_SLOTS:
void onAccountItemReady();
void onAccountItemRemoved();
diff --git a/src/add-account-assistant.cpp b/src/add-account-assistant.cpp
index 9147c23..15fa951 100644
--- a/src/add-account-assistant.cpp
+++ b/src/add-account-assistant.cpp
@@ -61,6 +61,8 @@ public:
QList<AbstractAccountParametersWidget*> optionalParametersWidgets;
KPageWidgetItem *pageOne;
KPageWidgetItem *pageTwo;
+ QString mandatoryPageDesc;
+ QList<QString> optionalPageDesc;
};
AddAccountAssistant::AddAccountAssistant(Tp::AccountManagerPtr accountManager, QWidget *parent)
@@ -79,9 +81,10 @@ AddAccountAssistant::AddAccountAssistant(Tp::AccountManagerPtr accountManager, Q
connect(d->protocolSelectWidget,
SIGNAL(protocolGotSelected(bool)),
SLOT(onProtocolSelected(bool)));
- connect(d->protocolSelectWidget,
- SIGNAL(protocolDoubleClicked()),
- SLOT(next()));
+ connect(d->protocolSelectWidget,
+ SIGNAL(protocolDoubleClicked()),
+ SLOT(onProtocolDoubleClicked()),
+ Qt::DirectConnection);
d->tabWidget = new KTabWidget(this);
d->pageTwo = new KPageWidgetItem(d->tabWidget);
@@ -180,12 +183,17 @@ void AddAccountAssistant::next()
item->mandatoryParameters(), QVariantMap(), d->tabWidget);
}
- d->tabWidget->addTab(d->mandatoryParametersWidget, i18n("Mandatory Parameters"));
+ if(d->mandatoryPageDesc.isEmpty())
+ d->tabWidget->addTab(d->mandatoryParametersWidget, i18n("Mandatory Parameters"));
+ else
+ d->tabWidget->addTab(d->mandatoryParametersWidget, d->mandatoryPageDesc);
// Get the list of parameters
Tp::ProtocolParameterList optionalParameters = item->optionalParameters();
Tp::ProtocolParameterList optionalParametersLeft = item->optionalParameters();
+ int pageIndex = 0;
+
// Check if the AbstractAccountUi exists. If not then we use the autogenerated UI for
// everything.
if (ui) {
@@ -209,7 +217,13 @@ void AddAccountAssistant::next()
foreach (AbstractAccountParametersWidget *widget, widgets) {
d->optionalParametersWidgets.append(widget);
- d->tabWidget->addTab(widget, i18n("Optional Parameters"));
+ int indexOf = widgets.indexOf(widget);
+ QString description = i18n("Optional parameter");
+ if(indexOf < d->optionalPageDesc.size())
+ description = d->optionalPageDesc.at(indexOf);
+
+ d->tabWidget->addTab(widget, description);
+ pageIndex++;
}
}
@@ -220,7 +234,10 @@ void AddAccountAssistant::next()
QVariantMap(),
d->tabWidget);
d->optionalParametersWidgets.append(opew);
- d->tabWidget->addTab(opew, i18n("Optional Parameters"));
+ if(pageIndex < d->optionalPageDesc.size())
+ d->tabWidget->addTab(opew, d->optionalPageDesc.at(pageIndex));
+ else
+ d->tabWidget->addTab(opew, i18n("Optional Parameters"));
}
KAssistantDialog::next();
@@ -385,8 +402,34 @@ void AddAccountAssistant::onSetEnabledFinished(Tp::PendingOperation *op)
void AddAccountAssistant::onProtocolSelected(bool value)
{
+ kDebug();
//if a protocol is selected, enable the next button on the first page
setValid(d->pageOne, value);
+
+ if(value)
+ {
+ ProtocolItem *item = d->protocolSelectWidget->selectedProtocol();
+ emit protocolSelected(item->protocol(), item->localizedName());
+ }
+}
+
+void AddAccountAssistant::onProtocolDoubleClicked()
+{
+ kDebug();
+
+ ProtocolItem *item = d->protocolSelectWidget->selectedProtocol();
+ emit protocolSelected(item->protocol(), item->localizedName());
+ next();
+}
+
+void AddAccountAssistant::onTitleForCustomPages(QString mandatoryPage, QList<QString> optionalPage)
+{
+ kDebug();
+ d->mandatoryPageDesc.clear();
+ d->optionalPageDesc.clear();
+
+ d->mandatoryPageDesc = mandatoryPage;
+ d->optionalPageDesc = optionalPage;
}
diff --git a/src/add-account-assistant.h b/src/add-account-assistant.h
index b16d76b..3cd3e08 100644
--- a/src/add-account-assistant.h
+++ b/src/add-account-assistant.h
@@ -44,11 +44,16 @@ protected Q_SLOTS:
Q_SIGNALS:
void cancelled();
+ void protocolSelected(QString, QString);
+
+public Q_SLOTS:
+ void onTitleForCustomPages(QString mandatoryPage, QList<QString> optionalPage);
private Q_SLOTS:
void onAccountCreated(Tp::PendingOperation *op);
void onSetEnabledFinished(Tp::PendingOperation *op);
void onProtocolSelected(bool value);
+ void onProtocolDoubleClicked();
private:
class Private;
diff --git a/src/edit-account-dialog.cpp b/src/edit-account-dialog.cpp
index 60ab1ff..350c16f 100644
--- a/src/edit-account-dialog.cpp
+++ b/src/edit-account-dialog.cpp
@@ -67,113 +67,14 @@ EditAccountDialog::EditAccountDialog(AccountItem *item, QWidget *parent)
resize(400, 480);
d->item = item;
+}
- // Get the protocol's parameters.
- Tp::ProtocolInfo *protocolInfo = d->item->account()->protocolInfo();
- Tp::ProtocolParameterList protocolParameters = protocolInfo->parameters();
-
- foreach (Tp::ProtocolParameter *parameter, protocolParameters) {
- if (parameter->isRequired()) {
- d->mandatoryProtocolParameters.append(parameter);
- } else {
- d->optionalProtocolParameters.append(parameter);
- }
- }
-
- // Get the parameter values.
- d->parameterValues = d->item->account()->parameters();
-
- // The rest of this method is based on code from add-account-assistant.cpp
-
- // Get the AccountsUi for the plugin, and get the optional parameter widgets for it.
- AbstractAccountUi *ui = PluginManager::instance()->accountUiForProtocol(item->account()->cmName(),
- item->account()->protocol());
-
- // Set up the Mandatory Parameters page
- Tp::ProtocolParameterList mandatoryParametersLeft = d->mandatoryProtocolParameters;
-
- // Create the custom UI or generic UI depending on available parameters.
- if (ui) {
- // UI does exist, set it up.
- AbstractAccountParametersWidget *widget = ui->mandatoryParametersWidget(d->mandatoryProtocolParameters,
- item->account()->parameters());
- QMap<QString, QVariant::Type> manParams = ui->supportedMandatoryParameters();
- QMap<QString, QVariant::Type>::const_iterator manIter = manParams.constBegin();
- while(manIter != manParams.constEnd()) {
- foreach (Tp::ProtocolParameter *parameter, d->mandatoryProtocolParameters) {
- // If the parameter is not
- if ((parameter->name() == manIter.key()) &&
- (parameter->type() == manIter.value())) {
- mandatoryParametersLeft.removeAll(parameter);
- }
- }
-
- ++manIter;
- }
-
- if (mandatoryParametersLeft.isEmpty()) {
- d->mandatoryParametersWidget = widget;
- } else {
- // FIXME: At the moment, if the custom widget can't handle all the mandatory
- // parameters we fall back to the generic one for all of them. It might be nicer
- // to have the custom UI for as many as possible, and stick a small generic one
- // underneath for those parameters it doesn't handle.
- widget->deleteLater();
- widget = 0;
- }
- }
-
- if (!d->mandatoryParametersWidget) {
- d->mandatoryParametersWidget = new MandatoryParameterEditWidget(
- d->mandatoryProtocolParameters,
- item->account()->parameters(),
- d->tabWidget);
- }
-
- d->tabWidget->addTab(d->mandatoryParametersWidget, i18n("Mandatory Parameters"));
-
- // Get the list of parameters
- Tp::ProtocolParameterList optionalParametersLeft = d->optionalProtocolParameters;
-
- // Check if the AbstractAccountUi exists. If not then we use the autogenerated UI for
- // everything.
- if (ui) {
- // UI Does exist, set it up.
- QList<AbstractAccountParametersWidget*> widgets = ui->optionalParametersWidgets(
- d->optionalProtocolParameters,
- item->account()->parameters());
-
- // Remove all handled parameters from the optionalParameters list.
- QMap<QString, QVariant::Type> opParams = ui->supportedOptionalParameters();
- QMap<QString, QVariant::Type>::const_iterator opIter = opParams.constBegin();
- while(opIter != opParams.constEnd()) {
- foreach (Tp::ProtocolParameter *parameter, d->optionalProtocolParameters) {
- // If the parameter is not
- if ((parameter->name() == opIter.key()) &&
- (parameter->type() == opIter.value())) {
- optionalParametersLeft.removeAll(parameter);
- }
- }
-
- ++opIter;
- }
-
- foreach (AbstractAccountParametersWidget *widget, widgets) {
- d->optionalParametersWidgets.append(widget);
- d->tabWidget->addTab(widget, i18n("Optional Parameters"));
- }
- }
-
- // Show the generic UI if optionalParameters is not empty.
- if (optionalParametersLeft.size() > 0) {
- OptionalParameterEditWidget *opew =
- new OptionalParameterEditWidget(optionalParametersLeft,
- item->account()->parameters(),
- d->tabWidget);
- d->optionalParametersWidgets.append(opew);
- d->tabWidget->addTab(opew, i18n("Optional Parameters"));
- }
+void EditAccountDialog::show()
+{
+ emit protocolSelected(d->item->account()->protocol(),
+ d->item->account()->cmName());
+ KDialog::show();
}
EditAccountDialog::~EditAccountDialog()
@@ -312,6 +213,130 @@ void EditAccountDialog::onParametersUpdated(Tp::PendingOperation *op)
emit finished();
}
+void EditAccountDialog::onTitleForCustomPages(QString mandatoryPageDesc, QList<QString> optionalPageDesc)
+{
+ kDebug();
+
+ // Get the protocol's parameters.
+ Tp::ProtocolInfo *protocolInfo = d->item->account()->protocolInfo();
+ Tp::ProtocolParameterList protocolParameters = protocolInfo->parameters();
+
+ foreach (Tp::ProtocolParameter *parameter, protocolParameters) {
+ if (parameter->isRequired()) {
+ d->mandatoryProtocolParameters.append(parameter);
+ } else {
+ d->optionalProtocolParameters.append(parameter);
+ }
+ }
+
+ // Get the parameter values.
+ d->parameterValues = d->item->account()->parameters();
+
+ // The rest of this method is based on code from add-account-assistant.cpp
+
+ // Get the AccountsUi for the plugin, and get the optional parameter widgets for it.
+ AbstractAccountUi *ui = PluginManager::instance()->accountUiForProtocol(d->item->account()->cmName(),
+ d->item->account()->protocol());
+
+ // Set up the Mandatory Parameters page
+ Tp::ProtocolParameterList mandatoryParametersLeft = d->mandatoryProtocolParameters;
+
+ // Create the custom UI or generic UI depending on available parameters.
+ if (ui) {
+ // UI does exist, set it up.
+ AbstractAccountParametersWidget *widget = ui->mandatoryParametersWidget(d->mandatoryProtocolParameters,
+ d->item->account()->parameters());
+ QMap<QString, QVariant::Type> manParams = ui->supportedMandatoryParameters();
+ QMap<QString, QVariant::Type>::const_iterator manIter = manParams.constBegin();
+ while(manIter != manParams.constEnd()) {
+ foreach (Tp::ProtocolParameter *parameter, d->mandatoryProtocolParameters) {
+ // If the parameter is not
+ if ((parameter->name() == manIter.key()) &&
+ (parameter->type() == manIter.value())) {
+ mandatoryParametersLeft.removeAll(parameter);
+ }
+ }
+
+ ++manIter;
+ }
+
+ if (mandatoryParametersLeft.isEmpty()) {
+ d->mandatoryParametersWidget = widget;
+ } else {
+ // FIXME: At the moment, if the custom widget can't handle all the mandatory
+ // parameters we fall back to the generic one for all of them. It might be nicer
+ // to have the custom UI for as many as possible, and stick a small generic one
+ // underneath for those parameters it doesn't handle.
+ widget->deleteLater();
+ widget = 0;
+ }
+ }
+
+ if (!d->mandatoryParametersWidget) {
+ d->mandatoryParametersWidget = new MandatoryParameterEditWidget(
+ d->mandatoryProtocolParameters,
+ d->item->account()->parameters(),
+ d->tabWidget);
+ }
+
+ if(mandatoryPageDesc.isEmpty())
+ d->tabWidget->addTab(d->mandatoryParametersWidget, i18n("Mandatory Parameters"));
+ else
+ d->tabWidget->addTab(d->mandatoryParametersWidget, mandatoryPageDesc);
+
+ // Get the list of parameters
+ Tp::ProtocolParameterList optionalParametersLeft = d->optionalProtocolParameters;
+
+ int pageIndex = 0;
+
+ // Check if the AbstractAccountUi exists. If not then we use the autogenerated UI for
+ // everything.
+ if (ui) {
+ // UI Does exist, set it up.
+ QList<AbstractAccountParametersWidget*> widgets = ui->optionalParametersWidgets(
+ d->optionalProtocolParameters,
+ d->item->account()->parameters());
+
+ // Remove all handled parameters from the optionalParameters list.
+ QMap<QString, QVariant::Type> opParams = ui->supportedOptionalParameters();
+ QMap<QString, QVariant::Type>::const_iterator opIter = opParams.constBegin();
+ while(opIter != opParams.constEnd()) {
+ foreach (Tp::ProtocolParameter *parameter, d->optionalProtocolParameters) {
+ // If the parameter is not
+ if ((parameter->name() == opIter.key()) &&
+ (parameter->type() == opIter.value())) {
+ optionalParametersLeft.removeAll(parameter);
+ }
+ }
+
+ ++opIter;
+ }
+
+ foreach (AbstractAccountParametersWidget *widget, widgets) {
+ d->optionalParametersWidgets.append(widget);
+ int indexOf = widgets.indexOf(widget);
+ QString description = i18n("Optional parameter");
+ if(indexOf < optionalPageDesc.size())
+ description = optionalPageDesc.at(indexOf);
+
+ d->tabWidget->addTab(widget, description);
+ pageIndex++;
+ }
+ }
+
+ // Show the generic UI if optionalParameters is not empty.
+ if (optionalParametersLeft.size() > 0) {
+ OptionalParameterEditWidget *opew =
+ new OptionalParameterEditWidget(optionalParametersLeft,
+ d->item->account()->parameters(),
+ d->tabWidget);
+ d->optionalParametersWidgets.append(opew);
+ if(pageIndex < optionalPageDesc.size())
+ d->tabWidget->addTab(opew, optionalPageDesc.at(pageIndex));
+ else
+ d->tabWidget->addTab(opew, i18n("Optional Parameters"));
+ }
+}
#include "edit-account-dialog.moc"
diff --git a/src/edit-account-dialog.h b/src/edit-account-dialog.h
index 6d44df4..56ce401 100644
--- a/src/edit-account-dialog.h
+++ b/src/edit-account-dialog.h
@@ -35,6 +35,13 @@ public:
explicit EditAccountDialog(AccountItem *item, QWidget *parent = 0);
virtual ~EditAccountDialog();
+Q_SIGNALS:
+ void protocolSelected(QString, QString);
+
+public Q_SLOTS:
+ void onTitleForCustomPages(QString, QList<QString>);
+ void show();
+
protected Q_SLOTS:
virtual void slotButtonClicked(int button);
diff --git a/src/kcm-telepathy-accounts.cpp b/src/kcm-telepathy-accounts.cpp
index 1d07be2..a8ebd93 100644
--- a/src/kcm-telepathy-accounts.cpp
+++ b/src/kcm-telepathy-accounts.cpp
@@ -152,6 +152,10 @@ void KCMTelepathyAccounts::onAddAccountClicked()
this, SLOT(onAddAccountAssistantClosed()));
connect(m_addAccountAssistant, SIGNAL(accepted()),
this, SLOT(onAddAccountAssistantClosed()));
+ connect(m_addAccountAssistant, SIGNAL(protocolSelected(QString, QString)),
+ this, SLOT(onProtocolSelected(QString, QString)));
+ connect(this, SIGNAL(setTitleForCustomPages(QString, QList<QString>)),
+ m_addAccountAssistant, SLOT(onTitleForCustomPages(QString, QList<QString>)));
// ...and finally show it.
m_addAccountAssistant->show();
@@ -179,6 +183,11 @@ void KCMTelepathyAccounts::onEditAccountClicked()
}
// Item is OK. Edit the item.
+ m_accountsListModel->disconnect();
+ connect(m_accountsListModel, SIGNAL(protocolSelected(QString, QString)),
+ this, SLOT(onProtocolSelected(QString, QString)));
+ connect(this, SIGNAL(setTitleForCustomPages(QString, QList<QString>)),
+ m_accountsListModel, SLOT(onTitleForCustomPages(QString, QList<QString>)));
m_accountsListModel->editAccount(index);
}
@@ -204,6 +213,23 @@ void KCMTelepathyAccounts::onAddAccountAssistantClosed()
m_addAccountAssistant = 0;
}
+void KCMTelepathyAccounts::onProtocolSelected(QString protocol, QString localizedName)
+{
+ kDebug() << protocol << localizedName;
+
+ QString mandatoryPage;
+ QList<QString> optionalPage;
+
+ if(protocol == "jabber")
+ {
+ mandatoryPage = i18n("Basic setup");
+ optionalPage.push_back(i18n("Account preferences"));
+ optionalPage.push_back(i18n("Connection settings"));
+ optionalPage.push_back(i18n("Advanced options"));
+ }
+
+ emit setTitleForCustomPages(mandatoryPage, optionalPage);
+}
#include "kcm-telepathy-accounts.moc"
diff --git a/src/kcm-telepathy-accounts.h b/src/kcm-telepathy-accounts.h
index 63a168a..87e3b91 100644
--- a/src/kcm-telepathy-accounts.h
+++ b/src/kcm-telepathy-accounts.h
@@ -44,6 +44,9 @@ public:
const QVariantList& args = QVariantList());
virtual ~KCMTelepathyAccounts();
+Q_SIGNALS:
+ void setTitleForCustomPages(QString mandatoryPage, QList<QString> optionalPage);
+
public Q_SLOTS:
virtual void load();
@@ -56,6 +59,7 @@ private Q_SLOTS:
void onEditAccountClicked();
void onRemoveAccountClicked();
void onAddAccountAssistantClosed();
+ void onProtocolSelected(QString protocol, QString localizedName);
private:
Tp::AccountManagerPtr m_accountManager;
--
ktp-accounts-kcm packaging
More information about the pkg-kde-commits
mailing list