< Development‎ | Tutorials‎ | Collaboration/HotNewStuff
Revision as of 11:52, 30 January 2020 by Leinir (talk | contribs) (→‎The Configuration File (.knsrc): Ensure we don't tell people to use download.k.o when autoconfig.k.o is what they should be using...)


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
This section needs improvements: Please help us to

cleanup confusing sections and fix sections which contain a todo


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.

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!

// 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)

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.

UploadCategories=KDE Wallpaper 1920x1200,KDE Wallpaper 1600x1200

Linking in CMakeLists.txt

To link against KNS3, just link against KF5::NewStuff. Example:

target_link_libraries(ktexteditor_codesnippets_core Qt5::Widgets KF5::TextEditor KF5::NewStuff)

This page was last edited on 30 January 2020, at 12:05. Content is available under Creative Commons License SA 4.0 unless otherwise noted.