[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdeplasma-addons/plasma/sreich/youtube-runner] runners/youtube: set it to low priority, youtube isn
From:       Shaun Reich <shaun.reich () kdemail ! net>
Date:       2012-02-25 12:34:45
Message-ID: 20120225123445.23EC8A60A6 () git ! kde ! org
[Download RAW message or body]

Git commit c4b18b55de44f05a78f4cfbec5b5329a35021fb1 by Shaun Reich.
Committed on 25/02/2012 at 05:10.
Pushed by sreich into branch 'plasma/sreich/youtube-runner'.

set it to low priority, youtube isn't 1st priority ;-)

M  +17   -7    runners/youtube/youtube.cpp
M  +1    -0    runners/youtube/youtube.h

http://commits.kde.org/kdeplasma-addons/c4b18b55de44f05a78f4cfbec5b5329a35021fb1

diff --git a/runners/youtube/youtube.cpp b/runners/youtube/youtube.cpp
index fde1617..f493fc1 100644
--- a/runners/youtube/youtube.cpp
+++ b/runners/youtube/youtube.cpp
@@ -21,9 +21,12 @@
 #include <KDebug>
 #include <KToolInvocation>
 
-#include <QXmlStreamReader>
-
+#include <QtCore/QTimer>
+#include <QtCore/QWaitCondition>
+#include <QtXml/QXmlStreamReader>
 
+//TODO: I'd really *love* to be able to embed a video *inside* krunner. you know how \
sexy that'd be? answer: very much. +//but seeing as youtube doesn't fully support \
html5 (only for non-ad'ed videos), i guess i'll have to hold off on it?  \
YouTube::YouTube(QObject *parent, const QVariantList& args)  : \
Plasma::AbstractRunner(parent, args)  {
@@ -37,6 +40,7 @@ YouTube::YouTube(QObject *parent, const QVariantList& args)
 
     addSyntax(Plasma::RunnerSyntax(QLatin1String( "youtube" ), i18n("Lists the \
videos matching the query, using YouTube search")));  setSpeed(SlowSpeed);
+    setPriority(LowPriority);
 }
 
 YouTube::~YouTube()
@@ -52,6 +56,9 @@ void YouTube::match(Plasma::RunnerContext &context)
 
     Plasma::QueryMatch match(this);
     match.setType(Plasma::QueryMatch::PossibleMatch);
+    // Wait a second, we don't want to  query on every keypress
+
+    startYouTubeJob();
     //  match.setRelevance(1.0);
     //  match.setIcon(m_icon);
     //  match.setData(i.key());
@@ -62,11 +69,6 @@ void YouTube::match(Plasma::RunnerContext &context)
 
 void YouTube::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch \
&match)  {
-    kDebug() << "%%%%%% YOUTUBE RUNNING JORB!";
-    KIO::TransferJob *job = \
KIO::get(KUrl("http://gdata.youtube.com/feeds/api/videos?max-results=1&q=taylor \
                swift"));
-    connect(job, SIGNAL(data(KIO::Job*,QByteArray)), this, \
                SLOT(dataArrived(KIO::Job*,QByteArray)));
-    job->start();
-
 //    Q_UNUSED(context)
 //    const QString session = match.data().toString();
 //    kDebug() << "Open Konsole Session " << session;
@@ -80,6 +82,14 @@ void YouTube::run(const Plasma::RunnerContext &context, const \
Plasma::QueryMatch  //    }
 }
 
+void YouTube::startYouTubeJob()
+{
+    kDebug() << "%%%%%% YOUTUBE RUNNING JORB!";
+    KIO::TransferJob *job = \
KIO::get(KUrl("http://gdata.youtube.com/feeds/api/videos?max-results=1&q=taylor \
swift")); +    connect(job, SIGNAL(data(KIO::Job*,QByteArray)), this, \
SLOT(dataArrived(KIO::Job*,QByteArray))); +    job->start();
+}
+
 void YouTube::dataArrived(KIO::Job* job, const QByteArray& data)
 {
     if (!data.isEmpty()) {
diff --git a/runners/youtube/youtube.h b/runners/youtube/youtube.h
index a42f8b8..8288321 100644
--- a/runners/youtube/youtube.h
+++ b/runners/youtube/youtube.h
@@ -37,6 +37,7 @@ public:
 
 private slots:
     void dataArrived(KIO::Job* job, const QByteArray& data);
+    void startYouTubeJob();
 
 private:
     void parseXML(QByteArray);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic