# HG changeset patch # User Oranger # Date 1322919396 -3600 # Node ID ad5741c252b9708e79033c01dc454e9b45ec3192 # Parent afb7ef0c1c6e01156923aaff80e83d2c7c13bd39 GCI task: describez diff -r afb7ef0c1c6e -r ad5741c252b9 QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Sat Dec 03 12:00:32 2011 +0100 +++ b/QTfrontend/hwform.cpp Sat Dec 03 14:36:36 2011 +0100 @@ -82,6 +82,7 @@ #include "bgwidget.h" #include "xfire.h" #include "drawmapwidget.h" +#include "mouseoverfilter.h" #include "HWDataManager.h" @@ -282,6 +283,23 @@ wBackground->startAnimation(); } + //Install all eventFilters : + + MouseOverFilter *filter = new MouseOverFilter(); + filter->setUi(&ui); + + QList widgets; + + for (int i=0; i < ui.Pages->count(); i++) + { + widgets = ui.Pages->widget(i)->findChildren(); + + for (int i=0; i < widgets.size(); i++) + { + widgets.at(i)->installEventFilter(filter); + } + } + PagesStack.push(ID_PAGE_MAIN); GoBack(); } diff -r afb7ef0c1c6e -r ad5741c252b9 QTfrontend/hwform.h --- a/QTfrontend/hwform.h Sat Dec 03 12:00:32 2011 +0100 +++ b/QTfrontend/hwform.h Sat Dec 03 14:36:36 2011 +0100 @@ -61,6 +61,8 @@ void updateXfire(); void PlayDemoQuick(const QString & demofilename); void exit(); + void setButtonDescription(QString desc); + void backDescription(); private slots: void GoToSaves(); diff -r afb7ef0c1c6e -r ad5741c252b9 QTfrontend/ui/mouseoverfilter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/mouseoverfilter.cpp Sat Dec 03 14:36:36 2011 +0100 @@ -0,0 +1,48 @@ +#include "mouseoverfilter.h" +#include "ui/page/AbstractPage.h" +#include "ui_hwform.h" + +#include +#include +#include +#include + +MouseOverFilter::MouseOverFilter(QObject *parent) : + QObject(parent) +{ +} + +bool MouseOverFilter::eventFilter( QObject *dist, QEvent *event ) +{ + if (event->type() == QEvent::Enter) + { + QWidget * widget = dynamic_cast(dist); + + abstractpage = qobject_cast(ui->Pages->currentWidget()); + + if (widget->whatsThis() != NULL) + abstractpage->setButtonDescription(widget->whatsThis()); + else if (widget->toolTip() != NULL) + abstractpage->setButtonDescription(widget->toolTip()); + + return true; + } + else if (event->type() == QEvent::Leave) + { + abstractpage = qobject_cast(ui->Pages->currentWidget()); + + if (abstractpage->getDefautDescription() != NULL) + { + abstractpage->setButtonDescription( * abstractpage->getDefautDescription()); + } + else + abstractpage->setButtonDescription(""); + } + + return false; +} + +void MouseOverFilter::setUi(Ui_HWForm *uiForm) +{ + ui = uiForm; +} diff -r afb7ef0c1c6e -r ad5741c252b9 QTfrontend/ui/mouseoverfilter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/mouseoverfilter.h Sat Dec 03 14:36:36 2011 +0100 @@ -0,0 +1,27 @@ +#ifndef MOUSEOVERFILTER_H +#define MOUSEOVERFILTER_H + +#include + +#include "ui_hwform.h" +#include "ui/page/AbstractPage.h" + +class MouseOverFilter : public QObject +{ + Q_OBJECT +public: + explicit MouseOverFilter(QObject *parent = 0); + void setUi(Ui_HWForm *uiForm); +protected: + bool eventFilter( QObject *dist, QEvent *event ); +signals: + +public slots: + +private: + Ui_HWForm *ui; + AbstractPage* abstractpage; + +}; + +#endif // MOUSEOVERFILTER_H diff -r afb7ef0c1c6e -r ad5741c252b9 QTfrontend/ui/page/AbstractPage.cpp --- a/QTfrontend/ui/page/AbstractPage.cpp Sat Dec 03 12:00:32 2011 +0100 +++ b/QTfrontend/ui/page/AbstractPage.cpp Sat Dec 03 14:36:36 2011 +0100 @@ -22,10 +22,14 @@ */ #include "AbstractPage.h" +#include +#include +#include AbstractPage::AbstractPage(QWidget* parent) { Q_UNUSED(parent); + defautDesc = new QString(); font14 = new QFont("MS Shell Dlg", 14); } @@ -45,12 +49,20 @@ pageLayout->addWidget(btnBack, 1, 0, 1, 1, Qt::AlignLeft | Qt::AlignBottom); // add body layout as defined by the subclass - pageLayout->addLayout(bodyLayoutDefinition(), 0, 0, 1, 2); + pageLayout->addLayout(bodyLayoutDefinition(), 0, 0, 1, 3); + + descLabel = new QLabel(); + descLabel->setAlignment(Qt::AlignCenter); + descLabel->setWordWrap(true); + descLabel->setOpenExternalLinks(true); + descLabel->setFixedHeight(50); + descLabel->setStyleSheet("font-size: 16px"); + pageLayout->addWidget(descLabel, 1, 1); // add footer layout QLayout * fld = footerLayoutDefinition(); if (fld != NULL) - pageLayout->addLayout(fld, 1, 1); + pageLayout->addLayout(fld, 1, 2); // connect signals connect(btnBack, SIGNAL(clicked()), this, SIGNAL(goBack())); @@ -97,3 +109,19 @@ { btnBack->setVisible(visible); } + +void AbstractPage::setButtonDescription(QString desc) +{ + descLabel->setText(desc); +} + +void AbstractPage::setDefautDescription(QString text) +{ + *defautDesc = text; + descLabel->setText(text); +} + +QString * AbstractPage::getDefautDescription() +{ + return defautDesc; +} diff -r afb7ef0c1c6e -r ad5741c252b9 QTfrontend/ui/page/AbstractPage.h --- a/QTfrontend/ui/page/AbstractPage.h Sat Dec 03 12:00:32 2011 +0100 +++ b/QTfrontend/ui/page/AbstractPage.h Sat Dec 03 14:36:36 2011 +0100 @@ -56,6 +56,27 @@ { Q_OBJECT + public: + + /** + * @brief Changes the desc text (should not be called manualy) + * + * @param desc the description of the widget focused + */ + void setButtonDescription(QString desc); + + /** + * @brief Changes the desc defaut text + * + * @param text the defaut desc + */ + void setDefautDescription(QString text); + + /** + * @brief Get the desc defaut text + */ + QString * getDefautDescription(); + signals: /** * @brief This signal is emitted when going back to the previous is @@ -153,6 +174,9 @@ QFont * font14; ///< used font + QLabel * descLabel; ///< text description + QString * defautDesc; + private: QPushButton * btnBack; ///< back button diff -r afb7ef0c1c6e -r ad5741c252b9 QTfrontend/ui/page/pagemain.cpp --- a/QTfrontend/ui/page/pagemain.cpp Sat Dec 03 12:00:32 2011 +0100 +++ b/QTfrontend/ui/page/pagemain.cpp Sat Dec 03 14:36:36 2011 +0100 @@ -91,10 +91,14 @@ if(!isDevBuild) { - mainNote->setText(QLabel::tr("Tip: ") + randomTip()); + //mainNote->setText(QLabel::tr("Tip: ") + randomTip()); + setDefautDescription(QLabel::tr("Tip: ") + randomTip()); } else - mainNote->setText(QLabel::tr("This development build is 'work in progress' and may not be compatible with other versions of the game. Some features might be broken or incomplete. Use at your own risk!")); + { + setDefautDescription(QLabel::tr("This development build is 'work in progress' and may not be compatible with other versions of the game. Some features might be broken or incomplete. Use at your own risk!")); + //mainNote->setText(QLabel::tr("This development build is 'work in progress' and may not be compatible with other versions of the game. Some features might be broken or incomplete. Use at your own risk!")); + } } diff -r afb7ef0c1c6e -r ad5741c252b9 project_files/hedgewars.pro --- a/project_files/hedgewars.pro Sat Dec 03 12:00:32 2011 +0100 +++ b/project_files/hedgewars.pro Sat Dec 03 14:36:36 2011 +0100 @@ -95,7 +95,9 @@ ../QTfrontend/ui_hwform.h \ ../QTfrontend/KB.h \ ../QTfrontend/hwconsts.h \ - ../QTfrontend/sdlkeys.h + ../QTfrontend/sdlkeys.h \ + ../QTfrontend/mouseoverfilter.h \ + ../QTfrontend/ui/mouseoverfilter.h SOURCES += ../QTfrontend/model/ammoSchemeModel.cpp \ ../QTfrontend/model/themesmodel.cpp \ @@ -169,7 +171,8 @@ ../QTfrontend/util/SDLInteraction.cpp \ ../QTfrontend/team.cpp \ ../QTfrontend/ui_hwform.cpp \ - ../QTfrontend/hwconsts.cpp + ../QTfrontend/hwconsts.cpp \ + ../QTfrontend/ui/mouseoverfilter.cpp win32 { SOURCES += ../QTfrontend/xfire.cpp