[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdenetwork/kopete
From: Gustavo P. Boiko <gustavo.boiko () kdemail ! net>
Date: 2007-10-31 22:09:37
Message-ID: 1193868577.126322.11563.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 731520 by boiko:
Identity actions are UI elements, so they don't belong to libkopete. Thanks
Bille for pointing that.
M +60 -4 kopete/kopeteidentitystatusbaricon.cpp
M +14 -1 kopete/kopeteidentitystatusbaricon.h
M +0 -12 kopete/kopetewindow.cpp
M +0 -5 kopete/kopetewindow.h
M +6 -64 libkopete/kopeteidentity.cpp
M +5 -14 libkopete/kopeteidentity.h
--- trunk/KDE/kdenetwork/kopete/kopete/kopeteidentitystatusbaricon.cpp #731519:731520
@@ -17,12 +17,18 @@
*/
#include "kopeteidentitystatusbaricon.h"
+#include <kopeteidentity.h>
#include <KDebug>
#include <QMouseEvent>
#include <QLabel>
#include <QEvent>
#include <QCursor>
+#include <KAction>
+#include <KActionMenu>
+#include <KIcon>
+#include <KLocale>
+#include <KMenu>
KopeteIdentityStatusBarIcon::KopeteIdentityStatusBarIcon( Kopete::Identity \
*identity, QWidget *parent ) : QLabel( parent )
@@ -32,24 +38,74 @@
show();
m_identity = identity;
+
+ // initialize actions
+ m_actionSetOnline = new KAction( KIcon("kopeteavailable"), i18n("&Online"), this );
+ m_actionSetOnline->setData((uint)Kopete::OnlineStatusManager::Online);
+
+ m_actionSetAway = new KAction( KIcon("kopeteaway"), i18n("&Away"), this );
+ m_actionSetAway->setData((uint)Kopete::OnlineStatusManager::Away);
+
+ m_actionSetBusy = new KAction( KIcon("kopeteaway"), i18n("&Busy"), this );
+ m_actionSetBusy->setData((uint)Kopete::OnlineStatusManager::Busy);
+
+ m_actionSetInvisible = new KAction( KIcon("kopeteavailable"), i18n( "&Invisible" ), \
this ); + m_actionSetInvisible->setData((uint)Kopete::OnlineStatusManager::Invisible);
+
+ m_actionSetOffline = new KAction( KIcon("connect-no"), i18n( "Offline" ), this );
+ m_actionSetOffline->setData((uint)Kopete::OnlineStatusManager::Offline);
+
+ // create the actionGroup
+ m_statusGroup = new QActionGroup(this);
+ m_statusGroup->addAction(m_actionSetOnline);
+ m_statusGroup->addAction(m_actionSetAway);
+ m_statusGroup->addAction(m_actionSetBusy);
+ m_statusGroup->addAction(m_actionSetInvisible);
+ m_statusGroup->addAction(m_actionSetOffline);
+
+ connect(m_statusGroup, SIGNAL(triggered(QAction*)),
+ this, SLOT(slotChangeStatus(QAction *)));
+
}
KopeteIdentityStatusBarIcon::~KopeteIdentityStatusBarIcon()
{
+ delete m_actionSetOnline;
+ delete m_actionSetAway;
+ delete m_actionSetBusy;
+ delete m_actionSetInvisible;
+ delete m_actionSetOffline;
+ delete m_statusGroup;
}
void KopeteIdentityStatusBarIcon::mousePressEvent( QMouseEvent *me )
{
- if( me->button() == Qt::RightButton )
+ if( me->button() == Qt::LeftButton )
{
- emit rightClicked( m_identity, QPoint( me->globalX(), me->globalY() ) );
+ emit leftClicked( m_identity, me->globalPos() );
}
- else if( me->button() == Qt::LeftButton )
+ else if( me->button() == Qt::RightButton )
{
- emit leftClicked( m_identity, QPoint( me->globalX(), me->globalY() ) );
+ // show the context menu for the left click
+ // creates the action menu
+ KActionMenu *statusMenu = new KActionMenu(m_identity->label(), this);
+
+ // add a title to the popup menu before the online action
+ statusMenu->menu()->addTitle(m_identity->label());
+
+ // add the status actions to the menu
+ foreach(QAction *action, m_statusGroup->actions())
+ statusMenu->addAction(action);
+
+ connect( statusMenu->menu(), SIGNAL( aboutToHide() ), statusMenu, SLOT( \
deleteLater() ) ); + statusMenu->menu()->popup( me->globalPos() );
}
}
+void KopeteIdentityStatusBarIcon::slotChangeStatus(QAction *a)
+{
+ m_identity->setOnlineStatus(a->data().toUInt(), m_identity->statusMessage());
+}
#include "kopeteidentitystatusbaricon.moc"
// vim: set noet ts=4 sts=4 sw=4:
--- trunk/KDE/kdenetwork/kopete/kopete/kopeteidentitystatusbaricon.h #731519:731520
@@ -29,6 +29,9 @@
class Identity;
}
+class KAction;
+class QActionGroup;
+
/**
* @author Duncan Mac-Vicar P. <duncan@kde.org>
*/
@@ -45,14 +48,24 @@
~KopeteIdentityStatusBarIcon();
signals:
- void rightClicked( Kopete::Identity *identity, const QPoint &p );
void leftClicked( Kopete::Identity *identity, const QPoint &p );
protected:
virtual void mousePressEvent( QMouseEvent *me );
+private slots:
+ void slotChangeStatus(QAction *);
+
private:
Kopete::Identity *m_identity;
+
+ // some actions
+ KAction *m_actionSetOnline;
+ KAction *m_actionSetAway;
+ KAction *m_actionSetBusy;
+ KAction *m_actionSetInvisible;
+ KAction *m_actionSetOffline;
+ QActionGroup *m_statusGroup;
};
#endif
--- trunk/KDE/kdenetwork/kopete/kopete/kopetewindow.cpp #731519:731520
@@ -760,8 +760,6 @@
this, SLOT( slotIdentityStatusIconChanged( Kopete::Identity * ) ) );
KopeteIdentityStatusBarIcon *sbIcon = new KopeteIdentityStatusBarIcon( identity, \
d->statusBarWidget );
- connect( sbIcon, SIGNAL( rightClicked( Kopete::Identity *, const QPoint & ) ),
- SLOT( slotIdentityStatusIconRightClicked( Kopete::Identity *, const QPoint & ) \
) ); connect( sbIcon, SIGNAL( leftClicked( Kopete::Identity *, const QPoint & ) ),
SLOT( slotIdentityStatusIconLeftClicked( Kopete::Identity *, const QPoint & ) \
) );
@@ -853,16 +851,6 @@
}
}
-void KopeteWindow::slotIdentityStatusIconRightClicked( Kopete::Identity *identity, \
const QPoint &p )
-{
- KActionMenu *actionMenu = identity->actionMenu();
- if ( !actionMenu )
- return;
-
- connect( actionMenu->menu(), SIGNAL( aboutToHide() ), actionMenu, SLOT( \
deleteLater() ) );
- actionMenu->menu()->popup( p );
-}
-
void KopeteWindow::slotIdentityStatusIconLeftClicked( Kopete::Identity *identity, \
const QPoint &p ) {
if (d->identitywidget->isVisible() && d->identitywidget->identity() == identity)
--- trunk/KDE/kdenetwork/kopete/kopete/kopetewindow.h #731519:731520
@@ -128,11 +128,6 @@
void slotIdentityStatusIconChanged();
/**
- * Show a context menu for an identity
- */
- void slotIdentityStatusIconRightClicked( Kopete::Identity *i,
- const QPoint &p );
- /**
* Show a in-place widget for an identity
*/
void slotIdentityStatusIconLeftClicked( Kopete::Identity *i,
--- trunk/KDE/kdenetwork/kopete/libkopete/kopeteidentity.cpp #731519:731520
@@ -39,9 +39,7 @@
class Identity::Private
{
public:
- Private(const QString &i, const QString &l) : onlineStatus( OnlineStatus::Unknown \
),
- actionSetOnline(0), actionSetAway(0), actionSetBusy(0), actionSetInvisible(0),
- actionSetOffline(0), statusGroup(0)
+ Private(const QString &i, const QString &l) : onlineStatus( OnlineStatus::Unknown )
{
id = i;
label = l;
@@ -53,20 +51,11 @@
KConfigGroup *configGroup;
OnlineStatus::StatusType onlineStatus;
QString statusMessage;
-
- // some actions
- KAction *actionSetOnline;
- KAction *actionSetAway;
- KAction *actionSetBusy;
- KAction *actionSetInvisible;
- KAction *actionSetOffline;
- QActionGroup *statusGroup;
};
Identity::Identity( const QString &id, const QString &label )
: d( new Private(id, label) )
{
- initActions();
load();
connect(this, SIGNAL(propertyChanged(PropertyContainer*, const QString&, const \
QVariant &, const QVariant &)), this, SLOT(slotSaveProperty(PropertyContainer*, \
const QString&, const QVariant &, const QVariant &))); @@ -75,7 +64,6 @@
Identity::Identity(const QString &label)
: d( new Private(KRandom::randomString(10), label) )
{
- initActions();
connect(this, SIGNAL(propertyChanged(PropertyContainer*, const QString&, const \
QVariant &, const QVariant &)), this, SLOT(slotSaveProperty(PropertyContainer*, \
const QString&, const QVariant &, const QVariant &))); }
@@ -83,7 +71,6 @@
Identity::Identity( Identity &existing )
{
d = new Private(KRandom::randomString(10), existing.label());
- initActions();
QMap<QString,QString> props;
@@ -105,36 +92,6 @@
delete d;
}
-void Identity::initActions()
-{
- d->actionSetOnline = new KAction( KIcon("kopeteavailable"), i18n("&Online"), this \
);
- d->actionSetOnline->setData((uint)Kopete::OnlineStatusManager::Online);
-
- d->actionSetAway = new KAction( KIcon("kopeteaway"), i18n("&Away"), this );
- d->actionSetAway->setData((uint)Kopete::OnlineStatusManager::Away);
-
- d->actionSetBusy = new KAction( KIcon("kopeteaway"), i18n("&Busy"), this );
- d->actionSetBusy->setData((uint)Kopete::OnlineStatusManager::Busy);
-
- d->actionSetInvisible = new KAction( KIcon("kopeteavailable"), i18n( "&Invisible" \
), this );
- d->actionSetInvisible->setData((uint)Kopete::OnlineStatusManager::Invisible);
-
- d->actionSetOffline = new KAction( KIcon("connect-no"), i18n( "Offline" ), this );
- d->actionSetOffline->setData((uint)Kopete::OnlineStatusManager::Offline);
-
- // create the actionGroup
- d->statusGroup = new QActionGroup(this);
- d->statusGroup->addAction(d->actionSetOnline);
- d->statusGroup->addAction(d->actionSetAway);
- d->statusGroup->addAction(d->actionSetBusy);
- d->statusGroup->addAction(d->actionSetInvisible);
- d->statusGroup->addAction(d->actionSetOffline);
-
- connect(d->statusGroup, SIGNAL(triggered(QAction*)),
- this, SLOT(slotChangeStatus(QAction *)));
-
-}
-
QString Identity::id() const
{
return d->id;
@@ -174,6 +131,11 @@
return d->onlineStatus;
}
+QString Identity::statusMessage() const
+{
+ return d->statusMessage;
+}
+
QString Identity::toolTip() const
{
@@ -209,21 +171,6 @@
}
-KActionMenu* Identity::actionMenu()
-{
- // creates the action menu
- KActionMenu *statusMenu = new KActionMenu(d->label, this);
-
- // add a title to the popup menu before the online action
- statusMenu->menu()->addTitle(d->label);
-
- // add the status actions to the menu
- foreach(QAction *action, d->statusGroup->actions())
- statusMenu->addAction(action);
-
- return statusMenu;
-}
-
QList<Account*> Identity::accounts() const
{
return d->accounts;
@@ -307,11 +254,6 @@
save();
}
-void Identity::slotChangeStatus(QAction *a)
-{
- setOnlineStatus(a->data().toUInt(), d->statusMessage);
-}
-
} //END namespace Kopete
#include "kopeteidentity.moc"
--- trunk/KDE/kdenetwork/kopete/libkopete/kopeteidentity.h #731519:731520
@@ -26,7 +26,6 @@
#include "kopete_export.h"
class KConfigGroup;
-class QAction;
namespace Kopete
{
@@ -69,11 +68,6 @@
~Identity();
/**
- * @brief Initialize the identity actions
- */
- void initActions();
-
- /**
* The id is a unique internal handle and should not be exposed in the UI
* @return the identity's id
*/
@@ -108,6 +102,11 @@
* @return the online status of the identity
*/
OnlineStatus::StatusType onlineStatus() const;
+
+ /**
+ * @brief Get the current status message of the identity
+ */
+ QString statusMessage() const;
/**
* \brief Get the tooltip for this identity
@@ -121,11 +120,6 @@
QString customIcon() const;
/**
- * @brief Return the menu for this identity
- */
- KActionMenu* actionMenu();
-
- /**
* Returns the accounts assigned to this identity
*/
QList<Account*> accounts() const;
@@ -167,9 +161,6 @@
void slotSaveProperty( PropertyContainer *container, const QString &key,
const QVariant &oldValue, const QVariant &newValue );
-private slots:
- void slotChangeStatus(QAction *);
-
signals:
void onlineStatusChanged(Kopete::Identity*,Kopete::OnlineStatus::StatusType, \
Kopete::OnlineStatus::StatusType); void identityDestroyed( const Kopete::Identity \
*identity );
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic