1 | /*
|
---|
2 | * systemwatch.h - Detect changes in the system state.
|
---|
3 | * Copyright (C) 2005 Remko Troncon
|
---|
4 | *
|
---|
5 | * This program is free software; you can redistribute it and/or
|
---|
6 | * modify it under the terms of the GNU General Public License
|
---|
7 | * as published by the Free Software Foundation; either version 2
|
---|
8 | * of the License, or (at your option) any later version.
|
---|
9 | *
|
---|
10 | * This program is distributed in the hope that it will be useful,
|
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | * GNU General Public License for more details.
|
---|
14 | *
|
---|
15 | * You should have received a copy of the GNU General Public License
|
---|
16 | * along with this library; if not, write to the Free Software
|
---|
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
18 | *
|
---|
19 | */
|
---|
20 |
|
---|
21 | #include "systemwatch.h"
|
---|
22 | #if defined(Q_OS_MAC)
|
---|
23 | #include "systemwatch_mac.h"
|
---|
24 | #elif defined(Q_OS_WIN32)
|
---|
25 | #include "systemwatch_win.h"
|
---|
26 | #elif defined(Q_WS_PM)
|
---|
27 | #include "systemwatch_pm.h"
|
---|
28 | #else
|
---|
29 | #include "systemwatch_unix.h"
|
---|
30 | #endif
|
---|
31 |
|
---|
32 |
|
---|
33 | SystemWatch::SystemWatch()
|
---|
34 | {
|
---|
35 | SystemWatchImpl* impl;
|
---|
36 | #if defined(Q_WS_MAC)
|
---|
37 | impl = MacSystemWatch::instance();
|
---|
38 | #elif defined(Q_WS_WIN)
|
---|
39 | impl = WinSystemWatch::instance();
|
---|
40 | #elif defined(Q_WS_PM)
|
---|
41 | impl = PMSystemWatch::instance();
|
---|
42 | #else
|
---|
43 | impl = UnixSystemWatch::instance();
|
---|
44 | #endif
|
---|
45 | connect(impl,SIGNAL(sleep()),this,SIGNAL(sleep()));
|
---|
46 | connect(impl,SIGNAL(idleSleep()),this,SIGNAL(idleSleep()));
|
---|
47 | connect(impl,SIGNAL(wakeup()),this,SIGNAL(wakeup()));
|
---|
48 | }
|
---|
49 |
|
---|
50 |
|
---|
51 | SystemWatch* SystemWatch::instance()
|
---|
52 | {
|
---|
53 | if (!instance_)
|
---|
54 | instance_ = new SystemWatch();
|
---|
55 |
|
---|
56 | return instance_;
|
---|
57 | }
|
---|
58 |
|
---|
59 |
|
---|
60 | SystemWatch* SystemWatch::instance_ = 0;
|
---|