toolprops.ui.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /****************************************************************************
  2. ** ui.h extension file, included from the uic-generated form implementation.
  3. **
  4. ** If you want to add, delete, or rename functions or slots, use
  5. ** Qt Designer to update this file, preserving your code.
  6. **
  7. ** You should not define a constructor or destructor in this file.
  8. ** Instead, write your code in functions called init() and destroy().
  9. ** These will automatically be called by the form's constructor and
  10. ** destructor.
  11. *****************************************************************************/
  12. /*
  13. ktigcc - TIGCC IDE for KDE
  14. Copyright (C) 2006 Kevin Kofler
  15. This program is free software; you can redistribute it and/or modify
  16. it under the terms of the GNU General Public License as published by
  17. the Free Software Foundation; either version 2, or (at your option)
  18. any later version.
  19. This program is distributed in the hope that it will be useful,
  20. but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. GNU General Public License for more details.
  23. You should have received a copy of the GNU General Public License
  24. along with this program; if not, write to the Free Software Foundation,
  25. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  26. */
  27. #include <ktextedit.h>
  28. #include <kurl.h>
  29. #include <kurlrequester.h>
  30. #include <kfiledialog.h>
  31. #include <kprocess.h>
  32. #include "ktigcc.h"
  33. void ToolProperties::init()
  34. {
  35. if (toolIndex>=0) {
  36. Tool &tool=tempTools[toolIndex];
  37. toolTitle->setText(tool.title);
  38. commandLine->setText(tool.commandLine);
  39. if (!tool.workingDirectory.isEmpty())
  40. workingDirectory->setKURL(KURL::fromPathOrURL(tool.workingDirectory));
  41. runInTerminal->setChecked(tool.runInTerminal);
  42. }
  43. }
  44. void ToolProperties::accept()
  45. {
  46. Tool tool(toolTitle->text(),commandLine->text(),
  47. workingDirectory->url().isEmpty()?QString():
  48. KURL(workingDirectory->url()).path(),runInTerminal->isChecked());
  49. if (toolIndex>=0)
  50. tempTools[toolIndex]=tool;
  51. else
  52. tempTools.append(tool);
  53. QDialog::accept();
  54. }
  55. void ToolProperties::validate()
  56. {
  57. okButton->setEnabled(!toolTitle->text().isEmpty()
  58. && !commandLine->text().isEmpty()
  59. && (workingDirectory->url().isEmpty()
  60. || (KURL(workingDirectory->url()).isValid()
  61. && KURL(workingDirectory->url()).isLocalFile())));
  62. }
  63. void ToolProperties::browseButton_clicked()
  64. {
  65. QString ret=KFileDialog::getOpenFileName("/usr/bin",
  66. "application/x-executable application/x-executable-script",this,
  67. "Choose executable");
  68. if (!ret.isEmpty())
  69. commandLine->setText(KProcess::quote(ret));
  70. }