src/configDialog.cpp

changeset 300
0c7e00cc3d44
parent 286
7a562bf3d829
child 303
8899806d382d
equal deleted inserted replaced
299:db60288fc36a 300:0c7e00cc3d44
314 extern_cfg (str, prog_ytruder); 314 extern_cfg (str, prog_ytruder);
315 extern_cfg (str, prog_rectifier); 315 extern_cfg (str, prog_rectifier);
316 extern_cfg (str, prog_intersector); 316 extern_cfg (str, prog_intersector);
317 extern_cfg (str, prog_coverer); 317 extern_cfg (str, prog_coverer);
318 extern_cfg (str, prog_isecalc); 318 extern_cfg (str, prog_isecalc);
319 extern_cfg (bool, prog_ytruder_wine);
320 extern_cfg (bool, prog_rectifier_wine);
321 extern_cfg (bool, prog_intersector_wine);
322 extern_cfg (bool, prog_coverer_wine);
323 extern_cfg (bool, prog_isecalc_wine);
319 static const struct extProgInfo { 324 static const struct extProgInfo {
320 const char* const name, *iconname; 325 const str name, iconname;
321 strconfig* const path; 326 strconfig* const path;
322 mutable QLineEdit* input; 327 mutable QLineEdit* input;
323 mutable QPushButton* setPathButton; 328 mutable QPushButton* setPathButton;
329 #ifndef _WIN32
330 boolconfig* const wine;
331 mutable QCheckBox* wineBox;
332 #endif // _WIN32
324 } g_extProgInfo[] = { 333 } g_extProgInfo[] = {
325 { "Ytruder", "ytruder", &prog_ytruder, null, null }, 334 #ifndef _WIN32
326 { "Rectifier", "rectifier", &prog_rectifier, null, null }, 335 # define EXTPROG(NAME, LOWNAME) { #NAME, #LOWNAME, &prog_##LOWNAME, null, null, &prog_##LOWNAME##_wine, null },
327 { "Intersector", "intersector", &prog_intersector, null, null }, 336 #else
328 { "Isecalc", "isecalc", &prog_isecalc, null, null }, 337 # define EXTPROG(NAME, LOWNAME) { #NAME, #LOWNAME, &prog_##LOWNAME, null, null },
329 { "Coverer", "coverer", &prog_coverer, null, null }, 338 #endif
339 EXTPROG (Ytruder, ytruder)
340 EXTPROG (Rectifir, rectifier)
341 EXTPROG (Intersector, intersector)
342 EXTPROG (Isecalc, isecalc)
343 EXTPROG (Coverer, coverer)
344 #undef EXTPROG
330 }; 345 };
331 346
332 void ConfigDialog::initExtProgTab () { 347 void ConfigDialog::initExtProgTab () {
333 QWidget* tab = new QWidget; 348 QWidget* tab = new QWidget;
334 QGridLayout* pathsLayout = new QGridLayout; 349 QGridLayout* pathsLayout = new QGridLayout;
338 ulong row = 0; 353 ulong row = 0;
339 for (const extProgInfo& info : g_extProgInfo) { 354 for (const extProgInfo& info : g_extProgInfo) {
340 QLabel* icon = new QLabel, 355 QLabel* icon = new QLabel,
341 *progLabel = new QLabel (info.name); 356 *progLabel = new QLabel (info.name);
342 QLineEdit* input = new QLineEdit; 357 QLineEdit* input = new QLineEdit;
343 QPushButton* setPathButton = new QPushButton (); 358 QPushButton* setPathButton = new QPushButton;
344 359
345 icon->setPixmap (getIcon (info.iconname)); 360 icon->setPixmap (getIcon (info.iconname));
346 input->setText (info.path->value); 361 input->setText (info.path->value);
347 setPathButton->setIcon (getIcon ("folder")); 362 setPathButton->setIcon (getIcon ("folder"));
348 info.input = input; 363 info.input = input;
352 367
353 pathsLayout->addWidget (icon, row, 0); 368 pathsLayout->addWidget (icon, row, 0);
354 pathsLayout->addWidget (progLabel, row, 1); 369 pathsLayout->addWidget (progLabel, row, 1);
355 pathsLayout->addWidget (input, row, 2); 370 pathsLayout->addWidget (input, row, 2);
356 pathsLayout->addWidget (setPathButton, row, 3); 371 pathsLayout->addWidget (setPathButton, row, 3);
372
373 #ifndef _WIN32
374 QCheckBox* wineBox = new QCheckBox ("Wine");
375 wineBox->setChecked (*info.wine);
376 info.wineBox = wineBox;
377 pathsLayout->addWidget (wineBox, row, 4);
378 #endif
379
357 ++row; 380 ++row;
358 } 381 }
359 382
360 pathsBox->setLayout (pathsLayout); 383 pathsBox->setLayout (pathsLayout);
361 layout->addWidget (pathsBox); 384 layout->addWidget (pathsBox);
626 str filter; 649 str filter;
627 #ifdef _WIN32 650 #ifdef _WIN32
628 filter = "Applications (*.exe)(*.exe);;All files (*.*)(*.*)"; 651 filter = "Applications (*.exe)(*.exe);;All files (*.*)(*.*)";
629 #endif // WIN32 652 #endif // WIN32
630 653
631 str fpath = QFileDialog::getOpenFileName (this, fmt ("Path to %1", info->name), "", filter); 654 str fpath = QFileDialog::getOpenFileName (this, fmt ("Path to %1", info->name), *info->path, filter);
632 if (fpath.length () == 0) 655 if (fpath.length () == 0)
633 return; 656 return;
634 657
635 info->input->setText (fpath); 658 info->input->setText (fpath);
636 } 659 }

mercurial