27 #include <QtCore/QDir>
28 #include <QtGui/QApplication>
29 #include <QtGui/QLabel>
33 #define P3D_CONFIG_ENVVAR "P3D_CONFIG_PATH"
37 :QDialog(parent), _currentEditorIdx(0)
39 this->setMinimumWidth(600);
40 QVBoxLayout* rootLayout=
new QVBoxLayout(0);
41 rootLayout->setMargin(2);
42 this->setLayout(rootLayout);
47 QSplitter* vsplitter=
new QSplitter( Qt::Vertical,
this );
48 rootLayout->addWidget(vsplitter);
50 QTabWidget* topTabWidget=
new QTabWidget();
51 vsplitter->addWidget(topTabWidget);
53 QWidget* previewLibraryWidget=
new QWidget();
54 QHBoxLayout* previewLibraryLayout=
new QHBoxLayout();
55 previewLibraryWidget->setLayout(previewLibraryLayout);
56 topTabWidget->addTab(previewLibraryWidget,
"Preview / Library");
58 QWidget* bottomWidget=
new QWidget();
59 vsplitter->addWidget(bottomWidget);
60 QVBoxLayout* bottomLayout=
new QVBoxLayout();
61 bottomLayout->setMargin(1);
62 bottomWidget->setLayout(bottomLayout);
65 QWidget* leftWidget=
new QWidget();
66 leftWidget->setFixedWidth(450);
67 QVBoxLayout* leftLayout=
new QVBoxLayout();
68 leftLayout->setMargin(0);
69 leftWidget->setLayout(leftLayout);
70 QHBoxLayout* previewLayout=
new QHBoxLayout();
72 previewLayout->addWidget(
grapher,0);
75 leftLayout->addLayout(previewLayout);
76 previewLibraryLayout->addWidget(leftWidget);
80 QHBoxLayout* buttonBarLayout =
new QHBoxLayout();
82 buttonBarLayout->setMargin(1);
94 bottomLayout->addLayout(buttonBarLayout);
99 QScrollArea* scrollArea=
new QScrollArea();
102 scrollArea->setFocusPolicy(Qt::NoFocus);
103 scrollArea->setMinimumHeight(100);
104 scrollArea->setFixedWidth(450);
105 scrollArea->setWidgetResizable(
true);
106 leftLayout->addWidget(scrollArea,1);
113 bottomLayout->addWidget(
editor);
117 previewLibraryLayout->addWidget(
browser);
120 QHBoxLayout* buttonLayout =
new QHBoxLayout(0);
121 buttonLayout->addItem(
new QSpacerItem(0,0, QSizePolicy::MinimumExpanding,
122 QSizePolicy::Minimum));
132 rootLayout->addLayout(buttonLayout);
169 return QDialog::exec();
174 if(event->key()==Qt::Key_Escape)
return;
175 return QDialog::keyPressEvent(event);
181 QDialog::closeEvent(event);
200 msgBox.setText(
"Your expression had possible errors.");
201 msgBox.setInformativeText(
"Do you want to accept your expression anyways?");
202 QPushButton* okButton = msgBox.addButton(
"OK", QMessageBox::RejectRole);
203 msgBox.addButton(
"Cancel", QMessageBox::AcceptRole);
204 int ret = msgBox.exec();
206 if(msgBox.clickedButton() == okButton)
220 msgBox.setText(
"Your expression had possible errors.");
221 msgBox.setInformativeText(
"Do you want to accept your expression anyways?");
222 QPushButton* okButton=msgBox.addButton(
"OK",QMessageBox::RejectRole);
223 msgBox.addButton(
"Cancel",QMessageBox::AcceptRole);
224 int ret = msgBox.exec();
226 if(msgBox.clickedButton()==okButton) {
236 QWidget* browserspace =
new QWidget(tab);
238 tab->addTab(browserspace,
"Help");
241 QFile *helpDoc =
new QFile(QCoreApplication::applicationDirPath() +
242 "/../share/doc/SeExpr2/SeExpressions.html");
243 if (helpDoc->exists()) {
244 QString sheet=
"body {background-color: #eeeeee; color: #000000;} \na {color: #3333ff; text-decoration: none;}\n";
245 helpBrowser->document()->setDefaultStyleSheet(sheet);
249 QPushButton* backPb =
new QPushButton(
"Back");
251 backPb->setEnabled(
false);
252 QPushButton* forwardPb =
new QPushButton(
"Forward");
254 forwardPb->setEnabled(
false);
256 QVBoxLayout * helpLayout =
new QVBoxLayout(browserspace);
257 QHBoxLayout * helpPbLayout =
new QHBoxLayout;
258 helpLayout->addLayout(helpPbLayout);
259 helpPbLayout->addWidget(backPb);
260 helpPbLayout->addWidget(forwardPb);
263 QHBoxLayout* findBar=
new QHBoxLayout();
264 helpPbLayout->addWidget(
new QLabel(
"Find"),
false);
268 QPushButton* nextButton=
new QPushButton(
"Find Next");
269 QPushButton* prevButton=
new QPushButton(
"Find Prev");
270 helpPbLayout->addWidget(nextButton,
false);
271 helpPbLayout->addWidget(prevButton,
false);
272 connect(nextButton,SIGNAL(clicked()),
this,SLOT(
findNextInHelp()));
273 connect(prevButton,SIGNAL(clicked()),
this,SLOT(
findPrevInHelp()));
274 helpPbLayout->addLayout(findBar,
false);
279 connect(backPb, SIGNAL(clicked()),
helpBrowser, SLOT(backward()));
280 connect(forwardPb, SIGNAL(clicked()),
helpBrowser, SLOT(forward()));
281 connect(
helpBrowser, SIGNAL(backwardAvailable(
bool)), backPb, SLOT(setEnabled(
bool)));
282 connect(
helpBrowser, SIGNAL(forwardAvailable(
bool)), forwardPb, SLOT(setEnabled(
bool)));
322 s<<
"<b>Variables not supported in preview (assumed zero):</b><br>";
327 s<<
"$"<<i->first<<
" ";
328 if(count%4==0) s<<
"<br>";
336 s<<
"<b>Functions not supported in preview (assumed zero):</b><br>";
341 s<<
""<<i->first<<
"() ";
342 if(count%4==0) s<<
"<br>";
353 for(
unsigned int i=0;i<errors.size();i++){
354 editor->
addError(errors[i].startPos,errors[i].endPos,errors[i].error);
void setupHelp(QTabWidget *tab)
QTextBrowser * helpBrowser
ExprGrapherWidget * grapher
void keyPressEvent(QKeyEvent *event)
QPushButton * saveAsButton
ExprControlCollection * controls
void findHelper(QTextDocument::FindFlags flags)
QPushButton * applyButton
void addError(const int startPos, const int endPos, const std::string &error)
QPushButton * clearButton
QPushButton * cancelButton
QPushButton * acceptButton
ExprDialog(QWidget *parent)
QPushButton * previewButton
QLabel * previewCommentLabel
const std::vector< Error > & getErrors() const
void setExpr(const std::string &str)
void closeEvent(QCloseEvent *event)
QPushButton * saveLocalButton
void setExpr(const std::string &expression, const bool apply=false)