summaryrefslogtreecommitdiffstats
path: root/embedded/visualboyadvance/visualboyadvance_part.cpp
blob: a3b842f48de91b75c68c2364bb1a158f47543e82 (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 <tdeaction.h>
#include <tdevgenericfactory.h>
#include <kiconloader.h>
#include <tdelocale.h>

#include "tdevcore.h"
#include "tdevproject.h"
#include "tdevappfrontend.h"
#include "domutil.h"
#include "tdevplugininfo.h"

#include "vbaconfigwidget.h"


using namespace VisualBoyAdvance;

typedef TDevGenericFactory<VisualBoyAdvancePart> VisualBoyAdvanceFactory;
static const TDevPluginInfo data("tdevvisualboyadvance");
K_EXPORT_COMPONENT_FACTORY( libtdevvisualboyadvance, VisualBoyAdvanceFactory( data ) )
  
VisualBoyAdvancePart::VisualBoyAdvancePart(TQObject *parent, const char *name, const TQStringList &)
  : TDevPlugin(&data, parent, name){
  setInstance(VisualBoyAdvanceFactory::instance());

  setXMLFile("tdevpart_visualboyadvance.rc");
  
  TDEAction *action;
  action = new TDEAction( 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(){
  TDevProject* 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 (TDevAppFrontend *appFrontend = extension<TDevAppFrontend>("TDevelop/AppFrontend"))
      appFrontend->startAppCommand(TQString(), program, terminal);
}

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

#include "visualboyadvance_part.moc"