summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-06-04 06:58:53 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-06-04 06:58:53 +0000
commit2a34d37f69c21224a1f0795aa802b75300aa96da (patch)
tree5b8ae885b48c3a2a0f876079f2dfb95258949786
parent9180817f1d52ffe67ea30ec07ebc87d8a274319c (diff)
[FIX] URLs now accepted on the command line
[FIX] Now remembers splitter position [FIX] Remembers opened files (via options) git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@192 6ecfd1a5-f3ed-3746-8530-beee90d26b22
-rw-r--r--Changelog9
-rw-r--r--pokemodr/PointWidget.h4
-rw-r--r--pokemodr/PokeModr.cpp11
-rw-r--r--pokemodr/PokeModrPreferences.cpp41
-rw-r--r--pokemodr/PokeModrPreferences.h41
-rw-r--r--pokemodr/PokeModrUI.cpp52
-rw-r--r--pokemodr/PokeModrUI.h2
-rw-r--r--pokemodr/PokemodTree.cpp24
-rw-r--r--pokemodr/PokemodTree.h7
-rw-r--r--pokemodr/pokemodr.pro2
10 files changed, 160 insertions, 33 deletions
diff --git a/Changelog b/Changelog
index 102201b0..c0ba46e3 100644
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,13 @@
-----------------
+Rev: 192
+Date: 4 June 2008
+User: MathStuf
+-----------------
+[FIX] URLs now accepted on the command line
+[FIX] Now remembers splitter position
+[FIX] Remembers opened files (via options)
+
+-----------------
Rev: 191
Date: 3 June 2008
User: MathStuf
diff --git a/pokemodr/PointWidget.h b/pokemodr/PointWidget.h
index 8f303f18..c8eac827 100644
--- a/pokemodr/PointWidget.h
+++ b/pokemodr/PointWidget.h
@@ -15,8 +15,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef __POINTWIDGET__
-#define __POINTWIDGET__
+#ifndef __POKEMODR_POINTWIDGET__
+#define __POKEMODR_POINTWIDGET__
// Pokemod includes
#include "../pokemod/Point.h"
diff --git a/pokemodr/PokeModr.cpp b/pokemodr/PokeModr.cpp
index c55f6209..8b707a10 100644
--- a/pokemodr/PokeModr.cpp
+++ b/pokemodr/PokeModr.cpp
@@ -39,16 +39,19 @@ int main(int argc, char* argv[])
KAboutData about("pokemodr", "pokemodr", ki18n("PokéModr"), VERSION_STRING, ki18n(""), KAboutData::License_Custom, ki18n("©2007-2008 Ben Boeckel and Nerdy Productions"), ki18n("This program offers an easy interface so that PokéMods can be easily created."), "http://sourceforge.net/projects/pokegen");
about.setLicenseTextFile("LICENSE");
about.setProgramName(ki18n("PokéModr"));
- about.addAuthor(ki18n("Ben Boeckel"), ki18n("Lead Programmer"), "MathStuf@gmail.com", "http://nerdyproductions.sobertillnoon.com");
+ about.addAuthor(ki18n("Ben Boeckel"), ki18n("Lead Programmer"), "MathStuf@gmail.com", "");
about.addCredit(ki18n("Peter Fernandes"), ki18n("Ideas"), "supersonicandtails@gmail.com", "http://www.hypersonicsoft.org");
about.addCredit(ki18n("Kevin Kofler"), ki18n("Qt, KDE, debugging help"), "kevin.kofler@chello.at", "http://www.tigen.org/kevin.kofler");
+ about.addCredit(ki18n("Luke Greco"), ki18n("Ideas"), "sirlewk@gmail.com", "");
KCmdLineArgs::init(argc, argv, &about);
- KApplication* app = new KApplication();
+ KCmdLineOptions options;
+ options.add("+[files]", ki18n("Files to open"));
+ KCmdLineArgs::addCmdLineOptions(options);
- KConfig cfg(KStandardDirs::locate("config", "pokemodrrc"));
+ KApplication* app = new KApplication();
- PokeModrUI* mainWindow = new PokeModrUI(cfg.group("pokemodr"));
+ PokeModrUI* mainWindow = new PokeModrUI;
mainWindow->show();
app->exec();
return 0;
diff --git a/pokemodr/PokeModrPreferences.cpp b/pokemodr/PokeModrPreferences.cpp
new file mode 100644
index 00000000..ca720077
--- /dev/null
+++ b/pokemodr/PokeModrPreferences.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2008 Ben Boeckel <MathStuf@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+// Header include
+#include "PokeModrPreferences.h"
+
+// Qt includes
+#include <QCheckBox>
+
+// KDE includes
+#include <KConfigGroup>
+
+PokeModrPreferences::PokeModrPreferences(QWidget* parent, KConfigGroup& config) :
+ KDialog(parent),
+ m_config(config)
+{
+ setCaption(QString::fromUtf8("PokéModr Preferences"));
+ setButtons(KDialog::Ok | KDialog::Cancel);
+ varReloadOnOpen = new QCheckBox("Reload files on open");
+ varReloadOnOpen->setChecked(m_config.readEntry("reloadOnStart", false) ? Qt::Checked : Qt::Unchecked);
+ setMainWidget(varReloadOnOpen);
+}
+
+void PokeModrPreferences::save()
+{
+ m_config.writeEntry("reloadOnStart", varReloadOnOpen->isChecked());
+}
diff --git a/pokemodr/PokeModrPreferences.h b/pokemodr/PokeModrPreferences.h
new file mode 100644
index 00000000..121e01ac
--- /dev/null
+++ b/pokemodr/PokeModrPreferences.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2008 Ben Boeckel <MathStuf@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __POKEMODR_PREFERENCES__
+#define __POKEMODR_PREFERENCES__
+
+// KDE includes
+#include <KDialog>
+
+// Forward declarations
+class KConfigGroup;
+class QCheckBox;
+
+class PokeModrPreferences : public KDialog
+{
+ Q_OBJECT
+
+ public:
+ PokeModrPreferences(QWidget* parent, KConfigGroup& config);
+ protected slots:
+ void save();
+ private:
+ KConfigGroup& m_config;
+ QCheckBox* varReloadOnOpen;
+};
+
+#endif
diff --git a/pokemodr/PokeModrUI.cpp b/pokemodr/PokeModrUI.cpp
index debb95bf..1367beef 100644
--- a/pokemodr/PokeModrUI.cpp
+++ b/pokemodr/PokeModrUI.cpp
@@ -20,6 +20,7 @@
// PokeModr includes
#include "ObjectUI.h"
+#include "PokeModrPreferences.h"
#include "PokemodTreeModel.h"
// Pokemod includes
@@ -47,33 +48,34 @@
#include <KUrl>
#include <KIO/NetAccess>
-PokeModrUI::PokeModrUI(KConfigGroup config, QWidget* parent) :
+PokeModrUI::PokeModrUI(QWidget* parent) :
KMainWindow(parent),
- m_config(config)
+ m_config(KGlobal::config()->group("pokemodr"))
{
setupUi(this);
setupActions();
- splitter->setSizes(QList<int>() << config.readEntry("treeWidth", 100) << config.readEntry("panelWidth", 100));
+ splitter->setSizes(QList<int>() << m_config.readEntry("treeWidth", 100) << m_config.readEntry("panelWidth", 100));
connect(buttonApply, SIGNAL(clicked()), this, SLOT(update()));
KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
- if (args)
+ if (args && args->count())
{
for(int i = 0; i < args->count(); ++i)
openPokemod(args->url(i));
args->clear();
}
- if (config.readEntry("reloadOnStart", false))
+ else if (m_config.readEntry("reloadOnStart", false))
{
- for (int i = 0; i < config.readEntry("openedFiles", 0); ++i)
- openPokemod(m_recent->urls().at(i));
+ QStringList urls = m_config.readEntry("Opened Files", QStringList());
+ foreach (QString url, urls)
+ openPokemod(KUrl(url));
}
setAutoSaveSettings("MainWindow", true);
}
PokeModrUI::~PokeModrUI()
{
+ m_config.config()->sync();
closeAllPokemods(true);
- m_recent->saveEntries(m_config);
}
void PokeModrUI::update()
@@ -83,6 +85,7 @@ void PokeModrUI::update()
void PokeModrUI::closeEvent(QCloseEvent* event)
{
+ m_recent->saveEntries(m_config.group("Recent Files"));
if (closeAllPokemods())
event->accept();
else
@@ -107,37 +110,38 @@ void PokeModrUI::newPokemod()
void PokeModrUI::openPokemod()
{
- KUrl::List urls(KFileDialog::getOpenUrls(KUrl("kfiledialog:///pokemod"), QString::fromUtf8("*.pmod|PokéMod files"), this));
+ KUrl::List urls = KFileDialog::getOpenUrls(KUrl("kfiledialog:///pokemod"), QString::fromUtf8("*.pmod|PokéMod files"), this);
foreach (KUrl url, urls)
{
if (!url.isEmpty())
- {
- if (openPokemod(url))
- {
- m_recent->addUrl(url);
- m_recent->saveEntries(m_config);
- }
- }
+ openPokemod(url);
}
}
bool PokeModrUI::openPokemod(const KUrl& url)
{
+ bool opened = false;
+ if (treePokemod->isOpen(url))
+ {
+ KMessageBox::error(this, "File is already opened", QString::fromUtf8("PokéMod error"));
+ return false;
+ }
if (url.isLocalFile())
- return openPokemod(url.path());
+ opened = openPokemod(url.path());
else
{
QString temp;
if (KIO::NetAccess::download(url, temp, this))
{
- const bool opened = openPokemod(temp, true);
+ opened = openPokemod(temp, true);
KIO::NetAccess::removeTempFile(temp);
- return opened;
}
else
KMessageBox::error(this, KIO::NetAccess::lastErrorString(), "KIO Error");
}
- return false;
+ if (opened)
+ m_recent->addUrl(url);
+ return opened;
}
bool PokeModrUI::openPokemod(const QString& path, const bool isRemote)
@@ -271,6 +275,8 @@ bool PokeModrUI::closePokemod(const Pokemod* pokemod, const bool force)
bool PokeModrUI::closeAllPokemods(const bool force)
{
QList<const Pokemod*> pokemods = treePokemod->openedPokemods();
+ if (pokemods.size())
+ m_config.writeEntry("Opened Files", treePokemod->urls());
for (int i = 0; i < pokemods.size(); )
{
if (closePokemod(pokemods[i], force))
@@ -295,7 +301,9 @@ void PokeModrUI::pasteObject()
void PokeModrUI::preferences()
{
- // TODO: preferences
+ PokeModrPreferences* dialog = new PokeModrPreferences(this, m_config);
+ connect(dialog, SIGNAL(okClicked()), dialog, SLOT(save()));
+ dialog->exec();
}
void PokeModrUI::on_splitter_splitterMoved()
@@ -365,7 +373,7 @@ void PokeModrUI::setupActions()
KAction* openNew = KStandardAction::openNew(this, SLOT(newPokemod()), this);
KAction* open = KStandardAction::open(this, SLOT(openPokemod()), this);
m_recent = KStandardAction::openRecent(this, SLOT(openPokemod(const KUrl&)), this);
- m_recent->loadEntries(m_config);
+ m_recent->loadEntries(m_config.group("Recent Files"));
KAction* close = KStandardAction::close(this, SLOT(closePokemod()), this);
KAction* save = KStandardAction::save(this, SLOT(savePokemod()), this);
KAction* saveAs = KStandardAction::saveAs(this, SLOT(saveAsPokemod()), this);
diff --git a/pokemodr/PokeModrUI.h b/pokemodr/PokeModrUI.h
index 7e261141..04029af3 100644
--- a/pokemodr/PokeModrUI.h
+++ b/pokemodr/PokeModrUI.h
@@ -39,7 +39,7 @@ class PokeModrUI : public KMainWindow, private Ui::formPokeModr
Q_OBJECT
public:
- PokeModrUI(KConfigGroup config, QWidget* parent = 0);
+ PokeModrUI(QWidget* parent = 0);
~PokeModrUI();
protected slots:
void update();
diff --git a/pokemodr/PokemodTree.cpp b/pokemodr/PokemodTree.cpp
index 661b5c85..6593ce1b 100644
--- a/pokemodr/PokemodTree.cpp
+++ b/pokemodr/PokemodTree.cpp
@@ -89,13 +89,13 @@ QList<const Pokemod*> PokemodTree::openedPokemods() const
void PokemodTree::addPokemod(Pokemod* pokemod)
{
static_cast<PokemodTreeModel*>(model())->addPokemod(pokemod);
- m_pokemods[pokemod] = QPair<KUrl, bool>(KUrl(), false);
+ m_pokemods[pokemod] = UrlDirty(KUrl(), false);
}
void PokemodTree::addPokemod(Pokemod* pokemod, const KUrl& url)
{
static_cast<PokemodTreeModel*>(model())->addPokemod(pokemod);
- m_pokemods[pokemod] = QPair<KUrl, bool>(url, false);
+ m_pokemods[pokemod] = UrlDirty(url, false);
}
void PokemodTree::deletePokemod(const Pokemod* pokemod)
@@ -107,6 +107,16 @@ void PokemodTree::deletePokemod(const Pokemod* pokemod)
}
}
+bool PokemodTree::isOpen(const KUrl& url) const
+{
+ foreach (UrlDirty pair, m_pokemods.values())
+ {
+ if (url == pair.first)
+ return true;
+ }
+ return false;
+}
+
KUrl PokemodTree::url(const Pokemod* pokemod) const
{
if (m_pokemods.contains(pokemod))
@@ -114,10 +124,18 @@ KUrl PokemodTree::url(const Pokemod* pokemod) const
return KUrl();
}
+QStringList PokemodTree::urls() const
+{
+ QStringList urls;
+ foreach (UrlDirty pair, m_pokemods.values())
+ urls << pair.first.prettyUrl();
+ return urls;
+}
+
void PokemodTree::setUrl(const Pokemod* pokemod, const KUrl& url)
{
if (m_pokemods.contains(pokemod))
- m_pokemods[pokemod] = QPair<KUrl, bool>(url, false);
+ m_pokemods[pokemod] = UrlDirty(url, false);
}
bool PokemodTree::dirty(const Pokemod* pokemod) const
diff --git a/pokemodr/PokemodTree.h b/pokemodr/PokemodTree.h
index cfdd151a..80bc0a6e 100644
--- a/pokemodr/PokemodTree.h
+++ b/pokemodr/PokemodTree.h
@@ -53,7 +53,10 @@ class PokemodTree : public QTreeView
void deletePokemod(const Pokemod* pokemod);
void deleteAllPokemods();
+ bool isOpen(const KUrl& url) const;
+
KUrl url(const Pokemod* pokemod) const;
+ QStringList urls() const;
void setUrl(const Pokemod* pokemod, const KUrl& url);
bool dirty(const Pokemod* pokemod) const;
@@ -61,7 +64,9 @@ class PokemodTree : public QTreeView
private slots:
void setDirty();
private:
- QMap<const Pokemod*, QPair<KUrl, bool> > m_pokemods;
+ typedef QPair<KUrl, bool> UrlDirty;
+
+ QMap<const Pokemod*, UrlDirty> m_pokemods;
};
#endif
diff --git a/pokemodr/pokemodr.pro b/pokemodr/pokemodr.pro
index efce6949..0f5baf2c 100644
--- a/pokemodr/pokemodr.pro
+++ b/pokemodr/pokemodr.pro
@@ -59,6 +59,7 @@ SOURCES += AbilityUI.cpp \
PokemodTreeModel.cpp \
PokemodUI.cpp \
PokeModr.cpp \
+ PokeModrPreferences.cpp \
PokeModrUI.cpp \
RulesUI.cpp \
ScriptWidget.cpp \
@@ -169,6 +170,7 @@ HEADERS += AbilityUI.h \
PokemodTreeModel.h \
PokemodUI.h \
PokeModr.h \
+ PokeModrPreferences.h \
PokeModrUI.h \
RulesUI.h \
ScriptWidget.h \