25 #include <KPassivePopup>
27 #include <KDiskFreeSpaceInfo>
28 #include <KStandardDirs>
29 #include <KNotification>
31 #include <KConfigGroup>
34 #include <Solid/PowerManagement>
36 #include <QtDBus/QDBusInterface>
43 void sendEvent(
const QString& event,
const QString& text,
const QString& iconName ) {
44 KNotification::event( event, text, KIcon( iconName ).pixmap( 32, 32 ) );
53 connect( Solid::PowerManagement::notifier(), SIGNAL( appShouldConserveResourcesChanged(
bool ) ),
54 this, SLOT(slotPowerManagementStatusChanged(
bool)) );
57 connect( &m_availSpaceTimer, SIGNAL( timeout() ),
58 this, SLOT( slotCheckAvailableSpace() ) );
61 KIdleTime* idleTime = KIdleTime::instance();
62 connect( idleTime, SIGNAL(timeoutReached(
int)),
this, SLOT(slotIdleTimeoutReached()) );
63 connect( idleTime, SIGNAL(resumingFromIdle()),
this, SLOT(slotResumeFromIdle()) );
65 m_isOnBattery = Solid::PowerManagement::appShouldConserveResources();
67 m_isDiskSpaceLow =
false;
77 void Nepomuk2::EventMonitor::slotPowerManagementStatusChanged(
bool conserveResources )
79 m_isOnBattery = conserveResources;
81 emit powerManagementStatusChanged( conserveResources );
86 void Nepomuk2::EventMonitor::slotCheckAvailableSpace()
92 QString path = KStandardDirs::locateLocal(
"data",
"nepomuk/repository/",
false );
93 KDiskFreeSpaceInfo info = KDiskFreeSpaceInfo::freeSpaceInfo( path );
94 if ( info.isValid() ) {
96 m_isDiskSpaceLow =
true;
97 emit diskSpaceStatusChanged(
true );
99 sendEvent(
"indexingSuspended",
100 i18n(
"Disk space is running low (%1 left). Suspending indexing of files.",
101 KIO::convertSize( info.available() ) ),
104 else if( m_isDiskSpaceLow ) {
106 m_isDiskSpaceLow =
false;
107 emit diskSpaceStatusChanged(
false );
109 sendEvent(
"indexingResumed", i18n(
"Resuming indexing of files for fast searching."),
"drive-harddisk" );
114 m_availSpaceTimer.stop();
127 if (!m_availSpaceTimer.isActive())
135 KIdleTime::instance()->removeAllIdleTimeouts();
138 m_availSpaceTimer.stop();
143 m_availSpaceTimer.stop();
148 if (m_enabled && !m_availSpaceTimer.isActive())
152 void Nepomuk2::EventMonitor::slotIdleTimeoutReached()
156 emit idleStatusChanged(
true );
158 KIdleTime::instance()->catchNextResumeEvent();
161 void Nepomuk2::EventMonitor::slotResumeFromIdle()
165 emit idleStatusChanged(
false );
170 #include "eventmonitor.moc"
static int s_availSpaceTimeout
void resumeDiskSpaceMonitor()
KIO::filesize_t minDiskSpace() const
The minimal available disk space.
void suspendDiskSpaceMonitor()
EventMonitor(QObject *parent=0)
static FileIndexerConfig * self()
Get the first created instance of FileIndexerConfig.