summaryrefslogtreecommitdiffstats
path: root/embedded/visualboyadvance/visualboyadvance_part.cpp
blob: d469bc1524a656fde7c1c0bc9666c7c78ec1b457 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "visualboyadvance_part.h"

#include <tqvbox.h>
#include <tqwhatsthis.h>

#include <kaction.h>
#include <kdevgenericfactory.h>
#include <kiconloader.h>
#include <klocale.h>

#include "kdevcore.h"
#include "kdevproject.h"
#include "kdevappfrontend.h"
#include "domutil.h"
#include "kdevplugininfo.h"

#include "vbaconfigwidget.h"


using namespace VisualBoyAdvance;

typedef KDevGenericFactory<VisualBoyAdvancePart> VisualBoyAdvanceFactory;
static const KDevPluginInfo data("kdevvisualboyadvance");
K_EXPORT_COMPONENT_FACTORY( libkdevvisualboyadvance, VisualBoyAdvanceFactory( data ) )
  
VisualBoyAdvancePart::VisualBoyAdvancePart(TQObject *tqparent, const char *name, const TQStringList &)
  : KDevPlugin(&data, tqparent, name){
  setInstance(VisualBoyAdvanceFactory::instance());

  setXMLFile("kdevpart_visualboyadvance.rc");
  
  KAction *action;
  action = new KAction( i18n("Execute Program"), "exec",  Key_F9,
			this, TQT_SLOT(slotExecute()),
			actionCollection(), "build_execute" );

  connect( core(), TQT_SIGNAL(projectConfigWidget(KDialogBase*)),
	   this, TQT_SLOT(projectConfigWidget(KDialogBase*)) );
}


VisualBoyAdvancePart::~VisualBoyAdvancePart()
{
  
}
void VisualBoyAdvancePart::slotExecute(){
  KDevProject* prj = project();
  TQDomDocument &doc = *projectDom();
  TQString binary = DomUtil::readEntry(doc, "/kdevvisualadvance/binary");
  TQString emulator = DomUtil::readEntry(doc, "/kdevvisualadvance/emulator");
  TQString graphicFilter = DomUtil::readEntry(doc, "/kdevvisualadvance/graphicFilter");
  TQString scaling = DomUtil::readEntry(doc, "/kdevvisualadvance/scaling");
  TQString addOptions = DomUtil::readEntry(doc, "/kdevvisualadvance/addOptions");
  bool terminal = DomUtil::readBoolEntry(doc, "/kdevvisualadvance/terminal");
  bool fullscreen = DomUtil::readBoolEntry(doc, "/kdevvisualadvance/fullscreen");

  if(emulator.isNull()) emulator = "VisualBoyAdvance";
  TQString program = emulator + " " + graphicFilter +" " + scaling + " " + addOptions +" ";
  if(fullscreen){
    program += "-F ";
  }

  program += prj->projectDirectory() + "/" + binary;

  if (KDevAppFrontend *appFrontend = extension<KDevAppFrontend>("KDevelop/AppFrontend"))
      appFrontend->startAppCommand(TQString(), program, terminal);
}

void VisualBoyAdvancePart::projectConfigWidget(KDialogBase *dlg){
  TQVBox *vbox;
  vbox = dlg->addVBoxPage(i18n("Run Options"), i18n("Run Options"), BarIcon( "make", KIcon::SizeMedium ));
  VBAConfigWidget* w = new VBAConfigWidget(this,vbox);
  connect( dlg, TQT_SIGNAL(okClicked()), w, TQT_SLOT(accept()) );
}
  

#include "visualboyadvance_part.moc"