• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Applets

leavemodel.cpp

Go to the documentation of this file.
00001 /*  
00002     Copyright 2007 Robert Knight <robertknight@gmail.com>
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to
00016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017     Boston, MA 02110-1301, USA.
00018 */
00019 
00020 // Own
00021 #include "core/leavemodel.h"
00022 
00023 // Qt
00024 #include <QFileInfo>
00025 
00026 // KDE
00027 #include <KLocalizedString>
00028 #include <KIcon>
00029 #include <solid/powermanagement.h>
00030 
00031 // Local
00032 #include "core/models.h"
00033 
00034 using namespace Kickoff;
00035 
00036 class LeaveModel::Private
00037 {
00038 };
00039 
00040 QStandardItem* LeaveModel::createStandardItem(const QString& url)
00041 {
00042     //Q_ASSERT(KUrl(url).scheme() == "leave");
00043     QStandardItem *item = new QStandardItem();
00044     const QString basename = QFileInfo(url).baseName();
00045     if (basename == "logout") {
00046         item->setText(i18n("Logout"));
00047         item->setIcon(KIcon("system-log-out"));
00048         item->setData(i18n("End session"),Kickoff::SubTitleRole);
00049     }
00050     else if (basename == "lock") {
00051         item->setText(i18n("Lock"));
00052         item->setIcon(KIcon("system-lock-screen"));
00053         item->setData(i18n("Lock the screen"),Kickoff::SubTitleRole);
00054     }
00055     else if (basename == "switch") {
00056         item->setText(i18n("Switch User"));
00057         item->setIcon(KIcon("system-switch-user"));
00058         item->setData(i18n("Start a parallel session as a different user"),Kickoff::SubTitleRole);
00059     }
00060     else if (basename == "sleep") {
00061         item->setText(i18n("Sleep"));
00062         item->setIcon(KIcon("system-suspend"));
00063         item->setData(url,Kickoff::SubTitleRole);
00064     }
00065     else if (basename == "hibernate") {
00066         item->setText(i18n("Hibernate"));
00067         item->setIcon(KIcon("system-suspend-hibernate"));
00068         item->setData(url,Kickoff::SubTitleRole);
00069     }
00070     else if (basename == "shutdown") {
00071         item->setText(i18n("Shutdown"));
00072         item->setIcon(KIcon("system-shutdown"));
00073         item->setData(i18n("Turn off the computer"),Kickoff::SubTitleRole);
00074     }
00075     else if (basename == "restart") {
00076         item->setText(i18n("Restart"));
00077         item->setIcon(KIcon("system-restart"));
00078         item->setData(i18n("Restart the computer"),Kickoff::SubTitleRole);
00079     }
00080     else {
00081         item->setText(basename);
00082         item->setData(url,Kickoff::SubTitleRole);
00083     }
00084     item->setData(url,Kickoff::UrlRole);
00085     return item;
00086 }
00087 
00088 LeaveModel::LeaveModel(QObject *parent)
00089     : QStandardItemModel(parent)
00090     , d(0)
00091 {
00092     // Session Options
00093     QStandardItem *sessionOptions = new QStandardItem(i18n("Session"));
00094 
00095         // Logout
00096         QStandardItem *logoutOption = createStandardItem("leave:/logout");
00097         sessionOptions->appendRow(logoutOption);
00098 
00099         // Lock
00100         QStandardItem *lockOption = createStandardItem("leave:/lock");
00101         sessionOptions->appendRow(lockOption);
00102 
00103         // Switch User
00104         QStandardItem *switchUserOption = createStandardItem("leave:/switch");
00105         sessionOptions->appendRow(switchUserOption);
00106 
00107     // System Options
00108     QStandardItem *systemOptions = new QStandardItem(i18n("System"));
00109 
00110         using namespace Solid::PowerManagement;
00111         QSet<SleepState> sleepStates = supportedSleepStates();
00112 
00113         // Sleep
00114         if (sleepStates.contains(SuspendState)) {
00115             QStandardItem *sleepOption = createStandardItem("leave:/sleep");
00116             systemOptions->appendRow(sleepOption);
00117         }
00118 
00119         // Hibernate
00120         if (sleepStates.contains(HibernateState)) {
00121             QStandardItem *hibernateOption = createStandardItem("leave:/hibernate");
00122             systemOptions->appendRow(hibernateOption);
00123         }
00124 
00125         // Shutdown
00126         QStandardItem *shutDownOption = createStandardItem("leave:/shutdown");
00127         systemOptions->appendRow(shutDownOption);
00128 
00129         // Restart
00130         QStandardItem *restartOption = createStandardItem("leave:/restart");
00131         systemOptions->appendRow(restartOption);
00132 
00133     appendRow(sessionOptions);
00134     appendRow(systemOptions);
00135 }
00136 LeaveModel::~LeaveModel()
00137 {
00138     delete d;
00139 }
00140 
00141 #include "leavemodel.moc"
00142 

Applets

Skip menu "Applets"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libplasma
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal