Update to the newest upstream version.
[vlp.git] / kernel / kernel.cpp
index a1ebed789f155169b91e04a6f655cce3f9043709..08ee51b75331fd786bb83fb379f7d1b021883a71 100644 (file)
@@ -31,7 +31,7 @@
 
 
 #include <qpixmap.h>
-#include <qwindow.h>
+//#include <qwindow.h>
 #include <qapp.h>
 #include <qframe.h>
 #include <qmlined.h>
@@ -59,6 +59,7 @@
 #include <qcombo.h>
 #include <qsocknot.h>
 #include <qdir.h>
+#include <qwindowsstyle.h>
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -160,7 +161,8 @@ public slots:
   void Connect();
   void Info();
 
-
+protected:
+  virtual void closeEvent ( QCloseEvent * e );
 
 private:
   QList<InterpEntry> Interpreters;         
@@ -192,11 +194,15 @@ private:
 };
 /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
 
+void QKernel::closeEvent ( QCloseEvent * e ) {
+  e->ignore();
+}
+
 QKernel::QKernel()
 {
- QFont f("Helvetica",12,QFont::Bold);
- QFont f1("Helvetica",12,QFont::Normal);
- QFont f2("Times Roman",12,QFont::Normal);
+ QFont f("Helvetica",10,QFont::Bold);
+ QFont f1("Helvetica",10,QFont::Normal);
+ QFont f2("Times Roman",10,QFont::Normal);
  QDir q(REMOTE_PATH);
  char ss[255];
 
@@ -277,8 +283,7 @@ void QKernel::resizeEvent( QResizeEvent *ev )
 
 void QKernel::n_impl()
 {
- QMessageBox::information(this,"Function info","This function is not implemented
- yet...","Ok");
+ QMessageBox::information(this,"Function info","This function is not implemented yet...","Ok");
 }
 
 
@@ -286,27 +291,32 @@ void QKernel::n_impl()
 
 void QKernel::LoadConfig()
 {
- QFile f("vlp.cfg");
- char line[256],val[255];
+QFile f("vlp.cfg");
+ QString line;
+ QString val;
+ int br=0;
 
  if (!f.exists())
  {
   WriteMessage("Cannot load configuration file!");sleep(2);exit(3);
   }
  f.open(IO_ReadOnly);
- f.readLine(line,256);
- while (!f.atEnd())
br = f.readLine(line,256);
+ while (br>0)
  {
-  if (line[strlen(line)-1]=='\n') line[strlen(line)-1]='\0';
-  strcpy(line,strtok(line,"="));
-  strcpy(val, strtok(NULL,"="));
-  if (strcmp(line,"node_number")==0) {NodeNumber = atoi(val);};
-  if (strcmp(line,"type")==0) {if (strcmp(val,"explicit")==0) ConType=1; else
+  QStringList l = QStringList::split("=",line,FALSE);
+  QStringList::Iterator it = l.begin();
+  line = *it;
+  ++it;
+  val = *it;
+  val = val.stripWhiteSpace();
+  if (line == "node_number") {NodeNumber = val.toInt();};
+  if (line == "type") {if (val=="explicit") ConType=1; else
                                ConType = 2; };
-  if (strcmp(line,"host")==0) {ConnectList.append(new ConnectEntry(val));};
-  if (strcmp(line,"progdir")==0) {strcpy(progdir,val);};
-  if (strcmp(line,"homedir")==0) {strcpy(HomeDir,val);};
-  f.readLine(line,256);
+  if (line == "host" ) {ConnectList.append(new ConnectEntry((char*)val.ascii()));};
+  if (line == "progdir") { strcpy(progdir,val.ascii());};
+  if (line == "homedir") { strcpy(HomeDir,val.ascii());};
+  br = f.readLine(line,256);
  }
  f.close();
 }
@@ -321,7 +331,7 @@ void QKernel::Run_Prog()
  {
     i = s.find(".log");
     if (i>0)  s.remove(i,4);
-    RunIntModule(s.data(),0);
+    RunIntModule((char*)s.ascii(),0);
  }
 }
 
@@ -456,6 +466,7 @@ void QKernel::QuitProc()
 {
  MESSAGE msg;
 
+if ( QMessageBox::question(this,"Close VLP","Terminate VLP ?",QMessageBox::Yes,QMessageBox::No,0) == QMessageBox::No ) return;
 if (!LOCKED)
 {
   /* 
@@ -993,7 +1004,7 @@ void QKernel::LockConsole()
              {
                 QMessageBox msg(this);
                 msg.setText("Not matching!");
-                msg.setButtonText("Close");
+                msg.setButtonText(0,"Close");
                 msg.show();
 
              }   
@@ -1041,7 +1052,7 @@ void QKernel::UnlockConsole()
           {
                 QMessageBox msg(this);
                 msg.setText("Wrong password!");
-                msg.setButtonText("Close");
+                msg.setButtonText(0,"Close");
                 msg.show();
 
              }      
@@ -1297,7 +1308,7 @@ int main( int argc, char **argv )
     for(i=1;i<argc;i++) strcpy(myargs[i-1],argv[i]);
     
     app = new QApplication(argc,argv);
-    app->setStyle(WindowsStyle);
+    app->setStyle(new QWindowsStyle());
     QKernel   draw;
     app->setMainWidget( &draw);
     draw.show();