summaryrefslogtreecommitdiffstats
path: root/quanta/plugins/quantapluginconfig.cpp
blob: 02bb37249e6b31d5061d8f686d522e22d0a108a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/***************************************************************************
                          quantapluginconfig.cpp  -  description
                             -------------------
    begin                : Sat Sep 21 2002
    copyright            : (C) 2002 by Marc Britton <consume@optushome.com.au>
                           (C) 2003-2004 by Andras Mantia <amantia@kde.org>
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

/* KDE INCLUDES */
#include <kdialogbase.h>
#include <tdefiledialog.h>
#include <kmessagebox.h>
#include <klocale.h>
#include <kicondialog.h>

/* QT INCLUDES */
#include <tqpushbutton.h>
#include <tqcheckbox.h>
#include <tqlineedit.h>
#include <tqstring.h>
#include <tqstringlist.h>
#include <tqcombobox.h>
#include <tqwidgetstack.h>

/* OTHER INCLUDES */
#include "quantapluginconfig.h"
#include "quantaplugin.h"
#include "pluginconfig.h"

QuantaPluginConfig::QuantaPluginConfig(TQWidget *a_parent, const char *a_name)
  : KDialogBase(a_parent, a_name, true, i18n("Configure Plugin"), KDialogBase::Ok | KDialogBase::Cancel)
{
  m_pluginConfigWidget = new PluginConfig(this);

  TQStringList windows;
  i18n("Message Area Tab");
  windows << i18n("Editor Tab") << i18n("Separate Toolview");
  m_pluginConfigWidget->outputWindow->insertStringList(windows);
  m_pluginConfigWidget->iconButton->setStrictIconSize(false);

  connect(m_pluginConfigWidget->pluginName, TQT_SIGNAL(textChanged(const TQString &)), this, TQT_SLOT(nameChanged(const TQString &)));
  connect(m_pluginConfigWidget->locationButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(selectLocation()));

  setMainWidget(m_pluginConfigWidget);
}

QuantaPluginConfig::~QuantaPluginConfig()
{
}

void QuantaPluginConfig::accept()
{
  if(m_pluginConfigWidget->validateCheckBox->isChecked())
  {
    bool isValid = QuantaPlugin::validatePluginInfo(m_pluginConfigWidget->pluginName->text(), m_pluginConfigWidget->location->text(), m_pluginConfigWidget->pluginFileName->text(), m_pluginConfigWidget->outputWindow->currentText());

    if(!isValid)
    {
      int answer = KMessageBox::questionYesNo(this, i18n("The plugin information you entered appears to be invalid. Are you sure you want to apply these settings?"), i18n("Invalid Plugin"), KStdGuiItem::apply(), i18n("Do Not Apply"));

      if(answer == KMessageBox::No)
        return;
    }
  }
  KDialogBase::accept();
}

/** Gets the plugin location */
void QuantaPluginConfig::selectLocation()
{
  TQString pluginLocation = KFileDialog::getExistingDirectory(TQString(), this, i18n("Select Plugin Folder"));
  if(!pluginLocation.isNull())
  {
    m_pluginConfigWidget->location->setText(pluginLocation);
  }
}

void QuantaPluginConfig::nameChanged(const TQString &a_text)
{
  TQString text = a_text;
  text = "lib" + text + ".la";
  m_pluginConfigWidget->pluginFileName->setText(text.lower());
}

#include "quantapluginconfig.moc"