From e4630543dc17d2a42c27d192518fe3f54e7888bc Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 27 Aug 2008 17:21:45 +0000 Subject: [FIX] Added KNewStuff2 for Pokémod upload and download [FIX] ValidationDialog can be used piecemeal now [ADD] Added KNewStuff configuration file [FIX] pokemodr-devel now includes the UI forms for use as well MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@247 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemodr/PokemodrUI.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'pokemodr/PokemodrUI.cpp') diff --git a/pokemodr/PokemodrUI.cpp b/pokemodr/PokemodrUI.cpp index 1d6dfd8f..3f7532e8 100644 --- a/pokemodr/PokemodrUI.cpp +++ b/pokemodr/PokemodrUI.cpp @@ -51,6 +51,7 @@ #include #include #include +#include Pokemodr::PokemodrUI::PokemodrUI(QWidget* parent) : KXmlGuiWindow(parent), @@ -247,6 +248,39 @@ void Pokemodr::PokemodrUI::saveAsPokemod(const Pokemod::Pokemod* pokemod) } } +void Pokemodr::PokemodrUI::downloadPokemod() +{ + KNS::Engine engine(this); + if (engine.init("pokemod.knsrc")) + engine.downloadDialogModal(); +} + +void Pokemodr::PokemodrUI::uploadPokemod() +{ + uploadPokemod(treePokemod->currentPokemod()); +} + +void Pokemodr::PokemodrUI::uploadPokemod(const Pokemod::Pokemod* pokemod) +{ + KUrl url = treePokemod->url(pokemod); + if (url == KUrl()) + { + KMessageBox::error(this, QString::fromUtf8("The Pokémod has not been saved!"), "Upload error"); + return; + } + if (!url.isLocalFile()) + { + KMessageBox::error(this, QString::fromUtf8("The Pokémod is not local!"), "Upload error"); + return; + } + KNS::Engine engine(this); + if (engine.init("pokemod.knsrc")) + { + if (!engine.uploadDialogModal(url.path())) + KMessageBox::error(this, QString::fromUtf8("An error occured attempting to upload!"), "Upload error"); + } +} + void Pokemodr::PokemodrUI::closePokemod() { closePokemod(treePokemod->currentPokemod()); @@ -395,6 +429,17 @@ void Pokemodr::PokemodrUI::setupActions() KStandardAction::cut(actionCollection()); KStandardAction::copy(actionCollection()); KStandardAction::paste(actionCollection()); + KAction* download = actionCollection()->addAction("download_pokemod"); + download->setText(i18n("Download")); + download->setIcon(KIcon("arrow-down-double")); + download->setShortcut(Qt::CTRL + Qt::Key_D); + connect(download, SIGNAL(triggered()), this, SLOT(downloadPokemod())); + KAction* upload = actionCollection()->addAction("upload_pokemod"); + upload->setText(i18n("Upload")); + upload->setIcon(KIcon("arrow-up-double")); + upload->setShortcut(Qt::CTRL + Qt::Key_U); + upload->setEnabled(false); + connect(upload, SIGNAL(triggered()), this, SLOT(uploadPokemod())); KStandardAction::showMenubar(this, SLOT(toggleMenubar()), actionCollection()); KStandardAction::configureToolbars(this, SLOT(configureToolbars()), actionCollection()); createStandardStatusBarAction(); -- cgit