File indexing completed on 2024-05-12 17:10:42

0001 /***************************************************************************
0002  *   Copyright (C) 2010 by Dario Freddi <drf@kde.org>                      *
0003  *                                                                         *
0004  *   This program is free software; you can redistribute it and/or modify  *
0005  *   it under the terms of the GNU General Public License as published by  *
0006  *   the Free Software Foundation; either version 2 of the License, or     *
0007  *   (at your option) any later version.                                   *
0008  *                                                                         *
0009  *   This program is distributed in the hope that it will be useful,       *
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0012  *   GNU General Public License for more details.                          *
0013  *                                                                         *
0014  *   You should have received a copy of the GNU General Public License     *
0015  *   along with this program; if not, write to the                         *
0016  *   Free Software Foundation, Inc.,                                       *
0017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
0018  ***************************************************************************/
0019 
0020 
0021 #ifndef POWERDEVIL_BUNDLEDACTIONS_SUSPENDSESSION_H
0022 #define POWERDEVIL_BUNDLEDACTIONS_SUSPENDSESSION_H
0023 
0024 #include <powerdevilaction.h>
0025 
0026 #include <QScopedPointer>
0027 
0028 namespace PowerDevil
0029 {
0030 
0031 class KWinKScreenHelperEffect;
0032 
0033 namespace BundledActions
0034 {
0035 
0036 class SuspendSession : public PowerDevil::Action
0037 {
0038     Q_OBJECT
0039     Q_DISABLE_COPY(SuspendSession)
0040     Q_CLASSINFO("D-Bus Interface", "org.kde.Solid.PowerManagement.Actions.SuspendSession")
0041 
0042 public:
0043     enum Mode {
0044         None = 0,
0045         ToRamMode = 1,
0046         ToDiskMode = 2,
0047         SuspendHybridMode = 4,
0048         ShutdownMode = 8,
0049         LogoutDialogMode = 16,
0050         LockScreenMode = 32,
0051         TurnOffScreenMode = 64,
0052         ToggleScreenOnOffMode = 128
0053     };
0054 
0055     explicit SuspendSession(QObject *parent, const QVariantList &);
0056     ~SuspendSession() override;
0057 
0058     bool loadAction(const KConfigGroup& config) override;
0059     
0060 protected:
0061     void onProfileUnload() override;
0062     void onWakeupFromIdle() override;
0063     void onIdleTimeout(int msec) override;
0064     void onProfileLoad() override;
0065     void triggerImpl(const QVariantMap& args) override;
0066 
0067 public Q_SLOTS:
0068     void suspendToRam();
0069     void suspendToDisk();
0070     void suspendHybrid();
0071 
0072 Q_SIGNALS:
0073     void aboutToSuspend();
0074     void resumingFromSuspend();
0075 
0076 private Q_SLOTS:
0077     void triggerSuspendSession(uint action);
0078 
0079 private:
0080     bool m_suspendThenHibernateEnabled = false;
0081     int m_idleTime = 0;
0082     uint m_autoType;
0083     QVariantMap m_savedArgs;
0084     QScopedPointer<PowerDevil::KWinKScreenHelperEffect> m_fadeEffect;
0085 
0086 };
0087 
0088 }
0089 
0090 }
0091 
0092 #endif // POWERDEVIL_BUNDLEDACTIONS_SUSPENDSESSION_H