diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-08-27 17:21:45 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-08-27 17:21:45 +0000 |
| commit | e4630543dc17d2a42c27d192518fe3f54e7888bc (patch) | |
| tree | eff8bb9a4cbae15fa9989ce2111e0f1d074cd4d3 /pokemodr/PokemodrUI.cpp | |
| parent | 1fe11fc794783370d8a03a93979b27508278b113 (diff) | |
[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
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@247 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemodr/PokemodrUI.cpp')
| -rw-r--r-- | pokemodr/PokemodrUI.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
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 <KUrl> #include <KXMLGUIFactory> #include <KIO/NetAccess> +#include <KNS/Engine> 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(); |
