summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-09-29 06:17:38 (GMT)
committerMontel Laurent <montel@kde.org>2016-09-29 06:17:38 (GMT)
commit9c1856de1351aaea8477bea8148cd10c7171f075 (patch)
tree799426a8dbe99d4bcbb103e15bee362eb96706c7
parent04412532d5093fe127ffe7fbb7f34badc70c2026 (diff)
Allow to enable/disable ok button when name is empty or not
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp1
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditdialog.cpp9
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditdialog.h3
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditwidget.cpp1
-rw-r--r--plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditwidget.h2
5 files changed, 16 insertions, 0 deletions
diff --git a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp
index 530a5ee..b0399a3 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp
+++ b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternalconfigurewidget.cpp
@@ -174,6 +174,7 @@ void ViewerPluginExternalConfigureWidget::save()
const ViewerPluginExternalScriptInfo &scriptInfo = item->scriptInfo();
QString filenamepath = scriptInfo.fileName();
if (filenamepath.isEmpty()) {
+
//TODO add correct filenamepath
}
KDesktopFile desktopFile(filenamepath);
diff --git a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditdialog.cpp b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditdialog.cpp
index aa6b084..5fac18d 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditdialog.cpp
+++ b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditdialog.cpp
@@ -22,6 +22,7 @@
#include <KLocalizedString>
#include <QDialogButtonBox>
#include <QVBoxLayout>
+#include <QPushButton>
ViewerPluginExternalEditDialog::ViewerPluginExternalEditDialog(QWidget *parent)
: QDialog(parent)
@@ -31,12 +32,15 @@ ViewerPluginExternalEditDialog::ViewerPluginExternalEditDialog(QWidget *parent)
mEditWidget = new ViewerPluginExternalEditWidget(this);
mEditWidget->setObjectName(QStringLiteral("editwidget"));
mainLayout->addWidget(mEditWidget);
+ connect(mEditWidget, &ViewerPluginExternalEditWidget::nameChanged, this, &ViewerPluginExternalEditDialog::slotNameChanged);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
buttonBox->setObjectName(QStringLiteral("buttonbox"));
connect(buttonBox, &QDialogButtonBox::accepted, this, &ViewerPluginExternalEditDialog::slotAccepted);
connect(buttonBox, &QDialogButtonBox::rejected, this, &ViewerPluginExternalEditDialog::reject);
mainLayout->addWidget(buttonBox);
+ mOkButton = buttonBox->button(QDialogButtonBox::Ok);
+ mOkButton->setEnabled(false);
}
ViewerPluginExternalEditDialog::~ViewerPluginExternalEditDialog()
@@ -44,6 +48,11 @@ ViewerPluginExternalEditDialog::~ViewerPluginExternalEditDialog()
}
+void ViewerPluginExternalEditDialog::slotNameChanged(const QString &name)
+{
+ mOkButton->setEnabled(!name.trimmed().isEmpty());
+}
+
void ViewerPluginExternalEditDialog::slotAccepted()
{
mEditWidget->save();
diff --git a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditdialog.h b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditdialog.h
index 2b04bc4..acb39b9 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditdialog.h
+++ b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditdialog.h
@@ -25,6 +25,7 @@
#include "../viewerpluginexternalscriptinfo.h"
class ViewerPluginExternalEditWidget;
+class QPushButton;
class ViewerPluginExternalEditDialog : public QDialog
{
Q_OBJECT
@@ -36,8 +37,10 @@ public:
ViewerPluginExternalScriptInfo scriptInfo() const;
private:
+ void slotNameChanged(const QString &name);
void slotAccepted();
ViewerPluginExternalEditWidget *mEditWidget;
+ QPushButton *mOkButton;
};
#endif // VIEWERPLUGINEXTERNALEDITDIALOG_H
diff --git a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditwidget.cpp b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditwidget.cpp
index cfd8641..d901890 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditwidget.cpp
+++ b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditwidget.cpp
@@ -47,6 +47,7 @@ ViewerPluginExternalEditWidget::ViewerPluginExternalEditWidget(QWidget *parent)
mExecutable = new QLineEdit(this);
mExecutable->setObjectName(QStringLiteral("executable"));
mainLayout->addRow(i18n("Executable:"), mExecutable);
+ connect(mName, &QLineEdit::textChanged, this, &ViewerPluginExternalEditWidget::nameChanged);
}
ViewerPluginExternalEditWidget::~ViewerPluginExternalEditWidget()
diff --git a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditwidget.h b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditwidget.h
index a91abf0..a551520 100644
--- a/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditwidget.h
+++ b/plugins/messageviewerplugins/externalscriptplugin/configuredialog/viewerpluginexternaleditwidget.h
@@ -34,6 +34,8 @@ public:
ViewerPluginExternalScriptInfo scriptInfo() const;
void save();
+Q_SIGNALS:
+ void nameChanged(const QString &name);
private:
ViewerPluginExternalScriptInfo mScriptInfo;
QLineEdit *mName;