2011-04-28 22:48:53 +02:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
|
|
|
|
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DIDYOUMEAN_H
|
|
|
|
#define DIDYOUMEAN_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
class QToolButton;
|
|
|
|
|
|
|
|
class DidYouMean : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public:
|
2011-04-28 22:48:53 +02:00
|
|
|
DidYouMean(QWidget* buddy, QWidget* parent);
|
|
|
|
|
|
|
|
static const int kPadding;
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public slots:
|
2011-04-29 16:01:59 +02:00
|
|
|
void SetCorrection(const QString& correction);
|
|
|
|
void Show(const QString& correction);
|
2011-04-28 22:48:53 +02:00
|
|
|
|
|
|
|
signals:
|
2011-04-29 16:01:59 +02:00
|
|
|
void Accepted(const QString& correction);
|
2011-04-28 22:48:53 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
protected:
|
2011-04-28 22:48:53 +02:00
|
|
|
void paintEvent(QPaintEvent*);
|
|
|
|
void showEvent(QShowEvent*);
|
|
|
|
void mouseReleaseEvent(QMouseEvent* e);
|
|
|
|
bool eventFilter(QObject* object, QEvent* event);
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2011-04-28 22:48:53 +02:00
|
|
|
void UpdateGeometry();
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2011-04-28 22:48:53 +02:00
|
|
|
QWidget* buddy_;
|
2011-04-29 16:01:59 +02:00
|
|
|
QString correction_;
|
2011-04-28 22:48:53 +02:00
|
|
|
|
|
|
|
QToolButton* close_;
|
2011-04-29 16:01:59 +02:00
|
|
|
|
|
|
|
QFont normal_font_;
|
|
|
|
QFont correction_font_;
|
|
|
|
QFont press_enter_font_;
|
2012-07-01 23:55:54 +02:00
|
|
|
|
|
|
|
QString did_you_mean_;
|
|
|
|
QString press_enter_;
|
|
|
|
|
2012-07-02 00:49:37 +02:00
|
|
|
// Size of the text to display, according to QFonts above.
|
2012-07-01 23:55:54 +02:00
|
|
|
// Stored here to avoid to recompute them each time
|
|
|
|
int did_you_mean_size_;
|
|
|
|
int press_enter_size_;
|
2011-04-28 22:48:53 +02:00
|
|
|
};
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
#endif // DIDYOUMEAN_H
|