Author: sh-sh-sh
Date: Fri Nov 30 17:12:18 2007
New Revision: 42560
URL: http://svn.opensuse.org/viewcvs/yast?rev=42560&view=rev
Log:
Added default button handling
Modified:
trunk/core/libyui/src/YDialog.cc
trunk/core/libyui/src/YDialog.h
trunk/core/libyui/src/YPushButton.cc
Modified: trunk/core/libyui/src/YDialog.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YDialog.cc?rev=42560&r1=42559&r2=42560&view=diff
==============================================================================
--- trunk/core/libyui/src/YDialog.cc (original)
+++ trunk/core/libyui/src/YDialog.cc Fri Nov 30 17:12:18 2007
@@ -22,6 +22,7 @@
#include
#include "YDialog.h"
#include "YShortcutManager.h"
+#include "YPushButton.h"
#include "YUIException.h"
using std::string;
@@ -43,6 +44,7 @@
YDialogType dialogType;
YDialogColorMode colorMode;
bool shortcutCheckPostponed;
+ YPushButton * defaultButton;
};
@@ -115,6 +117,26 @@
}
+YPushButton *
+YDialog::defaultButton() const
+{
+ return priv->defaultButton;
+}
+
+
+void
+YDialog::setDefaultButton( YPushButton * newDefaultButton )
+{
+ if ( newDefaultButton && priv->defaultButton ) // already have one?
+ {
+ y2error( "Too many `opt(`default) PushButtons: [%s]",
+ newDefaultButton->label().c_str() );
+ }
+
+ priv->defaultButton = newDefaultButton;
+}
+
+
void
YDialog::setInitialSize()
{
Modified: trunk/core/libyui/src/YDialog.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YDialog.h?rev=42560&r1=42559&r2=42560&view=diff
==============================================================================
--- trunk/core/libyui/src/YDialog.h (original)
+++ trunk/core/libyui/src/YDialog.h Fri Nov 30 17:12:18 2007
@@ -25,9 +25,10 @@
class YMacroRecorder;
class YShortcutManager;
+class YPushButton;
class YDialogPrivate;
-// See YTypes.h for enum YDialogType and enum YDialogColorMode
+// See YTypes.h for enum YDialogType and enum YDialogColorMode
class YDialog : public YSingleChildContainerWidget
@@ -62,7 +63,7 @@
* Delete the topmost dialog.
*
* Will throw a YUINoDialogException if there is no dialog and 'doThrow' is
- * 'true'.
+ * 'true'.
*
* Returns 'true' if there is another open dialog after deleting,
* 'false' if there is none.
@@ -84,7 +85,7 @@
* Return the current (topmost) dialog.
*
* If there is none, throw a YUINoDialogException if 'doThrow' is 'true'
- * and return 0 if 'doThrow' is false.
+ * and return 0 if 'doThrow' is false.
**/
static YDialog * currentDialog( bool doThrow = true );
@@ -132,6 +133,27 @@
bool shortcutCheckPostponed() const;
/**
+ * Return this dialog's default button: The button that is activated when
+ * the user hits [Return] anywhere in this dialog. Note that this is not
+ * the same as the button that currently has the keyboard focus.
+ *
+ * This might return 0 if there is no default button.
+ **/
+ YPushButton * defaultButton() const;
+
+ /**
+ * Set this dialog's default button (the button that is activated when
+ * the user hits [Return] anywhere in this dialog). 0 means no default
+ * button.
+ *
+ * There should be no more than one default button in a dialog.
+ *
+ * Derived classes are free to overwrite this method, but they should
+ * call this base class method in the new implementation.
+ **/
+ virtual void setDefaultButton( YPushButton * defaultButton );
+
+ /**
* Implements the ui command queryWidget
**/
YCPValue queryWidget( const YCPSymbol & property );
@@ -139,7 +161,7 @@
protected:
static std::stack _dialogStack;
-
+
private:
ImplPtr<YDialogPrivate> priv;
Modified: trunk/core/libyui/src/YPushButton.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YPushButton.cc?rev=42560&r1=42559&r2=42560&view=diff
==============================================================================
--- trunk/core/libyui/src/YPushButton.cc (original)
+++ trunk/core/libyui/src/YPushButton.cc Fri Nov 30 17:12:18 2007
@@ -22,6 +22,7 @@
#include "YUI.h"
#include "YApplication.h"
+#include "YDialog.h"
#include "YUISymbols.h"
#include "YPushButton.h"
@@ -57,7 +58,12 @@
YPushButton::~YPushButton()
{
- // NOP
+ YDialog * dialog = findDialog();
+
+ if ( dialog && dialog->defaultButton() == this )
+ {
+ dialog->setDefaultButton( 0 );
+ }
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org