[SCM] ktp-contact-list packaging branch, master, updated. debian/15.12.1-2-1070-g6c56f91

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:06:56 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-list.git;a=commitdiff;h=d175fb4

The following commit has been merged in the master branch:
commit d175fb4c746cfe564b515fb37bf0c0637183e9f8
Author: Martin Klapetek <martin.klapetek at gmail.com>
Date:   Wed Jul 13 17:46:54 2011 +0200

    Check for Presence Plasmoid over D-Bus and warn user if the plasmoid is not active.
    
    CCBUG: 270675
    REVIEW: 101918
    Reviewed-by: David Edmundson
---
 main-widget.cpp | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 main-widget.h   |  4 +++
 2 files changed, 85 insertions(+), 3 deletions(-)

diff --git a/main-widget.cpp b/main-widget.cpp
index 0c676a0..dcc42b8 100644
--- a/main-widget.cpp
+++ b/main-widget.cpp
@@ -806,7 +806,7 @@ void MainWidget::onCustomContextMenuRequested(const QPoint &pos)
 
         QStringList groupList;
         QList<Tp::AccountPtr> accounts = m_accountManager->allAccounts();
-        foreach (const Tp::AccountPtr account, accounts) {
+        foreach (const Tp::AccountPtr &account, accounts) {
             if (!account->connection().isNull()) {
                 groupList.append(account->connection()->contactManager()->allKnownGroups());
             }
@@ -1071,7 +1071,7 @@ void MainWidget::selectAvatarFromAccount(const QString &accountUID)
 
     Tp::Avatar avatar = qobject_cast<AccountsModelItem*>(m_model->accountItemForId(accountUID))->data(AccountsModel::AvatarRole).value<Tp::Avatar>();
 
-    foreach (const Tp::AccountPtr account, m_accountManager->allAccounts()) {
+    foreach (const Tp::AccountPtr &account, m_accountManager->allAccounts()) {
         //don't set the avatar for the account from where it was taken
         if (account->uniqueIdentifier() == accountUID) {
             continue;
@@ -1150,7 +1150,7 @@ void MainWidget::onAvatarFetched(KJob *job)
 
         Q_ASSERT(fetchJob);
 
-        foreach (const Tp::AccountPtr account, m_accountManager->allAccounts()) {
+        foreach (const Tp::AccountPtr &account, m_accountManager->allAccounts()) {
             Tp::PendingOperation *op = account->setAvatar(fetchJob->avatar());
 
             //connect for eventual error displaying
@@ -1289,4 +1289,82 @@ void MainWidget::onSwitchToCompactView()
     guiConfigGroup.config()->sync();
 }
 
+void MainWidget::closeEvent(QCloseEvent* e)
+{
+    KSharedConfigPtr config = KGlobal::config();
+    KConfigGroup generalConfigGroup(config, "General");
+
+    bool checkForPlasmoid = generalConfigGroup.readEntry("check_for_plasmoid", true);
+
+    if (checkForPlasmoid) {
+
+        if (!isPlasmoidPresent()) {
+            KDialog *noPlasmoidDialog = new KDialog(this);
+
+            QWidget *dialogMainWidget = new QWidget(noPlasmoidDialog);
+
+            QLabel *text = new QLabel(i18n("You don't have any other presence controls active (a Presence plasmoid for example).

"
+                                           "Do you want to stay online or would you rather go offline?

"),
+                                    dialogMainWidget);
+            QCheckBox *dontAskCheckbox = new QCheckBox(i18n("Remember my preference"), dialogMainWidget);
+
+            QLabel *icon = new QLabel();
+            icon->setPixmap(KIconLoader::global()->loadIcon("dialog-information", KIconLoader::Dialog, 48));
+
+            QHBoxLayout *mainLayout = new QHBoxLayout(dialogMainWidget);
+            mainLayout->addWidget(icon);
+
+            QVBoxLayout *innerLayout = new QVBoxLayout(dialogMainWidget);
+            innerLayout->addWidget(text);
+            innerLayout->addWidget(dontAskCheckbox);
+
+            mainLayout->addLayout(innerLayout);
+
+            noPlasmoidDialog->setCaption(i18n("No other presence controls found"));
+            noPlasmoidDialog->setButtons(KDialog::Yes | KDialog::No);
+            noPlasmoidDialog->setMainWidget(dialogMainWidget);
+            noPlasmoidDialog->setButtonText(KDialog::Yes, i18n("Stay online"));
+            noPlasmoidDialog->setButtonText(KDialog::No, i18n("Go offline"));
+
+            if (noPlasmoidDialog->exec() == KDialog::No) {
+                generalConfigGroup.writeEntry("go_offline_when_closing", true);
+                goOffline();
+            }
+
+            if (dontAskCheckbox->isChecked()) {
+                generalConfigGroup.writeEntry("check_for_plasmoid", false);
+            }
+
+            generalConfigGroup.config()->sync();
+        }
+    } else {
+        bool shouldGoOffline = generalConfigGroup.readEntry("go_offline_when_closing", false);
+        if (shouldGoOffline) {
+            goOffline();
+        }
+    }
+
+    KMainWindow::closeEvent(e);
+}
+
+bool MainWidget::isPlasmoidPresent()
+{
+    QDBusInterface plasmoidOnDbus("org.kde.Telepathy.PresenceEngineActive", "/PresenceEngineActive");
+
+    if (plasmoidOnDbus.isValid()) {
+        return true;
+    } else {
+        return false;
+    }
+}
+
+void MainWidget::goOffline()
+{
+    foreach (const Tp::AccountPtr &account, m_accountManager->allAccounts()) {
+        if (account->isEnabled() && account->isValid()) {
+            account->setRequestedPresence(Tp::Presence::offline());
+        }
+    }
+}
+
 #include "main-widget.moc"
diff --git a/main-widget.h b/main-widget.h
index 313f74f..dbe2f17 100644
--- a/main-widget.h
+++ b/main-widget.h
@@ -51,6 +51,8 @@ public:
     MainWidget(QWidget *parent = 0);
     ~MainWidget();
 
+    bool isPlasmoidPresent();
+
     enum SystemMessageType {
         /*
          * this will show a system message to the user
@@ -95,6 +97,7 @@ public Q_SLOTS:
     void onCustomContextMenuRequested(const QPoint &point);
     void onGroupContacts(bool enabled);
     void onJoinChatRoomRequested();         /** join chat room action is triggered */
+    void goOffline();
 
 private Q_SLOTS:
     void slotAddContactToGroupTriggered();
@@ -121,6 +124,7 @@ Q_SIGNALS:
 private:
     /** handle connection errors for given account. This method provides visual notification */
     void handleConnectionError(const Tp::AccountPtr &account);
+    void closeEvent(QCloseEvent *e);
 
     AccountsModel          *m_model;
     GroupsModel            *m_groupsModel;

-- 
ktp-contact-list packaging



More information about the pkg-kde-commits mailing list