File indexing completed on 2024-10-13 03:43:43

0001 /*
0002     SPDX-FileCopyrightText: 2003 Marco Krüger <grisuji@gmx.de>
0003     SPDX-FileCopyrightText: 2003 Ian Wadham <iandw.au@gmail.com>
0004     SPDX-FileCopyrightText: 2009 Ian Wadham <iandw.au@gmail.com>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #ifndef KGRSELECTOR_H
0010 #define KGRSELECTOR_H
0011 
0012 #include <QDialog>
0013 #include <QList>
0014 #include <QTreeWidget>
0015 #include <QTreeWidgetItem>
0016 
0017 /**
0018 @author Ian Wadham and Marco Krüger
0019 */
0020 
0021 class KGrGameData;
0022 class KGrThumbNail;
0023 class KGrGameListItem;
0024 class KGrGameIO;
0025 class QSpinBox;
0026 class QScrollBar;
0027 class QPushButton;
0028 class QLabel;
0029 class QTextEdit;
0030 
0031 /******************************************************************************/
0032 /*******************    DIALOG TO SELECT A GAME AND LEVEL   *******************/
0033 /******************************************************************************/
0034 
0035 class KGrSLDialog : public QDialog
0036 {
0037 Q_OBJECT
0038 public:
0039     KGrSLDialog (int action, int requestedLevel, int gameIndex,
0040                  QList<KGrGameData *> & gameList,
0041                  const QString & pSystemDir, const QString & pUserDir,
0042                  QWidget * parent = nullptr);
0043     ~KGrSLDialog() override;
0044 
0045     bool selectLevel (int & selectedGame, int & selectedLevel);
0046 
0047 Q_SIGNALS:
0048     void editNameAndHint();
0049 
0050 private Q_SLOTS:
0051     void slSetGames (int cIndex);
0052     void slGame();
0053     void slShowLevel (int i);
0054     void slUpdate (const QString & text);
0055     void slPaintLevel();
0056     void slotHelp();                // Will replace KDE slotHelp().
0057 
0058 private:
0059     void                setupWidgets();
0060 
0061     int         slAction;
0062     QList<KGrGameData *> myGameList;    // List of games.
0063     int         defaultGame;
0064     int         defaultLevel;
0065     int         slGameIndex;
0066     QString             systemDir;
0067     QString             userDir;
0068     QWidget *       slParent;
0069 
0070     QLabel *        gameL;
0071     QTreeWidget *   games;
0072     QLabel *        gameN;
0073     QLabel *        gameD;
0074     QTextEdit *     gameAbout;
0075 
0076     QLabel *        numberL;
0077     QSpinBox *      display;
0078     QScrollBar *    number;
0079     QPushButton *   levelNH;
0080     QLabel *        slName;
0081     KGrThumbNail *  thumbNail;
0082 };
0083 
0084 /*******************************************************************************
0085 *************************  ITEM FOR THE LIST OF GAMES  *************************
0086 *******************************************************************************/
0087 
0088 class KGrGameListItem : public QTreeWidgetItem
0089 {
0090 public:
0091     explicit KGrGameListItem (const QStringList & data, const int internalId = -1);
0092     int id() const;
0093     void setId (const int internalId);
0094 private:
0095     int mInternalId;
0096 };
0097 
0098 /******************************************************************************/
0099 /**********************    CLASS TO DISPLAY THUMBNAIL   ***********************/
0100 /******************************************************************************/
0101 
0102 class KGrThumbNail : public QFrame
0103 {
0104 public:
0105     explicit KGrThumbNail (QWidget *parent = nullptr);
0106     ~KGrThumbNail() override;
0107 
0108     void setLevelData (const QString& dir, const QString& prefix,
0109                        int level, QLabel * sln);
0110 
0111     static QColor backgroundColor;
0112     static QColor brickColor;
0113     static QColor ladderColor;
0114     static QColor poleColor;
0115 
0116 protected:
0117     void paintEvent (QPaintEvent * event) override; // Draw a preview of a level.
0118 
0119 private:
0120     KGrGameIO * io;
0121     QByteArray  levelName;
0122     QByteArray  levelLayout;
0123     QLabel *    lName;              // Place to write level-name.
0124 };
0125 
0126 #endif