Move preferences dialog layout code into separate ui file
[vlp.git] / src / edit / editor.cpp
index 59e7f9e53d0eae1885a5bcbb8343e959d60b7907..b507a6fb6ee796149135d1c6dc044988657ce2fa 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "ProgramStructureDialog.h"
 #include "UnitStructureDialog.h"
+#include "PreferencesDialog.h"
 
 #include "editor.h"
 
@@ -128,19 +129,19 @@ void Editor::compile(int mode)
        /*  fn.truncate(i);*/
        switch(mode) {
        case COMP_MODE:
-               sprintf(cmd, "%s %s > comp_data!", compiler_path.toAscii().data(),
-                                                       fname.toAscii().data());
+               sprintf(cmd, "%s %s > comp_data!", compiler_path.toStdString().c_str(),
+                                                       fname.toStdString().c_str());
                break;
        case GEN_MODE:
-               sprintf(cmd, "%s %s > comp_data!", gen_path.toAscii().data(),
-                                                       fname.toAscii().data());
+               sprintf(cmd, "%s %s > comp_data!", gen_path.toStdString().c_str(),
+                                                       fname.toStdString().c_str());
                break;
        case ALL_MODE:
-               sprintf(cmd, "%s %s > comp_data!", compiler_path.toAscii().data(),
-                                                       fname.toAscii().data());
+               sprintf(cmd, "%s %s > comp_data!", compiler_path.toStdString().c_str(),
+                                                       fname.toStdString().c_str());
                system(cmd);
-               sprintf(cmd, "%s %s >> comp_data!", gen_path.toAscii().data(),
-                                                       fname.toAscii().data());
+               sprintf(cmd, "%s %s >> comp_data!", gen_path.toStdString().c_str(),
+                                                       fname.toStdString().c_str());
        break;
        }
 
@@ -308,69 +309,16 @@ void Editor::on_actionFind_Next_triggered()
  */
 void Editor::on_actionPreferences_triggered()
 {
-       QDialog dlg(this, Qt::Dialog);
-
-       QLineEdit *files;
-       files = new QLineEdit(&dlg);
-       files->setGeometry(130, 20, 250, 30);
-       files->setText(file_path);
-       files->setMaxLength(32767);
-       files->setEchoMode(QLineEdit::Normal);
-       files->setFrame(TRUE);
+       PreferencesDialog dialog(this);
 
-       QLabel *tmpQLabel;
-       tmpQLabel = new QLabel("Path to files:", &dlg);
-       tmpQLabel->setGeometry(10, 20, 100, 30);
-       tmpQLabel->setAlignment(Qt::AlignLeft);
-       tmpQLabel->setMargin(-1);
-
-       tmpQLabel = new QLabel("Path to compiler:", &dlg);
-       tmpQLabel->setGeometry(10, 60, 100, 30);
-       tmpQLabel->setAlignment(Qt::AlignLeft);
-       tmpQLabel->setMargin(-1);
-
-       /*
-       tmpQLabel = new QLabel(&dlg, "Label_3");
-       tmpQLabel->setGeometry(10, 100, 100, 30);
-       tmpQLabel->setText("Path to gen:");
-       tmpQLabel->setAlignment(289);
-       tmpQLabel->setMargin(-1);
-       */
-
-       QLineEdit *compp;
-       compp = new QLineEdit(compiler_path, &dlg);
-       compp->setGeometry(130, 60, 250, 30);
-       compp->setMaxLength(32767);
-       compp->setEchoMode(QLineEdit::Normal);
-       compp->setFrame(TRUE);
-
-       /*
-       QLineEdit* genp;
-       genp = new QLineEdit(&dlg, "g_path");
-       genp->setGeometry(130, 100, 250, 30);
-       genp->setText(gen_path.data());
-       genp->setMaxLength(32767);
-       genp->setEchoMode(QLineEdit::Normal);
-       genp->setFrame(TRUE);
-       */
-
-       QPushButton* tmpQPushButton;
-       tmpQPushButton = new QPushButton("Ok", &dlg);
-       tmpQPushButton->setGeometry(90, 100, 70, 30);
-       tmpQPushButton->setAutoRepeat(FALSE);
-       connect(tmpQPushButton,SIGNAL(clicked()), &dlg, SLOT(accept()));
-
-       tmpQPushButton = new QPushButton("Cancel", &dlg);
-       tmpQPushButton->setGeometry(180, 100, 70, 30);
-       tmpQPushButton->setAutoRepeat(FALSE);
-       connect(tmpQPushButton,SIGNAL(clicked()), &dlg, SLOT(reject()));
-
-       dlg.resize(400, 140);
+       dialog.setCompilerPath(compiler_path);
+       dialog.setFilesPath(file_path);
+       dialog.setGenPath(gen_path);
 
-       if (dlg.exec()) {
-               compiler_path.sprintf("%s", compp->text().toAscii().data());
-               /* gen_path.sprintf("%s",genp->text()); */
-               file_path.sprintf("%s", files->text().toAscii().data());
+       if (dialog.exec()) {
+               compiler_path.sprintf("%s", dialog.getCompilerPath().toStdString().c_str());
+               gen_path.sprintf("%s",dialog.getGenPath().toStdString().c_str());
+               file_path.sprintf("%s", dialog.getFilesPath().toStdString().c_str());
        };
 }