2 Copyright 2011 Volker Krause <vkrause@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #include "nepomukwarning.h"
22 #include <Nepomuk/ResourceManager>
26 #include <KConfigGroup>
28 #include <KLocalizedString>
29 #include <KStandardDirs>
34 KPIM::NepomukWarning::NepomukWarning( const char *neverShowAgainKey
, QWidget
*parent
)
35 : KMessageWidget( parent
),
36 m_neverShowAgainKey( QLatin1String( neverShowAgainKey
) )
38 const bool neverShowAgain
= missingNepomukWarning( neverShowAgainKey
);
39 if ( !neverShowAgain
)
41 setMessageType( Warning
);
42 setCloseButtonVisible( true );
44 setText( i18n( "You do not have the semantic desktop system enabled. "
45 "Many important features of this software depend on the "
46 "semantic desktop system and will not work correctly without it." ) );
48 connect( Nepomuk::ResourceManager::instance(), SIGNAL(nepomukSystemStarted()),
49 SLOT(animatedHide()) );
50 connect( Nepomuk::ResourceManager::instance(), SIGNAL(nepomukSystemStopped()),
51 SLOT(animatedShow()) );
53 setVisible( !Nepomuk::ResourceManager::instance()->initialized() );
55 KAction
*action
= this->findChild
<KAction
*>(); // should give us the close action...
57 connect( action
, SIGNAL(triggered(bool)), SLOT(explicitlyClosed()) );
60 action
= new KAction( KIcon( "configure" ), i18n( "&Configure" ), this );
61 connect( action
, SIGNAL(triggered(bool)), SLOT(configure()) );
68 bool KPIM::NepomukWarning::missingNepomukWarning( const char *neverShowAgainKey
)
70 const KConfigGroup
cfgGroup( KGlobal::config(), QLatin1String( "Missing Nepomuk Warning" ) );
71 const bool neverShowAgain
= cfgGroup
.readEntry( neverShowAgainKey
, false );
72 return neverShowAgain
;
75 void KPIM::NepomukWarning::configure()
77 if ( KService::serviceByStorageId( "kcm_nepomuk.desktop" ) ) {
78 QProcess::startDetached( KStandardDirs::findExe( QLatin1String( "kcmshell4" ) ),
79 QStringList( QLatin1String( "kcm_nepomuk" ) ) );
81 KAction
*action
= qobject_cast
<KAction
*>( sender() );
82 action
->setEnabled( false );
83 setText( i18n( "The module to configure the semantic desktop system (Nepomuk) "
84 "was not found on your system. Please make sure Nepomuk was "
85 "properly installed." ) );
90 void KPIM::NepomukWarning::setMissingFeatures( const QStringList
&features
)
92 if ( !features
.isEmpty() ) {
93 setText( i18n( "You do not have the semantic desktop system enabled. "
94 "The following features will not work correctly:<ul><li>%1</li></ul>",
95 features
.join( QLatin1String( "</li><li>" ) ) ) );
99 void KPIM::NepomukWarning::explicitlyClosed()
101 KConfigGroup
cfgGroup( KGlobal::config(), QLatin1String( "Missing Nepomuk Warning" ) );
102 cfgGroup
.writeEntry( m_neverShowAgainKey
, true );
105 #include "nepomukwarning.moc"