Commit 415f86e1 authored by David Edmundson's avatar David Edmundson
Browse files

Add a button to open log viewer with a specific contact from the text-ui

BUG: 294653
REVIEW: 104057
Reviewed-by: Martin Klapetek
parent b84fc360
......@@ -43,6 +43,7 @@
#include <KLineEdit>
#include <KMenu>
#include <KToolBar>
#include <KToolInvocation>
#include <QEvent>
#include <QWidgetAction>
......@@ -479,6 +480,24 @@ void ChatWindow::onShareDesktopTriggered()
startShareDesktop(currChat->account(), currChat->textChannel()->targetContact());
}
void ChatWindow::onOpenLogTriggered()
{
int index = m_tabWidget->currentIndex();
ChatTab* currentChatTab = qobject_cast<ChatTab*>(m_tabWidget->widget(index));
Q_ASSERT(currentChatTab);
Tp::AccountPtr account = currentChatTab->account();
Tp::ContactPtr contact = currentChatTab->textChannel()->targetContact();
if (!contact.isNull()) {
KToolInvocation::kdeinitExec(QLatin1String("ktp-log-viewer"),
QStringList() << account->uniqueIdentifier() << contact->id());
} else {
KToolInvocation::kdeinitExec(QLatin1String("ktp-log-viewer"),
QStringList() << account->uniqueIdentifier() << currentChatTab->textChannel()->targetId());
}
}
void ChatWindow::showSettingsDialog()
{
......@@ -574,6 +593,9 @@ void ChatWindow::setupCustomActions()
spellDictComboAction->setIcon(KIcon(QLatin1String("tools-check-spelling")));
spellDictComboAction->setIconText(i18n("Choose Spelling Language"));
KAction *openLogAction = new KAction(KIcon(QLatin1String("view-pim-journal")), i18nc("Action to open the log viwer with a specified contact","&Previous conversations"), this);
connect(openLogAction, SIGNAL(triggered()), SLOT(onOpenLogTriggered()));
KAction *accountIconAction = new KAction(KIcon(QLatin1String("telepathy-kde")), i18n("Account Icon"), this);
m_accountIconLabel = new QLabel(this);
accountIconAction->setDefaultWidget(m_accountIconLabel);
......@@ -589,6 +611,7 @@ void ChatWindow::setupCustomActions()
actionCollection()->addAction(QLatin1String("language"), spellDictComboAction);
actionCollection()->addAction(QLatin1String("account-icon"), accountIconAction);
actionCollection()->addAction(QLatin1String("block-contact"), blockContactAction);
actionCollection()->addAction(QLatin1String("open-log"), openLogAction);
}
void ChatWindow::setAudioCallEnabled(bool enable)
......
......@@ -97,6 +97,7 @@ private Q_SLOTS:
void onUserTypingChanged(Tp::ChannelChatState state);
void onUnblockContactTriggered(); /** Unblocks contact when already blocked */
void onShareDesktopTriggered(); /** start a desktop share */
void onOpenLogTriggered(); /** Starts ktp-log-viewer accountId contactId */
void setTabSpellDictionary(const QString &dict); /** set the spelling language for the current chat tab*/
void toggleBlockButton(bool contactIsBlocked); /** Toggle block/unblock action according to the flag */
......
......@@ -15,6 +15,7 @@ set(ktp-log-viewer_SRCS
log-viewer.cpp
entity-model.cpp
message-view.cpp
entity-view.cpp
conversation-date-picker.cpp
)
......
/***************************************************************************
* Copyright (C) 2012 by David Edmundson <kde@davidedmundson.co.uk> *
* *
* 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 2 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, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "entity-view.h"
#include <KCmdLineArgs>
#include <TelepathyQt/Account>
#include <TelepathyLoggerQt4/Entity>
#include "entity-model.h"
EntityView::EntityView(QWidget *parent) :
QListView(parent)
{
}
void EntityView::rowsInserted(const QModelIndex &parent, int start, int end)
{
QListView::rowsInserted(parent, start, end);
static bool loadedCurrentContact = false;
if (loadedCurrentContact) {
return;
}
if (KCmdLineArgs::parsedArgs()->count() == 2) {
QString selectAccountId = KCmdLineArgs::parsedArgs()->arg(0);
QString selectContactId = KCmdLineArgs::parsedArgs()->arg(1);
for (int i=start; i<end;i++) {
QModelIndex index = model()->index(i, 0, parent);
QString accountId = index.data(EntityModel::AccountRole).value<Tp::AccountPtr>()->uniqueIdentifier();
QString contactId = index.data(EntityModel::EntityRole).value<Tpl::EntityPtr>()->identifier();
if (selectAccountId == accountId && selectContactId == contactId) {
setCurrentIndex(index);
Q_EMIT activated(index); // this is normally emitted when a user clicks a contact
//we emit it here to trigger the same results.
loadedCurrentContact = true;
}
}
}
}
/***************************************************************************
* Copyright (C) 2012 by David Edmundson <kde@davidedmundson.co.uk> *
* *
* 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 2 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, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#ifndef ENTITYVIEW_H
#define ENTITYVIEW_H
#include <QListView>
//model is loaded asynchronously so we need to select the correct element on each new element
//this is done in the view to avoid having to be careful with proxy models.
class EntityView : public QListView
{
Q_OBJECT
public:
explicit EntityView(QWidget *parent = 0);
protected Q_SLOTS:
void rowsInserted(const QModelIndex &parent, int start, int end);
};
#endif // ENTITYVIEW_H
......@@ -17,7 +17,7 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListView" name="entityList"/>
<widget class="EntityView" name="entityList"/>
</item>
<item>
<widget class="KFilterProxySearchLine" name="entityFilter"/>
......@@ -58,6 +58,11 @@
<header>conversation-date-picker.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>EntityView</class>
<extends>QListView</extends>
<header>entity-view.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
......
......@@ -32,10 +32,16 @@ int main(int argc, char *argv[])
aboutData.addAuthor(ki18n("Daniele E. Domenichelli"), ki18n("Developer"), "daniele.domenichelli@gmail.com");
aboutData.setProductName("telepathy/logger"); //set the correct name for bug reporting
aboutData.setLicense(KAboutData::License_GPL_V2);
KCmdLineArgs::init(argc, argv, &aboutData);
KCmdLineArgs::parsedArgs();
KUniqueApplication a;
KCmdLineOptions options;
options.add("+accountID", ki18n("The UID of the account to preselect"));
options.add("+contactID", ki18n("The UID of the contact to preselect"));
KCmdLineArgs::addCmdLineOptions(options);
KApplication a;
LogViewer w;
w.show();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment