[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/base/nepomuk-kde/scribo/plugins/opencalais
From: Sebastian Trueg <sebastian () trueg ! de>
Date: 2009-10-22 9:17:58
Message-ID: 1256203078.353274.30228.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1038900 by trueg:
* Fixed configure button
* Only show the notification once.
M +1 -13 lookupjob.cpp
M +0 -1 lookupjob.h
M +6 -0 opencalaisconfig.kcfg
M +32 -6 opencalaistextmatchplugin.cpp
M +3 -0 opencalaistextmatchplugin.h
--- trunk/playground/base/nepomuk-kde/scribo/plugins/opencalais/lookupjob.cpp \
#1038899:1038900 @@ -34,14 +34,12 @@
#include <KLocale>
#include <KDebug>
-#include <KNotification>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkReply>
#include <QtCore/QFile>
-#include <QtCore/QProcess>
class OpenCalais::LookupJob::Private
@@ -109,16 +107,12 @@
d->resultModel = 0;
d->modelRetrieved = false;
- QUrl url( "http://api.opencalais.com/enlighten/rest/" );
+ QUrl url( "http://api.opencalais.com/enlighten/rest/" );
QString key = Config::licenseKey();
if ( key.isEmpty() ) {
kDebug() << "no key";
setErrorText( i18n( "No OpenCalais API key configured." ) );
- KNotification* n = KNotification::event( KNotification::Warning,
- i18n( "No OpenCalais API key \
configured." ) );
- n->setActions( QStringList() << i18n( "Configure..." ) );
- connect( n, SIGNAL( activated() ), this, SLOT( slotConfigure() ) );
emitResult();
return;
}
@@ -186,10 +180,4 @@
emitResult();
}
-
-void OpenCalais::LookupJob::slotConfigure()
-{
- QProcess::startDetached( "kcmshell4", QStringList() << "kcm_kopencalais" );
-}
-
#include "lookupjob.moc"
--- trunk/playground/base/nepomuk-kde/scribo/plugins/opencalais/lookupjob.h \
#1038899:1038900 @@ -52,7 +52,6 @@
private Q_SLOTS:
void slotTransferResult();
- void slotConfigure();
private:
class Private;
--- trunk/playground/base/nepomuk-kde/scribo/plugins/opencalais/opencalaisconfig.kcfg \
#1038899:1038900 @@ -9,4 +9,10 @@
<label>Open Calais registration key</label>
</entry>
</group>
+ <group name="General">
+ <entry key="Show Key Warning" type="bool">
+ <label>Show a warning if Key is missing</label>
+ <default>true</default>
+ </entry>
+ </group>
</kcfg>
--- trunk/playground/base/nepomuk-kde/scribo/plugins/opencalais/opencalaistextmatchplugin.cpp \
#1038899:1038900 @@ -21,6 +21,7 @@
#include "opencalaistextmatchplugin.h"
#include "lookupjob.h"
#include "worker.h"
+#include "opencalaisconfig.h"
#include "entity.h"
#include "statement.h"
@@ -39,9 +40,12 @@
#include <KDebug>
#include <KPluginFactory>
+#include <KNotification>
#include <QtCore/QCoreApplication>
+#include <QtCore/QProcess>
+
Q_DECLARE_METATYPE( Scribo::TextMatch )
@@ -75,13 +79,28 @@
{
// cancel previous jobs
delete m_lookupJob;
+ m_lookupJob = 0;
- // do the lookup
- m_lookupJob = new OpenCalais::LookupJob( this );
- connect( m_lookupJob, SIGNAL( result( KJob* ) ),
- this, SLOT( slotResult( KJob* ) ) );
- m_lookupJob->setContent( text );
- m_lookupJob->start();
+ if ( OpenCalais::Config::licenseKey().isEmpty() ) {
+ kDebug() << "no key";
+ if ( OpenCalais::Config::showKeyWarning() ) {
+ KNotification* n = KNotification::event( KNotification::Warning,
+ i18n( "No OpenCalais API key \
configured." ) ); + n->setActions( QStringList() << i18n( "Configure..." ) \
); + connect( n, SIGNAL( action1Activated() ), this, SLOT( slotConfigure() \
) ); + OpenCalais::Config::self()->findItem( "ShowKeyWarning" \
)->setProperty( false ); +// OpenCalais::Config::self()->writeConfig();
+ }
+ emitFinished();
+ }
+ else {
+ // do the lookup
+ m_lookupJob = new OpenCalais::LookupJob( this );
+ connect( m_lookupJob, SIGNAL( result( KJob* ) ),
+ this, SLOT( slotResult( KJob* ) ) );
+ m_lookupJob->setContent( text );
+ m_lookupJob->start();
+ }
}
@@ -115,6 +134,13 @@
return *it;
}
+
+void OpenCalaisTextMatchPlugin::slotConfigure()
+{
+ kDebug();
+ QProcess::startDetached( "kcmshell4", QStringList() << "kcm_kopencalais" );
+}
+
SCRIBO_EXPORT_TEXTMATCH_PLUGIN( OpenCalaisTextMatchPlugin, \
"scribo_opencalaistextmatchplugin" )
#include "opencalaistextmatchplugin.moc"
--- trunk/playground/base/nepomuk-kde/scribo/plugins/opencalais/opencalaistextmatchplugin.h \
#1038899:1038900 @@ -45,6 +45,9 @@
QUrl matchPimoType( const QUrl& openCalaisType );
+public Q_SLOTS:
+ void slotConfigure();
+
protected:
void doGetPossibleMatches( const QString& text );
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic