diff -Naur qt-x11-opensource-desktop-4.0.0-orig/src/gui/kernel/qaction.cpp qt-x11-opensource-desktop-4.0.0/src/gui/kernel/qaction.cpp
--- qt-x11-opensource-desktop-4.0.0-orig/src/gui/kernel/qaction.cpp 2005-06-24 10:54:44.000000000 -0300
+++ qt-x11-opensource-desktop-4.0.0/src/gui/kernel/qaction.cpp 2005-07-05 15:00:03.000000000 -0300
@@ -592,12 +592,23 @@
QString QAction::toolTip() const
{
Q_D(const QAction);
- if (d->tooltip.isEmpty()) {
- if (!d->text.isEmpty())
- return qt_strippedText(d->text);
- return d->iconText;
+
+ QString s = d->tooltip;
+ if (s.isEmpty())
+ s = qt_strippedText(d->text);
+
+ if (!isEnabled()) {
+ QString reason = disableReason();
+ if (!reason.isEmpty()) {
+ QString fmt("
%1
"
+ "This item is not available for use.
"
+ "The reason it has been disabled is:
"
+ "%2
");
+ s = fmt.arg(s, reason);
+ }
}
- return d->tooltip;
+
+ return s;
}
/*!
@@ -624,7 +635,18 @@
QString QAction::statusTip() const
{
Q_D(const QAction);
- return d->statustip;
+
+ QString s = d->statustip;
+
+ if (!isEnabled()) {
+ QString reason = disableReason();
+ if (!reason.isEmpty()) {
+ QString fmt("%1%2Disabled:%3");
+ s = fmt.arg(s, (s.isEmpty() ? "" : " "), reason);
+ }
+ }
+
+ return s;
}
/*!
@@ -653,6 +675,25 @@
return d->whatsthis;
}
+/*!
+ \property QAction::disableReason
+ \brief the action's disable reason
+*/
+void QAction::setDisableReason(const QString &reason)
+{
+ Q_D(QAction);
+ if (d->disablereason == reason)
+ return;
+
+ d->disablereason = reason;
+ d->sendDataChanged();
+}
+
+QString QAction::disableReason() const
+{
+ Q_D(const QAction);
+ return d->disablereason;
+}
/*!
\property QAction::checkable
@@ -771,6 +812,21 @@
return d->enabled;
}
+
+void QAction::disable(const QString &reason)
+{
+ setEnabled(false);
+ setDisableReason(reason);
+}
+
+void QAction::enable()
+{
+ setDisableReason("");
+ setEnabled(true);
+}
+
+
+
/*!
\property QAction::visible
\brief whether the action can be seen (e.g. in menus and toolbars)
diff -Naur qt-x11-opensource-desktop-4.0.0-orig/src/gui/kernel/qaction.h qt-x11-opensource-desktop-4.0.0/src/gui/kernel/qaction.h
--- qt-x11-opensource-desktop-4.0.0-orig/src/gui/kernel/qaction.h 2005-06-24 10:54:44.000000000 -0300
+++ qt-x11-opensource-desktop-4.0.0/src/gui/kernel/qaction.h 2005-07-05 14:12:00.000000000 -0300
@@ -53,6 +53,7 @@
Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip)
Q_PROPERTY(QString statusTip READ statusTip WRITE setStatusTip)
Q_PROPERTY(QString whatsThis READ whatsThis WRITE setWhatsThis)
+ Q_PROPERTY(QString disableReason READ disableReason WRITE setDisableReason)
Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut)
Q_PROPERTY(QFont font READ font WRITE setFont)
Q_PROPERTY(Qt::ShortcutContext shortcutContext READ shortcutContext WRITE setShortcutContext)
@@ -93,6 +94,9 @@
void setWhatsThis(const QString &what);
QString whatsThis() const;
+ void setDisableReason(const QString &reason);
+ QString disableReason() const;
+
QMenu *menu() const;
void setMenu(QMenu *menu);
@@ -153,6 +157,8 @@
void toggle();
void setEnabled(bool);
inline void setDisabled(bool b) { setEnabled(!b); }
+ void disable(const QString &reason);
+ void enable();
void setVisible(bool);
signals:
diff -Naur qt-x11-opensource-desktop-4.0.0-orig/src/gui/kernel/qaction_p.h qt-x11-opensource-desktop-4.0.0/src/gui/kernel/qaction_p.h
--- qt-x11-opensource-desktop-4.0.0-orig/src/gui/kernel/qaction_p.h 2005-06-24 10:54:44.000000000 -0300
+++ qt-x11-opensource-desktop-4.0.0/src/gui/kernel/qaction_p.h 2005-07-05 14:10:50.000000000 -0300
@@ -64,6 +64,7 @@
QString tooltip;
QString statustip;
QString whatsthis;
+ QString disablereason;
QKeySequence shortcut;
QVariant userData;
int shortcutId;
diff -Naur qt-x11-opensource-desktop-4.0.0-orig/src/gui/kernel/qwidget.cpp qt-x11-opensource-desktop-4.0.0/src/gui/kernel/qwidget.cpp
--- qt-x11-opensource-desktop-4.0.0-orig/src/gui/kernel/qwidget.cpp 2005-06-24 10:54:45.000000000 -0300
+++ qt-x11-opensource-desktop-4.0.0/src/gui/kernel/qwidget.cpp 2005-07-05 15:00:20.000000000 -0300
@@ -1831,6 +1831,18 @@
d->setEnabled_helper(enable);
}
+void QWidget::disable(const QString &reason)
+{
+ setEnabled(false);
+ setDisableReason(reason);
+}
+
+void QWidget::enable()
+{
+ setDisableReason("");
+ setEnabled(true);
+}
+
void QWidgetPrivate::setEnabled_helper(bool enable)
{
Q_Q(QWidget);
@@ -4917,20 +4929,26 @@
break;
case QEvent::Enter:
- if (d->statusTip.size()) {
- QStatusTipEvent tip(d->statusTip);
- QApplication::sendEvent(const_cast(this), &tip);
- }
- enterEvent(e);
- break;
+ {
+ QString s = statusTip();
+ if (s.size()) {
+ QStatusTipEvent tip(s);
+ QApplication::sendEvent(const_cast(this), &tip);
+ }
+ enterEvent(e);
+ }
+ break;
case QEvent::Leave:
- if (d->statusTip.size()) {
- QString empty;
- QStatusTipEvent tip(empty);
- QApplication::sendEvent(const_cast(this), &tip);
- }
- leaveEvent(e);
+ {
+ QString s = statusTip();
+ if (s.size()) {
+ QString empty;
+ QStatusTipEvent tip(empty);
+ QApplication::sendEvent(const_cast(this), &tip);
+ }
+ leaveEvent(e);
+ }
break;
case QEvent::HoverEnter:
@@ -5113,10 +5131,14 @@
break;
case QEvent::ToolTip:
- if (d->toolTip.size() && isActiveWindow())
- QToolTip::showText(static_cast(e)->globalPos(), d->toolTip, this);
- else
- e->ignore();
+ {
+ QString s = toolTip();
+ if (!s.isEmpty() && isActiveWindow())
+ QToolTip::showText(static_cast(e)->globalPos(),
+ s, this);
+ else
+ e->ignore();
+ }
break;
#ifndef QT_NO_WHATSTHIS
@@ -6585,7 +6607,21 @@
QString QWidget::toolTip() const
{
Q_D(const QWidget);
- return d->toolTip;
+
+ QString s = d->toolTip;
+
+ if (!isEnabled()) {
+ QString reason = disableReason();
+ if (!reason.isEmpty()) {
+ QString fmt("%1
"
+ "This item is not available for use.
"
+ "The reason it has been disabled is:
"
+ "%2
");
+ s = fmt.arg(s, reason);
+ }
+ }
+
+ return s;
}
/*!
@@ -6604,7 +6640,18 @@
QString QWidget::statusTip() const
{
Q_D(const QWidget);
- return d->statusTip;
+
+ QString s = d->statusTip;
+
+ if (!isEnabled()) {
+ QString reason = disableReason();
+ if (!reason.isEmpty()) {
+ QString fmt("%1%2Disabled:%3");
+ s = fmt.arg(s, (s.isEmpty() ? "" : " "), reason);
+ }
+ }
+
+ return s;
}
/*!
@@ -6626,6 +6673,33 @@
return d->whatsThis;
}
+/*!
+ \property QWidget::disableReason
+
+ \brief the reason why widget is disabled.
+
+ \sa QWidget::toolTip QWidget::statusTip QWidget::disabled()
+*/
+void QWidget::setDisableReason(const QString &s)
+{
+ Q_D(QWidget);
+ d->disableReason = s;
+}
+
+QString QWidget::disableReason() const
+{
+ Q_D(const QWidget);
+
+ QString s = d->disableReason;
+
+ if (s.isEmpty()) {
+ QWidget *p = (QWidget*)parent();
+ if (p != NULL)
+ s = p->disableReason();
+ }
+ return s;
+}
+
#ifndef QT_NO_ACCESSIBILITY
/*!
\property QWidget::accessibleName
diff -Naur qt-x11-opensource-desktop-4.0.0-orig/src/gui/kernel/qwidget.h qt-x11-opensource-desktop-4.0.0/src/gui/kernel/qwidget.h
--- qt-x11-opensource-desktop-4.0.0-orig/src/gui/kernel/qwidget.h 2005-06-24 10:54:45.000000000 -0300
+++ qt-x11-opensource-desktop-4.0.0/src/gui/kernel/qwidget.h 2005-07-04 17:43:19.000000000 -0300
@@ -166,6 +166,7 @@
Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip)
Q_PROPERTY(QString statusTip READ statusTip WRITE setStatusTip)
Q_PROPERTY(QString whatsThis READ whatsThis WRITE setWhatsThis)
+ Q_PROPERTY(QString disableReason READ disableReason WRITE setDisableReason)
#ifndef QT_NO_ACCESSIBILITY
Q_PROPERTY(QString accessibleName READ accessibleName WRITE setAccessibleName)
Q_PROPERTY(QString accessibleDescription READ accessibleDescription WRITE setAccessibleDescription)
@@ -203,6 +204,8 @@
public slots:
void setEnabled(bool);
void setDisabled(bool);
+ void disable(const QString &);
+ void enable();
void setWindowModified(bool);
// Widget coordinates
@@ -315,6 +318,9 @@
void setWhatsThis(const QString &);
QString whatsThis() const;
+ void setDisableReason(const QString &);
+ QString disableReason() const;
+
#ifndef QT_NO_ACCESSIBILITY
QString accessibleName() const;
void setAccessibleName(const QString &name);
@@ -581,6 +587,7 @@
QWidget(QWidgetPrivate &d, QWidget* parent, Qt::WFlags f);
private:
+
bool testAttribute_helper(Qt::WidgetAttribute) const;
friend class QApplication;
diff -Naur qt-x11-opensource-desktop-4.0.0-orig/src/gui/kernel/qwidget_p.h qt-x11-opensource-desktop-4.0.0/src/gui/kernel/qwidget_p.h
--- qt-x11-opensource-desktop-4.0.0-orig/src/gui/kernel/qwidget_p.h 2005-06-24 10:54:45.000000000 -0300
+++ qt-x11-opensource-desktop-4.0.0/src/gui/kernel/qwidget_p.h 2005-07-04 17:50:09.000000000 -0300
@@ -305,7 +305,7 @@
int leftmargin, topmargin, rightmargin, bottommargin;
// ### TODO: reorganize private/extra/topextra to save memory
QPointer compositeChildGrab;
- QString toolTip, statusTip, whatsThis;
+ QString toolTip, statusTip, whatsThis, disableReason;
QString accessibleName, accessibleDescription;
#ifndef QT_NO_PALETTE