Author: sh-sh-sh
Date: Thu Jul 12 16:26:13 2007
New Revision: 39368
URL: http://svn.opensuse.org/viewcvs/yast?rev=39368&view=rev
Log:
use new helper widget
Modified:
branches/tmp/sh/mod-ui/qt/src/YQInputField.cc
branches/tmp/sh/mod-ui/qt/src/YQInputField.h
branches/tmp/sh/mod-ui/qt/src/YQWidgetCaption.cc
Modified: branches/tmp/sh/mod-ui/qt/src/YQInputField.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQInputField.cc?rev=39368&r1=39367&r2=39368&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQInputField.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQInputField.cc Thu Jul 12 16:26:13 2007
@@ -20,7 +20,6 @@
#include
-#include
#define y2log_component "qt-ui"
#include
@@ -33,6 +32,7 @@
#include "YQInputField.h"
#include "YQi18n.h"
#include "YQSignalBlocker.h"
+#include "YQWidgetCaption.h"
// Include low-level X headers AFTER Qt headers:
// X.h pollutes the global namespace (!!!) with pretty useless #defines
@@ -58,15 +58,13 @@
setSpacing( YQWidgetSpacing );
setMargin( YQWidgetMargin );
- _qt_label = new QLabel( fromUTF8( label ), this );
- _qt_label->setTextFormat( QLabel::PlainText );
-
- if ( label.empty() )
- _qt_label->hide();
-
+ _caption = new YQWidgetCaption( this, label );
+ YUI_CHECK_NEW( _caption );
+
_qt_lineEdit = new YQRawLineEdit( this );
+ YUI_CHECK_NEW( _qt_lineEdit );
- _qt_label->setBuddy( _qt_lineEdit );
+ _caption->setBuddy( _qt_lineEdit );
connect( _qt_lineEdit, SIGNAL( textChanged( const QString & ) ),
this, SLOT ( changed ( const QString & ) ) );
@@ -117,9 +115,9 @@
int YQInputField::preferredWidth()
{
int minSize = shrinkable() ? 20 : 200;
- int hintWidth = _qt_label->sizeHint().width();
+ int hintWidth = _caption->sizeHint().width();
- if ( ! _qt_label->isVisible() )
+ if ( ! _caption->isVisible() )
hintWidth = 0;
return max( minSize, hintWidth );
@@ -140,19 +138,7 @@
void YQInputField::setLabel( const string & label )
{
- _qt_label->setText( fromUTF8(label ) );
-
- if ( label.empty() )
- {
- if ( _qt_label->isVisible() )
- _qt_label->hide();
- }
- else
- {
- if ( _qt_label->isHidden() )
- _qt_label->show();
- }
-
+ _caption->setText( label );
YInputField::setLabel( label );
}
@@ -237,7 +223,7 @@
// In particular, please don't translate this to death in German.
// Simply leave it.
- _qt_label->setText( _( "CapsLock!" ) );
+ _caption->setText( _( "CapsLock!" ) );
_displayingCapsLockWarning = true;
}
@@ -251,7 +237,7 @@
if ( _qt_lineEdit->echoMode() == QLineEdit::Normal )
return;
- _qt_label->setText( fromUTF8( label() ) );
+ _caption->setText( label() );
_displayingCapsLockWarning = false;
}
Modified: branches/tmp/sh/mod-ui/qt/src/YQInputField.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQInputField.h?rev=39368&r1=39367&r2=39368&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQInputField.h (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQInputField.h Thu Jul 12 16:26:13 2007
@@ -27,11 +27,11 @@
#include "YInputField.h"
-class QString;
-class QLabel;
class QLineEdit;
+class QString;
class QY2CharValidator;
class YQRawLineEdit;
+class YQWidgetCaption;
using std::string;
@@ -150,7 +150,7 @@
// Data members
//
- QLabel * _qt_label;
+ YQWidgetCaption * _caption;
YQRawLineEdit * _qt_lineEdit;
QY2CharValidator * _validator;
bool _shrinkable;
Modified: branches/tmp/sh/mod-ui/qt/src/YQWidgetCaption.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQWidgetCaption.cc?rev=39368&r1=39367&r2=39368&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQWidgetCaption.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQWidgetCaption.cc Thu Jul 12 16:26:13 2007
@@ -17,6 +17,9 @@
/-*/
+#define y2log_component "qt-ui"
+#include
+
#include "YQWidgetCaption.h"
#include "utf8.h"
@@ -26,14 +29,25 @@
: QLabel( fromUTF8( text ), parent )
{
setTextFormat( QLabel::PlainText );
- handleVisibility( text );
+
+ // Can't use handleVisibility() here because in the constructor the widget
+ // will always not be visible yet.
+
+ if ( text.empty() )
+ hide();
}
YQWidgetCaption::YQWidgetCaption( QWidget * parent, const QString & text )
: QLabel( text, parent )
{
- handleVisibility( text );
+ setTextFormat( QLabel::PlainText );
+
+ // Can't use handleVisibility() here because in the constructor the widget
+ // will always not be visible yet.
+
+ if ( text.isEmpty() )
+ hide();
}
@@ -72,11 +86,15 @@
{
if ( textIsEmpty )
{
+ y2debug( "Text is empty" );
+
if ( isVisible() )
hide();
}
else
{
+ y2debug( "Text is non-empty" );
+
if ( isHidden() )
show();
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org