[SCM] ktp-accounts-kcm packaging branch, master, updated. debian/15.12.1-1-1157-gc4589c5

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:01:50 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-accounts-kcm.git;a=commitdiff;h=849b101

The following commit has been merged in the master branch:
commit 849b101b6042003c4f22684585f6ac5549dfe03c
Author: Daniele E. Domenichelli <daniele.domenichelli at gmail.com>
Date:   Mon Feb 27 22:45:12 2012 +0100

    Add class EditDisplayNameButton
---
 src/CMakeLists.txt                                 |   1 +
 src/edit-display-name-button.cpp                   | 161 +++++++++++++++++++++
 ...account-dialog.h => edit-display-name-button.h} |  36 +++--
 3 files changed, 179 insertions(+), 19 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8fb139a..8014005 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -19,6 +19,7 @@ set (kcm_ktp_accounts_SRCS
      account-identity-dialog.cpp
      salut-details-dialog.cpp
      accounts-list-delegate.cpp
+     edit-display-name-button.cpp
 )
 
 
diff --git a/src/edit-display-name-button.cpp b/src/edit-display-name-button.cpp
new file mode 100644
index 0000000..a93447a
--- /dev/null
+++ b/src/edit-display-name-button.cpp
@@ -0,0 +1,161 @@
+/*
+ * This file is part of telepathy-accounts-kcm
+ *
+ * Copyright (C) 2012 Daniele E. Domenichelli <daniele.domenichelli at gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "edit-display-name-button.h"
+
+#include <QtGui/QVBoxLayout>
+#include <QtGui/QLabel>
+
+#include <KDE/KDialog>
+#include <KDE/KLineEdit>
+#include <KDE/KLocalizedString>
+#include <KDE/KDebug>
+
+#include <TelepathyQt/Account>
+#include <TelepathyQt/PendingOperation>
+
+
+class EditDisplayNameDialog : public KDialog
+{
+    Q_OBJECT
+    Q_DISABLE_COPY(EditDisplayNameDialog)
+
+public:
+    EditDisplayNameDialog(Tp::AccountPtr account,
+                          QWidget* parent = 0,
+                          Qt::WFlags flags = 0);
+    virtual ~EditDisplayNameDialog();
+
+    QString displayName() const;
+
+private Q_SLOTS:
+    void onTextChanged(const QString &text);
+
+private:
+    Tp::AccountPtr m_account;
+    KLineEdit *m_displayNameLineEdit;
+};
+
+
+EditDisplayNameDialog::EditDisplayNameDialog(Tp::AccountPtr account,
+                                             QWidget* parent,
+                                             Qt::WFlags flags)
+    : KDialog(parent, flags),
+      m_account(account)
+{
+    setCaption(i18n("Edit display name"));
+    setButtons( KDialog::Ok | KDialog::Cancel );
+    setWindowIcon(KIcon(QLatin1String("telepathy-kde")));
+    setFixedSize(400, 150);
+    enableButtonOk(false);
+
+    QVBoxLayout *mainLayout = new QVBoxLayout(this);
+
+    QHBoxLayout *topLayout = new QHBoxLayout(this);
+
+    QLabel *topLabel = new QLabel(i18n("Choose a new display name for your account"), this);
+    QFont font = topLabel->font();
+    font.setBold(true);
+    topLabel->setFont(font);
+    topLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
+
+    QLabel *icon = new QLabel;
+    icon->setPixmap(KIcon(account->iconName()).pixmap(KIconLoader::SizeMedium));
+    icon->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
+
+    topLayout->addWidget(topLabel);
+    topLayout->addWidget(icon);
+
+    mainLayout->addLayout(topLayout);
+
+    m_displayNameLineEdit = new KLineEdit(account->displayName(), this);
+    mainLayout->addWidget(m_displayNameLineEdit);
+
+    QLabel *bottomLabel = new QLabel(i18n("A display name is your local alias for the account, only you will see it."), this);
+    mainLayout->addWidget(bottomLabel);
+
+    QWidget * mainWidget = new QWidget(this);
+    mainWidget->setLayout(mainLayout);
+    setMainWidget(mainWidget);
+
+    connect(m_displayNameLineEdit, SIGNAL(textChanged(QString)), SLOT(onTextChanged(QString)));
+}
+
+EditDisplayNameDialog::~EditDisplayNameDialog()
+{
+}
+
+void EditDisplayNameDialog::onTextChanged(const QString& text)
+{
+    enableButtonOk(text != m_account->displayName());
+}
+
+QString EditDisplayNameDialog::displayName() const
+{
+    return m_displayNameLineEdit->text();
+}
+
+
+
+EditDisplayNameButton::EditDisplayNameButton(QWidget* parent) :
+    KPushButton(parent)
+{
+    connect(this,
+            SIGNAL(clicked(bool)),
+            SLOT(onClicked()));
+}
+
+EditDisplayNameButton::~EditDisplayNameButton()
+{
+}
+
+void EditDisplayNameButton::setAccount(Tp::AccountPtr account)
+{
+    m_account = account;
+}
+
+Tp::AccountPtr EditDisplayNameButton::account() const
+{
+    return m_account;
+}
+
+void EditDisplayNameButton::onClicked()
+{
+    if (!m_account.isNull() && m_account->isValid()) {
+        EditDisplayNameDialog *dialog = new EditDisplayNameDialog(m_account, this);
+        dialog->exec();
+        if (dialog->result() == KDialog::Accepted) {
+            kDebug() << "Setting display name" << dialog->displayName() << "for account" << account()->uniqueIdentifier();
+            Tp::PendingOperation *op = m_account->setDisplayName(dialog->displayName());
+            connect(op, SIGNAL(finished(Tp::PendingOperation*)), SLOT(onFinished(Tp::PendingOperation*)));
+        }
+    }
+}
+
+void EditDisplayNameButton::onFinished(Tp::PendingOperation* op)
+{
+    if (op->isError()) {
+        kWarning() << "Cannot set display name" << op->errorName() << op->errorMessage();
+    }
+}
+
+
+#include "edit-display-name-button.moc"
+#include "moc_edit-display-name-button.cpp"
diff --git a/src/edit-account-dialog.h b/src/edit-display-name-button.h
similarity index 56%
copy from src/edit-account-dialog.h
copy to src/edit-display-name-button.h
index 6fdf98d..159b63d 100644
--- a/src/edit-account-dialog.h
+++ b/src/edit-display-name-button.h
@@ -1,7 +1,7 @@
 /*
  * This file is part of telepathy-accounts-kcm
  *
- * Copyright (C) 2009 Collabora Ltd. <info at collabora.com>
+ * Copyright (C) 2012 Daniele E. Domenichelli <daniele.domenichelli at gmail.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -18,34 +18,32 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef KCM_TELEPATHY_ACCOUNTS_EDIT_ACCOUNT_DIALOG_H
-#define KCM_TELEPATHY_ACCOUNTS_EDIT_ACCOUNT_DIALOG_H
+#ifndef EDIT_DISPLAY_NAME_BUTTON_H
+#define EDIT_DISPLAY_NAME_BUTTON_H
 
-#include "account-item.h"
+#include <KDE/KPushButton>
+#include <TelepathyQt/Types>
 
-#include <KDialog>
+namespace Tp { class PendingOperation; }
 
-class EditAccountDialog : public KDialog
+class EditDisplayNameButton : public KPushButton
 {
     Q_OBJECT
+    Q_DISABLE_COPY(EditDisplayNameButton)
 
 public:
-    explicit EditAccountDialog(AccountItem *item, QWidget *parent = 0);
-    virtual ~EditAccountDialog();
+    explicit EditDisplayNameButton(QWidget *parent = 0);
+    virtual ~EditDisplayNameButton();
+
+    void setAccount(Tp::AccountPtr account);
+    Tp::AccountPtr account() const;
 
 private Q_SLOTS:
-    void onParametersUpdated(Tp::PendingOperation *op);
-    void onDisplayNameUpdated(Tp::PendingOperation *op);
+    void onClicked();
+    void onFinished(Tp::PendingOperation* op);
 
 private:
-    Q_DISABLE_COPY(EditAccountDialog);
-
-    void accept();
-
-    class Private;
-    Private * const d;
+    Tp::AccountPtr m_account;
 };
 
-
-#endif // header guard
-
+#endif // EDIT_DISPLAY_NAME_BUTTON_H

-- 
ktp-accounts-kcm packaging



More information about the pkg-kde-commits mailing list