[kde-doc-english] [trojita/addressbook] src/Gui: GUI: integrate the addressbook with Trojita

Jan Kundrát jkt at flaska.net
Sat May 25 12:31:35 UTC 2013


Git commit 680b496f201f87b7fd93b3ed617a24337ccb7d63 by Jan Kundrát.
Committed on 25/05/2013 at 14:31.
Pushed by jkt into branch 'addressbook'.

GUI: integrate the addressbook with Trojita

M  +14   -3    src/Gui/Window.cpp
M  +7    -0    src/Gui/Window.h

http://commits.kde.org/trojita/680b496f201f87b7fd93b3ed617a24337ccb7d63

diff --git a/src/Gui/Window.cpp b/src/Gui/Window.cpp
index 6ff1b54..293d984 100644
--- a/src/Gui/Window.cpp
+++ b/src/Gui/Window.cpp
@@ -148,6 +148,7 @@ void MainWindow::defineActions()
     shortcutHandler->defineAction(QLatin1String("action_reply_all"), QLatin1String("mail-reply-all"), tr("Reply to &All"), tr("Ctrl+Alt+Shift+R"));
     shortcutHandler->defineAction(QLatin1String("action_reply_list"), QLatin1String("mail-reply-list"), tr("Reply to &Mailing List"), tr("Ctrl+L"));
     shortcutHandler->defineAction(QLatin1String("action_reply_guess"), QString(), tr("Reply by &Guess"), tr("Ctrl+R"));
+    shortcutHandler->defineAction(QLatin1String("action_contact_editor"), QLatin1String("contact-unknown"), tr("Address Book..."));
 }
 
 void MainWindow::createActions()
@@ -424,6 +425,7 @@ void MainWindow::createMenus()
 {
     QMenu *imapMenu = menuBar()->addMenu(tr("&IMAP"));
     imapMenu->addMenu(m_composeMenu);
+    imapMenu->addAction(ShortcutHandler::instance()->createAction(QLatin1String("action_contact_editor"), this, SLOT(invokeContactEditor()), this));
     imapMenu->addAction(m_replyGuess);
     imapMenu->addAction(m_replyPrivate);
     imapMenu->addAction(m_replyAll);
@@ -1461,9 +1463,18 @@ void MainWindow::slotManageContact(const QUrl &url)
     if (!Imap::Message::MailAddress::fromUrl(addr, url, QLatin1String("x-trojita-manage-contact")))
         return;
 
-    BE::Contacts *contacts = new BE::Contacts(dynamic_cast<AbookAddressbook*>(m_addressBook));
-    contacts->show();
-    contacts->manageContact(addr.mailbox + QLatin1Char('@') + addr.host, addr.name);
+    invokeContactEditor();
+    m_contactsWidget->manageContact(addr.mailbox + QLatin1Char('@') + addr.host, addr.name);
+}
+
+void MainWindow::invokeContactEditor()
+{
+    if (m_contactsWidget)
+        return;
+
+    m_contactsWidget = new BE::Contacts(dynamic_cast<AbookAddressbook*>(m_addressBook));
+    m_contactsWidget->setAttribute(Qt::WA_DeleteOnClose, true);
+    m_contactsWidget->show();
 }
 
 ComposeWidget *MainWindow::invokeComposeDialog(const QString &subject, const QString &body,
diff --git a/src/Gui/Window.h b/src/Gui/Window.h
index 64a9f32..9ab7af2 100644
--- a/src/Gui/Window.h
+++ b/src/Gui/Window.h
@@ -25,6 +25,7 @@
 
 #include <QMainWindow>
 #include <QModelIndex>
+#include <QPointer>
 #include <QSystemTrayIcon>
 
 #include "Composer/Recipients.h"
@@ -42,6 +43,10 @@ class QSslError;
 class QToolButton;
 class QTreeView;
 
+namespace BE {
+class Contacts;
+}
+
 namespace Composer
 {
 class SenderIdentitiesModel;
@@ -168,6 +173,7 @@ private slots:
 
     void slotIconActivated(const QSystemTrayIcon::ActivationReason reason);
     void slotToggleSysTray();
+    void invokeContactEditor();
 private:
     void defineActions();
     void createMenus();
@@ -282,6 +288,7 @@ private:
     bool m_ignoreStoredPassword;
 
     AbstractAddressbook *m_addressBook;
+    QPointer<BE::Contacts> m_contactsWidget;
 
     MainWindow(const MainWindow &); // don't implement
     MainWindow &operator=(const MainWindow &); // don't implement


More information about the kde-doc-english mailing list