├── .gitignore ├── DialogMaster ├── LICENSE ├── QCompressor ├── qcompressor.cpp ├── qcompressor.h └── qcompressor.pri ├── QElementModel ├── qelementmodel.cpp ├── qelementmodel.h └── qelementmodel.pri ├── QFlowLayout ├── qflowlayout.cpp ├── qflowlayout.h └── qflowlayout.pri ├── QProgressGroup ├── progressbaradapter.cpp ├── progressbaradapter.h ├── qprogressgroup.cpp ├── qprogressgroup.h ├── qprogressgroup.pri ├── systemtrayprogressadapter.cpp ├── systemtrayprogressadapter.h ├── wintaskbarprogressadapter.cpp └── wintaskbarprogressadapter.h ├── QPropertySettings ├── changedmonitorobject.cpp ├── changedmonitorobject.h ├── qpropertysettings.cpp ├── qpropertysettings.h └── qpropertysettings.pri ├── QSslServer ├── qsslserver.cpp ├── qsslserver.h └── qsslserver.pri ├── QUrlValidator ├── QtUtils ├── README.md └── qtutils.pri /.gitignore: -------------------------------------------------------------------------------- 1 | # C++ objects and libs 2 | 3 | *.slo 4 | *.lo 5 | *.o 6 | *.a 7 | *.la 8 | *.lai 9 | *.so 10 | *.dll 11 | *.dylib 12 | 13 | # Qt-es 14 | 15 | /.qmake.cache 16 | /.qmake.stash 17 | *.pro.user 18 | *.pro.user.* 19 | *.qbs.user 20 | *.qbs.user.* 21 | *.moc 22 | moc_*.cpp 23 | qrc_*.cpp 24 | ui_*.h 25 | Makefile* 26 | *build-* 27 | 28 | # QtCreator 29 | 30 | *.autosave 31 | 32 | # QtCtreator Qml 33 | *.qmlproject.user 34 | *.qmlproject.user.* 35 | 36 | # QtCtreator CMake 37 | CMakeLists.txt.user 38 | 39 | -------------------------------------------------------------------------------- /DialogMaster: -------------------------------------------------------------------------------- 1 | https://github.com/Skycoder42/DialogMaster -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Felix Barz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /QCompressor/qcompressor.cpp: -------------------------------------------------------------------------------- 1 | #include "qcompressor.h" 2 | #include 3 | #include 4 | 5 | QCompressor::QCompressor(QIODevice *outDevice, QObject *parent) : 6 | QCompressor(outDevice, 100*MB, 9, parent) 7 | {} 8 | 9 | QCompressor::QCompressor(QByteArray *outArray, QObject *parent) : 10 | QCompressor(outArray, 100*MB, 9, parent) 11 | {} 12 | 13 | QCompressor::QCompressor(QIODevice *outDevice, quint32 blockSize, int compressionRate, QObject *parent) : 14 | QObject(parent), 15 | blockSize(blockSize), 16 | compressionRate(compressionRate), 17 | outDevice(outDevice), 18 | blockBuffer(new uchar[blockSize]), 19 | bufferPos(0), 20 | allOk(true) 21 | { 22 | if(outDevice->isOpen()) { 23 | QIODevice::OpenMode mode = outDevice->openMode(); 24 | if(!mode.testFlag(QIODevice::WriteOnly)) { 25 | outDevice->close(); 26 | outDevice->open(mode | QIODevice::WriteOnly); 27 | } 28 | } else 29 | outDevice->open(QIODevice::WriteOnly); 30 | } 31 | 32 | QCompressor::QCompressor(QByteArray *outArray, quint32 blockSize, int compressionRate, QObject *parent) : 33 | QCompressor(new QBuffer(outArray, this), blockSize, compressionRate, parent) 34 | {} 35 | 36 | QCompressor::~QCompressor() 37 | { 38 | delete this->blockBuffer; 39 | } 40 | 41 | void QCompressor::addData(QByteArray data) 42 | { 43 | QBuffer buff(&data); 44 | buff.open(QIODevice::ReadOnly); 45 | this->addData(&buff); 46 | buff.close(); 47 | } 48 | 49 | void QCompressor::addData(QIODevice *device) 50 | { 51 | while(device->bytesAvailable() > 0) { 52 | qint64 read = device->read((char*)(this->blockBuffer + this->bufferPos), 53 | this->blockSize - this->bufferPos); 54 | if(read == -1) { 55 | this->allOk = false; 56 | return; 57 | } 58 | this->bufferPos += (quint32)read; 59 | 60 | if(this->bufferPos == this->blockSize) 61 | this->writeBlock(); 62 | } 63 | } 64 | 65 | bool QCompressor::finish() 66 | { 67 | this->writeBlock(); 68 | return this->allOk; 69 | } 70 | 71 | void QCompressor::writeBlock() 72 | { 73 | QByteArray compressed = qCompress(this->blockBuffer, (int)this->bufferPos, this->compressionRate); 74 | quint32 cSize = compressed.size(); 75 | cSize = qToBigEndian(cSize); 76 | if(this->outDevice->write((char*)&cSize, sizeof(quint32)) == sizeof(quint32)) { 77 | if(this->outDevice->write(compressed) != compressed.size()) 78 | this->allOk = false; 79 | } else 80 | this->allOk = false; 81 | this->bufferPos = 0; 82 | } 83 | 84 | 85 | QDecompressor::QDecompressor(QIODevice *outDevice, QObject *parent) : 86 | QObject(parent), 87 | outDevice(outDevice), 88 | blockBuffer(NULL), 89 | blockSize(0), 90 | blockSizeBuffer(), 91 | bufferPos(0), 92 | allOk(true) 93 | { 94 | if(outDevice->isOpen()) { 95 | QIODevice::OpenMode mode = outDevice->openMode(); 96 | if(!mode.testFlag(QIODevice::WriteOnly)) { 97 | outDevice->close(); 98 | outDevice->open(mode | QIODevice::WriteOnly); 99 | } 100 | } else 101 | outDevice->open(QIODevice::WriteOnly); 102 | } 103 | 104 | QDecompressor::QDecompressor(QByteArray *outArray, QObject *parent) : 105 | QDecompressor(new QBuffer(outArray, this), parent) 106 | {} 107 | 108 | QDecompressor::~QDecompressor() 109 | { 110 | delete this->blockBuffer; 111 | } 112 | 113 | void QDecompressor::addData(QByteArray data) 114 | { 115 | QBuffer buff(&data); 116 | buff.open(QIODevice::ReadOnly); 117 | this->addData(&buff); 118 | buff.close(); 119 | } 120 | 121 | void QDecompressor::addData(QIODevice *device) 122 | { 123 | while(device->bytesAvailable() > 0) { 124 | if(this->blockSize == 0) { 125 | this->blockSizeBuffer += device->read(sizeof(quint32) - 126 | this->blockSizeBuffer.size()); 127 | if(this->blockSizeBuffer.size() == sizeof(quint32)) { 128 | this->blockSize = qFromBigEndian((uchar*)this->blockSizeBuffer.data()); 129 | this->blockSizeBuffer.clear(); 130 | this->blockBuffer = new uchar[this->blockSize]; 131 | } else 132 | return; 133 | } 134 | 135 | qint64 read = device->read((char*)(this->blockBuffer + this->bufferPos), 136 | this->blockSize - this->bufferPos); 137 | if(read == -1) { 138 | this->allOk = false; 139 | return; 140 | } 141 | this->bufferPos += (quint32)read; 142 | 143 | if(this->bufferPos == this->blockSize) 144 | this->writeBlock(); 145 | } 146 | } 147 | 148 | bool QDecompressor::finish() 149 | { 150 | if(this->blockSize > 0) 151 | this->allOk = false; 152 | return this->allOk; 153 | } 154 | 155 | void QDecompressor::writeBlock() 156 | { 157 | if(this->blockSize > 0) { 158 | QByteArray raw = qUncompress(this->blockBuffer, (int)this->bufferPos); 159 | if(raw.isEmpty()) 160 | this->allOk = false; 161 | else { 162 | if(this->outDevice->write(raw) != raw.size()) 163 | this->allOk = false; 164 | } 165 | delete this->blockBuffer; 166 | this->blockBuffer = NULL; 167 | this->blockSize = 0; 168 | this->bufferPos = 0; 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /QCompressor/qcompressor.h: -------------------------------------------------------------------------------- 1 | #ifndef QCOMPRESSOR_H 2 | #define QCOMPRESSOR_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #define KB 1024ul 9 | #define MB 1048576ul 10 | #define GB 1073741824ul 11 | 12 | class QCompressor : public QObject 13 | { 14 | public: 15 | explicit QCompressor(QIODevice *outDevice, QObject *parent); 16 | explicit QCompressor(QByteArray *outArray, QObject *parent); 17 | explicit QCompressor(QIODevice *outDevice, quint32 blockSize = 100*MB, int compressionRate = 9, QObject *parent = NULL); 18 | explicit QCompressor(QByteArray *outArray, quint32 blockSize = 100*MB, int compressionRate = 9, QObject *parent = NULL); 19 | ~QCompressor(); 20 | 21 | void addData(QByteArray data); 22 | void addData(QIODevice *device); 23 | 24 | bool finish(); 25 | 26 | private: 27 | const quint32 blockSize; 28 | const int compressionRate; 29 | QIODevice *outDevice; 30 | uchar *blockBuffer; 31 | quint32 bufferPos; 32 | bool allOk; 33 | 34 | void writeBlock(); 35 | }; 36 | 37 | class QDecompressor : public QObject 38 | { 39 | public: 40 | explicit QDecompressor(QIODevice *outDevice, QObject *parent = NULL); 41 | explicit QDecompressor(QByteArray *outArray, QObject *parent = NULL); 42 | ~QDecompressor(); 43 | 44 | void addData(QByteArray data); 45 | void addData(QIODevice *device); 46 | 47 | bool finish(); 48 | 49 | private: 50 | QIODevice *outDevice; 51 | uchar *blockBuffer; 52 | quint32 blockSize; 53 | QByteArray blockSizeBuffer; 54 | quint32 bufferPos; 55 | bool allOk; 56 | 57 | void writeBlock(); 58 | }; 59 | 60 | #endif // QCOMPRESSOR_H 61 | -------------------------------------------------------------------------------- /QCompressor/qcompressor.pri: -------------------------------------------------------------------------------- 1 | HEADERS += $$PWD/qcompressor.h 2 | SOURCES += $$PWD/qcompressor.cpp 3 | 4 | INCLUDEPATH += $$PWD 5 | -------------------------------------------------------------------------------- /QElementModel/qelementmodel.cpp: -------------------------------------------------------------------------------- 1 | #include "qelementmodel.h" 2 | #include 3 | 4 | QElementModel::QElementModel(QObject *parent) : 5 | QAbstractListModel(parent), 6 | headerTitle(), 7 | itemRoles(), 8 | roleIndex(Qt::UserRole + 1), 9 | elements() 10 | {} 11 | 12 | QElementModel::QElementModel(const QStringList &roles, QObject *parent) : 13 | QElementModel(parent) 14 | { 15 | this->setRoles(roles); 16 | } 17 | 18 | QVariant QElementModel::headerData(int section, Qt::Orientation orientation, int role) const 19 | { 20 | if(section == 0 && 21 | orientation == Qt::Horizontal && 22 | role == Qt::DisplayRole) 23 | return this->headerTitle; 24 | else 25 | return QVariant(); 26 | } 27 | 28 | int QElementModel::rowCount(const QModelIndex &parent) const 29 | { 30 | if (parent.isValid()) 31 | return 0; 32 | else 33 | return this->elements.size(); 34 | } 35 | 36 | QHash QElementModel::roleNames() const 37 | { 38 | QHash res; 39 | for(auto it = this->itemRoles.constBegin(), end = this->itemRoles.constEnd(); it != end; ++it) 40 | res.insert(it.value(), it.key().toLatin1()); 41 | return res; 42 | } 43 | 44 | QVariant QElementModel::data(const QModelIndex &index, int role) const 45 | { 46 | if (!index.isValid() || 47 | index.column() != 0 || 48 | index.row() < 0 || 49 | index.row() >= this->elements.size()) 50 | return QVariant(); 51 | 52 | auto roleName = this->itemRoles.key(role); 53 | if(roleName.isNull()) 54 | return QVariant(); 55 | else 56 | return this->elements[index.row()]->property(roleName.toLatin1().constData()); 57 | } 58 | 59 | bool QElementModel::setData(const QModelIndex &index, const QVariant &value, int role) 60 | { 61 | if(this->readonly) 62 | return false; 63 | 64 | if (!index.isValid() || 65 | index.column() != 0 || 66 | index.row() < 0 || 67 | index.row() >= this->elements.size()) 68 | return false; 69 | 70 | auto roleName = this->itemRoles.key(role); 71 | if(roleName.isNull()) 72 | return false; 73 | else { 74 | this->elements[index.row()]->setProperty(roleName.toLatin1().constData(), value); 75 | emit dataChanged(index, index, {role}); 76 | return true; 77 | } 78 | } 79 | 80 | Qt::ItemFlags QElementModel::flags(const QModelIndex &index) const 81 | { 82 | if (!index.isValid()) 83 | return Qt::NoItemFlags; 84 | 85 | auto flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemNeverHasChildren; 86 | if(!this->readonly) 87 | flags |= Qt::ItemIsEditable; 88 | return flags; 89 | } 90 | 91 | QObject *QElementModel::element(int index) const 92 | { 93 | return this->elements[index]; 94 | } 95 | 96 | void QElementModel::append(QObject *object, bool takeOwn) 97 | { 98 | auto index = this->elements.size(); 99 | this->beginInsertRows(QModelIndex(), index, index); 100 | this->elements.append(object); 101 | if(takeOwn) 102 | object->setParent(this); 103 | this->endInsertRows(); 104 | } 105 | 106 | QObject *QElementModel::append(QHash fieldMap) 107 | { 108 | auto obj = new QObject(this); 109 | for(auto it = fieldMap.constBegin(), end = fieldMap.constEnd(); it != end; ++it) 110 | obj->setProperty(it.key().toLatin1(), it.value()); 111 | this->append(obj, false); 112 | return obj; 113 | } 114 | 115 | void QElementModel::insert(int index, QObject *object, bool takeOwn) 116 | { 117 | this->beginInsertRows(QModelIndex(), index, index); 118 | this->elements.append(object); 119 | if(takeOwn) 120 | object->setParent(this); 121 | this->endInsertRows(); 122 | } 123 | 124 | QObject *QElementModel::insert(int index, QHash fieldMap) 125 | { 126 | auto obj = new QObject(this); 127 | for(auto it = fieldMap.constBegin(), end = fieldMap.constEnd(); it != end; ++it) 128 | obj->setProperty(it.key().toLatin1(), it.value()); 129 | this->insert(index, obj, false); 130 | return obj; 131 | } 132 | 133 | void QElementModel::remove(int index) 134 | { 135 | this->beginRemoveRows(QModelIndex(), index, index); 136 | auto obj = this->elements.takeAt(index); 137 | if(obj->parent() == this) 138 | obj->deleteLater(); 139 | this->endRemoveRows(); 140 | } 141 | 142 | void QElementModel::move(int fromIndex, int toIndex) 143 | { 144 | if(this->beginMoveRows(QModelIndex(), fromIndex, fromIndex, QModelIndex(), toIndex)) { 145 | this->elements.move(fromIndex, toIndex); 146 | this->endMoveRows(); 147 | } 148 | } 149 | 150 | void QElementModel::reset(bool resetRoles) 151 | { 152 | this->beginResetModel(); 153 | this->elements.clear(); 154 | if(resetRoles) { 155 | this->itemRoles.clear(); 156 | emit rolesChanged({}); 157 | } 158 | this->endResetModel(); 159 | } 160 | 161 | QString QElementModel::header() const 162 | { 163 | return this->headerTitle; 164 | } 165 | 166 | bool QElementModel::isReadonly() const 167 | { 168 | return this->readonly; 169 | } 170 | 171 | QStringList QElementModel::roles() const 172 | { 173 | return this->itemRoles.keys(); 174 | } 175 | 176 | int QElementModel::roleId(QString role) const 177 | { 178 | return this->itemRoles.value(role, -1); 179 | } 180 | 181 | void QElementModel::setHeader(QString header) 182 | { 183 | if (this->headerTitle == header) 184 | return; 185 | 186 | this->headerTitle = header; 187 | emit headerChanged(header); 188 | emit headerDataChanged(Qt::Horizontal, 0, 0); 189 | } 190 | 191 | void QElementModel::setReadonly(bool readonly) 192 | { 193 | if (this->readonly == readonly) 194 | return; 195 | 196 | this->readonly = readonly; 197 | emit readonlyChanged(readonly); 198 | } 199 | 200 | void QElementModel::setRoles(QStringList roles) 201 | { 202 | this->itemRoles.clear(); 203 | foreach(auto role, roles) 204 | this->itemRoles.insert(role, this->roleIndex++); 205 | emit rolesChanged(roles); 206 | } 207 | 208 | void QElementModel::addRole(QString role) 209 | { 210 | this->itemRoles.insert(role, this->roleIndex++); 211 | } 212 | 213 | void QElementModel::removeRole(QString role) 214 | { 215 | this->itemRoles.remove(role); 216 | } 217 | 218 | void QElementModel::initRoles(QMetaObject metaObject, bool includeSuperClass) 219 | { 220 | QStringList propertyNames; 221 | for(auto i = includeSuperClass ? 0 : metaObject.propertyOffset(); i < metaObject.propertyCount(); i++) { 222 | auto property = metaObject.property(i); 223 | propertyNames.append(QString::fromLatin1(property.name())); 224 | } 225 | this->setRoles(propertyNames); 226 | } 227 | 228 | void QElementModel::initRoles(QObject *object, bool includeSuperClass) 229 | { 230 | this->initRoles(*(object->metaObject()), includeSuperClass); 231 | } 232 | -------------------------------------------------------------------------------- /QElementModel/qelementmodel.h: -------------------------------------------------------------------------------- 1 | #ifndef QELEMENTMODEL_H 2 | #define QELEMENTMODEL_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class QElementModel : public QAbstractListModel 9 | { 10 | Q_OBJECT 11 | 12 | Q_PROPERTY(QString header READ header WRITE setHeader NOTIFY headerChanged) 13 | Q_PROPERTY(bool readonly READ isReadonly WRITE setReadonly NOTIFY readonlyChanged) 14 | Q_PROPERTY(QStringList roles READ roles WRITE setRoles NOTIFY rolesChanged) 15 | 16 | public: 17 | explicit QElementModel(QObject *parent = nullptr); 18 | explicit QElementModel(const QStringList &roles, QObject *parent = nullptr); 19 | 20 | QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; 21 | 22 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; 23 | QHash roleNames() const override; 24 | 25 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 26 | bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; 27 | Qt::ItemFlags flags(const QModelIndex& index) const override; 28 | 29 | QObject *element(int index) const; 30 | void append(QObject *object, bool takeOwn = true); 31 | QObject *append(QHash fieldMap); 32 | void insert(int index, QObject *object, bool takeOwn = true); 33 | QObject *insert(int index, QHash fieldMap); 34 | void remove(int index); 35 | void move(int fromIndex, int toIndex); 36 | void reset(bool resetRoles = false); 37 | 38 | QString header() const; 39 | bool isReadonly() const; 40 | QStringList roles() const; 41 | int roleId(QString role) const; 42 | 43 | public slots: 44 | void setHeader(QString header); 45 | void setReadonly(bool readonly); 46 | void setRoles(QStringList roles); 47 | 48 | void addRole(QString role); 49 | void removeRole(QString role); 50 | void initRoles(QMetaObject metaObject, bool includeSuperClass = true); 51 | void initRoles(QObject *object, bool includeSuperClass = true); 52 | 53 | signals: 54 | void headerChanged(QString header); 55 | void readonlyChanged(bool readonly); 56 | void rolesChanged(QStringList roles); 57 | 58 | private: 59 | QString headerTitle; 60 | bool readonly; 61 | QHash itemRoles; 62 | int roleIndex; 63 | 64 | QObjectList elements; 65 | }; 66 | 67 | #endif // QELEMENTMODEL_H 68 | -------------------------------------------------------------------------------- /QElementModel/qelementmodel.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/qelementmodel.h 3 | 4 | SOURCES += \ 5 | $$PWD/qelementmodel.cpp 6 | 7 | INCLUDEPATH += $$PWD 8 | -------------------------------------------------------------------------------- /QFlowLayout/qflowlayout.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the examples of the Qt Toolkit. 7 | ** 8 | ** $QT_BEGIN_LICENSE:BSD$ 9 | ** You may use this file under the terms of the BSD license as follows: 10 | ** 11 | ** "Redistribution and use in source and binary forms, with or without 12 | ** modification, are permitted provided that the following conditions are 13 | ** met: 14 | ** * Redistributions of source code must retain the above copyright 15 | ** notice, this list of conditions and the following disclaimer. 16 | ** * Redistributions in binary form must reproduce the above copyright 17 | ** notice, this list of conditions and the following disclaimer in 18 | ** the documentation and/or other materials provided with the 19 | ** distribution. 20 | ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names 21 | ** of its contributors may be used to endorse or promote products derived 22 | ** from this software without specific prior written permission. 23 | ** 24 | ** 25 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 36 | ** 37 | ** $QT_END_LICENSE$ 38 | ** 39 | ****************************************************************************/ 40 | 41 | #include 42 | #include "qflowlayout.h" 43 | 44 | QFlowLayout::QFlowLayout(QWidget *parent, QMargins margins, int hSpacing, int vSpacing) : 45 | QLayout(parent), 46 | m_hSpace(hSpacing), 47 | m_vSpace(vSpacing) 48 | { 49 | this->setContentsMargins(margins); 50 | } 51 | 52 | QFlowLayout::QFlowLayout(QMargins margins, int hSpacing, int vSpacing) : 53 | QLayout(NULL), 54 | m_hSpace(hSpacing), 55 | m_vSpace(vSpacing) 56 | { 57 | this->setContentsMargins(margins); 58 | } 59 | 60 | QFlowLayout::~QFlowLayout() 61 | { 62 | qDeleteAll(this->itemList); 63 | } 64 | 65 | void QFlowLayout::addItem(QLayoutItem *item) 66 | { 67 | this->itemList.append(item); 68 | this->update(); 69 | } 70 | 71 | void QFlowLayout::insertItem(int pos, QLayoutItem *item) 72 | { 73 | this->itemList.insert(pos, item); 74 | this->update(); 75 | } 76 | 77 | void QFlowLayout::moveItem(int oldPos, int newPos) 78 | { 79 | this->itemList.move(oldPos, newPos); 80 | this->update(); 81 | } 82 | 83 | void QFlowLayout::insertWidget(int pos, QWidget *w) 84 | { 85 | this->addWidget(w); 86 | this->itemList.move(this->itemList.size() - 1, pos); 87 | this->update(); 88 | } 89 | 90 | int QFlowLayout::horizontalSpacing() const 91 | { 92 | if (this->m_hSpace >= 0) 93 | return this->m_hSpace; 94 | else 95 | return this->smartSpacing(QStyle::PM_LayoutHorizontalSpacing); 96 | } 97 | 98 | int QFlowLayout::verticalSpacing() const 99 | { 100 | if (this->m_vSpace >= 0) 101 | return this->m_vSpace; 102 | else 103 | return this->smartSpacing(QStyle::PM_LayoutVerticalSpacing); 104 | } 105 | 106 | int QFlowLayout::count() const 107 | { 108 | return this->itemList.size(); 109 | } 110 | 111 | QLayoutItem *QFlowLayout::itemAt(int index) const 112 | { 113 | return this->itemList.value(index); 114 | } 115 | 116 | QLayoutItem *QFlowLayout::takeAt(int index) 117 | { 118 | if (index >= 0 && index < this->itemList.size()) 119 | return this->itemList.takeAt(index); 120 | else 121 | return 0; 122 | } 123 | 124 | Qt::Orientations QFlowLayout::expandingDirections() const 125 | { 126 | return 0; 127 | } 128 | 129 | bool QFlowLayout::hasHeightForWidth() const 130 | { 131 | return true; 132 | } 133 | 134 | int QFlowLayout::heightForWidth(int width) const 135 | { 136 | int height = this->doLayout(QRect(0, 0, width, 0), true); 137 | return height; 138 | } 139 | 140 | void QFlowLayout::setGeometry(const QRect &rect) 141 | { 142 | this->QLayout::setGeometry(rect); 143 | this->doLayout(rect, false); 144 | } 145 | 146 | QSize QFlowLayout::sizeHint() const 147 | { 148 | return this->minimumSize(); 149 | } 150 | 151 | QSize QFlowLayout::minimumSize() const 152 | { 153 | QSize size; 154 | foreach (QLayoutItem *item, this->itemList) 155 | size = size.expandedTo(item->minimumSize()); 156 | 157 | int left; 158 | int top; 159 | int right; 160 | int bottom; 161 | this->getContentsMargins(&left, &top, &right, &bottom); 162 | size += QSize(left + right, top + bottom); 163 | return size; 164 | } 165 | 166 | int QFlowLayout::doLayout(const QRect &rect, bool testOnly) const 167 | { 168 | int left, top, right, bottom; 169 | this->getContentsMargins(&left, &top, &right, &bottom); 170 | QRect effectiveRect = rect.adjusted(+left, +top, -right, -bottom); 171 | int x = effectiveRect.x(); 172 | int y = effectiveRect.y(); 173 | int lineHeight = 0; 174 | 175 | foreach (QLayoutItem *item, this->itemList) 176 | { 177 | QWidget *wid = item->widget(); 178 | 179 | int spaceX = this->horizontalSpacing(); 180 | if (spaceX == -1) 181 | spaceX = wid->style()->layoutSpacing(QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal); 182 | 183 | int spaceY = this->verticalSpacing(); 184 | if (spaceY == -1) 185 | spaceY = wid->style()->layoutSpacing(QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical); 186 | 187 | int nextX = x + item->sizeHint().width() + spaceX; 188 | if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) 189 | { 190 | x = effectiveRect.x(); 191 | y = y + lineHeight + spaceY; 192 | nextX = x + item->sizeHint().width() + spaceX; 193 | lineHeight = 0; 194 | } 195 | 196 | if (!testOnly) 197 | item->setGeometry(QRect(QPoint(x, y), item->sizeHint())); 198 | 199 | x = nextX; 200 | lineHeight = qMax(lineHeight, item->sizeHint().height()); 201 | } 202 | 203 | return y + lineHeight - rect.y() + bottom; 204 | } 205 | 206 | int QFlowLayout::smartSpacing(QStyle::PixelMetric pm) const 207 | { 208 | QObject *parent = this->parent(); 209 | if (!parent) 210 | return -1; 211 | else if (parent->isWidgetType()) 212 | { 213 | QWidget *pw = static_cast(parent); 214 | return pw->style()->pixelMetric(pm, 0, pw); 215 | } 216 | else 217 | return static_cast(parent)->spacing(); 218 | } 219 | -------------------------------------------------------------------------------- /QFlowLayout/qflowlayout.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 4 | ** Contact: http://www.qt-project.org/legal 5 | ** 6 | ** This file is part of the examples of the Qt Toolkit. 7 | ** 8 | ** $QT_BEGIN_LICENSE:BSD$ 9 | ** You may use this file under the terms of the BSD license as follows: 10 | ** 11 | ** "Redistribution and use in source and binary forms, with or without 12 | ** modification, are permitted provided that the following conditions are 13 | ** met: 14 | ** * Redistributions of source code must retain the above copyright 15 | ** notice, this list of conditions and the following disclaimer. 16 | ** * Redistributions in binary form must reproduce the above copyright 17 | ** notice, this list of conditions and the following disclaimer in 18 | ** the documentation and/or other materials provided with the 19 | ** distribution. 20 | ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names 21 | ** of its contributors may be used to endorse or promote products derived 22 | ** from this software without specific prior written permission. 23 | ** 24 | ** 25 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 36 | ** 37 | ** $QT_END_LICENSE$ 38 | ** 39 | ****************************************************************************/ 40 | 41 | #ifndef QFLOWLAYOUT_H 42 | #define QFLOWLAYOUT_H 43 | 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | class QFlowLayout : public QLayout 50 | { 51 | public: 52 | explicit QFlowLayout(QWidget *parent, QMargins margins = QMargins(), int hSpacing = -1, int vSpacing = -1); 53 | explicit QFlowLayout(QMargins margins = QMargins(), int hSpacing = -1, int vSpacing = -1); 54 | ~QFlowLayout(); 55 | 56 | void addItem(QLayoutItem *item); 57 | void insertItem(int pos, QLayoutItem *item); 58 | void moveItem(int oldPos, int newPos); 59 | 60 | void insertWidget(int pos, QWidget *w); 61 | 62 | int horizontalSpacing() const; 63 | int verticalSpacing() const; 64 | 65 | Qt::Orientations expandingDirections() const; 66 | bool hasHeightForWidth() const; 67 | int heightForWidth(int) const; 68 | int count() const; 69 | 70 | QSize minimumSize() const; 71 | void setGeometry(const QRect &rect); 72 | QSize sizeHint() const; 73 | 74 | QLayoutItem *itemAt(int index) const; 75 | QLayoutItem *takeAt(int index); 76 | 77 | private: 78 | int doLayout(const QRect &rect, bool testOnly) const; 79 | int smartSpacing(QStyle::PixelMetric pm) const; 80 | 81 | QList itemList; 82 | int m_hSpace; 83 | int m_vSpace; 84 | }; 85 | 86 | #endif // QFLOWLAYOUT_H 87 | -------------------------------------------------------------------------------- /QFlowLayout/qflowlayout.pri: -------------------------------------------------------------------------------- 1 | HEADERS += $$PWD/qflowlayout.h 2 | SOURCES += $$PWD/qflowlayout.cpp 3 | 4 | INCLUDEPATH += $$PWD 5 | -------------------------------------------------------------------------------- /QProgressGroup/progressbaradapter.cpp: -------------------------------------------------------------------------------- 1 | #include "progressbaradapter.h" 2 | 3 | ProgressBarAdapter::ProgressBarAdapter(QProgressBar *bar) : 4 | ProgressAdapter(), 5 | bar(bar) 6 | {} 7 | 8 | void ProgressBarAdapter::changeState(QProgressGroup::BarState state, int minimum, int maximum, int value) 9 | { 10 | switch(state) { 11 | case QProgressGroup::Off: 12 | this->bar->setRange(0, 1); 13 | this->bar->setValue(0); 14 | this->bar->setTextVisible(false); 15 | break; 16 | case QProgressGroup::Indeterminated: 17 | this->bar->setRange(0, 0); 18 | this->bar->setTextVisible(false); 19 | break; 20 | case QProgressGroup::Active: 21 | case QProgressGroup::Paused: 22 | case QProgressGroup::Stopped: 23 | this->bar->setRange(minimum, maximum); 24 | this->bar->setValue(value); 25 | this->bar->setTextVisible(true); 26 | break; 27 | } 28 | } 29 | 30 | void ProgressBarAdapter::setMinimum(int minimum) 31 | { 32 | this->bar->setMinimum(minimum); 33 | } 34 | 35 | void ProgressBarAdapter::setMaximum(int maximum) 36 | { 37 | this->bar->setMaximum(maximum); 38 | } 39 | 40 | void ProgressBarAdapter::setRange(int minimum, int maximum) 41 | { 42 | this->bar->setRange(minimum, maximum); 43 | } 44 | 45 | void ProgressBarAdapter::setValue(int value) 46 | { 47 | this->bar->setValue(value); 48 | } 49 | -------------------------------------------------------------------------------- /QProgressGroup/progressbaradapter.h: -------------------------------------------------------------------------------- 1 | #ifndef PROGRESSBARADAPTER_H 2 | #define PROGRESSBARADAPTER_H 3 | 4 | #include "qprogressgroup.h" 5 | #include 6 | 7 | class ProgressBarAdapter : public QProgressGroup::ProgressAdapter 8 | { 9 | public: 10 | ProgressBarAdapter(QProgressBar *bar); 11 | 12 | // ProgressAdapter interface 13 | void changeState(QProgressGroup::BarState state, int minimum, int maximum, int value) Q_DECL_OVERRIDE; 14 | 15 | void setMinimum(int minimum) Q_DECL_OVERRIDE; 16 | void setMaximum(int maximum) Q_DECL_OVERRIDE; 17 | void setRange(int minimum, int maximum) Q_DECL_OVERRIDE; 18 | void setValue(int value) Q_DECL_OVERRIDE; 19 | 20 | private: 21 | QProgressBar *bar; 22 | }; 23 | 24 | #endif // PROGRESSBARADAPTER_H 25 | -------------------------------------------------------------------------------- /QProgressGroup/qprogressgroup.cpp: -------------------------------------------------------------------------------- 1 | #include "qprogressgroup.h" 2 | 3 | QProgressGroup::QProgressGroup(QObject *parent) : 4 | QProgressGroup({}, parent) 5 | {} 6 | 7 | QProgressGroup::QProgressGroup(const std::initializer_list &adapters, QObject *parent) : 8 | QObject(parent), 9 | adapterList(adapters), 10 | state(Off), 11 | min(0), 12 | max(100), 13 | val(0) 14 | {} 15 | 16 | QProgressGroup::~QProgressGroup() 17 | { 18 | qDeleteAll(this->adapterList); 19 | } 20 | 21 | QProgressGroup::BarState QProgressGroup::barState() const 22 | { 23 | return this->state; 24 | } 25 | 26 | void QProgressGroup::setBarState(QProgressGroup::BarState barState) 27 | { 28 | if(this->state == barState) 29 | return; 30 | 31 | foreach (ProgressAdapter *adapter, this->adapterList) { 32 | adapter->changeState(barState, 33 | this->min, 34 | this->max, 35 | this->val); 36 | } 37 | 38 | this->state = barState; 39 | emit barStateChanged(barState); 40 | } 41 | 42 | int QProgressGroup::minimum() const 43 | { 44 | return this->min; 45 | } 46 | 47 | void QProgressGroup::setMinimum(int minimum) 48 | { 49 | switch (this->state) { 50 | case Active: 51 | case Paused: 52 | case Stopped: 53 | foreach(ProgressAdapter *adapter, this->adapterList) 54 | adapter->setMinimum(minimum); 55 | break; 56 | default: 57 | break; 58 | } 59 | this->min = minimum; 60 | } 61 | 62 | int QProgressGroup::maximum() const 63 | { 64 | return this->max; 65 | } 66 | 67 | void QProgressGroup::setMaximum(int maximum) 68 | { 69 | switch (this->state) { 70 | case Active: 71 | case Paused: 72 | case Stopped: 73 | foreach(ProgressAdapter *adapter, this->adapterList) 74 | adapter->setMaximum(maximum); 75 | break; 76 | default: 77 | break; 78 | } 79 | this->max = maximum; 80 | } 81 | 82 | void QProgressGroup::setRange(int minimum, int maximum) 83 | { 84 | switch (this->state) { 85 | case Active: 86 | case Paused: 87 | case Stopped: 88 | foreach(ProgressAdapter *adapter, this->adapterList) 89 | adapter->setRange(minimum, maximum); 90 | break; 91 | default: 92 | break; 93 | } 94 | this->min = minimum; 95 | this->max = maximum; 96 | } 97 | 98 | int QProgressGroup::value() const 99 | { 100 | return this->val; 101 | } 102 | 103 | void QProgressGroup::setValue(int value) 104 | { 105 | switch (this->state) { 106 | case Active: 107 | case Paused: 108 | case Stopped: 109 | foreach(ProgressAdapter *adapter, this->adapterList) 110 | adapter->setValue(value); 111 | break; 112 | default: 113 | break; 114 | } 115 | this->val = value; 116 | emit valueChanged(value); 117 | } 118 | 119 | void QProgressGroup::addAdapter(QProgressGroup::ProgressAdapter *adapter) 120 | { 121 | this->adapterList.append(adapter); 122 | adapter->changeState(this->state, 123 | this->min, 124 | this->max, 125 | this->val); 126 | } 127 | 128 | bool QProgressGroup::takeAdapter(QProgressGroup::ProgressAdapter *adapter) 129 | { 130 | return (this->adapterList.removeAll(adapter) > 0); 131 | } 132 | 133 | QList QProgressGroup::adapters() const 134 | { 135 | return this->adapterList; 136 | } 137 | 138 | void QProgressGroup::sync() 139 | { 140 | foreach (ProgressAdapter *adapter, this->adapterList) { 141 | adapter->changeState(this->state, 142 | this->min, 143 | this->max, 144 | this->val); 145 | } 146 | } 147 | 148 | void QProgressGroup::reset() 149 | { 150 | this->setBarState(Off); 151 | this->setValue(this->min); 152 | } 153 | 154 | void QProgressGroup::clearAdapters() 155 | { 156 | qDeleteAll(this->adapterList); 157 | this->adapterList.clear(); 158 | } 159 | -------------------------------------------------------------------------------- /QProgressGroup/qprogressgroup.h: -------------------------------------------------------------------------------- 1 | #ifndef QPROGRESSGROUP_H 2 | #define QPROGRESSGROUP_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class QProgressGroup : public QObject 10 | { 11 | Q_OBJECT 12 | 13 | Q_PROPERTY(BarState barState READ barState WRITE setBarState NOTIFY barStateChanged) 14 | Q_PROPERTY(int minimum READ minimum WRITE setMinimum) 15 | Q_PROPERTY(int maximum READ maximum WRITE setMaximum) 16 | Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged) 17 | Q_PROPERTY(QList adapters READ adapters RESET clearAdapters) 18 | public: 19 | enum BarState { 20 | Off, 21 | Indeterminated, 22 | Active, 23 | Paused, 24 | Stopped 25 | }; 26 | Q_ENUM(BarState) 27 | 28 | class ProgressAdapter { 29 | public: 30 | virtual inline ~ProgressAdapter(){} 31 | virtual void changeState(QProgressGroup::BarState state, 32 | int minimum, 33 | int maximum, 34 | int value) = 0; 35 | 36 | virtual void setMinimum(int minimum) = 0; 37 | virtual void setMaximum(int maximum) = 0; 38 | virtual void setRange(int minimum, int maximum) = 0; 39 | 40 | virtual void setValue(int value) = 0; 41 | }; 42 | 43 | explicit QProgressGroup(QObject *parent = 0); 44 | QProgressGroup(const std::initializer_list &adapters, QObject *parent = 0); 45 | ~QProgressGroup(); 46 | 47 | BarState barState() const; 48 | int minimum() const; 49 | int maximum() const; 50 | int value() const; 51 | 52 | void addAdapter(ProgressAdapter *adapter); 53 | bool takeAdapter(ProgressAdapter *adapter); 54 | 55 | QList adapters() const; 56 | 57 | public slots: 58 | void setBarState(BarState barState); 59 | void setMinimum(int minimum); 60 | void setMaximum(int maximum); 61 | void setRange(int minimum, int maximum); 62 | void setValue(int value); 63 | 64 | void sync(); 65 | void reset(); 66 | 67 | void clearAdapters(); 68 | 69 | signals: 70 | void barStateChanged(BarState barState); 71 | void valueChanged(int value); 72 | 73 | private: 74 | QList adapterList; 75 | BarState state; 76 | int min; 77 | int max; 78 | int val; 79 | }; 80 | 81 | #endif // QPROGRESSGROUP_H 82 | -------------------------------------------------------------------------------- /QProgressGroup/qprogressgroup.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/progressbaradapter.h \ 3 | $$PWD/qprogressgroup.h \ 4 | $$PWD/systemtrayprogressadapter.h 5 | 6 | SOURCES += \ 7 | $$PWD/progressbaradapter.cpp \ 8 | $$PWD/qprogressgroup.cpp \ 9 | $$PWD/systemtrayprogressadapter.cpp 10 | 11 | win32 { 12 | QT *= winextras 13 | 14 | HEADERS += \ 15 | $$PWD/wintaskbarprogressadapter.h 16 | 17 | SOURCES += \ 18 | $$PWD/wintaskbarprogressadapter.cpp 19 | } 20 | 21 | INCLUDEPATH += $$PWD 22 | -------------------------------------------------------------------------------- /QProgressGroup/systemtrayprogressadapter.cpp: -------------------------------------------------------------------------------- 1 | #include "systemtrayprogressadapter.h" 2 | 3 | SystemTrayProgressAdapter::SystemTrayProgressAdapter(QSystemTrayIcon *trayIco, QMovie *animation, bool showTrayOff) : 4 | ProgressAdapter(), 5 | tray(trayIco), 6 | movie(animation), 7 | ico(trayIco->icon()), 8 | sTrayOff(showTrayOff) 9 | { 10 | QObject::connect(this->movie, &QMovie::frameChanged, 11 | this, &SystemTrayProgressAdapter::movieUpdate); 12 | } 13 | 14 | bool SystemTrayProgressAdapter::showTrayOff() const 15 | { 16 | return this->sTrayOff; 17 | } 18 | 19 | void SystemTrayProgressAdapter::setShowTrayOff(bool showTrayOff, QIcon offIcon) 20 | { 21 | this->sTrayOff = showTrayOff; 22 | if(!offIcon.isNull()) 23 | this->ico = offIcon; 24 | } 25 | 26 | void SystemTrayProgressAdapter::changeState(QProgressGroup::BarState state, int minimum, int maximum, int value) 27 | { 28 | Q_UNUSED(minimum) 29 | Q_UNUSED(maximum) 30 | Q_UNUSED(value) 31 | switch(state) { 32 | case QProgressGroup::Off: 33 | this->movie->stop(); 34 | if(this->sTrayOff) 35 | this->tray->setIcon(this->ico); 36 | else 37 | this->tray->hide(); 38 | break; 39 | case QProgressGroup::Indeterminated: 40 | case QProgressGroup::Active: 41 | case QProgressGroup::Paused: 42 | case QProgressGroup::Stopped: 43 | this->movie->start(); 44 | if(!this->sTrayOff) 45 | this->tray->show(); 46 | break; 47 | } 48 | } 49 | 50 | void SystemTrayProgressAdapter::setMinimum(int minimum) 51 | { 52 | Q_UNUSED(minimum) 53 | } 54 | 55 | void SystemTrayProgressAdapter::setMaximum(int maximum) 56 | { 57 | Q_UNUSED(maximum) 58 | } 59 | 60 | void SystemTrayProgressAdapter::setRange(int minimum, int maximum) 61 | { 62 | Q_UNUSED(minimum) 63 | Q_UNUSED(maximum) 64 | } 65 | 66 | void SystemTrayProgressAdapter::setValue(int value) 67 | { 68 | Q_UNUSED(value) 69 | } 70 | 71 | void SystemTrayProgressAdapter::movieUpdate(int frame) 72 | { 73 | Q_UNUSED(frame) 74 | this->tray->setIcon(QIcon(this->movie->currentPixmap())); 75 | } 76 | -------------------------------------------------------------------------------- /QProgressGroup/systemtrayprogressadapter.h: -------------------------------------------------------------------------------- 1 | #ifndef SYSTEMTRAYPROGRESSADAPTER_H 2 | #define SYSTEMTRAYPROGRESSADAPTER_H 3 | 4 | #include 5 | #include "qprogressgroup.h" 6 | #include 7 | #include 8 | 9 | class SystemTrayProgressAdapter : public QObject, public QProgressGroup::ProgressAdapter 10 | { 11 | Q_OBJECT 12 | 13 | Q_PROPERTY(bool showTrayOff READ showTrayOff WRITE setShowTrayOff) 14 | public: 15 | SystemTrayProgressAdapter(QSystemTrayIcon *trayIco, QMovie *animation, bool showTrayOff = true); 16 | 17 | bool showTrayOff() const; 18 | void setShowTrayOff(bool showTrayOff, QIcon offIcon = QIcon()); 19 | 20 | // ProgressAdapter interface 21 | void changeState(QProgressGroup::BarState state, int minimum, int maximum, int value) Q_DECL_OVERRIDE; 22 | 23 | void setMinimum(int minimum) Q_DECL_OVERRIDE; 24 | void setMaximum(int maximum) Q_DECL_OVERRIDE; 25 | void setRange(int minimum, int maximum) Q_DECL_OVERRIDE; 26 | void setValue(int value) Q_DECL_OVERRIDE; 27 | 28 | private slots: 29 | void movieUpdate(int frame); 30 | 31 | private: 32 | QSystemTrayIcon *tray; 33 | QMovie *movie; 34 | QIcon ico; 35 | bool sTrayOff; 36 | }; 37 | 38 | #endif // SYSTEMTRAYPROGRESSADAPTER_H 39 | -------------------------------------------------------------------------------- /QProgressGroup/wintaskbarprogressadapter.cpp: -------------------------------------------------------------------------------- 1 | #include "wintaskbarprogressadapter.h" 2 | 3 | WinTaskbarProgressAdapter::WinTaskbarProgressAdapter(QWinTaskbarProgress *bar) : 4 | ProgressAdapter(), 5 | bar(bar) 6 | {} 7 | 8 | void WinTaskbarProgressAdapter::changeState(QProgressGroup::BarState state, int minimum, int maximum, int value) 9 | { 10 | switch(state) { 11 | case QProgressGroup::Off: 12 | this->bar->hide(); 13 | break; 14 | case QProgressGroup::Indeterminated: 15 | this->bar->setRange(0, 0); 16 | this->bar->setValue(0); 17 | this->bar->show(); 18 | break; 19 | case QProgressGroup::Active: 20 | this->bar->setRange(minimum, maximum); 21 | this->bar->setValue(value); 22 | this->bar->resume(); 23 | this->bar->show(); 24 | break; 25 | case QProgressGroup::Paused: 26 | this->bar->setRange(minimum, maximum); 27 | this->bar->setValue(value); 28 | this->bar->pause(); 29 | this->bar->show(); 30 | break; 31 | case QProgressGroup::Stopped: 32 | this->bar->setRange(minimum, maximum); 33 | this->bar->setValue(value); 34 | this->bar->stop(); 35 | this->bar->show(); 36 | break; 37 | } 38 | } 39 | 40 | void WinTaskbarProgressAdapter::setMinimum(int minimum) 41 | { 42 | this->bar->setMinimum(minimum); 43 | } 44 | 45 | void WinTaskbarProgressAdapter::setMaximum(int maximum) 46 | { 47 | this->bar->setMaximum(maximum); 48 | } 49 | 50 | void WinTaskbarProgressAdapter::setRange(int minimum, int maximum) 51 | { 52 | this->bar->setRange(minimum, maximum); 53 | } 54 | 55 | void WinTaskbarProgressAdapter::setValue(int value) 56 | { 57 | this->bar->setValue(value); 58 | } 59 | -------------------------------------------------------------------------------- /QProgressGroup/wintaskbarprogressadapter.h: -------------------------------------------------------------------------------- 1 | #ifndef WINTASKBARPROGRESSADAPTER_H 2 | #define WINTASKBARPROGRESSADAPTER_H 3 | 4 | #include "qprogressgroup.h" 5 | #include 6 | 7 | class WinTaskbarProgressAdapter : public QProgressGroup::ProgressAdapter 8 | { 9 | public: 10 | WinTaskbarProgressAdapter(QWinTaskbarProgress *bar); 11 | 12 | // ProgressAdapter interface 13 | void changeState(QProgressGroup::BarState state, int minimum, int maximum, int value) Q_DECL_OVERRIDE; 14 | 15 | void setMinimum(int minimum) Q_DECL_OVERRIDE; 16 | void setMaximum(int maximum) Q_DECL_OVERRIDE; 17 | void setRange(int minimum, int maximum) Q_DECL_OVERRIDE; 18 | void setValue(int value) Q_DECL_OVERRIDE; 19 | 20 | private: 21 | QWinTaskbarProgress *bar; 22 | }; 23 | 24 | #endif // WINTASKBARPROGRESSADAPTER_H 25 | -------------------------------------------------------------------------------- /QPropertySettings/changedmonitorobject.cpp: -------------------------------------------------------------------------------- 1 | #include "changedmonitorobject.h" 2 | 3 | ChangedMonitorObject::ChangedMonitorObject(int id, QObject *parent) : 4 | QObject(parent), 5 | id(id) 6 | {} 7 | 8 | void ChangedMonitorObject::trigger() { 9 | emit triggered(id); 10 | } 11 | -------------------------------------------------------------------------------- /QPropertySettings/changedmonitorobject.h: -------------------------------------------------------------------------------- 1 | #ifndef CHANGEDMONITOROBJECT_H 2 | #define CHANGEDMONITOROBJECT_H 3 | 4 | #include 5 | 6 | class ChangedMonitorObject : public QObject 7 | { 8 | Q_OBJECT 9 | 10 | public: 11 | ChangedMonitorObject(int id, QObject *parent = nullptr); 12 | 13 | public slots: 14 | void trigger(); 15 | 16 | signals: 17 | void triggered(int id); 18 | 19 | private: 20 | const int id; 21 | }; 22 | 23 | #endif // CHANGEDMONITOROBJECT_H 24 | -------------------------------------------------------------------------------- /QPropertySettings/qpropertysettings.cpp: -------------------------------------------------------------------------------- 1 | #include "qpropertysettings.h" 2 | #include "changedmonitorobject.h" 3 | #include 4 | 5 | QPropertySettings::QPropertySettings(QObject *parent) : 6 | QPropertySettings(nullptr, parent) 7 | {} 8 | 9 | QPropertySettings::QPropertySettings(QSettings *settings, QObject *parent) : 10 | QObject(parent), 11 | settings(settings ? settings : new QSettings(this)), 12 | indexCounter(0), 13 | propertyData() 14 | {} 15 | 16 | int QPropertySettings::findId(QObject *object, const char *property) const 17 | { 18 | auto metaProperty = this->getMetaProperty(object, property); 19 | if(metaProperty.isValid()) 20 | return this->findId(object, metaProperty); 21 | else 22 | return -1; 23 | } 24 | 25 | int QPropertySettings::findId(QObject *object, const QMetaProperty &property) const 26 | { 27 | for(auto it = this->propertyData.constBegin(), end = this->propertyData.constEnd(); it != end; ++it) { 28 | if(it->object == object && 29 | QString(it->property.name()) == property.name()) 30 | return it.key(); 31 | } 32 | 33 | return -1; 34 | } 35 | 36 | int QPropertySettings::addProperty(QObject *object, const char *property, const QString &group, const QString &key) 37 | { 38 | auto metaProperty = this->getMetaProperty(object, property); 39 | if(metaProperty.isValid()) 40 | return this->addProperty(object, metaProperty, group, key); 41 | else 42 | return -1; 43 | } 44 | 45 | int QPropertySettings::addProperty(QObject *object, const QMetaProperty &property, QString group, QString key) 46 | { 47 | int mapId = this->indexCounter++; 48 | PropertyData data; 49 | data.object = object; 50 | data.property = property; 51 | 52 | if(group.isNull()) { 53 | group = object->objectName(); 54 | if(group.isEmpty()) 55 | group = QString::fromLocal8Bit(object->metaObject()->className()); 56 | } 57 | if(key.isEmpty()) 58 | key = QString::fromLocal8Bit(property.name()); 59 | if(!group.isEmpty()) 60 | group.append(QLatin1Char('/')); 61 | data.fullKey = group + key; 62 | 63 | if(property.hasNotifySignal()) { 64 | data.monitor = new ChangedMonitorObject(mapId, this); 65 | auto signalMethod = property.notifySignal(); 66 | auto slotMethod = this->getChangedSlot(data.monitor); 67 | connect(object, signalMethod, data.monitor, slotMethod, Qt::DirectConnection); 68 | connect(data.monitor, &ChangedMonitorObject::triggered, 69 | this, &QPropertySettings::saveProperty, 70 | Qt::QueuedConnection); 71 | } else 72 | qWarning("Property without changed signal will not automatically save!"); 73 | 74 | this->propertyData.insert(mapId, data); 75 | this->loadProperty(mapId); 76 | return mapId; 77 | } 78 | 79 | void QPropertySettings::loadProperty(int id) 80 | { 81 | auto data = this->propertyData.value(id); 82 | if(!data.object.isNull() && 83 | data.property.isWritable()) { 84 | auto loadData = this->settings->value(data.fullKey); 85 | qDebug() << "Loading" << data.fullKey << "with value" << loadData; 86 | if(loadData.isValid()) 87 | data.property.write(data.object, loadData); 88 | } 89 | } 90 | 91 | void QPropertySettings::loadAll() 92 | { 93 | foreach (auto key, this->propertyData.keys()) 94 | this->loadProperty(key); 95 | } 96 | 97 | void QPropertySettings::saveProperty(int id) 98 | { 99 | auto data = this->propertyData.value(id); 100 | if(!data.object.isNull() && 101 | data.property.isReadable()) { 102 | auto saveData = data.property.read(data.object); 103 | qDebug() << "Saving" << data.fullKey << "with value" << saveData; 104 | if(saveData.isValid()) 105 | this->settings->setValue(data.fullKey, saveData); 106 | } 107 | } 108 | 109 | void QPropertySettings::saveAll() 110 | { 111 | foreach (auto key, this->propertyData.keys()) 112 | this->saveProperty(key); 113 | } 114 | 115 | void QPropertySettings::resetProperty(int id, bool resetProperty) 116 | { 117 | auto data = this->propertyData.value(id); 118 | if(!data.object.isNull()) { 119 | qDebug() << "Resetting" << data.fullKey; 120 | this->settings->remove(data.fullKey); 121 | if(resetProperty && data.property.isResettable()) 122 | data.property.reset(data.object); 123 | } 124 | } 125 | 126 | void QPropertySettings::resetAll(bool resetProperty) 127 | { 128 | foreach (auto key, this->propertyData.keys()) 129 | this->resetProperty(key, resetProperty); 130 | } 131 | 132 | void QPropertySettings::removeProperty(int id, bool resetSettings) 133 | { 134 | auto data = this->propertyData.take(id); 135 | if(!data.fullKey.isNull()) { 136 | if(resetSettings) 137 | this->settings->remove(data.fullKey); 138 | } 139 | if(data.monitor) 140 | data.monitor->deleteLater(); 141 | } 142 | 143 | void QPropertySettings::removeAll(bool resetSettings) 144 | { 145 | foreach (auto key, this->propertyData.keys()) 146 | this->removeProperty(key, resetSettings); 147 | } 148 | 149 | QMetaMethod QPropertySettings::getChangedSlot(ChangedMonitorObject *monitor) const 150 | { 151 | auto metaObject = monitor->metaObject(); 152 | auto slotIndex = metaObject->indexOfSlot("trigger()"); 153 | return metaObject->method(slotIndex); 154 | } 155 | 156 | QMetaProperty QPropertySettings::getMetaProperty(QObject *object, const char *property) const 157 | { 158 | auto metaObject = object->metaObject(); 159 | auto propIndex = metaObject->indexOfProperty(property); 160 | if(propIndex >= 0) 161 | return metaObject->property(propIndex); 162 | else 163 | return QMetaProperty(); 164 | } 165 | 166 | 167 | 168 | QPropertySettings::PropertyData::PropertyData() : 169 | object(nullptr), 170 | property(), 171 | fullKey(), 172 | monitor(nullptr) 173 | {} 174 | -------------------------------------------------------------------------------- /QPropertySettings/qpropertysettings.h: -------------------------------------------------------------------------------- 1 | #ifndef QPROPERTYSETTINGS_H 2 | #define QPROPERTYSETTINGS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | class ChangedMonitorObject; 10 | 11 | class QPropertySettings : public QObject 12 | { 13 | Q_OBJECT 14 | public: 15 | explicit QPropertySettings(QObject *parent = nullptr); 16 | explicit QPropertySettings(QSettings *settings, QObject *parent = nullptr); 17 | 18 | int findId(QObject *object, const char *property) const; 19 | int findId(QObject *object, const QMetaProperty &property) const; 20 | 21 | int addProperty(QObject *object, const char *property, const QString &group = QString(), const QString &key = QString()); 22 | int addProperty(QObject *object, const QMetaProperty &property, QString group = QString(), QString key = QString()); 23 | 24 | public slots: 25 | void loadProperty(int id); 26 | void loadAll(); 27 | void saveProperty(int id); 28 | void saveAll(); 29 | void resetProperty(int id, bool resetProperty = true); 30 | void resetAll(bool resetProperty = true); 31 | void removeProperty(int id, bool resetSettings = true); 32 | void removeAll(bool resetSettings = true); 33 | 34 | private: 35 | struct PropertyData { 36 | PropertyData(); 37 | 38 | QPointer object; 39 | QMetaProperty property; 40 | QString fullKey; 41 | 42 | ChangedMonitorObject *monitor; 43 | }; 44 | 45 | QSettings *settings; 46 | int indexCounter; 47 | QHash propertyData; 48 | 49 | QMetaMethod getChangedSlot(ChangedMonitorObject *monitor) const; 50 | QMetaProperty getMetaProperty(QObject *object, const char *property) const; 51 | }; 52 | 53 | #endif // QPROPERTYSETTINGS_H 54 | -------------------------------------------------------------------------------- /QPropertySettings/qpropertysettings.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/qpropertysettings.h \ 3 | $$PWD/changedmonitorobject.h \ 4 | 5 | SOURCES += \ 6 | $$PWD/qpropertysettings.cpp \ 7 | $$PWD/changedmonitorobject.cpp \ 8 | 9 | INCLUDEPATH += $$PWD 10 | -------------------------------------------------------------------------------- /QSslServer/qsslserver.cpp: -------------------------------------------------------------------------------- 1 | #include "qsslserver.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | QSslServer::QSslServer(QObject *parent) : 9 | QTcpServer(parent), 10 | configuration(QSslConfiguration::defaultConfiguration()), 11 | lastError(QAbstractSocket::UnknownSocketError), 12 | lastSslErrors() 13 | {} 14 | 15 | QSslSocket *QSslServer::nextPendingSslConnection() 16 | { 17 | return qobject_cast(this->nextPendingConnection()); 18 | } 19 | 20 | void QSslServer::addCaCertificate(const QSslCertificate &certificate) 21 | { 22 | QList certs = this->configuration.caCertificates(); 23 | certs.append(certificate); 24 | this->configuration.setCaCertificates(certs); 25 | } 26 | 27 | bool QSslServer::addCaCertificate(const QString &path, QSsl::EncodingFormat format) 28 | { 29 | bool ret = false; 30 | QFile file(path); 31 | if(file.open(QIODevice::ReadOnly)) 32 | { 33 | QSslCertificate cert(file.readAll(), format); 34 | if(!cert.isNull()) 35 | { 36 | this->addCaCertificate(cert); 37 | ret = true; 38 | } 39 | file.close(); 40 | } 41 | 42 | return ret; 43 | } 44 | 45 | void QSslServer::addCaCertificates(const QList &certificates) 46 | { 47 | QList certs = this->configuration.caCertificates(); 48 | certs.append(certificates); 49 | this->configuration.setCaCertificates(certs); 50 | } 51 | 52 | QList QSslServer::caCertificates() const 53 | { 54 | return this->configuration.caCertificates(); 55 | } 56 | 57 | void QSslServer::setCaCertificates(const QList &certificates) 58 | { 59 | this->configuration.setCaCertificates(certificates); 60 | } 61 | 62 | QSslCertificate QSslServer::localCertificate() const 63 | { 64 | return this->configuration.localCertificate(); 65 | } 66 | 67 | QList QSslServer::localCertificateChain() const 68 | { 69 | return this->configuration.localCertificateChain(); 70 | } 71 | 72 | void QSslServer::setLocalCertificate(const QSslCertificate &certificate) 73 | { 74 | this->configuration.setLocalCertificate(certificate); 75 | } 76 | 77 | bool QSslServer::setLocalCertificate(const QString &path, QSsl::EncodingFormat format) 78 | { 79 | bool ret = false; 80 | QFile file(path); 81 | if(file.open(QIODevice::ReadOnly)) 82 | { 83 | QSslCertificate cert(file.readAll(), format); 84 | if(!cert.isNull()) 85 | { 86 | this->configuration.setLocalCertificate(cert); 87 | ret = true; 88 | } 89 | file.close(); 90 | } 91 | 92 | return ret; 93 | } 94 | 95 | void QSslServer::setLocalCertificateChain(const QList &localChain) 96 | { 97 | this->configuration.setLocalCertificateChain(localChain); 98 | } 99 | 100 | QSslKey QSslServer::privateKey() const 101 | { 102 | return this->configuration.privateKey(); 103 | } 104 | 105 | void QSslServer::setPrivateKey(const QSslKey &key) 106 | { 107 | this->configuration.setPrivateKey(key); 108 | } 109 | 110 | bool QSslServer::setPrivateKey(const QString &fileName, QSsl::KeyAlgorithm algorithm, QSsl::EncodingFormat format, const QByteArray &passPhrase) 111 | { 112 | bool ret = false; 113 | QFile file(fileName); 114 | if(file.open(QIODevice::ReadOnly)) 115 | { 116 | QSslKey newKey(file.readAll(), algorithm, format, QSsl::PrivateKey, passPhrase); 117 | if(!newKey.isNull()) 118 | { 119 | this->configuration.setPrivateKey(newKey); 120 | ret = true; 121 | } 122 | file.close(); 123 | } 124 | 125 | return ret; 126 | } 127 | 128 | QList QSslServer::ciphers() const 129 | { 130 | return this->configuration.ciphers(); 131 | } 132 | 133 | void QSslServer::setCiphers(const QList &ciphers) 134 | { 135 | this->configuration.setCiphers(ciphers); 136 | } 137 | 138 | void QSslServer::setCiphers(const QString &ciphers) 139 | { 140 | QStringList cphl = ciphers.split(":", QString::SkipEmptyParts); 141 | QList cphs; 142 | foreach(QString cph, cphl) 143 | { 144 | QSslCipher c(cph); 145 | if(!c.isNull()) 146 | cphs.append(c); 147 | } 148 | this->configuration.setCiphers(cphs); 149 | } 150 | 151 | QSsl::SslProtocol QSslServer::protocol() const 152 | { 153 | return this->configuration.protocol(); 154 | } 155 | 156 | void QSslServer::setProtocol(QSsl::SslProtocol protocol) 157 | { 158 | this->configuration.setProtocol(protocol); 159 | } 160 | 161 | void QSslServer::setSslConfiguration(const QSslConfiguration &configuration) 162 | { 163 | this->configuration = configuration; 164 | } 165 | 166 | QSslConfiguration QSslServer::sslConfiguration() const 167 | { 168 | return this->configuration; 169 | } 170 | 171 | QAbstractSocket::SocketError QSslServer::clientError() const 172 | { 173 | return this->lastError; 174 | } 175 | 176 | QList QSslServer::clientSslErrors() const 177 | { 178 | return this->lastSslErrors; 179 | } 180 | 181 | void QSslServer::incomingConnection(qintptr handle) 182 | { 183 | //Create Socket 184 | QSslSocket *socket = new QSslSocket; 185 | if (!socket) 186 | { 187 | qCritical() << "Not enough memory to create new QSslSocket!!!"; 188 | return; 189 | } 190 | if (!socket->setSocketDescriptor(handle)) 191 | { 192 | this->lastError = socket->error(); 193 | delete socket; 194 | emit clientError(this->lastError); 195 | return; 196 | } 197 | 198 | //Connects 199 | QObject::connect(socket, SIGNAL(encrypted()), this, SLOT(socketReady())); 200 | QObject::connect(socket, SIGNAL(sslErrors(QList)), this, SLOT(socketErrors(QList))); 201 | QObject::connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketErrors(QAbstractSocket::SocketError))); 202 | 203 | //set ssl data 204 | socket->setSslConfiguration(this->configuration); 205 | socket->startServerEncryption(); 206 | } 207 | 208 | void QSslServer::socketReady() 209 | { 210 | QSslSocket *socket = qobject_cast(QObject::sender()); 211 | if(socket != NULL) 212 | { 213 | socket->disconnect(); 214 | this->addPendingConnection(socket); 215 | emit newSslConnection(); 216 | } 217 | } 218 | 219 | void QSslServer::socketErrors(QList errors) 220 | { 221 | this->lastSslErrors = errors; 222 | emit clientSslErrors(errors); 223 | QSslSocket *socket = qobject_cast(QObject::sender()); 224 | if(socket != NULL) 225 | socket->deleteLater(); 226 | } 227 | 228 | void QSslServer::socketErrors(QAbstractSocket::SocketError error) 229 | { 230 | this->lastError = error; 231 | emit clientError(error); 232 | QSslSocket *socket = qobject_cast(QObject::sender()); 233 | if(socket != NULL) 234 | socket->deleteLater(); 235 | } 236 | 237 | -------------------------------------------------------------------------------- /QSslServer/qsslserver.h: -------------------------------------------------------------------------------- 1 | #ifndef QSSLSERVER_H 2 | #define QSSLSERVER_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class QSslServer : public QTcpServer 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit QSslServer(QObject *parent = 0); 13 | 14 | QSslSocket *nextPendingSslConnection(); 15 | 16 | //Ca-Certificates 17 | void addCaCertificate(const QSslCertificate & certificate); 18 | bool addCaCertificate(const QString &path, QSsl::EncodingFormat format = QSsl::Pem); 19 | void addCaCertificates(const QList & certificates); 20 | QList caCertificates() const; 21 | void setCaCertificates(const QList & certificates); 22 | 23 | //Local Certificates 24 | QSslCertificate localCertificate() const; 25 | QList localCertificateChain() const; 26 | void setLocalCertificate(const QSslCertificate & certificate); 27 | bool setLocalCertificate(const QString &path, QSsl::EncodingFormat format = QSsl::Pem); 28 | void setLocalCertificateChain(const QList & localChain); 29 | 30 | //PrivKey 31 | QSslKey privateKey() const; 32 | void setPrivateKey(const QSslKey & key); 33 | bool setPrivateKey(const QString & fileName, QSsl::KeyAlgorithm algorithm = QSsl::Rsa, QSsl::EncodingFormat format = QSsl::Pem, const QByteArray & passPhrase = QByteArray()); 34 | 35 | //Ciphers and protocols 36 | QList ciphers() const; 37 | void setCiphers(const QList & ciphers); 38 | void setCiphers(const QString & ciphers); 39 | QSsl::SslProtocol protocol() const; 40 | void setProtocol(QSsl::SslProtocol protocol); 41 | 42 | //Configuration 43 | void setSslConfiguration(const QSslConfiguration &configuration); 44 | QSslConfiguration sslConfiguration() const; 45 | 46 | //Errors 47 | QAbstractSocket::SocketError clientError() const; 48 | QList clientSslErrors() const; 49 | 50 | signals: 51 | void newSslConnection(); 52 | void clientError(QAbstractSocket::SocketError error); 53 | void clientSslErrors(QList errors); 54 | 55 | protected: 56 | void incomingConnection(qintptr handle); 57 | 58 | private slots: 59 | void socketReady(); 60 | void socketErrors(QAbstractSocket::SocketError error); 61 | void socketErrors(QList errors); 62 | 63 | private: 64 | QSslConfiguration configuration; 65 | 66 | QAbstractSocket::SocketError lastError; 67 | QList lastSslErrors; 68 | }; 69 | 70 | #endif // QSSLSERVER_H 71 | -------------------------------------------------------------------------------- /QSslServer/qsslserver.pri: -------------------------------------------------------------------------------- 1 | HEADERS += $$PWD/qsslserver.h 2 | SOURCES += $$PWD/qsslserver.cpp 3 | 4 | INCLUDEPATH += $$PWD 5 | -------------------------------------------------------------------------------- /QUrlValidator: -------------------------------------------------------------------------------- 1 | https://github.com/Skycoder42/QUrlValidator -------------------------------------------------------------------------------- /QtUtils: -------------------------------------------------------------------------------- 1 | #ifndef QTUTILS_H 2 | #define QTUTILS_H 3 | 4 | #include "qpropertysettings.h" 5 | #include "qelementmodel.h" 6 | #include "qcompressor.h" 7 | 8 | #ifdef QT_WIDGETS_LIB 9 | #include "qflowlayout.h" 10 | #include "qprogressgroup.h"//TODO include all... 11 | #endif 12 | 13 | #ifdef QT_NETWORK_LIB 14 | #include "qsslserver.h" 15 | #endif 16 | 17 | #endif // QTUTILS_H 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # QtUtils 2 | A collection of various Qt-Classes, branch-sorted. 3 | 4 | **Important! This prject is slowly beeing replaced by qpm packages. Use those in your projects instead. The folders have been replaced with links to the new github projects.** 5 | 6 | Currently on qpm: 7 | 8 | - DialogMaster: [`de.skycoder42.dialog-master`](https://www.qpm.io/packages/de.skycoder42.dialog-master/index.html) 9 | - QUrlValidator: [`de.skycoder42.qurlvalidator`](https://www.qpm.io/packages/de.skycoder42.qurlvalidator/index.html) 10 | 11 | ## Projekt structure 12 | The utils are simply a collection of various helpful Qt-Classes. Whats special about this project is the way they are organized: 13 | Every part of thus library has it's own branch. All those branches are based on the "Base" branch. The master branch combines them all and provides a simple library projekt to include. The library branch contains the compiled library for all platforms (may not always be up to date!) 14 | 15 | This structure has a great advantage: If you want to use the whole library, or don't really care, because you can use a library, you can use the master branch (or the library branch). However, if you only want to use one specific module of the utils, simply use this repository as submodule and checkout the correpsonding branch. It will only contain this readme, the license and the single subfolder with the module that you require. 16 | 17 | ## Example 18 | The DialogMaster is one of the various modules of the library. If you need this one, you have the following choices: 19 | 1. Use the QtUtils.lib provided in the releases. It includes all modules, including the DialogMaster 20 | 2. Add a submodule to your project and checkout the "DialogMaster" branch. This way you will only have the dialog master in your projekt 21 | 3. Same as 2, but with the master branch, if you need all of the modules. 22 | 4. Same as 3, but use the library branch. This way you don't have to compile the utils. Note: 3 and 4 are compatible. You can easily switch between both of them. If you added the library via the `.pri` file, nothing will change from the outside. 23 | 5. Build it yourself. This is, of course, always an option ;) 24 | 25 | ## Modules 26 | ### QPropertySettings 27 | The property settings are an extension for QSettings to autmatically store properties of an object in the settings. 28 | 29 | ### QElementModel 30 | The element model provides a object-based list model with dynamic roles to be used with QML Views. 31 | 32 | ### QCompressor 33 | A class to compress data of any size, by splitting it into chucks that Qt's build in compression algorithms can handel. This is NOT a Zip-library. It simply compresses binary data, without any metadata or compability with other tools (but cross-plattform, i.e. data can be compressed and extracted on different devices) 34 | 35 | ### QFlowLayout 36 | The Flow layout from Qts flow layout example, with soem adjustments and improvements. for the original, see here: https://doc.qt.io/qt-5/qtwidgets-layouts-flowlayout-example.html. 37 | As the same suggests, it's a layout implementation to organize elements in a dynamic flow. 38 | 39 | ### QProgressGroup 40 | A class to combine multiple kinds of progress indicators, and manage them with a combined interface. Example: YOu have a normal progressbar and a taskbar progress. Thanks to this class, you can simply add both to a progress group, and everytime you update the progress group, both bars will be updated accordingly. 41 | 42 | Currently supported kinds of progress elements are: 43 | - [QProgressBar](https://doc.qt.io/qt-5/qprogressbar.html) 44 | - [QSystemTrayIcon](https://doc.qt.io/qt-5/qsystemtrayicon.html) (With some additional code to make the tray show a busy indicator) 45 | - [QWinTaskbarProgress](https://doc.qt.io/qt-5/qwintaskbarprogress.html) 46 | 47 | ### QSslServer 48 | The QSslServer is an extension of the [QTcpServer](https://doc.qt.io/qt-5/qtcpserver.html) to provide a server that can handle ssl connections. It works just like the tcp version, but with ssl, and uses the [QSslSocket](https://doc.qt.io/qt-5/qsslsocket.html) for connections. 49 | -------------------------------------------------------------------------------- /qtutils.pri: -------------------------------------------------------------------------------- 1 | include(./QPropertySettings/qpropertysettings.pri) 2 | include(./QElementModel/qelementmodel.pri) 3 | include(./QCompressor/qcompressor.pri) 4 | 5 | contains(QT, widgets) { 6 | include(./QFlowLayout/qflowlayout.pri) 7 | include(./QProgressGroup/qprogressgroup.pri) 8 | } 9 | 10 | contains(QT, network) { 11 | include(./QSslServer/qsslserver.pri) 12 | } 13 | --------------------------------------------------------------------------------