[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: 'Leave message' option for krunner_lock
From: Robert Zwerus <arzie () dds ! nl>
Date: 2008-06-11 20:16:05
Message-ID: 200806112216.06036.arzie () dds ! nl
[Download RAW message or body]
Hey everybody,
I've been busy porting the KDE3-patch below to KDE4:
http://www.kde-apps.org/content/show.php/Leave+Message+clone+from+gnome-2.20?content=66631
The KDE4-version doesn't depend on libnotify, but uses KNotify for the
notifications. I couldn't figure out yet how to keep them persistent (as
opposed to automatically disappearing after a while), so that's a FIXME.
Also, the clipboard shouldn't be accessible when entering a message, for which
I requested a QTextEdit::disableClipboard() method:
http://trolltech.com/developer/task-tracker/index_html?id=215407&method=entry
Does anybody have comments? If not, can I commit it and work on the FIXME's
later?
--
A Dieu,
Robert Zwerus - WWW: http://zwering.adsl.utwente.nl
ICQ UIN: 3943443 - MSNM: robert_zwerus@hotmail.com
["krunner_lock_leavemessage.diff" (text/x-diff)]
Index: workspace/solid/networkmanager-0.6/NetworkManager-networkmanager.h
===================================================================
--- workspace/solid/networkmanager-0.6/NetworkManager-networkmanager.h (revision 815658)
+++ workspace/solid/networkmanager-0.6/NetworkManager-networkmanager.h (working copy)
@@ -29,7 +29,7 @@
class NMNetworkManagerPrivate;
class NMNetworkManager : public Solid::Control::Ifaces::NetworkManager
{
-Q_INTERFACES(Solid::Control::Ifaces::NetworkManager)
+//Q_INTERFACES(Solid::Control::Ifaces::NetworkManager)
Q_OBJECT
public:
NMNetworkManager(QObject * parent, const QVariantList & args);
Index: workspace/krunner/lock/msgdlg.cc
===================================================================
--- workspace/krunner/lock/msgdlg.cc (revision 0)
+++ workspace/krunner/lock/msgdlg.cc (revision 0)
@@ -0,0 +1,17 @@
+//===========================================================================
+//
+// This file is part of the KDE project
+//
+// Copyright 2008 Robert Zwerus <arzie@dds.nl>
+
+#include "msgdlg.h"
+
+LeaveMessageDialog::LeaveMessageDialog( QWidget * parent, Qt::WindowFlags f )
+ : QDialog ( parent, f )
+{
+ setupUi( this );
+}
+
+LeaveMessageDialog::~LeaveMessageDialog()
+{
+}
Index: workspace/krunner/lock/lockdlg.cc
===================================================================
--- workspace/krunner/lock/lockdlg.cc (revision 815658)
+++ workspace/krunner/lock/lockdlg.cc (working copy)
@@ -5,6 +5,7 @@
// Copyright 1999 Martin R. Jones <mjones@kde.org>
// Copyright 2003 Chris Howells <howells@kde.org>
// Copyright 2003 Oswald Buddenhagen <ossi@kde.org>
+// Copyright 2008 Robert Zwerus <arzie@dds.nl>
#include <config-unix.h> // HAVE_PAM
@@ -13,6 +14,7 @@
#include <kcheckpass-enums.h>
#include <kdisplaymanager.h>
+#include <knotification.h>
#include <KApplication>
#include <KLocale>
@@ -48,6 +50,8 @@
#include <QTimerEvent>
#include <QVBoxLayout>
#include <QFile>
+#include <QTextEdit>
+#include <QClipboard>
#include <ctype.h>
#include <unistd.h>
@@ -106,6 +110,7 @@
ok = new KPushButton( i18n("Unl&ock"), w );
cancel = new KPushButton( KStandardGuiItem::cancel(), w );
+ msg = new KPushButton( i18n("Leave &message"), w );
mNewSessButton = new KPushButton( KGuiItem(i18n("Sw&itch User..."), "fork"), w );
// Using KXKB component
@@ -130,6 +135,7 @@
layButtons->addWidget( mNewSessButton );
layButtons->addStretch();
layButtons->addWidget( ok );
+ layButtons->addWidget( msg );
layButtons->addWidget( cancel );
frameLayout = new QGridLayout( w );
@@ -145,6 +151,7 @@
setButtons(None);
connect(cancel, SIGNAL(clicked()), SLOT(reject()));
connect(ok, SIGNAL(clicked()), SLOT(slotOK()));
+ connect(msg, SIGNAL(clicked()), SLOT(slotMsg()));
connect(mNewSessButton, SIGNAL(clicked()), SLOT(slotSwitchUser()));
if (!KDisplayManager().isSwitchable() || !KAuthorized::authorizeKAction("switch_user"))
@@ -157,7 +164,7 @@
connect(qApp, SIGNAL(activity()), SLOT(slotActivity()) );
greet->start();
-
+
capsLocked();
}
@@ -480,11 +487,66 @@
greet->next();
}
+void clearClipboard()
+{
+ // FIXME: this is a workaround, should be fixed in a cleaner and non-destructive way
+ // I requested QTextEdit::disableClipboard():
+ // http://trolltech.com/developer/task-tracker/index_html?id=215407&method=entry
+ QApplication::clipboard()->clear( QClipboard::Clipboard );
+ if ( QApplication::clipboard()->supportsSelection() )
+ QApplication::clipboard()->clear( QClipboard::Selection );
+}
+
+void PasswordDlg::slotMsg()
+{
+ KUser user;
+ msg_dialog = new LeaveMessageDialog( this, Qt::X11BypassWindowManagerHint );
+ msg_dialog->msg_l->setText( QString( i18n( "Enter your message for %1 here:",
+ user.property( KUser::FullName ).toString() ) ) );
+
+ // Clear the clipboard, so possibly private data is not accessible
+ clearClipboard();
+
+ connect( msg_dialog->buttonBox, SIGNAL(rejected()), this, SLOT(slotCloseMsg()) );
+ connect( msg_dialog->buttonBox, SIGNAL(accepted()), this, SLOT(slotSendMsg()) );
+
+ static_cast< LockProcess* >( parent())->execDialog( msg_dialog );
+
+ delete msg_dialog;
+}
+
+void PasswordDlg::slotCloseMsg()
+{
+ if ( msg_dialog )
+ msg_dialog->close();
+
+ clearClipboard();
+}
+
+void PasswordDlg::slotSendMsg()
+{
+ KNotification *notification = new KNotification ( "newmessages" );
+
+ // FIXME: the notification popup disappears automatically now, but
+ // it should only disappear after clicking 'Close'
+ notification->setFlags ( KNotification::Persistent );
+ notification->setWidget ( NULL );
+
+ notification->setText( QString::fromLatin1 ( "%1\n\n%2" ).arg (
+ KGlobal::locale()->formatDateTime( QDateTime::currentDateTime() ).toUtf8().data(),
+ msg_dialog->msg_edit->toPlainText().toUtf8().data()
+ ) );
+ notification->setActions( i18n ( "Close" ).split(",") );
+
+ notification->sendEvent();
+
+ slotCloseMsg();
+}
void PasswordDlg::setVisible( bool visible )
{
QDialog::setVisible( visible );
-
+
if ( visible )
QApplication::flush();
}
Index: workspace/krunner/lock/msgdlg.h
===================================================================
--- workspace/krunner/lock/msgdlg.h (revision 0)
+++ workspace/krunner/lock/msgdlg.h (revision 0)
@@ -0,0 +1,16 @@
+//===========================================================================
+//
+// This file is part of the KDE project
+//
+// Copyright 2008 Robert Zwerus <arzie@dds.nl>
+
+#include <QDialog>
+#include "ui_msgdlg.h"
+
+class LeaveMessageDialog : public QDialog, public Ui::LeaveMessageDialog
+{
+Q_OBJECT
+public:
+ LeaveMessageDialog(QWidget * parent = 0, Qt::WindowFlags f = 0);
+ ~LeaveMessageDialog();
+};
Index: workspace/krunner/lock/lockdlg.h
===================================================================
--- workspace/krunner/lock/lockdlg.h (revision 815658)
+++ workspace/krunner/lock/lockdlg.h (working copy)
@@ -4,7 +4,8 @@
//
// Copyright 1999 Martin R. Jones <mjones@kde.org>
// Copyright 2003 Oswald Buddenhagen <ossi@kde.org>
-//
+// Copyright 2008 Robert Zwerus <arzie@dds.nl>
+
#ifndef __LOCKDLG_H__
#define __LOCKDLG_H__
@@ -19,6 +20,8 @@
#include <QGridLayout>
#include <QEvent>
+#include "msgdlg.h"
+
struct GreeterPluginHandle;
class LockProcess;
class QFrame;
@@ -60,6 +63,9 @@
void slotSessionActivated();
void slotStartNewSession();
void slotOK();
+ void slotMsg();
+ void slotCloseMsg();
+ void slotSendMsg();
void slotActivity();
private:
@@ -76,18 +82,19 @@
void handleVerify();
void reapVerify();
void cantCheck();
- GreeterPluginHandle *mPlugin;
- KGreeterPlugin *greet;
- QFrame *frame;
- QGridLayout *frameLayout;
- QLabel *mStatusLabel;
- KPushButton *mNewSessButton, *ok, *cancel;
- int mFailedTimerId;
- int mTimeoutTimerId;
- int mCapsLocked;
- bool mUnlockingFailed;
- int sPid, sFd;
- QTreeWidget *lv;
+ GreeterPluginHandle *mPlugin;
+ KGreeterPlugin *greet;
+ QFrame *frame;
+ QGridLayout *frameLayout;
+ QLabel *mStatusLabel;
+ KPushButton *mNewSessButton, *ok, *cancel, *msg;
+ LeaveMessageDialog *msg_dialog;
+ int mFailedTimerId;
+ int mTimeoutTimerId;
+ int mCapsLocked;
+ bool mUnlockingFailed;
+ int sPid, sFd;
+ QTreeWidget *lv;
};
#endif
Index: workspace/krunner/lock/krunner_lock.notifyrc
===================================================================
--- workspace/krunner/lock/krunner_lock.notifyrc (revision 0)
+++ workspace/krunner/lock/krunner_lock.notifyrc (revision 0)
@@ -0,0 +1,13 @@
+[Global]
+IconName=KDE screen locker
+Comment=KDE screen locking application
+
+[Context/messages]
+Name=Received messages
+Comment=
+
+[Event/newmessages]
+Name=New messages
+Comment=You have received new messages while away
+Contexts=messages
+Action=Popup
\ No newline at end of file
Index: workspace/krunner/lock/msgdlg.ui
===================================================================
--- workspace/krunner/lock/msgdlg.ui (revision 0)
+++ workspace/krunner/lock/msgdlg.ui (revision 0)
@@ -0,0 +1,102 @@
+<ui version="4.0" >
+ <class>LeaveMessageDialog</class>
+ <widget class="QDialog" name="LeaveMessageDialog" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>563</width>
+ <height>299</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Dialog</string>
+ </property>
+ <widget class="QLabel" name="msg_l" >
+ <property name="geometry" >
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>539</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string>Enter your message here:</string>
+ </property>
+ <property name="buddy" >
+ <cstring>msg_edit</cstring>
+ </property>
+ </widget>
+ <widget class="QTextEdit" name="msg_edit" >
+ <property name="geometry" >
+ <rect>
+ <x>10</x>
+ <y>34</y>
+ <width>539</width>
+ <height>192</height>
+ </rect>
+ </property>
+ <property name="lineWrapColumnOrWidth" >
+ <number>0</number>
+ </property>
+ </widget>
+ <widget class="QWidget" name="layoutWidget" >
+ <property name="geometry" >
+ <rect>
+ <x>10</x>
+ <y>232</y>
+ <width>539</width>
+ <height>32</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout" >
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons" >
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>LeaveMessageDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>LeaveMessageDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
Index: workspace/krunner/lock/CMakeLists.txt
===================================================================
--- workspace/krunner/lock/CMakeLists.txt (revision 815658)
+++ workspace/krunner/lock/CMakeLists.txt (working copy)
@@ -12,9 +12,14 @@
set(krunner_lock_SRCS
lockprocess.cc
lockdlg.cc
+ msgdlg.cc
autologout.cc
main.cc )
+kde4_add_ui_files(krunner_lock_SRCS
+ msgdlg.ui
+ )
+
set(ksmserver_xml ${KDEBASE_WORKSPACE_SOURCE_DIR}/ksmserver/org.kde.KSMServerInterface.xml)
QT4_ADD_DBUS_INTERFACE(krunner_lock_SRCS ${ksmserver_xml} ksmserver_interface)
set(kscreensaver_xml ${KDEBASE_WORKSPACE_SOURCE_DIR}/krunner/org.kde.screensaver.xml)
@@ -45,6 +50,7 @@
endif(HAVE_GLXCHOOSEVISUAL)
install(TARGETS krunner_lock DESTINATION ${LIBEXEC_INSTALL_DIR})
+install(FILES krunner_lock.notifyrc DESTINATION ${DATA_INSTALL_DIR}/krunner_lock)
install_pam_service(kscreensaver)
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic