1
// -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8; -*-
2
/* This file is part of the KDE project
4
Copyright (C) by Andrew Stanley-Jones
5
Copyright (C) 2000 by Carsten Pfeiffer <pfeiffer@kde.org>
6
Copyright (C) 2004 Esben Mose Hansen <kde@mosehansen.dk>
8
This program is free software; you can redistribute it and/or
9
modify it under the terms of the GNU General Public
10
License as published by the Free Software Foundation; either
11
version 2 of the License, or (at your option) any later version.
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
General Public License for more details.
18
You should have received a copy of the GNU General Public License
19
along with this program; see the file COPYING. If not, write to
20
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21
Boston, MA 02110-1301, USA.
31
#include "klipperpopup.h"
33
#include <KNotification>
35
KlipperTray::KlipperTray()
36
: KStatusNotifierItem()
38
m_klipper = new Klipper( this, KGlobal::config());
39
setTitle( i18n( "Klipper" ) );
40
setIconByName( "klipper" );
41
setToolTip( "klipper", i18n( "Clipboard Contents" ), i18n( "Clipboard is empty" ) );
42
setCategory( SystemServices );
44
setStandardActionsEnabled( false );
45
setContextMenu( m_klipper->history()->popup() );
46
setAssociatedWidget( m_klipper->history()->popup() );
47
connect( m_klipper->history(), SIGNAL(changed()), SLOT(slotSetToolTipFromHistory()));
48
slotSetToolTipFromHistory();
49
connect( m_klipper, SIGNAL(passivePopup(QString,QString)), SLOT(passive_popup(QString,QString)));
52
void KlipperTray::slotSetToolTipFromHistory()
54
if (m_klipper->history()->empty()) {
55
setToolTipSubTitle( i18n("Clipboard is empty"));
57
const HistoryItem* top = m_klipper->history()->first();
58
setToolTipSubTitle(top->text());
62
void KlipperTray::passive_popup(const QString& caption, const QString& text)
65
m_notification->setTitle(caption);
66
m_notification->setText(text);
68
m_notification = KNotification::event(KNotification::Notification, caption, text,
69
KIcon("klipper").pixmap(QSize(16, 16)));