Difference between revisions of "Development/Tutorials/Collaboration/HotNewStuff/Upload"

Jump to: navigation, search
m (Text replace - "<code>" to "<syntaxhighlight lang="text">")
 
(2 intermediate revisions by one user not shown)
Line 1: Line 1:
{{Template:I18n/Language Navigation Bar|Development/Tutorials/Collaboration/HotNewStuff/Upload}}
 
  
 
{{TutorialBrowser|
 
{{TutorialBrowser|
Line 15: Line 14:
 
==== The Code  ====
 
==== The Code  ====
  
<code  cppqt="cppqt">
+
<syntaxhighlight lang="cpp-qt">
 
#include <knewstuff3/uploaddialog.h>
 
#include <knewstuff3/uploaddialog.h>
  
Line 34: Line 33:
 
// show the dialog as modal (you can also use show of course)
 
// show the dialog as modal (you can also use show of course)
 
dialog.exec();
 
dialog.exec();
</code>
+
</syntaxhighlight>
  
 
==== The Configuration File (.knsrc)  ====
 
==== The Configuration File (.knsrc)  ====
Line 43: Line 42:
 
ProvidersUrl=http://download.kde.org/ocs/providers.xml
 
ProvidersUrl=http://download.kde.org/ocs/providers.xml
 
UploadCategories=KDE Wallpaper 1920x1200,KDE Wallpaper 1600x1200
 
UploadCategories=KDE Wallpaper 1920x1200,KDE Wallpaper 1600x1200
</code>  
+
</syntaxhighlight>  
  
 
==== Linking in CMakeLists.txt ====
 
==== Linking in CMakeLists.txt ====
Line 51: Line 50:
 
target_link_libraries(ktexteditor_codesnippets_core
 
target_link_libraries(ktexteditor_codesnippets_core
 
${KDE4_KDEUI_LIBS} ${KDE4_KTEXTEDITOR_LIBS} ${KDE4_KNEWSTUFF3_LIBS})
 
${KDE4_KDEUI_LIBS} ${KDE4_KTEXTEDITOR_LIBS} ${KDE4_KNEWSTUFF3_LIBS})
</code>
+
</syntaxhighlight>

Latest revision as of 16:42, 19 July 2012

Get Hot New Stuff 3 - Upload
Tutorial Series   HotNewStuff
Previous   Get Hot New Stuff 3 - Updates
What's Next   n/a
Further Reading   API Documentation

Contents

[edit] Overview

Adding an upload dialog to an application is straight forward. If you already have a download dialog, you just need to add a few lines to the .knsrc file and create the dialog. Uploading currently only works with openDesktop.org and other websites that implement the Open Collaboration Services API.

[edit] The Code

#include <knewstuff3/uploaddialog.h>
 
// create the dialog
KNS3::UploadDialog dialog(parentWidget);
 
// set it up to help the user fill it out
// the file to be uploaded - this is important!
dialog.setUploadFile("some_url_here");
 
// a suggested title, the user can still change it
// don't set it if you can't make a reasonable suggestion
dialog.setUploadName("A suggested title for the upload");
 
// a longer description, optional
dialog.setDescription("This is a great file. It was created using foo.");
 
// show the dialog as modal (you can also use show of course)
dialog.exec();

[edit] The Configuration File (.knsrc)

In addition to the download version, you need to add UploadCategories, to set up where the contents can be uploaded to.

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

[edit] Linking in CMakeLists.txt

To link against KNS3, just link against ${KDE4_KNEWSTUFF3_LIBS}. Example:

target_link_libraries(ktexteditor_codesnippets_core
${KDE4_KDEUI_LIBS} ${KDE4_KTEXTEDITOR_LIBS} ${KDE4_KNEWSTUFF3_LIBS})

This page was last modified on 19 July 2012, at 16:42. This page has been accessed 5,536 times. Content is available under Creative Commons License SA 3.0 as well as the GNU Free Documentation License 1.2.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal