1
/***************************************************************************
2
File : ScriptingLangDialog.cpp
4
--------------------------------------------------------------------
5
Copyright : (C) 2006 by Knut Franke, Ion Vasilief
6
Email (use @ for *) : knut.franke*gmx.de, ion_vasilief*yahoo.fr
7
Description : Dialog for changing the current scripting
10
***************************************************************************/
12
/***************************************************************************
14
* This program is free software; you can redistribute it and/or modify *
15
* it under the terms of the GNU General Public License as published by *
16
* the Free Software Foundation; either version 2 of the License, or *
17
* (at your option) any later version. *
19
* This program is distributed in the hope that it will be useful, *
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22
* GNU General Public License for more details. *
24
* You should have received a copy of the GNU General Public License *
25
* along with this program; if not, write to the Free Software *
26
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
27
* Boston, MA 02110-1301 USA *
29
***************************************************************************/
30
#include "ScriptingLangDialog.h"
31
#include "ApplicationWindow.h"
33
#include <QListWidget>
34
#include <QPushButton>
36
#include <QMessageBox>
38
ScriptingLangDialog::ScriptingLangDialog(ScriptingEnv *env, ApplicationWindow *parent, Qt::WFlags fl )
39
: QDialog(parent, fl), scripted(env)
41
setCaption(tr("Select scripting language"));
43
langList = new QListWidget(this);
45
btnOK = new QPushButton(tr("OK"));
46
btnCancel = new QPushButton(tr("Cancel"));
48
QHBoxLayout *hbox1 = new QHBoxLayout();
50
hbox1->addWidget(btnOK);
51
hbox1->addWidget(btnCancel);
53
QVBoxLayout *vl = new QVBoxLayout(this);
54
vl->addWidget(langList);
57
connect(btnOK, SIGNAL(clicked()), this, SLOT(accept()));
58
connect(btnCancel, SIGNAL(clicked()), this, SLOT(close()));
59
connect(langList, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(accept()));
64
void ScriptingLangDialog::updateLangList()
67
langList->insertItems(0, ScriptingLangManager::languages());
68
QListWidgetItem *current = langList->findItems(scriptEnv->name(), Qt::MatchExactly).first();
70
langList->setCurrentItem(current);
73
void ScriptingLangDialog::accept()
75
ApplicationWindow *app = (ApplicationWindow*) parent();
76
if (app->setScriptingLang(langList->currentItem()->text()))
79
QMessageBox::critical(this, tr("Scripting Error"),
80
tr("Scripting language \"%1\" failed to initialize.").arg(langList->currentItem()->text()));