File indexing completed on 2024-05-19 04:07:51
0001 /* 0002 SPDX-FileCopyrightText: 2009, 2010 Stefan Majewsky <majewsky@gmx.net> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef PALAPELI_TEXTUREHELPER_H 0008 #define PALAPELI_TEXTUREHELPER_H 0009 0010 class QGraphicsScene; 0011 #include <QStandardItemModel> 0012 0013 namespace Palapeli 0014 { 0015 //NOTE: Singleton, needs to be initialized in main(). 0016 class TextureHelper : public QStandardItemModel 0017 { 0018 Q_OBJECT 0019 public: 0020 enum CustomRoles { 0021 BrushRole = Qt::UserRole + 1, 0022 IdentifierRole = Qt::UserRole + 2 0023 }; 0024 0025 static Palapeli::TextureHelper* instance(); 0026 int currentIndex() const; 0027 public Q_SLOTS: 0028 void readSettings(); 0029 void addScene(QGraphicsScene* scene); 0030 void removeScene(QObject* object); 0031 private: 0032 TextureHelper(); 0033 static QPixmap render(const QString& filePath); 0034 0035 QList<QObject*> m_scenes; 0036 int m_currentIndex; 0037 QBrush m_currentBrush; 0038 0039 static const QSize DefaultThumbnailSize; 0040 static const QSize DefaultPixmapSize; 0041 }; 0042 } 0043 0044 #endif // PALAPELI_TEXTUREHELPER_H