diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-05-13 07:07:57 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-05-13 07:07:57 +0000 |
| commit | 56f272b11d13bbc5d829283ccf2813d3a7e41dbc (patch) | |
| tree | dbd826fc0df0e9b087f5c0d1889e3f9eaca5181f | |
| parent | 654b25d1b4e73e840e5fe2ab63d844c2157f3379 (diff) | |
| download | sigen-56f272b11d13bbc5d829283ccf2813d3a7e41dbc.tar.gz sigen-56f272b11d13bbc5d829283ccf2813d3a7e41dbc.tar.xz sigen-56f272b11d13bbc5d829283ccf2813d3a7e41dbc.zip | |
[ADD] Sound UI code
[FIX] Using class-named includes for KDE as well now
[FIX] Signals fixed for UI classes
[FIX] FileDialog now created on heap rather than the stack
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@128 6ecfd1a5-f3ed-3746-8530-beee90d26b22
44 files changed, 493 insertions, 148 deletions
@@ -1,4 +1,14 @@ ----------------- +Rev: 128 +Date: 13 May 2008 +User: MathStuf +----------------- +[ADD] Sound UI code +[FIX] Using class-named includes for KDE as well now +[FIX] Signals fixed for UI classes +[FIX] FileDialog now created on heap rather than the stack + +----------------- Rev: 127 Date: 12 May 2008 User: MathStuf diff --git a/general/Audio.h b/general/Audio.h index 32bf5c26..115d2590 100644 --- a/general/Audio.h +++ b/general/Audio.h @@ -24,8 +24,8 @@ #include <QObject> // KDE includes -#include <phonon/audiooutput.h> -#include <phonon/mediaobject.h> +#include <Phonon/AudioOutput> +#include <Phonon/MediaObject> class Audio : public QObject { diff --git a/general/general.pro b/general/general.pro index 4dd1df7f..7fd0d9e7 100644 --- a/general/general.pro +++ b/general/general.pro @@ -23,7 +23,7 @@ win32 { } KDEINCDIR = $$KDEPREFIX/include # $$KDEINCDIR/mingw contains the kdewin32 headers, defining stuff like mkdtemp. - INCLUDEPATH += $$KDEINCDIR/mingw $$KDEINCDIR + INCLUDEPATH += $$KDEINCDIR/mingw $$KDEINCDIR $$KDEINCDIR/KDE LIBS += -lkdewin32 QMAKE_LIBDIR = $$KDEPREFIX/lib $$QMAKE_LIBDIR }else { @@ -36,7 +36,7 @@ win32 { } else { KDEINCDIR = $$KDEPREFIX/include } - INCLUDEPATH += $$KDEINCDIR + INCLUDEPATH += $$KDEINCDIR $$KDEINCDIR/KDE KDELIBDIR = $$KDEPREFIX/lib$$system(kde4-config --libsuffix) KDEDEVELLIBDIR = $$KDELIBDIR exists($$KDEDEVELLIBDIR/kde4/devel){ diff --git a/pokemod/Object.h b/pokemod/Object.h index 34a07b5f..d7f0a935 100644 --- a/pokemod/Object.h +++ b/pokemod/Object.h @@ -152,10 +152,11 @@ class Object : public QObject xml_##variable.setAttribute("y", point_##variable.y()) #define SAVE_QPixmap(variable, value) \ QByteArray bytes_##variable; \ - QBuffer buffer_##variable(&bytes_##variable); \ - buffer_##variable.open(QIODevice::WriteOnly); \ - value.save(&buffer_##variable, "PNG"); \ - SAVE_VALUE(xml_##variable, bytes_##variable.toBase64()) + QBuffer* buffer_##variable = new QBuffer(&bytes_##variable); \ + buffer_##variable->open(QIODevice::WriteOnly); \ + value.save(buffer_##variable, "PNG"); \ + SAVE_VALUE(xml_##variable, bytes_##variable.toBase64()); \ + delete buffer_##variable #define SAVE_QByteArray(variable, value) SAVE_VALUE(xml_##variable, value.toBase64()) #define SAVE_ARRAY(type, variable, size) \ QDomElement xml_array_##variable = QDomDocument().createElement(#variable); \ diff --git a/pokemodr/BadgeUI.cpp b/pokemodr/BadgeUI.cpp index 60b47654..19a76039 100644 --- a/pokemodr/BadgeUI.cpp +++ b/pokemodr/BadgeUI.cpp @@ -33,8 +33,8 @@ BadgeUI::BadgeUI(Badge* badge, QWidget* parent) : setObjects(badge, new Badge(*badge)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } @@ -93,22 +93,24 @@ void BadgeUI::on_varObey_valueChanged(const int obey) void BadgeUI::on_varFace_pressed() { - FileDialog dialog(QSize(64, 64)); - if (dialog.exec()) + FileDialog* dialog = new FileDialog(QSize(64, 64)); + if (dialog->exec() == QDialog::Accepted) { - static_cast<Badge*>(modified())->setFace(QPixmap(dialog.selectedFile())); + static_cast<Badge*>(modified())->setFace(QPixmap(dialog->selectedFile())); setGui(); } + delete dialog; } void BadgeUI::on_varBadge_pressed() { - FileDialog dialog(QSize(64, 64)); - if (dialog.exec()) + FileDialog* dialog = new FileDialog(QSize(64, 64)); + if (dialog->exec() == QDialog::Accepted) { - static_cast<Badge*>(modified())->setBadge(QPixmap(dialog.selectedFile())); + static_cast<Badge*>(modified())->setBadge(QPixmap(dialog->selectedFile())); setGui(); } + delete dialog; } void BadgeUI::on_varStatMultiplier_valueChanged(const Fraction& multiplier) diff --git a/pokemodr/CoinListObjectUI.cpp b/pokemodr/CoinListObjectUI.cpp index 283a55c9..a214b258 100644 --- a/pokemodr/CoinListObjectUI.cpp +++ b/pokemodr/CoinListObjectUI.cpp @@ -34,8 +34,8 @@ CoinListObjectUI::CoinListObjectUI(CoinListObject* object, QWidget* parent) : setObjects(object, new CoinListObject(*object)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/CoinListUI.cpp b/pokemodr/CoinListUI.cpp index 17e49b89..8e7737a9 100644 --- a/pokemodr/CoinListUI.cpp +++ b/pokemodr/CoinListUI.cpp @@ -32,8 +32,8 @@ CoinListUI::CoinListUI(CoinList* coinList, QWidget* parent) : setObjects(coinList, new CoinList(*coinList)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/EggGroupUI.cpp b/pokemodr/EggGroupUI.cpp index 2a948935..1ae27e05 100644 --- a/pokemodr/EggGroupUI.cpp +++ b/pokemodr/EggGroupUI.cpp @@ -29,8 +29,8 @@ EggGroupUI::EggGroupUI(EggGroup* eggGroup, QWidget* parent) : setObjects(eggGroup, new EggGroup(*eggGroup)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/FileDialog.cpp b/pokemodr/FileDialog.cpp index 2de38c4a..6b7bb103 100644 --- a/pokemodr/FileDialog.cpp +++ b/pokemodr/FileDialog.cpp @@ -24,9 +24,9 @@ #include <QStringList> // KDE includes -#include <kdiroperator.h> -#include <kfilewidget.h> -#include <kimagefilepreview.h> +#include <KDirOperator> +#include <KFileDialog> +#include <KImageFilePreview> FileDialog::FileDialog(const QSize& size) : KFileDialog(KUrl("kfiledialog:///image"), "", NULL) diff --git a/pokemodr/FileDialog.h b/pokemodr/FileDialog.h index c52d0592..6789f81e 100644 --- a/pokemodr/FileDialog.h +++ b/pokemodr/FileDialog.h @@ -22,8 +22,8 @@ #include <QSize> // KDE includes -#include <kfiledialog.h> -#include <kfileitem.h> +#include <KFileDialog> +#include <KFileItem> class FileDialog : public KFileDialog { diff --git a/pokemodr/ItemTypeUI.cpp b/pokemodr/ItemTypeUI.cpp index a49c8835..03bf7584 100644 --- a/pokemodr/ItemTypeUI.cpp +++ b/pokemodr/ItemTypeUI.cpp @@ -29,8 +29,8 @@ ItemTypeUI::ItemTypeUI(ItemType* itemType, QWidget* parent) : setObjects(itemType, new ItemType(*itemType)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/ItemUI.cpp b/pokemodr/ItemUI.cpp index 9a8d2fdd..da6de440 100644 --- a/pokemodr/ItemUI.cpp +++ b/pokemodr/ItemUI.cpp @@ -31,8 +31,8 @@ ItemUI::ItemUI(Item* item, QWidget* parent) : setObjects(item, new Item(*item)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/MapTrainerTeamMemberUI.cpp b/pokemodr/MapTrainerTeamMemberUI.cpp index c3cef705..90096dd5 100644 --- a/pokemodr/MapTrainerTeamMemberUI.cpp +++ b/pokemodr/MapTrainerTeamMemberUI.cpp @@ -33,8 +33,8 @@ MapTrainerTeamMemberUI::MapTrainerTeamMemberUI(MapTrainerTeamMember* teamMember, setObjects(teamMember, new MapTrainerTeamMember(*teamMember)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/MapUI.cpp b/pokemodr/MapUI.cpp index 77ab875e..e954085a 100644 --- a/pokemodr/MapUI.cpp +++ b/pokemodr/MapUI.cpp @@ -31,7 +31,7 @@ #include <QHeaderView> // KDE includes -#include <kicon.h> +#include <KIcon> MapUI::MapUI(Map* map, QWidget* parent) : ObjectUI(parent), @@ -43,8 +43,8 @@ MapUI::MapUI(Map* map, QWidget* parent) : m_model = new TilemapModel(this, static_cast<Map*>(modified())->map(), static_cast<const Pokemod*>(static_cast<Map*>(original())->pokemod())); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/MapWarpUI.cpp b/pokemodr/MapWarpUI.cpp index c56393bb..d7388bfd 100644 --- a/pokemodr/MapWarpUI.cpp +++ b/pokemodr/MapWarpUI.cpp @@ -33,8 +33,8 @@ MapWarpUI::MapWarpUI(MapWarp* warp, QWidget* parent) : setObjects(warp, new MapWarp(*warp)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/MapWildListEncounterUI.cpp b/pokemodr/MapWildListEncounterUI.cpp index 70d74b7a..89eec7b5 100644 --- a/pokemodr/MapWildListEncounterUI.cpp +++ b/pokemodr/MapWildListEncounterUI.cpp @@ -31,8 +31,8 @@ MapWildListEncounterUI::MapWildListEncounterUI(MapWildListEncounter* encounter, setObjects(encounter, new MapWildListEncounter(*encounter)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/MapWildListUI.cpp b/pokemodr/MapWildListUI.cpp index fd9e2453..721e97d7 100644 --- a/pokemodr/MapWildListUI.cpp +++ b/pokemodr/MapWildListUI.cpp @@ -33,8 +33,8 @@ MapWildListUI::MapWildListUI(MapWildList* wildList, QWidget* parent) : setObjects(wildList, new MapWildList(*wildList)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/MoveUI.cpp b/pokemodr/MoveUI.cpp index 78182684..71b7007b 100644 --- a/pokemodr/MoveUI.cpp +++ b/pokemodr/MoveUI.cpp @@ -31,8 +31,8 @@ MoveUI::MoveUI(Move* move, QWidget* parent) : setObjects(move, new Move(*move)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/NatureUI.cpp b/pokemodr/NatureUI.cpp index 4915dc79..98af9ede 100644 --- a/pokemodr/NatureUI.cpp +++ b/pokemodr/NatureUI.cpp @@ -30,8 +30,8 @@ NatureUI::NatureUI(Nature* nature, QWidget* parent) : setObjects(nature, new Nature(*nature)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/ObjectUI.h b/pokemodr/ObjectUI.h index a85a5448..cbe03bb9 100644 --- a/pokemodr/ObjectUI.h +++ b/pokemodr/ObjectUI.h @@ -27,7 +27,7 @@ #include <QWidget> // KDE includes -#include <kmessagebox.h> +#include <KMessageBox> #define DBL_PREC 7 diff --git a/pokemodr/PokeModr.cpp b/pokemodr/PokeModr.cpp index 35df3157..5d17be27 100644 --- a/pokemodr/PokeModr.cpp +++ b/pokemodr/PokeModr.cpp @@ -26,11 +26,11 @@ #include <QTextCodec> // KDE includes -#include <kaboutdata.h> -#include <kapplication.h> -#include <kcmdlineargs.h> -#include <kconfig.h> -#include <kconfiggroup.h> +#include <KAboutData> +#include <KApplication> +#include <KCmdLineArgs> +#include <KConfig> +#include <KConfigGroup> int main(int argc, char* argv[]) { @@ -49,6 +49,6 @@ int main(int argc, char* argv[]) PokeModrUI* mainWindow = new PokeModrUI(cfg.group("pokemodr"), cfg.group("pokemodr-recent")); mainWindow->show(); - app->exec(); + app->exec() == QDialog::Accepted; return 0; } diff --git a/pokemodr/PokeModrUI.cpp b/pokemodr/PokeModrUI.cpp index 72d145b9..ad9dd884 100644 --- a/pokemodr/PokeModrUI.cpp +++ b/pokemodr/PokeModrUI.cpp @@ -30,17 +30,18 @@ #include <QString> // KDE includes -#include <kaction.h> -#include <kfiledialog.h> -#include <kicon.h> -#include <klocalizedstring.h> -#include <kmenu.h> -#include <kmenubar.h> -#include <kmessagebox.h> -#include <kstandardaction.h> -#include <kstandarddirs.h> -#include <ktoolbar.h> -#include <kurl.h> +#include <KAction> +#include <KFileDialog> +#include <KIcon> +#include <KLocalizedString> +#include <KMenu> +#include <KMenuBar> +#include <KMessageBox> +#include <KRecentFilesAction> +#include <KStandardAction> +#include <KStandardDirs> +#include <KToolBar> +#include <KUrl> PokeModrUI::PokeModrUI(KConfigGroup config, KConfigGroup history, QWidget* parent) : KMainWindow(parent), diff --git a/pokemodr/PokeModrUI.h b/pokemodr/PokeModrUI.h index 1b61cf9f..fb559a3f 100644 --- a/pokemodr/PokeModrUI.h +++ b/pokemodr/PokeModrUI.h @@ -19,15 +19,15 @@ #define __POKEMODR_POKEMODRUI__ // KDE includes -#include <kconfiggroup.h> -#include <kmainwindow.h> -#include <krecentfilesaction.h> -#include <kurl.h> +#include <KConfigGroup> +#include <KMainWindow> // Form include #include "ui_pokemodr.h" // Forward declarations +class KRecentFilesAction; +class KUrl; class Object; class Pokemod; diff --git a/pokemodr/PokemodUI.cpp b/pokemodr/PokemodUI.cpp index 76059e5b..c693b57f 100644 --- a/pokemodr/PokemodUI.cpp +++ b/pokemodr/PokemodUI.cpp @@ -37,8 +37,8 @@ PokemodUI::PokemodUI(Pokemod* pokemod, QWidget* parent) : setObjects(pokemod, new Pokemod(*pokemod)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } @@ -158,62 +158,68 @@ void PokemodUI::on_varSuperPCPassword_textChanged(const QString& password) void PokemodUI::on_varWalkSkin_pressed() { - FileDialog dialog(QSize(192, 168)); - if (dialog.exec()) + FileDialog* dialog = new FileDialog(QSize(192, 168)); + if (dialog->exec() == QDialog::Accepted) { - static_cast<Pokemod*>(original())->setWalkSkin(QPixmap(dialog.selectedFile())); + static_cast<Pokemod*>(original())->setWalkSkin(QPixmap(dialog->selectedFile())); setGui(); } + delete dialog; } void PokemodUI::on_varBikeSkin_pressed() { - FileDialog dialog(QSize(192, 168)); - if (dialog.exec()) + FileDialog* dialog = new FileDialog(QSize(192, 168)); + if (dialog->exec() == QDialog::Accepted) { - static_cast<Pokemod*>(original())->setBikeSkin(QPixmap(dialog.selectedFile())); + static_cast<Pokemod*>(original())->setBikeSkin(QPixmap(dialog->selectedFile())); setGui(); } + delete dialog; } void PokemodUI::on_varFlySkin_pressed() { - FileDialog dialog(QSize(192, 168)); - if (dialog.exec()) + FileDialog* dialog = new FileDialog(QSize(192, 168)); + if (dialog->exec() == QDialog::Accepted) { - static_cast<Pokemod*>(original())->setFlySkin(QPixmap(dialog.selectedFile())); + static_cast<Pokemod*>(original())->setFlySkin(QPixmap(dialog->selectedFile())); setGui(); } + delete dialog; } void PokemodUI::on_varSurfSkin_pressed() { - FileDialog dialog(QSize(192, 168)); - if (dialog.exec()) + FileDialog* dialog = new FileDialog(QSize(192, 168)); + if (dialog->exec() == QDialog::Accepted) { - static_cast<Pokemod*>(original())->setSurfSkin(QPixmap(dialog.selectedFile())); + static_cast<Pokemod*>(original())->setSurfSkin(QPixmap(dialog->selectedFile())); setGui(); } + delete dialog; } void PokemodUI::on_varFishSkin_pressed() { - FileDialog dialog(QSize(192, 168)); - if (dialog.exec()) + FileDialog* dialog = new FileDialog(QSize(192, 168)); + if (dialog->exec() == QDialog::Accepted) { - static_cast<Pokemod*>(original())->setFishSkin(QPixmap(dialog.selectedFile())); + static_cast<Pokemod*>(original())->setFishSkin(QPixmap(dialog->selectedFile())); setGui(); } + delete dialog; } void PokemodUI::on_varSurfFishSkin_pressed() { - FileDialog dialog(QSize(192, 168)); - if (dialog.exec()) + FileDialog* dialog = new FileDialog(QSize(192, 168)); + if (dialog->exec() == QDialog::Accepted) { - static_cast<Pokemod*>(original())->setSurfFishSkin(QPixmap(dialog.selectedFile())); + static_cast<Pokemod*>(original())->setSurfFishSkin(QPixmap(dialog->selectedFile())); setGui(); } + delete dialog; } void PokemodUI::on_varTypechart_currentItemChanged(QTableWidgetItem* current, QTableWidgetItem* previous) diff --git a/pokemodr/RulesUI.cpp b/pokemodr/RulesUI.cpp index 7c3a0080..be68010c 100644 --- a/pokemodr/RulesUI.cpp +++ b/pokemodr/RulesUI.cpp @@ -29,8 +29,8 @@ RulesUI::RulesUI(Rules* rules, QWidget* parent) : setObjects(rules, new Rules(*rules)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/SoundUI.cpp b/pokemodr/SoundUI.cpp new file mode 100644 index 00000000..f6142884 --- /dev/null +++ b/pokemodr/SoundUI.cpp @@ -0,0 +1,132 @@ +/* + * 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 "SoundUI.h" + +// Pokemod includes +#include "../pokemod/Sound.h" +#include "../pokemod/Pokemod.h" + +// Qt includes +// #include <Phonon> +#include <QBuffer> +#include <QFile> + +// KDE includes +#include <KFileDialog> +#include <Phonon/MediaObject> + +SoundUI::SoundUI(Sound* sound, QWidget* parent) : + ObjectUI(parent), + m_media(new Phonon::MediaObject) +{ + setupUi(this); + QMetaObject::connectSlotsByName(this); + setObjects(sound, new Sound(*sound)); + connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); + connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); + init(); +} + +SoundUI::~SoundUI() +{ + delete m_media; +} + +void SoundUI::initGui() +{ + seeker->setMediaObject(m_media); + connect(m_media, SIGNAL(finished()), buttonStop, SLOT(clicked())); + buttonPlayPause->setIcon(KIcon("media-playback-play")); + buttonStop->setIcon(KIcon("media-playback-stop")); + buttonBrowse->setIcon(KIcon("document-open")); +} + +void SoundUI::refreshGui() +{ + on_buttonStop_clicked(); + QBuffer* buffer = new QBuffer; + buffer->setData(static_cast<Sound*>(modified())->data()); + m_media->setCurrentSource(Phonon::MediaSource(buffer)); + delete buffer; +} + +void SoundUI::setGui() +{ + varName->setText(static_cast<Sound*>(modified())->name()); +} + +void SoundUI::on_buttonApply_clicked() +{ + *static_cast<Sound*>(original()) = *static_cast<Sound*>(modified()); + emit(changed(false)); +} + +void SoundUI::on_buttonDiscard_clicked() +{ + *static_cast<Sound*>(modified()) = *static_cast<Sound*>(original()); + setGui(); + emit(changed(false)); +} + +void SoundUI::on_varName_textChanged(const QString& name) +{ + static_cast<Sound*>(modified())->setName(name); +} + +void SoundUI::on_buttonPlayPause_clicked() +{ + if (m_media->state() == Phonon::PlayingState) + { + buttonPlayPause->setIcon(KIcon("media-playback-play")); + buttonPlayPause->setEnabled(true); + m_media->pause(); + } + else if (m_media->state() == Phonon::PausedState) + { + buttonPlayPause->setIcon(KIcon("media-playback-pause")); + buttonPlayPause->setEnabled(true); + m_media->play(); + } + else if (m_media->state() == Phonon::ErrorState) + { + buttonPlayPause->setIcon(KIcon("media-playback-play")); + buttonPlayPause->setEnabled(false); + m_media->stop(); + } +} + +void SoundUI::on_buttonStop_clicked() +{ + buttonPlayPause->setIcon(KIcon("media-playback-play")); + m_media->stop(); +} + +void SoundUI::on_buttonBrowse_clicked() +{ + QFile file(KFileDialog::getOpenFileName(KUrl("kfiledialog:///audio"), "*.ogg|OGG files", this)); + if (file.open(QIODevice::ReadOnly)) + { + static_cast<Sound*>(modified())->setData(file.readAll()); + file.close(); + refreshGui(); + } +} diff --git a/pokemodr/SoundUI.h b/pokemodr/SoundUI.h new file mode 100644 index 00000000..41125f22 --- /dev/null +++ b/pokemodr/SoundUI.h @@ -0,0 +1,56 @@ +/* + * 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_SOUNDUI__ +#define __POKEMODR_SOUNFUI__ + +// PokeModr includes +#include "ObjectUI.h" + +// Form include +#include "ui_sound.h" + +// Forward declarations +class Sound; +namespace Phonon +{ + class MediaObject; +} + +class SoundUI : public ObjectUI, private Ui::formSound +{ + Q_OBJECT + + public: + SoundUI(Sound* sound, QWidget* parent); + ~SoundUI(); + public slots: + void on_buttonApply_clicked(); + void on_buttonDiscard_clicked(); + void on_varName_textChanged(const QString& name); + void on_buttonPlayPause_clicked(); + void on_buttonStop_clicked(); + void on_buttonBrowse_clicked(); + private slots: + void initGui(); + void refreshGui(); + void setGui(); + private: + Phonon::MediaObject* m_media; +}; + +#endif diff --git a/pokemodr/SpeciesAbilityUI.cpp b/pokemodr/SpeciesAbilityUI.cpp index 3fc43533..fe78706b 100644 --- a/pokemodr/SpeciesAbilityUI.cpp +++ b/pokemodr/SpeciesAbilityUI.cpp @@ -31,8 +31,8 @@ SpeciesAbilityUI::SpeciesAbilityUI(SpeciesAbility* ability, QWidget* parent) : setObjects(ability, new SpeciesAbility(*ability)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/SpeciesEvolutionUI.cpp b/pokemodr/SpeciesEvolutionUI.cpp index 26a32d03..49049830 100644 --- a/pokemodr/SpeciesEvolutionUI.cpp +++ b/pokemodr/SpeciesEvolutionUI.cpp @@ -34,8 +34,8 @@ SpeciesEvolutionUI::SpeciesEvolutionUI(SpeciesEvolution* evolution, QWidget* par setObjects(evolution, new SpeciesEvolution(*evolution)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/SpeciesItemUI.cpp b/pokemodr/SpeciesItemUI.cpp index b4b0407d..e2ad80d7 100644 --- a/pokemodr/SpeciesItemUI.cpp +++ b/pokemodr/SpeciesItemUI.cpp @@ -31,8 +31,8 @@ SpeciesItemUI::SpeciesItemUI(SpeciesItem* item, QWidget* parent) : setObjects(item, new SpeciesItem(*item)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/SpeciesMoveUI.cpp b/pokemodr/SpeciesMoveUI.cpp index d9fa8a29..e3b8a17f 100644 --- a/pokemodr/SpeciesMoveUI.cpp +++ b/pokemodr/SpeciesMoveUI.cpp @@ -31,8 +31,8 @@ SpeciesMoveUI::SpeciesMoveUI(SpeciesMove* move, QWidget* parent) : setObjects(move, new SpeciesMove(*move)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/SpeciesUI.cpp b/pokemodr/SpeciesUI.cpp index 5b233573..35e453e8 100644 --- a/pokemodr/SpeciesUI.cpp +++ b/pokemodr/SpeciesUI.cpp @@ -35,8 +35,8 @@ SpeciesUI::SpeciesUI(Species* species, QWidget* parent) : setObjects(species, new Species(*species)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } @@ -225,52 +225,57 @@ void SpeciesUI::on_varPokedexEntry_textChanged() void SpeciesUI::on_varFrontMaleSprite_pressed() { - FileDialog dialog(QSize(64, 64)); - if (dialog.exec()) + FileDialog* dialog = new FileDialog(QSize(64, 64)); + if (dialog->exec() == QDialog::Accepted) { - static_cast<Species*>(modified())->setFrontMaleSprite(QPixmap(dialog.selectedFile())); + static_cast<Species*>(modified())->setFrontMaleSprite(QPixmap(dialog->selectedFile())); setGui(); } + delete dialog; } void SpeciesUI::on_varBackMaleSprite_pressed() { - FileDialog dialog(QSize(64, 64)); - if (dialog.exec()) + FileDialog* dialog = new FileDialog(QSize(64, 64)); + if (dialog->exec() == QDialog::Accepted) { - static_cast<Species*>(modified())->setBackMaleSprite(QPixmap(dialog.selectedFile())); + static_cast<Species*>(modified())->setBackMaleSprite(QPixmap(dialog->selectedFile())); setGui(); } + delete dialog; } void SpeciesUI::on_varFrontFemaleSprite_pressed() { - FileDialog dialog(QSize(64, 64)); - if (dialog.exec()) + FileDialog* dialog = new FileDialog(QSize(64, 64)); + if (dialog->exec() == QDialog::Accepted) { - static_cast<Species*>(modified())->setFrontFemaleSprite(QPixmap(dialog.selectedFile())); + static_cast<Species*>(modified())->setFrontFemaleSprite(QPixmap(dialog->selectedFile())); setGui(); } + delete dialog; } void SpeciesUI::on_varBackFemaleSprite_pressed() { - FileDialog dialog(QSize(64, 64)); - if (dialog.exec()) + FileDialog* dialog = new FileDialog(QSize(64, 64)); + if (dialog->exec() == QDialog::Accepted) { - static_cast<Species*>(modified())->setBackFemaleSprite(QPixmap(dialog.selectedFile())); + static_cast<Species*>(modified())->setBackFemaleSprite(QPixmap(dialog->selectedFile())); setGui(); } + delete dialog; } void SpeciesUI::on_varListSprite_pressed() { - FileDialog dialog(QSize(128, 64)); - if (dialog.exec()) + FileDialog* dialog = new FileDialog(QSize(128, 64)); + if (dialog->exec() == QDialog::Accepted) { - static_cast<Species*>(modified())->setListSprite(QPixmap(dialog.selectedFile())); + static_cast<Species*>(modified())->setListSprite(QPixmap(dialog->selectedFile())); setGui(); } + delete dialog; } void SpeciesUI::on_boxGenderChance_toggled(const bool genderChance) diff --git a/pokemodr/StoreUI.cpp b/pokemodr/StoreUI.cpp index 7c1ff177..80f6f635 100644 --- a/pokemodr/StoreUI.cpp +++ b/pokemodr/StoreUI.cpp @@ -31,8 +31,8 @@ StoreUI::StoreUI(Store* store, QWidget* parent) : setObjects(store, new Store(*store)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/TileDelegate.cpp b/pokemodr/TileDelegate.cpp index 5d5a93d4..59a11f80 100644 --- a/pokemodr/TileDelegate.cpp +++ b/pokemodr/TileDelegate.cpp @@ -28,7 +28,7 @@ #include "../pokemod/Tile.h" // KDE includes -#include <kcombobox.h> +#include <KComboBox> QWidget* TileDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem&, const QModelIndex&) const { diff --git a/pokemodr/TileUI.cpp b/pokemodr/TileUI.cpp index d391193e..cae50262 100644 --- a/pokemodr/TileUI.cpp +++ b/pokemodr/TileUI.cpp @@ -33,8 +33,8 @@ TileUI::TileUI(Tile* tile, QWidget* parent) : setObjects(tile, new Tile(*tile)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } @@ -102,12 +102,13 @@ void TileUI::on_varName_textChanged(const QString& name) void TileUI::on_varImage_pressed() { - FileDialog dialog(QSize(64, 64)); - if (dialog.exec()) + FileDialog* dialog = new FileDialog(QSize(64, 64)); + if (dialog->exec() == QDialog::Accepted) { - static_cast<Tile*>(modified())->setSprite(QPixmap(dialog.selectedFile())); + static_cast<Tile*>(modified())->setSprite(QPixmap(dialog->selectedFile())); setGui(); } + delete dialog; } void TileUI::on_varWild_valueChanged(const Fraction& wildChance) diff --git a/pokemodr/TilemapModel.cpp b/pokemodr/TilemapModel.cpp index dc205250..cddaa035 100644 --- a/pokemodr/TilemapModel.cpp +++ b/pokemodr/TilemapModel.cpp @@ -26,7 +26,7 @@ #include "../pokemod/Tile.h" // KDE includes -#include <kcombobox.h> +#include <KComboBox> TilemapModel::TilemapModel(QObject* parent, Matrix<int>* map, const Pokemod* pokemod) : QAbstractTableModel(parent), diff --git a/pokemodr/TimeUI.cpp b/pokemodr/TimeUI.cpp index b4ae1fdd..1196c15f 100644 --- a/pokemodr/TimeUI.cpp +++ b/pokemodr/TimeUI.cpp @@ -29,8 +29,8 @@ TimeUI::TimeUI(Time* time, QWidget* parent) : setObjects(time, new Time(*time)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/TrainerUI.cpp b/pokemodr/TrainerUI.cpp index fdd86a48..506cfa7a 100644 --- a/pokemodr/TrainerUI.cpp +++ b/pokemodr/TrainerUI.cpp @@ -32,8 +32,8 @@ TrainerUI::TrainerUI(Trainer * trainer, QWidget * parent) : setObjects(trainer, new Trainer(*trainer)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } @@ -74,17 +74,18 @@ void TrainerUI::on_varMoneyFactor_valueChaged(const int moneyFactor) void TrainerUI::on_varSkin_pressed() { - FileDialog dialog(QSize(192, 168)); - if (dialog.exec()) + FileDialog* dialog = new FileDialog(QSize(192, 168)); + if (dialog->exec() == QDialog::Accepted) { - static_cast<Trainer*>(modified())->setSkin(QPixmap(dialog.selectedFile())); + static_cast<Trainer*>(modified())->setSkin(QPixmap(dialog->selectedFile())); setGui(); } + delete dialog; } // void TrainerUI::on_varAI_pressed() // { -// FileDialog dialog(QString::fromUtf8("*.pai|PokéMod AI Files")); +// FileDialog* dialog = new FileDialog(QString::fromUtf8("*.pai|PokéMod AI Files")); // if (dlg.show()) // { // try diff --git a/pokemodr/TypeUI.cpp b/pokemodr/TypeUI.cpp index d10a3af8..49697a24 100644 --- a/pokemodr/TypeUI.cpp +++ b/pokemodr/TypeUI.cpp @@ -29,8 +29,8 @@ TypeUI::TypeUI(Type* type, QWidget* parent) : setObjects(type, new Type(*type)); connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); connect(modified(), SIGNAL(error(const QString&)), this, SLOT(setGui())); - connect(modified(), SIGNAL(error(QString&)), this, SLOT(errorMessage(QString&))); - connect(modified(), SIGNAL(warning(QString&)), this, SLOT(warningMessage(QString&))); + connect(modified(), SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&))); + connect(modified(), SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&))); connect(modified(), SIGNAL(changed()), this, SLOT(setChanged())); init(); } diff --git a/pokemodr/gui/sound.ui b/pokemodr/gui/sound.ui new file mode 100644 index 00000000..9a90a230 --- /dev/null +++ b/pokemodr/gui/sound.ui @@ -0,0 +1,94 @@ +<ui version="4.0" > + <class>formSound</class> + <widget class="QWidget" name="formSound" > + <layout class="QVBoxLayout" > + <item> + <widget class="QGroupBox" name="boxButtons" > + <layout class="QHBoxLayout" > + <item> + <widget class="KPushButton" name="buttonApply" > + <property name="text" > + <string>&Apply</string> + </property> + <property name="shortcut" > + <string>Ctrl+Return</string> + </property> + </widget> + </item> + <item> + <widget class="KPushButton" name="buttonDiscard" > + <property name="text" > + <string>&Discard</string> + </property> + <property name="shortcut" > + <string>Esc</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="boxName" > + <property name="title" > + <string>Name</string> + </property> + <layout class="QHBoxLayout" > + <item> + <widget class="KLineEdit" name="varName" > + <property name="toolTip" > + <string>Name of the sound</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="boxSound" > + <property name="title" > + <string>Sound</string> + </property> + <layout class="QGridLayout" > + <item row="1" column="0" > + <widget class="KPushButton" name="buttonPlayPause" /> + </item> + <item row="1" column="1" > + <widget class="KPushButton" name="buttonStop" /> + </item> + <item row="2" column="0" colspan="2" > + <widget class="KPushButton" name="buttonBrowse" > + <property name="text" > + <string>Browse...</string> + </property> + </widget> + </item> + <item row="0" column="0" colspan="2" > + <widget class="Phonon::SeekSlider" native="1" name="seeker" /> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>KLineEdit</class> + <extends>QLineEdit</extends> + <header>klineedit.h</header> + </customwidget> + <customwidget> + <class>KPushButton</class> + <extends>QPushButton</extends> + <header>kpushbutton.h</header> + </customwidget> + <customwidget> + <class>Phonon::SeekSlider</class> + <extends>QWidget</extends> + <header location="global" >Phonon/SeekSlider</header> + <container>1</container> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> diff --git a/pokemodr/gui/type.ui b/pokemodr/gui/type.ui index 2faeba8b..5e5e71bf 100644 --- a/pokemodr/gui/type.ui +++ b/pokemodr/gui/type.ui @@ -63,6 +63,38 @@ </layout> </widget> </item> + <item> + <widget class="QGroupBox" name="boxStatusImmunity" > + <property name="title" > + <string>Status Immunity</string> + </property> + <layout class="QVBoxLayout" > + <item> + <widget class="KListWidget" name="varStatusImmunity" > + <property name="selectionMode" > + <enum>QAbstractItemView::ExtendedSelection</enum> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="boxWeatherImmunity" > + <property name="title" > + <string>Weather Immunity</string> + </property> + <layout class="QVBoxLayout" > + <item> + <widget class="KListWidget" name="varWeatherImmunity" > + <property name="selectionMode" > + <enum>QAbstractItemView::ExtendedSelection</enum> + </property> + </widget> + </item> + </layout> + </widget> + </item> </layout> </widget> <customwidgets> @@ -72,6 +104,11 @@ <header>klineedit.h</header> </customwidget> <customwidget> + <class>KListWidget</class> + <extends>QListWidget</extends> + <header>klistwidget.h</header> + </customwidget> + <customwidget> <class>KPushButton</class> <extends>QPushButton</extends> <header>kpushbutton.h</header> diff --git a/pokemodr/models/RootModel.cpp b/pokemodr/models/RootModel.cpp index 40759f7f..fd2af87f 100644 --- a/pokemodr/models/RootModel.cpp +++ b/pokemodr/models/RootModel.cpp @@ -28,7 +28,9 @@ #include <QFile> #include "../../pokemod/Ability.h" #include "../../pokemod/AbilityEffect.h" +#include "../../pokemod/Sound.h" #include "AbilityModel.h" +#include "SoundModel.h" RootModel::RootModel(const QList<QVariant>& pokemods) : GroupModel(NULL, NULL) @@ -78,7 +80,10 @@ void RootModel::setupData(const QList<QVariant>& pokemods) Ability* ability = pokemod->newAbility(); ability->setName("foo"); ability->newEffect()->setEffect(AbilityEffect::E_PreventDamage); + Sound* sound = pokemod->newSound(); + sound->setName("bar"); m_objects.append(new AbilityModel(this, ability)); + m_objects.append(new SoundModel(this, sound)); m_objects.append(new AbilityGroupModel(this, pokemod)); Pokemod* full = new Pokemod(xml.documentElement()); m_objects.append(new PokemodModel(this, full)); diff --git a/pokemodr/models/SoundModel.cpp b/pokemodr/models/SoundModel.cpp index 90112f81..ffec4226 100644 --- a/pokemodr/models/SoundModel.cpp +++ b/pokemodr/models/SoundModel.cpp @@ -19,7 +19,7 @@ #include "SoundModel.h" // PokeModr includes -// #include "../SoundUI.h" +#include "../SoundUI.h" // Pokemod includes #include "../../pokemod/Sound.h" @@ -49,9 +49,8 @@ QVariant SoundModel::data(int role) const } else if (role == BaseModel::WidgetRole) { - // TODO: SoundUI -// QWidget* widget = new SoundUI(static_cast<Sound*>(m_object), NULL); -// return QVariant::fromValue(widget); + QWidget* widget = new SoundUI(static_cast<Sound*>(m_object), NULL); + return QVariant::fromValue(widget); } return QVariant(); } diff --git a/pokemodr/pokemodr.pro b/pokemodr/pokemodr.pro index e84f1189..ae021254 100644 --- a/pokemodr/pokemodr.pro +++ b/pokemodr/pokemodr.pro @@ -35,7 +35,7 @@ win32 { } KDEINCDIR = $$KDEPREFIX/include # $$KDEINCDIR/mingw contains the kdewin32 headers, defining stuff like mkdtemp. - INCLUDEPATH += $$KDEINCDIR/mingw $$KDEINCDIR + INCLUDEPATH += $$KDEINCDIR/mingw $$KDEINCDIR $$KDEINCDIR/KDE LIBS += -lkdewin32 QMAKE_LIBDIR = $$KDEPREFIX/lib $$QMAKE_LIBDIR }else { @@ -48,7 +48,7 @@ win32 { } else { KDEINCDIR = $$KDEPREFIX/include } - INCLUDEPATH += $$KDEINCDIR + INCLUDEPATH += $$KDEINCDIR $$KDEINCDIR/KDE KDELIBDIR = $$KDEPREFIX/lib$$system(kde4-config --libsuffix) KDEDEVELLIBDIR = $$KDELIBDIR exists($$KDEDEVELLIBDIR/kde4/devel){ @@ -88,6 +88,7 @@ SOURCES += AbilityUI.cpp \ PokeModr.cpp \ PokeModrUI.cpp \ RulesUI.cpp \ + SoundUI.cpp \ SpeciesUI.cpp \ SpeciesAbilityUI.cpp \ SpeciesEvolutionUI.cpp \ @@ -162,6 +163,7 @@ HEADERS += AbilityUI.h \ PokeModr.h \ PokeModrUI.h \ RulesUI.h \ + SoundUI.h \ SpeciesUI.h \ SpeciesAbilityUI.h \ SpeciesEvolutionUI.h \ @@ -238,6 +240,7 @@ FORMS += gui/ability.ui \ gui/pokemod.ui \ gui/pokemodr.ui \ gui/rules.ui \ + gui/sound.ui \ gui/species.ui \ gui/speciesability.ui \ gui/speciesevolution.ui \ @@ -249,14 +252,6 @@ FORMS += gui/ability.ui \ gui/trainer.ui \ gui/type.ui -; IMAGES += images/overlays/effect.png \ -; images/overlays/no-walk.png \ -; images/overlays/trainer.png \ -; images/overlays/walk.png \ -; images/overlays/warp.png \ -; images/overlays/water.png \ -; images/overlays/wilds.png - INSTALLS += target isEmpty(PREFIX){ PREFIX = $$(PREFIX) |
