From de5b228d370dd7775dc535fa8c985eefb35677d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Mon, 28 Jun 2004 14:28:11 +0000 Subject: [PATCH] Warn about overly generic window specifications. svn path=/trunk/kdebase/kwin/; revision=324274 --- kcmkwin/kwinrules/ruleswidget.cpp | 27 +++++++++++++++++++++++++-- kcmkwin/kwinrules/ruleswidget.h | 1 + 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/kcmkwin/kwinrules/ruleswidget.cpp b/kcmkwin/kwinrules/ruleswidget.cpp index 3bf7455bf1..f89a303b20 100644 --- a/kcmkwin/kwinrules/ruleswidget.cpp +++ b/kcmkwin/kwinrules/ruleswidget.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include "../../rules.h" @@ -415,7 +416,7 @@ Rules* RulesWidget::rules() const rules->types = 0; bool all_types = true; for( int i = 0; - i <= 9; + i < types->count(); ++i ) if( !types->isSelected( i )) all_types = false; @@ -513,6 +514,26 @@ void RulesWidget::detected( bool ok ) detect_dlg = NULL; } +bool RulesWidget::finalCheck() + { + bool all_types = true; + for( int i = 0; + i < types->count(); + ++i ) + if( !types->isSelected( i )) + all_types = false; + if( wmclass_match->currentItem() == Rules::UnimportantMatch && all_types ) + { + if( KMessageBox::warningContinueCancel( topLevelWidget(), + i18n( "You have specified the window class as unimportant.\n" + "This means the settings will possibly apply to windows from all applications. " + "If you really want to create a generic setting, it is recommended you at least " + "limit the window types to avoid special window types." )) != KMessageBox::Continue ) + return false; + } + return true; + } + RulesDialog::RulesDialog( QWidget* parent, const char* name ) : KDialogBase( parent, name, true, "", Ok | Cancel ) { @@ -530,8 +551,10 @@ Rules* RulesDialog::edit( Rules* r ) void RulesDialog::accept() { - KDialogBase::accept(); + if( !widget->finalCheck()) + return; rules = widget->rules(); + KDialogBase::accept(); } } // namespace diff --git a/kcmkwin/kwinrules/ruleswidget.h b/kcmkwin/kwinrules/ruleswidget.h index e96765b619..4e7b09265a 100644 --- a/kcmkwin/kwinrules/ruleswidget.h +++ b/kcmkwin/kwinrules/ruleswidget.h @@ -38,6 +38,7 @@ class RulesWidget RulesWidget( QWidget* parent = NULL, const char* name = NULL ); void setRules( Rules* r ); Rules* rules() const; + bool finalCheck(); signals: void changed( bool state ); protected slots: