23 #ifndef OVERLAYWINDOWMANAGER_P_H_
24 #define OVERLAYWINDOWMANAGER_P_H_
29 #include <QGestureEvent>
30 #include <QGraphicsObject>
36 #include "Localization.h"
50 , m_qp_pillPmo(p_mainPixmap)
51 , m_qp_iconPmo(p_iconPixmap)
56 setCacheMode(QGraphicsItem::DeviceCoordinateCache);
58 m_boundingRect = m_geom.adjusted(-0.5,-0.5,0.5,0.5);
61 m_qp_pillPmo->resize(m_geom.size().toSize());
65 QFont font(qFromUtf8Stl(Settings::LunaSettings()->fontQuicklaunch), 18);
66 font.setPixelSize(18);
67 font.setStyle(QFont::StyleOblique);
68 QString title = qFromUtf8Stl(LOCALIZED(
"Just type..."));
70 QRect textBounds(0, 0, m_boundingRect.width(), m_boundingRect.height());
71 textBounds.adjust(20,0,-45,0);
73 QFontMetrics metrics(font);
74 title = metrics.elidedText(title, Qt::ElideRight, textBounds.width());
76 int width = metrics.width(title);
80 m_textPix = QPixmap(width + 20, textBounds.height());
81 m_textPix.fill(Qt::transparent);
82 painter.begin(&m_textPix);
83 painter.setPen(Qt::white);
84 painter.setFont(font);
85 painter.setOpacity(0.8);
86 painter.drawText(textBounds, title, QTextOption(Qt::AlignLeft|Qt::AlignVCenter));
90 grabGesture(Qt::TapGesture);
95 ungrabGesture(Qt::TapGesture);
100 if (event->type() == QEvent::GestureOverride) {
106 else if (event->type() == QEvent::Gesture) {
108 QGestureEvent* ge =
static_cast<QGestureEvent*
>(event);
109 QGesture* g = ge->gesture(Qt::TapGesture);
110 if (g && g->state() == Qt::GestureFinished && canInteract()) {
114 return QGraphicsObject::sceneEvent(event);
124 return m_boundingRect;
141 m_iconPos = QPointF(m_geom.right()-iconGeom.width()-rightOffset,
142 m_geom.top()+(m_geom.height()-iconGeom.height())/2.0);
152 prepareGeometryChange();
153 QSize newSize = QSize((width < 2 ? 2 : width - (width %2)),(height < 2 ? 2 : height - (height %2)));
155 m_boundingRect = m_geom.adjusted(-0.5,-0.5,0.5,0.5);
158 m_qp_pillPmo->resize(newSize);
166 #define SEARCH_PILL_TIPS_WIDTH 50
168 virtual void paint(QPainter* painter,
const QStyleOptionGraphicsItem*, QWidget*)
174 m_qp_pillPmo->paint(painter,m_geom.topLeft());
178 m_qp_iconPmo->paint(painter,m_iconPos);
180 painter->drawPixmap(m_textPos, m_textPix);
189 bool canInteract() {
return opacity() == 1.0; }
192 QPointer<PixmapObject> m_qp_pillPmo;
193 QPointer<PixmapObject> m_qp_iconPmo;
198 QRectF m_boundingRect;