Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4StartClient.h"
00015
00016 #include <QDir>
00017 #include <QFileInfo>
00018 #include <QFileDialog>
00019 #include "TGo4QSettings.h"
00020
00021 TGo4StartClient::TGo4StartClient( QWidget* parent )
00022 : QDialog( parent )
00023 {
00024 setupUi(this);
00025
00026 setObjectName("Go4StartClient");
00027
00028 #ifdef WIN32
00029
00030 go4sett->setClientShellMode(0);
00031 rsh_selected->setEnabled(false);
00032 ssh_selected->setEnabled(false);
00033
00034 go4sett->setClientTermMode(1);
00035 xterm_selected->setEnabled(false);
00036 konsole_selected->setEnabled(false);
00037 go4sett->setClientNode("localhost");
00038 LineEditClientNode->setEnabled(false);
00039 #endif
00040
00041 fSelectedFilter = -1;
00042
00043 ClientShellGroup = new QButtonGroup(this);
00044 ClientShellGroup->addButton(exec_selected, 0);
00045 ClientShellGroup->addButton(rsh_selected, 1);
00046 ClientShellGroup->addButton(ssh_selected, 2);
00047 ClientShellGroup->button(go4sett->getClientShellMode())->setChecked(true);
00048
00049 ClientTermGroup = new QButtonGroup(this);
00050 ClientTermGroup->addButton(qt_selected, 1);
00051 ClientTermGroup->addButton(xterm_selected, 2);
00052 ClientTermGroup->addButton(konsole_selected, 3);
00053 ClientTermGroup->button(go4sett->getClientTermMode())->setChecked(true);
00054
00055 ExeModeCombo->setCurrentIndex(go4sett->getClientExeMode());
00056
00057 LineEditClientName->setText(go4sett->getClientName());
00058 LineEditClientNode->setText(go4sett->getClientNode());
00059 LineEditClientDir->setText(go4sett->getClientDir());
00060 LineEditClientExec->setText(go4sett->getClientExec());
00061 LineEditArgs->setText(go4sett->getClientArgs());
00062
00063 if (LineEditClientDir->text().isEmpty())
00064 LineEditClientDir->setText(QDir::currentPath());
00065
00066 bool isserver = go4sett->getClientIsServer();
00067 #ifdef WIN32
00068 isserver = false;
00069 ServerModeCombo->setEnabled(false);
00070 #endif
00071 ServerModeCombo->setCurrentIndex(isserver ? 1 : 0);
00072
00073 #ifndef WIN32
00074 qt_selected->setEnabled(!isserver);
00075 if (isserver && ClientTermGroup->checkedId()==1)
00076 ClientTermGroup->button(2)->setChecked(true);
00077 #endif
00078 }
00079
00080 void TGo4StartClient::ExeMode_changed(int id)
00081 {
00082 LineEditClientExec->setText(go4sett->getClientExec(id));
00083 }
00084
00085 void TGo4StartClient::getResults()
00086 {
00087 go4sett->setClientName(LineEditClientName->text());
00088 go4sett->setClientNode(LineEditClientNode->text());
00089 go4sett->setClientDir(LineEditClientDir->text());
00090 go4sett->setClientExeMode(ExeModeCombo->currentIndex());
00091 go4sett->setClientExec(LineEditClientExec->text());
00092 go4sett->setClientArgs(LineEditArgs->text());
00093 go4sett->setClientShellMode(ClientShellGroup->checkedId());
00094 go4sett->setClientTermMode(ClientTermGroup->checkedId());
00095 go4sett->setClientIsServer(ServerModeCombo->currentIndex()==1);
00096 }
00097
00098 void TGo4StartClient::SelectDir()
00099 {
00100 QFileDialog fd(this, "Select your working directory");
00101 fd.setFileMode(QFileDialog::DirectoryOnly);
00102 QString dir = LineEditClientDir->text();
00103 if (dir.isEmpty() || !QDir(dir).exists())
00104 dir = QDir::currentPath();
00105 fd.setDirectory(dir);
00106
00107 if (fd.exec() != QDialog::Accepted ) return;
00108
00109 QStringList flst = fd.selectedFiles();
00110 if (flst.isEmpty()) return;
00111
00112 LineEditClientDir->setText(flst[0]);
00113
00114 QString fileName = LineEditClientExec->text();
00115 if (fileName.length()==0) return;
00116
00117 QString exeDirPath = QFileInfo(fileName).path();
00118 if (exeDirPath.isEmpty() || ((exeDirPath == QString(".")) && (fileName[0]!='.'))) {
00119 fileName = QFileInfo(QDir(flst[0]), fileName).filePath();
00120 LineEditClientExec->setText(fileName);
00121 }
00122
00123 }
00124
00125 void TGo4StartClient::SelectProg()
00126 {
00127 const char* caption = 0;
00128
00129 #ifdef WIN32
00130 QString exe1_filter("User analysis (MainUserAnalysis.exe)");
00131 QString exe2_filter("Any executable (*.exe)");
00132 QString dll1_filter("User library (libGo4UserAnalysis.dll)");
00133 QString dll2_filter("Any shared library (*.dll)");
00134 QString any_filter("Any files (*.*)");
00135 #else
00136 QString exe1_filter("User analysis (MainUserAnalysis)");
00137 QString exe2_filter("Any executable (*)");
00138 QString dll1_filter("User library (libGo4UserAnalysis.so)");
00139 QString dll2_filter("Any shared library (*.so)");
00140 QString any_filter("Any files (*)");
00141 #endif
00142
00143 QStringList filters;
00144 filters << exe1_filter << exe2_filter << dll1_filter << dll2_filter << any_filter;
00145
00146 QFileDialog fd(this, caption);
00147 fd.setFileMode(QFileDialog::ExistingFile);
00148 fd.setNameFilters(filters);
00149
00150 int select_filer = fSelectedFilter;
00151 if (select_filer<0)
00152 select_filer= (ExeModeCombo->currentIndex()==0) ? 0 : 2;
00153 switch (select_filer) {
00154 case 0: fd.selectNameFilter(exe1_filter); break;
00155 case 1: fd.selectNameFilter(exe2_filter); break;
00156 case 2: fd.selectNameFilter(dll1_filter); break;
00157 case 3: fd.selectNameFilter(dll2_filter); break;
00158 default: fd.selectNameFilter(any_filter); break;
00159 }
00160
00161 QString filename = LineEditClientExec->text();
00162 if (filename.length() > 0)
00163 fd.selectFile(filename);
00164
00165 if (fd.exec() != QDialog::Accepted) return;
00166
00167 QStringList flst = fd.selectedFiles();
00168 if (flst.isEmpty()) return;
00169
00170 select_filer = 4;
00171 if (fd.selectedNameFilter()==exe1_filter) select_filer = 0; else
00172 if (fd.selectedNameFilter()==exe2_filter) select_filer = 1; else
00173 if (fd.selectedNameFilter()==dll1_filter) select_filer = 2; else
00174 if (fd.selectedNameFilter()==dll2_filter) select_filer = 3;
00175 fSelectedFilter = select_filer;
00176
00177 if ((select_filer==0) || (select_filer==1)) ExeModeCombo->setCurrentIndex(0); else
00178 if ((select_filer==2) || (select_filer==3)) ExeModeCombo->setCurrentIndex(1);
00179
00180 LineEditClientExec->setText(flst[0]);
00181 }
00182
00183
00184 void TGo4StartClient::ServerModeCombo_activated(int id)
00185 {
00186 #ifndef WIN32
00187
00188 bool isserver = (id==1);
00189
00190 qt_selected->setEnabled(!isserver);
00191
00192 if (isserver) {
00193 if (ClientTermGroup->checkedId()==1)
00194 ClientTermGroup->button(2)->setChecked(true);
00195 }
00196 else {
00197 if (ClientTermGroup->checkedId()==2)
00198 ClientTermGroup->button(1)->setChecked(true);
00199 }
00200 #endif
00201 }