From 9200ed0568719fc3ffbf9c1f2fd07a667097b875 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 26 May 2008 07:08:59 +0000 Subject: [FIX] Recent files now works [FIX] Various UI fixes [FIX] Scripts are now escaped correctly in the XML git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@176 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemodr/PokeModrUI.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'pokemodr/PokeModrUI.cpp') diff --git a/pokemodr/PokeModrUI.cpp b/pokemodr/PokeModrUI.cpp index 7dff096d..69ce08bf 100644 --- a/pokemodr/PokeModrUI.cpp +++ b/pokemodr/PokeModrUI.cpp @@ -24,6 +24,7 @@ // Pokemod includes #include "../pokemod/Pokemod.h" +#include "../pokemod/Rules.h" // Qt includes #include @@ -46,19 +47,19 @@ #include #include -PokeModrUI::PokeModrUI(KConfigGroup config, KConfigGroup history, QWidget* parent) : +PokeModrUI::PokeModrUI(KConfigGroup config, QWidget* parent) : KMainWindow(parent), - m_config(config), - m_recent(new KRecentFilesAction("&Recent Files...", this)) + m_config(config) { setupUi(this); - m_recent->loadEntries(history); // FIXME: Somehow get KAction/KMenus into the ui files KMenuBar* menubar = new KMenuBar(this); KMenu* menuFile = new KMenu("&File", menubar); menuFile->addAction(KStandardAction::openNew(this, SLOT(newPokemod()), menuFile)); menuFile->addAction(KStandardAction::open(this, SLOT(openPokemod()), menuFile)); - menuFile->addAction(KStandardAction::openRecent(this, SLOT(openPokemod(const KUrl&)), menuFile)); + m_recent = KStandardAction::openRecent(this, SLOT(openPokemod(const KUrl&)), menuFile); + m_recent->loadEntries(m_config); + menuFile->addAction(m_recent); menuFile->addAction(KStandardAction::close(this, SLOT(closePokemod()), menuFile)); menuFile->addSeparator(); menuFile->addAction(KStandardAction::save(this, SLOT(savePokemod()), menuFile)); @@ -78,7 +79,7 @@ PokeModrUI::PokeModrUI(KConfigGroup config, KConfigGroup history, QWidget* paren KToolBar* toolbar = new KToolBar("toolbar", this, Qt::TopToolBarArea, false, true, true); toolbar->addAction(KStandardAction::openNew(this, SLOT(newPokemod()), toolbar)); toolbar->addAction(KStandardAction::open(this, SLOT(openPokemod()), toolbar)); - toolbar->addAction(KStandardAction::openRecent(this, SLOT(openPokemod(const KUrl&)), toolbar)); + toolbar->addAction(m_recent); toolbar->addAction(KStandardAction::close(this, SLOT(closePokemod()), toolbar)); toolbar->addSeparator(); toolbar->addAction(KStandardAction::save(this, SLOT(savePokemod()), toolbar)); @@ -112,6 +113,7 @@ PokeModrUI::PokeModrUI(KConfigGroup config, KConfigGroup history, QWidget* paren PokeModrUI::~PokeModrUI() { closeAllPokemods(true); + m_recent->saveEntries(m_config); } void PokeModrUI::update() @@ -168,7 +170,7 @@ bool PokeModrUI::openPokemod(const KUrl& url) QString temp; if (KIO::NetAccess::download(url, temp, this)) { - const bool opened = openPokemod(temp); + const bool opened = openPokemod(temp, true); KIO::NetAccess::removeTempFile(temp); return opened; } @@ -178,7 +180,7 @@ bool PokeModrUI::openPokemod(const KUrl& url) return false; } -bool PokeModrUI::openPokemod(const QString& path) +bool PokeModrUI::openPokemod(const QString& path, const bool isRemote) { QFile file(path); if (file.open(QIODevice::ReadOnly)) @@ -188,7 +190,7 @@ bool PokeModrUI::openPokemod(const QString& path) { if (xml.doctype().name() == "Pokemod") { - treePokemod->addPokemod(new Pokemod(xml.documentElement())); + treePokemod->addPokemod(new Pokemod(xml.documentElement()), isRemote ? KUrl() : KUrl(path)); return true; } else @@ -198,6 +200,8 @@ bool PokeModrUI::openPokemod(const QString& path) KMessageBox::error(this, "The file is not a valid XML file.", QString::fromUtf8("Invalid PokéMod")); file.close(); } + else + KMessageBox::error(this, QString("Cannot open file:\n%1").arg(path), "No such file"); return false; } -- cgit