File indexing completed on 2024-04-21 04:02:38

0001 /*
0002     SPDX-FileCopyrightText: 2012 Christian Krippendorf <Coding@Christian-Krippendorf.de>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef SELECTIONANIMATION_H
0008 #define SELECTIONANIMATION_H
0009 
0010 // Qt
0011 #include <QTimer>
0012 
0013 // Forward declarations...
0014 template <class T>
0015 class QList;
0016 class GameItem;
0017 
0018 /**
0019  * A class for animating GameItems with the help of selection.
0020  *
0021  * @author Christian Krippendorf */
0022 class SelectionAnimation : public QTimer
0023 {
0024     Q_OBJECT
0025 
0026 public:
0027     explicit SelectionAnimation(QObject * parent = nullptr);
0028     ~SelectionAnimation() override;
0029 
0030     /**
0031      * Set the count of repetitions.
0032      *
0033      * @param repetitions The number of repetitions. */
0034     void setRepetitions(int repetitions);
0035 
0036     /**
0037      * Set the animation speed in milliseconds.
0038      *
0039      * @param animationSpeed The animation speed in milliseconds. */
0040     void setAnimationSpeed(int animationSpeed);
0041 
0042     /**
0043      * Get the animation speed in milliseconds.
0044      *
0045      * @return Get the animation speed in milliseconds. */
0046     int getAnimationSpeed() const;
0047 
0048     /**
0049      * Get the number of repetitions set.
0050      *
0051      * @return The number of repetitions. */
0052     int getRepetitions() const;
0053 
0054     /**
0055      * Add the GameItems that should be selected.
0056      *
0057      * @param gameItem The game item that should be selected. */
0058     void addGameItem(GameItem * gameItem);
0059 
0060     /**
0061      * Get all the game items.
0062      *
0063      * @return A list of game items. */
0064     QList<GameItem *> getGameItems() const;
0065 
0066     /**
0067      * Override of QTimer. */
0068     void start();
0069 
0070     /**
0071      * Override of QTimer. */
0072     void stop();
0073 
0074 public Q_SLOTS:
0075 
0076 Q_SIGNALS:
0077 
0078 private Q_SLOTS:
0079     /**
0080      * The timeout occurred. */
0081     void timeoutOccurred();
0082 
0083 private:
0084     /**
0085      * Set the selection state of all game items.
0086      *
0087      * @param selected True if all items should be selected and false for deselecting all items. */
0088     void setSelectedGameItems(bool selected);
0089 
0090     int m_animationSpeed;
0091     int m_repetitions;
0092     int m_finishedRepetitions;
0093     bool m_itemsSelected;
0094 
0095     QList<GameItem *> * m_gameItems;
0096 };
0097 
0098 #endif // SELECTIONANIMATION_H