summaryrefslogtreecommitdiffstats
path: root/pokemodr/PokeModrUI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokemodr/PokeModrUI.cpp')
-rw-r--r--pokemodr/PokeModrUI.cpp158
1 files changed, 77 insertions, 81 deletions
diff --git a/pokemodr/PokeModrUI.cpp b/pokemodr/PokeModrUI.cpp
index ad9dd884..6a9ea1b1 100644
--- a/pokemodr/PokeModrUI.cpp
+++ b/pokemodr/PokeModrUI.cpp
@@ -54,14 +54,14 @@ PokeModrUI::PokeModrUI(KConfigGroup config, KConfigGroup history, QWidget* paren
m_recent->loadEntries(history);
KMenuBar* menubar = new KMenuBar(this);
KMenu* menuFile = new KMenu("&File", menubar);
- menuFile->addAction(KStandardAction::openNew(this, SLOT(on_actionNew_triggered()), menuFile));
- menuFile->addAction(KStandardAction::open(this, SLOT(on_actionOpen_triggered()), menuFile));
- menuFile->addAction(KStandardAction::openRecent(this, SLOT(openPokeMod(const KUrl&)), menuFile));
+ 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));
menuFile->addSeparator();
- menuFile->addAction(KStandardAction::save(this, SLOT(on_actionSave_triggered()), menuFile));
- menuFile->addAction(KStandardAction::saveAs(this, SLOT(on_actionSaveAs_triggered()), menuFile));
+ menuFile->addAction(KStandardAction::save(this, SLOT(savePokemod()), menuFile));
+ menuFile->addAction(KStandardAction::saveAs(this, SLOT(saveAsPokemod()), menuFile));
menuFile->addSeparator();
- menuFile->addAction(KStandardAction::quit(this, SLOT(on_actionQuit_triggered()), menuFile));
+ menuFile->addAction(KStandardAction::quit(this, SLOT(quit()), menuFile));
menubar->addMenu(menuFile);
KMenu* menuEdit = new KMenu("&Edit", menubar);
menuEdit->addAction(KStandardAction::cut(menuEdit));
@@ -71,27 +71,27 @@ PokeModrUI::PokeModrUI(KConfigGroup config, KConfigGroup history, QWidget* paren
KAction* menuCut = new KAction(KIcon("edit-cut"), "Cu&t Object", menuEdit);
menuCut->setShortcut(KShortcut("Alt+X"));
menuEdit->addAction(menuCut);
- connect(menuCut, SIGNAL(triggered()), this, SLOT(on_actionCut_triggered()));
+ connect(menuCut, SIGNAL(triggered()), this, SLOT(cutObject()));
KAction* menuCopy = new KAction(KIcon("edit-copy"), "Cop&y Object", menuEdit);
menuCopy->setShortcut(KShortcut("Alt+C"));
menuEdit->addAction(menuCopy);
- connect(menuCopy, SIGNAL(triggered()), this, SLOT(on_actionCopy_triggered()));
+ connect(menuCopy, SIGNAL(triggered()), this, SLOT(copyObject()));
KAction* menuPaste = new KAction(KIcon("edit-paste"), "Past&e Object", menuEdit);
menuPaste->setShortcut(KShortcut("Alt+V"));
menuEdit->addAction(menuPaste);
- connect(menuPaste, SIGNAL(triggered()), this, SLOT(on_actionPaste_triggered()));
+ connect(menuPaste, SIGNAL(triggered()), this, SLOT(pasteObject()));
menuEdit->addSeparator();
- menuEdit->addAction(KStandardAction::preferences(this, SLOT(on_actionPreferences_triggered()), menuEdit));
+ menuEdit->addAction(KStandardAction::preferences(this, SLOT(preferences()), menuEdit));
menubar->addMenu(menuEdit);
menubar->addMenu(customHelpMenu(false));
setMenuBar(menubar);
KToolBar* toolbar = new KToolBar("toolbar", this, Qt::TopToolBarArea, false, true, true);
- toolbar->addAction(KStandardAction::openNew(this, SLOT(on_actionNew_triggered()), toolbar));
- toolbar->addAction(KStandardAction::open(this, SLOT(on_actionOpen_triggered()), toolbar));
- toolbar->addAction(KStandardAction::openRecent(this, SLOT(openPokeMod(const KUrl&)), toolbar));
+ 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->addSeparator();
- toolbar->addAction(KStandardAction::save(this, SLOT(on_actionSave_triggered()), toolbar));
- toolbar->addAction(KStandardAction::saveAs(this, SLOT(on_actionSaveAs_triggered()), toolbar));
+ toolbar->addAction(KStandardAction::save(this, SLOT(savePokemod()), toolbar));
+ toolbar->addAction(KStandardAction::saveAs(this, SLOT(saveAsPokemod()), toolbar));
toolbar->addSeparator();
toolbar->addAction(KStandardAction::cut(toolbar));
toolbar->addAction(KStandardAction::copy(toolbar));
@@ -99,17 +99,17 @@ PokeModrUI::PokeModrUI(KConfigGroup config, KConfigGroup history, QWidget* paren
toolbar->addSeparator();
KAction* toolbarCut = new KAction(KIcon("edit-cut"), "Cu&t Object", toolbar);
toolbar->addAction(toolbarCut);
- connect(toolbarCut, SIGNAL(triggered()), this, SLOT(on_actionCut_triggered()));
+ connect(toolbarCut, SIGNAL(triggered()), this, SLOT(cutObject()));
KAction* toolbarCopy = new KAction(KIcon("edit-copy"), "Cop&y Object", toolbar);
toolbar->addAction(toolbarCopy);
- connect(toolbarCopy, SIGNAL(triggered()), this, SLOT(on_actionCopy_triggered()));
+ connect(toolbarCopy, SIGNAL(triggered()), this, SLOT(copyObject()));
KAction* toolbarPaste = new KAction(KIcon("edit-paste"), "Past&e Object", toolbar);
toolbar->addAction(toolbarPaste);
- connect(toolbarPaste, SIGNAL(triggered()), this, SLOT(on_actionPaste_triggered()));
+ connect(toolbarPaste, SIGNAL(triggered()), this, SLOT(pasteObject()));
toolbar->addSeparator();
- toolbar->addAction(KStandardAction::preferences(this, SLOT(on_actionPreferences_triggered()), toolbar));
+ toolbar->addAction(KStandardAction::preferences(this, SLOT(preferences()), toolbar));
toolbar->addSeparator();
- toolbar->addAction(KStandardAction::quit(this, SLOT(on_actionQuit_triggered()), toolbar));
+ toolbar->addAction(KStandardAction::quit(this, SLOT(quit()), toolbar));
addToolBar(toolbar);
splitter->setSizes(QList<int>() << config.readEntry("treeWidth", 100) << config.readEntry("panelWidth", 100));
// if (config.readEntry("reloadOnStart", false))
@@ -127,7 +127,37 @@ PokeModrUI::~PokeModrUI()
// on_actionQuit_triggered();
}
-void PokeModrUI::openPokeMod(const KUrl& path)
+void PokeModrUI::closeEvent(QCloseEvent* event)
+{
+ quit();
+ event->accept();
+}
+
+void PokeModrUI::setChangedTitle(const bool changed)
+{
+ // TODO: set the title
+// if (formPanel->widget())
+// setWindowTitle(QString::fromUtf8("%1%2 - PokéModr").arg(static_cast<ObjectUI*>(formPanel->widget())->original()->pokemod()->title()).arg(c ? "*" : ""));
+// else
+// setWindowTitle(QString::fromUtf8("PokéModr"));
+}
+
+void PokeModrUI::newPokemod()
+{
+ // TODO: add a blank pokemod to the tree
+}
+
+void PokeModrUI::openPokemod()
+{
+ QFile file(KFileDialog::getOpenFileName(KUrl("kfiledialog:///pokemod"), QString::fromUtf8("*.pmod|PokéMods"), this));
+ if (file.open(QIODevice::ReadOnly))
+ {
+ // TODO: open the file into the tree
+ file.close();
+ }
+}
+
+void PokeModrUI::openPokemod(const KUrl& path)
{
if (path.isLocalFile())
{
@@ -137,11 +167,26 @@ void PokeModrUI::openPokeMod(const KUrl& path)
}
}
-void PokeModrUI::savePokeMod()
+void PokeModrUI::savePokemod()
{
- // TODO: save pokemod
-// if (formPanel->widget())
-// static_cast<ObjectUI*>(formPanel->widget())->original()->pokemod()->save();
+ // TODO: Save the current pokemod with the object open
+// if (!treePokemod->currentItem())
+// return;
+// static_cast<PokeModTreeItem*>(treePokemod->currentItem())->save();
+// static_cast<Pokemod*>(static_cast<PokeModTreeItem*>(treePokemod->currentItem())->object())->pokemod()->save();
+}
+
+void PokeModrUI::saveAsPokemod()
+{
+ // TODO: Save the current pokemod to a new file
+// if (!treePokemod->currentItem())
+// return;
+// QString dir = KFileDialog::existingDirectory(KUrl(KStandardDirs::locateLocal("data", "pokegen/pokemods", true)), this, QString::fromUtf8("Open PokéMod"));
+// if (dir != "")
+// {
+// static_cast<PokeModTreeItem*>(treePokemod->currentItem())->save();
+// static_cast<PokeModTreeItem*>(treePokemod->currentItem())->pokemod()->setPath(dir);
+// }
}
void PokeModrUI::closePokeMod()
@@ -174,59 +219,9 @@ void PokeModrUI::closePokeMod()
// }
}
-void PokeModrUI::closeEvent(QCloseEvent* event)
-{
- on_actionQuit_triggered();
- event->accept();
-}
-
-void PokeModrUI::setChangedTitle(const bool c)
-{
- // TODO: set the title
-// if (formPanel->widget())
-// setWindowTitle(QString::fromUtf8("%1%2 - PokéModr").arg(static_cast<ObjectUI*>(formPanel->widget())->original()->pokemod()->title()).arg(c ? "*" : ""));
-// else
-// setWindowTitle(QString::fromUtf8("PokéModr"));
-}
-
-void PokeModrUI::on_actionNew_triggered()
-{
-// QString dir = KFileDialog::existingDirectory(KUrl(KStandardDirs::locateLocal("data", "pokegen/pokemods", true)), this, QString::fromUtf8("New PokéMod"));
-// if (dir != "")
-// openPokeMod(KUrl(dir));
-}
-
-void PokeModrUI::on_actionOpen_triggered()
-{
-// QString dir = KFileDialog::existingDirectory(KUrl(KStandardDirs::locateLocal("data", "pokegen/pokemods", true)), this, QString::fromUtf8("Open PokéMod"));
-// if (dir != "")
-// openPokeMod(KUrl(dir));
-}
-
-void PokeModrUI::on_actionSave_triggered()
-{
- // TODO: Save the current pokemod with the object open
-// if (!treePokemod->currentItem())
-// return;
-// static_cast<PokeModTreeItem*>(treePokemod->currentItem())->save();
-// static_cast<Pokemod*>(static_cast<PokeModTreeItem*>(treePokemod->currentItem())->object())->pokemod()->save();
-}
-
-void PokeModrUI::on_actionSaveAs_triggered()
-{
- // TODO: Save the current pokemod to a new file
-// if (!treePokemod->currentItem())
-// return;
-// QString dir = KFileDialog::existingDirectory(KUrl(KStandardDirs::locateLocal("data", "pokegen/pokemods", true)), this, QString::fromUtf8("Open PokéMod"));
-// if (dir != "")
-// {
-// static_cast<PokeModTreeItem*>(treePokemod->currentItem())->save();
-// static_cast<PokeModTreeItem*>(treePokemod->currentItem())->pokemod()->setPath(dir);
-// }
-}
-
-void PokeModrUI::on_actionQuit_triggered()
+void PokeModrUI::quit()
{
+ // TODO: clean up the tree
// while (m_pokemods.size())
// closePokeMod();
// if (m_clipboard)
@@ -234,7 +229,7 @@ void PokeModrUI::on_actionQuit_triggered()
close();
}
-void PokeModrUI::on_actionCut_triggered()
+void PokeModrUI::cutObject()
{
// TODO: cut the item
// if (!treePokemod->currentItem())
@@ -244,7 +239,7 @@ void PokeModrUI::on_actionCut_triggered()
// m_clipboard = static_cast<PokeModTreeItem*>(treePokemod->currentItem())->cut();
}
-void PokeModrUI::on_actionCopy_triggered()
+void PokeModrUI::copyObject()
{
// TODO: copy the item
// if (!treePokemod->currentItem())
@@ -254,7 +249,7 @@ void PokeModrUI::on_actionCopy_triggered()
// m_clipboard = static_cast<PokeModTreeItem*>(treePokemod->currentItem())->copy();
}
-void PokeModrUI::on_actionPaste_triggered()
+void PokeModrUI::pasteObject()
{
// TODO: paste the item
// if (!m_clipboard || !treePokemod->currentItem())
@@ -262,8 +257,9 @@ void PokeModrUI::on_actionPaste_triggered()
// static_cast<PokeModTreeItem*>(treePokemod->currentItem())->paste(m_clipboard);
}
-void PokeModrUI::on_actionPreferences_triggered()
+void PokeModrUI::preferences()
{
+ // TODO: preferences
}
void PokeModrUI::on_splitter_splitterMoved()