[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdevelop/parts/fileview
From:       Laurent Montel <montel () kde ! org>
Date:       2003-11-09 11:58:29
[Download RAW message or body]

CVS commit by mlaurent: 

Disable ok button when lines are empty.
Use kstdguiitem


  M +14 -6     addfilegroupdlg.cpp   1.5
  M +5 -3      addfilegroupdlg.h   1.3


--- kdevelop/parts/fileview/addfilegroupdlg.cpp  #1.4:1.5
@@ -15,4 +15,5 @@
 #include <kbuttonbox.h>
 #include <klocale.h>
+#include <kstdguiitem.h>
 
 #include "addfilegroupdlg.h"
@@ -26,4 +27,5 @@ AddFileGroupDialog::AddFileGroupDialog(c
     title_edit->setFocus();
     title_label->setBuddy(title_edit);
+    connect( title_edit, SIGNAL( textChanged ( const QString & ) ), this, SLOT( slotTextChanged() ) );
 
     QLabel *pattern_label = new QLabel(i18n("&Pattern:"), this);
@@ -32,5 +34,5 @@ AddFileGroupDialog::AddFileGroupDialog(c
     QFontMetrics fm(pattern_edit->fontMetrics());
     pattern_edit->setMinimumWidth(fm.width('X')*35);
-    
+    connect( pattern_edit, SIGNAL( textChanged ( const QString & ) ), this, SLOT( slotTextChanged() ) );
     QVBoxLayout *layout = new QVBoxLayout(this, 10);
     
@@ -48,11 +50,12 @@ AddFileGroupDialog::AddFileGroupDialog(c
     KButtonBox *buttonbox = new KButtonBox(this);
     buttonbox->addStretch();
-    QPushButton *ok = buttonbox->addButton(i18n("&OK"));
-    QPushButton *cancel = buttonbox->addButton(i18n("Cancel"));
-    ok->setDefault(true);
-    connect( ok, SIGNAL(clicked()), this, SLOT(accept()) );
+    m_pOk = buttonbox->addButton(KStdGuiItem::ok().text());
+    QPushButton *cancel = buttonbox->addButton(KStdGuiItem::cancel().text());
+    m_pOk->setDefault(true);
+    connect( m_pOk, SIGNAL(clicked()), this, SLOT(accept()) );
     connect( cancel, SIGNAL(clicked()), this, SLOT(reject()) );
     buttonbox->layout();
     layout->addWidget(buttonbox, 0);
+    slotTextChanged();
 }
 
@@ -60,4 +63,9 @@ AddFileGroupDialog::AddFileGroupDialog(c
 AddFileGroupDialog::~AddFileGroupDialog()
 {}
+
+void AddFileGroupDialog::slotTextChanged()
+{
+    m_pOk->setEnabled( !title_edit->text().isEmpty() && !pattern_edit->text().isEmpty() );
+}
 
 #include "addfilegroupdlg.moc"

--- kdevelop/parts/fileview/addfilegroupdlg.h  #1.2:1.3
@@ -15,5 +15,5 @@
 #include <qdialog.h>
 #include <qlineedit.h>
-
+class QPushButton;
 
 class AddFileGroupDialog : public QDialog
@@ -29,8 +29,10 @@ public: 
     QString pattern() const
         { return pattern_edit->text(); }
-    
+ private slots:
+    void slotTextChanged();
 private:
     QLineEdit *title_edit;
     QLineEdit *pattern_edit;
+    QPushButton *m_pOk;
 };
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic