[Kde-games-devel] KHotNewStuff3 Support

Robert Marmorstein robert at narnia.homeunix.com
Sat Apr 7 03:04:37 UTC 2012


I've written a short patch that adds support for Get Hot New Stuff (version 3) 
to Palapeli for downloading puzzles.  This is to scratch a personal itch of 
mine -- I love Palapeli, but dislike the process of downloading a bunch of 
image files and generating puzzles from them.  GHNS seemed like a good way to 
get other people to do the hard work for me. 

I can't really test it until there's a "Palapeli Puzzle" category on kde-
files.org or some place, but I thought I'd post it here and get some feedback 
on it.  As far as I can tell, Palapeli doesn't use reviewboard?

Anyway, here it is in all its glory (thanks for any comments!):

Index: palapeliui.rc
===================================================================
--- palapeliui.rc       (revision 1288501)
+++ palapeliui.rc       (working copy)
@@ -10,6 +10,7 @@
                        <Separator/>
                        <Action name="file_export"/>
                        <Action name="file_delete"/>
+                       <Action name="ghns_download"/>
                </Menu>
                <Menu name="game">
                        <Action name="go_collection"/>
@@ -22,6 +23,7 @@
                <Action name="file_new"/>
                <Action name="file_delete"/>
                <Separator/>
+               <Action name="ghns_download"/>
                <Action name="file_import"/>
                <Action name="file_export"/>
                <Separator/>
Index: palapeli_puzzles.knsrc
===================================================================
--- palapeli_puzzles.knsrc      (revision 0)
+++ palapeli_puzzles.knsrc      (revision 0)
@@ -0,0 +1,4 @@
+[KNewStuff3]
+Categories=Palapeli Puzzle
+TargetDir=collection
+Uncompress=archive
Index: window/mainwindow.h
===================================================================
--- window/mainwindow.h (revision 1288501)
+++ window/mainwindow.h (working copy)
@@ -40,6 +40,7 @@
                        void actionGoCollection();
                        void actionCreate();
                        void actionDelete();
+                       void actionGHNS();
                        void actionImport();
                        void actionExport();
                private:
Index: window/mainwindow.cpp
===================================================================
--- window/mainwindow.cpp       (revision 1288501)
+++ window/mainwindow.cpp       (working copy)
@@ -37,6 +37,7 @@
 #include <KDE/KMessageBox>
 #include <KDE/KStandardAction>
 #include <KDE/KToggleAction>
+#include <knewstuff3/downloaddialog.h>
 
 //TODO: move LoadingWidget into here (stack into m_centralWidget)
 
@@ -96,6 +97,11 @@
        actionCollection()->addAction("file_delete", deleteAct);
        connect(m_collectionView, SIGNAL(canDeleteChanged(bool)), deleteAct, 
SLOT(setEnabled(bool)));
        connect(deleteAct, SIGNAL(triggered()), SLOT(actionDelete()));
+       //Use GHNS to download new puzzles
+       KAction* ghnsAct = new KAction(KIcon("get-hot-new-stuff"), i18n("Get 
New Puzzles..."), 0);
+       ghnsAct->setToolTip(i18n("Use Get Hot New Stuff to Download Puzzles 
from kde-look.org"));
+       actionCollection()->addAction("ghns_download", ghnsAct);
+       connect(ghnsAct, SIGNAL(triggered()), this, SLOT(actionGHNS()));
        //Import from file...
        KAction* importAct = new KAction(KIcon("document-import"), 
i18n("&Import from file..."), 0);
        importAct->setToolTip(i18n("Import a new puzzle from a file into your 
collection"));
@@ -176,6 +182,12 @@
                coll->deletePuzzle(index);
 }
 
+void Palapeli::MainWindow::actionGHNS()
+{
+       KNS3::DownloadDialog dialog("palapeli_puzzles.knsrc");
+       dialog.exec();
+}
+
 void Palapeli::MainWindow::actionImport()
 {
        const QString filter = i18nc("Filter for a file dialog", "*.puzzle|
Palapeli puzzles (*.puzzle)");
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt      (revision 1288501)
+++ CMakeLists.txt      (working copy)
@@ -46,10 +46,11 @@
 kde4_add_app_icon(palapeli_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/../pics/hi*-app-
palapeli.png")
 
 kde4_add_executable(palapeli ${palapeli_SRCS})
-target_link_libraries(palapeli pala ${KDE4_KFILE_LIBS})
+target_link_libraries(palapeli pala ${KDE4_KFILE_LIBS} 
${KDE4_KNEWSTUFF3_LIBS})
 
 install(TARGETS palapeli ${INSTALL_TARGETS_DEFAULT_ARGS})
-install(FILES palapeli.kcfg palapeli.notifyrc palapeliui.rc
+install(FILES palapeli.kcfg palapeli.notifyrc palapeliui.rc 
         DESTINATION ${DATA_INSTALL_DIR}/palapeli)
+install(FILES palapeli_puzzles.knsrc DESTINATION ${CONFIG_INSTALL_DIR})
 install(PROGRAMS palapeli.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
 add_subdirectory(pics)
-----------------------------------------


More information about the kde-games-devel mailing list