Development/Tutorials/Collaboration/HotNewStuff/Introduction: Difference between revisions

From KDE TechBase
(Created page with '{{Template:I18n/Language Navigation Bar|Development/Tutorials/Collaboration/HotNewStuff/Introduction}} {{TutorialBrowser| series=HotNewStuff| name=Get Hot New Stuff 3 In...')
 
No edit summary
Line 7: Line 7:
}}
}}


==Overview==
== Overview ==
Here is a small example of an application that asks [http://opendesktop.org openDesktop.org] for wallpapers. It lets the user install them into the system wallpaper directory.


====The Code====
Here is a small example of an application that asks [http://opendesktop.org openDesktop.org] for wallpapers. It lets the user install them into the system wallpaper directory.
The example consists of just one c++ source file.
 
<code cppqt>
==== The Code ====
 
The example consists of just one c++ source file. <code cppqt="cppqt">
//khotnewstuff.cpp
//khotnewstuff.cpp


Line 38: Line 39:
     return 0;
     return 0;
}
}
</code>
</code>  


For this to work, a file that sets up KNewStuff <em>khotnewstuff_example.knsrc</em> is needed. The file has to be in <em>kde/share/config/khotnewstuff_example.knsrc</em>. (The name of the file is taken from the about data).
For this to work, a file that sets up KNewStuff ''khotnewstuff_example.knsrc'' is needed. The file has to be in ''kde/share/config/khotnewstuff_example.knsrc''. (The name of the file is taken from the about data).  


<code>
<code>
Line 47: Line 48:
Categories=KDE Wallpaper 1920x1200,KDE Wallpaper 1600x1200
Categories=KDE Wallpaper 1920x1200,KDE Wallpaper 1600x1200
TargetDir=wallpapers
TargetDir=wallpapers
</code>
</code>  
 
To link against KNS3, just link against ''${KDE4_KNEWSTUFF4_LIBS}''.

Revision as of 02:32, 8 January 2010


Development/Tutorials/Collaboration/HotNewStuff/Introduction


Get Hot New Stuff 3 Introduction
Tutorial Series   HotNewStuff
Previous   Getting started with KDE development
What's Next   n/a
Further Reading   n/a

Overview

Here is a small example of an application that asks openDesktop.org for wallpapers. It lets the user install them into the system wallpaper directory.

The Code

The example consists of just one c++ source file. //khotnewstuff.cpp

  1. include <kapplication.h>
  2. include <kdebug.h>
  3. include <klocale.h>
  4. include <kcmdlineargs.h>
  5. include <kaboutdata.h>
  1. include <knewstuff3/downloaddialog.h>

int main(int argc, char **argv) {

   KAboutData about("khotnewstuff_example", 0, ki18n("KHotNewStuff"), "0.4");
   about.setProgramIconName("get-hot-new-stuff");
   
   KApplication i;
   KNS3::DownloadDialog dialog(args->arg(0));
   dialog.exec();
   foreach (const KNS3::Entry& e, dialog.changedEntries()) {
       kDebug() << "Changed Entry: " << e.name();
   }

   return 0;

}

For this to work, a file that sets up KNewStuff khotnewstuff_example.knsrc is needed. The file has to be in kde/share/config/khotnewstuff_example.knsrc. (The name of the file is taken from the about data).

[KNewStuff3] ProvidersUrl=http://download.kde.org/ocs/providers.xml Categories=KDE Wallpaper 1920x1200,KDE Wallpaper 1600x1200 TargetDir=wallpapers

To link against KNS3, just link against ${KDE4_KNEWSTUFF4_LIBS}.