[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-panel-devel
Subject: [Panel-devel] patch: Krunner Interface - switchUser
From: David Solbach <d () vidsolbach ! de>
Date: 2007-06-18 21:13:21
Message-ID: 200706182313.22124.d () vidsolbach ! de
[Download RAW message or body]
Hi,
as talked on irc, here is the switchUser() function to display the running
Sessions in KRunner.
Thanks for the time to explain things.
David
["krunner_switchuser.patch" (text/x-diff)]
Index: interface.h
===================================================================
--- interface.h (Revision 677294)
+++ interface.h (Arbeitskopie)
@@ -88,6 +88,8 @@
SearchMatch* m_defaultMatch;
QMap<Plasma::AbstractRunner*, SearchMatch*> m_matches;
QList<SearchMatch*> m_searchMatches;
+
+ void resetInterface();
};
#endif
Index: interface.cpp
===================================================================
--- interface.cpp (Revision 677294)
+++ interface.cpp (Arbeitskopie)
@@ -237,7 +237,38 @@
void Interface::switchUser()
{
- //TODO: use the SessionRunner
+ SessionRunner* sessionrunner = 0;
+
+ resetInterface();
+
+ for (int i = 0; i < m_runners.size(); ++i) {
+ if (m_runners.at(i)->objectName() == i18n( "Sessions" )) {
+ sessionrunner = (SessionRunner*)m_runners.at(i);
+ break;
+ }
+ }
+
+ if (!sessionrunner)
+ {
+ kDebug() << "Could not find the Sessionrunner; not showing any sessions!" << endl;
+ return;
+ }
+
+ KActionCollection* matches = sessionrunner->matches( "SESSIONS", 0, 0 );
+
+ foreach ( QAction* action, matches->actions() ) {
+ bool makeDefault = !m_defaultMatch && action->isEnabled();
+
+ SearchMatch* match = new SearchMatch( action, sessionrunner, m_matchList );
+ m_searchMatches.append( match );
+
+ if ( makeDefault ) {
+ m_defaultMatch = match;
+ m_defaultMatch->setDefault( true );
+ m_runButton->setEnabled( true );
+ m_optionsButton->setEnabled( sessionrunner->hasOptions() );
+ }
+ }
}
void Interface::setWidgetPalettes()
@@ -254,6 +285,17 @@
m_matchList->setPalette( widgetPalette );
}
+void Interface::resetInterface()
+{
+ m_searchTerm->clear();
+ m_matches.clear();
+ m_searchMatches.clear();
+ m_matchList->clear();
+ m_runButton->setEnabled( false );
+ m_optionsButton->setEnabled( false );
+ showOptions( false );
+}
+
void Interface::showEvent( QShowEvent* e )
{
Q_UNUSED( e )
@@ -265,11 +307,7 @@
void Interface::hideEvent( QHideEvent* e )
{
kDebug() << "hide event" << endl;
- showOptions( false );
- m_searchTerm->clear();
- m_matchList->clear() ;
- m_runButton->setEnabled( false );
- m_optionsButton->setEnabled( false );
+ resetInterface();
e->accept();
}
@@ -293,12 +331,7 @@
QString term = t.trimmed();
if ( term.isEmpty() ) {
- m_matches.clear();
- m_searchMatches.clear();
- m_matchList->clear();
- m_runButton->setEnabled( false );
- m_optionsButton->setEnabled( false );
- showOptions( false );
+ resetInterface();
return;
}
_______________________________________________
Panel-devel mailing list
Panel-devel@kde.org
https://mail.kde.org/mailman/listinfo/panel-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic