File indexing completed on 2024-10-13 03:44:24

0001 /*
0002     SPDX-FileCopyrightText: 2007 Paolo Capriotti <p.capriotti@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef WELCOMESCREEN_H
0008 #define WELCOMESCREEN_H
0009 
0010 #include <QHash>
0011 #include <QFont>
0012 #include <QGraphicsRectItem>
0013 
0014 #include "grid.h"
0015 
0016 class Button;
0017 
0018 class WelcomeScreen : public QObject, public QGraphicsRectItem 
0019 {
0020 Q_OBJECT
0021     typedef QHash<Coord, Button*> Buttons;
0022     Buttons m_buttons;
0023     QFont m_font;
0024     QSizeF m_size;
0025     
0026     Button* m_clicked;
0027     Button* m_hover;
0028     bool m_active;
0029 public:
0030     explicit WelcomeScreen(const QFont& font);
0031     
0032     void resize(const QSizeF&);
0033     
0034     Button* addButton(int x, int y, const QIcon& icon, const QString& text);
0035     void removeButton(int x, int y);
0036     void moveButton(int x1, int y1, int x2, int y2);
0037     void clearButtons();
0038     
0039     void onMousePress(Button *button);
0040     void onMouseRelease(Button *button);
0041     void onMouseMove(Button *button);
0042     void onMouseLeave();
0043     
0044     bool active() const { return m_active; }
0045     void show();
0046     
0047 public Q_SLOTS:
0048     void hide();
0049     void fadeOut();
0050     void refresh();
0051     
0052 Q_SIGNALS:
0053     void clicked(Button*);
0054     void shown();
0055     void hidden();
0056 };
0057 
0058 #endif // WELCOMESCREEN_H