more updates
This commit is contained in:
@@ -6,7 +6,7 @@ set(CMAKE_AUTOUIC ON)
|
|||||||
set(CMAKE_AUTOMOC ON)
|
set(CMAKE_AUTOMOC ON)
|
||||||
set(CMAKE_AUTORCC ON)
|
set(CMAKE_AUTORCC ON)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
|
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
|
||||||
@@ -25,7 +25,7 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
|||||||
MANUAL_FINALIZATION
|
MANUAL_FINALIZATION
|
||||||
${PROJECT_SOURCES}
|
${PROJECT_SOURCES}
|
||||||
tiercard.hpp tiercard.cpp
|
tiercard.hpp tiercard.cpp
|
||||||
flowlayout.cpp flowlayout.h flowlayout.pro
|
flowlayout.cpp flowlayout.h
|
||||||
tiercardlayout.hpp tiercardlayout.cpp
|
tiercardlayout.hpp tiercardlayout.cpp
|
||||||
aspectratiopixmaplabel.hpp aspectratiopixmaplabel.cpp
|
aspectratiopixmaplabel.hpp aspectratiopixmaplabel.cpp
|
||||||
fullsizelayout.hpp fullsizelayout.cpp
|
fullsizelayout.hpp fullsizelayout.cpp
|
||||||
@@ -35,6 +35,8 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
|||||||
utils.hpp
|
utils.hpp
|
||||||
rowholder.hpp rowholder.cpp
|
rowholder.hpp rowholder.cpp
|
||||||
settings.hpp settings.cpp
|
settings.hpp settings.cpp
|
||||||
|
invalididexception.hpp invalididexception.cpp
|
||||||
|
tierplaceholder.hpp tierplaceholder.cpp
|
||||||
|
|
||||||
)
|
)
|
||||||
# Define target properties for Android with Qt 6 as:
|
# Define target properties for Android with Qt 6 as:
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include "flowlayout.h"
|
#include "flowlayout.h"
|
||||||
//! [1]
|
//! [1]
|
||||||
FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing)
|
FlowLayout::FlowLayout(QWidget* parent, int margin, int hSpacing, int vSpacing)
|
||||||
: QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing)
|
: QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing)
|
||||||
{
|
{
|
||||||
setContentsMargins(margin, margin, margin, margin);
|
setContentsMargins(margin, margin, margin, margin);
|
||||||
@@ -102,6 +102,8 @@ QSize FlowLayout::minimumSize() const
|
|||||||
|
|
||||||
const QMargins margins = contentsMargins();
|
const QMargins margins = contentsMargins();
|
||||||
size += QSize(margins.left() + margins.right(), margins.top() + margins.bottom());
|
size += QSize(margins.left() + margins.right(), margins.top() + margins.bottom());
|
||||||
|
if (size.height() < minimumHeight())
|
||||||
|
size.rheight() = minimumHeight();
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,12 +145,41 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
|
|||||||
int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const
|
int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const
|
||||||
{
|
{
|
||||||
QObject* parent = this->parent();
|
QObject* parent = this->parent();
|
||||||
if (!parent) {
|
if (!parent)
|
||||||
|
{
|
||||||
return -1;
|
return -1;
|
||||||
} else if (parent->isWidgetType()) {
|
}
|
||||||
QWidget* pw = static_cast<QWidget *>(parent);
|
else if (parent->isWidgetType())
|
||||||
|
{
|
||||||
|
QWidget* pw = static_cast<QWidget*>(parent);
|
||||||
return pw->style()->pixelMetric(pm, nullptr, pw);
|
return pw->style()->pixelMetric(pm, nullptr, pw);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return static_cast<QLayout*>(parent)->spacing();
|
return static_cast<QLayout*>(parent)->spacing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FlowLayout::setIndex(QWidget* wid, int index)
|
||||||
|
{
|
||||||
|
if (itemAt(index)->widget() == wid)
|
||||||
|
return;
|
||||||
|
wid->setParent(nullptr);
|
||||||
|
addWidget(wid);
|
||||||
|
if (index < 0)
|
||||||
|
return;
|
||||||
|
for (int i = count()-1; i > index; i--)
|
||||||
|
{
|
||||||
|
itemList.swapItemsAt(i-1, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlowLayout::setMinimumHeight(int minh)
|
||||||
|
{
|
||||||
|
_minimumHeight = minh;
|
||||||
|
}
|
||||||
|
|
||||||
|
int FlowLayout::minimumHeight() const
|
||||||
|
{
|
||||||
|
return _minimumHeight;
|
||||||
|
}
|
||||||
|
|||||||
14
flowlayout.h
14
flowlayout.h
@@ -7,7 +7,7 @@
|
|||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
#include <QRect>
|
#include <QRect>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
//! [0]
|
|
||||||
class FlowLayout : public QLayout
|
class FlowLayout : public QLayout
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -22,20 +22,22 @@ public:
|
|||||||
bool hasHeightForWidth() const override;
|
bool hasHeightForWidth() const override;
|
||||||
int heightForWidth(int) const override;
|
int heightForWidth(int) const override;
|
||||||
int count() const override;
|
int count() const override;
|
||||||
QLayoutItem *itemAt(int index) const override;
|
QLayoutItem* itemAt(int index) const override;
|
||||||
QSize minimumSize() const override;
|
QSize minimumSize() const override;
|
||||||
void setGeometry(const QRect &rect) override;
|
void setGeometry(const QRect &rect) override;
|
||||||
QSize sizeHint() const override;
|
QSize sizeHint() const override;
|
||||||
QLayoutItem *takeAt(int index) override;
|
QLayoutItem* takeAt(int index) override;
|
||||||
|
void setIndex(QWidget* wid, int index);
|
||||||
|
void setMinimumHeight(int minh);
|
||||||
|
int minimumHeight() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int doLayout(const QRect &rect, bool testOnly) const;
|
int doLayout(const QRect &rect, bool testOnly) const;
|
||||||
int smartSpacing(QStyle::PixelMetric pm) const;
|
int smartSpacing(QStyle::PixelMetric pm) const;
|
||||||
|
int _minimumHeight = 0;
|
||||||
QList<QLayoutItem *> itemList;
|
QList<QLayoutItem*> itemList;
|
||||||
int m_hSpace;
|
int m_hSpace;
|
||||||
int m_vSpace;
|
int m_vSpace;
|
||||||
};
|
};
|
||||||
//! [0]
|
|
||||||
|
|
||||||
#endif // FLOWLAYOUT_H
|
#endif // FLOWLAYOUT_H
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
QT += widgets
|
|
||||||
|
|
||||||
HEADERS = flowlayout.h \
|
|
||||||
window.h
|
|
||||||
SOURCES = flowlayout.cpp \
|
|
||||||
main.cpp \
|
|
||||||
window.cpp
|
|
||||||
|
|
||||||
# install
|
|
||||||
target.path = $$[QT_INSTALL_EXAMPLES]/widgets/layouts/flowlayout
|
|
||||||
INSTALLS += target
|
|
||||||
@@ -41,7 +41,7 @@ bool FullSizeLayout::hasHeightForWidth() const
|
|||||||
}
|
}
|
||||||
int FullSizeLayout::heightForWidth(int width) const
|
int FullSizeLayout::heightForWidth(int width) const
|
||||||
{
|
{
|
||||||
int h = -1;
|
int h = 0;
|
||||||
for (auto child : itemList)
|
for (auto child : itemList)
|
||||||
{
|
{
|
||||||
h = std::max(h, child->heightForWidth(width));
|
h = std::max(h, child->heightForWidth(width));
|
||||||
@@ -58,7 +58,7 @@ QLayoutItem* FullSizeLayout::itemAt(int index) const
|
|||||||
}
|
}
|
||||||
QSize FullSizeLayout::minimumSize() const
|
QSize FullSizeLayout::minimumSize() const
|
||||||
{
|
{
|
||||||
QSize size;
|
QSize size(0, 0);
|
||||||
for (auto child : itemList)
|
for (auto child : itemList)
|
||||||
{
|
{
|
||||||
// auto wid = child->widget();
|
// auto wid = child->widget();
|
||||||
|
|||||||
38
invalididexception.cpp
Normal file
38
invalididexception.cpp
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#include "invalididexception.hpp"
|
||||||
|
|
||||||
|
InvalidIdException::InvalidIdException()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
InvalidRowIdException::InvalidRowIdException(TierRow::IdType id)
|
||||||
|
: _id(id), _what(std::format("id: {}", _id))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TierRow::IdType InvalidRowIdException::id() const
|
||||||
|
{
|
||||||
|
return _id;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* InvalidRowIdException::what() const noexcept
|
||||||
|
{
|
||||||
|
return _what.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
InvalidCardIdException::InvalidCardIdException(TierCard::IdType id)
|
||||||
|
: _id(id), _what(std::format("id: {}", _id))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TierCard::IdType InvalidCardIdException::id() const
|
||||||
|
{
|
||||||
|
return _id;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* InvalidCardIdException::what() const noexcept
|
||||||
|
{
|
||||||
|
return _what.c_str();
|
||||||
|
}
|
||||||
39
invalididexception.hpp
Normal file
39
invalididexception.hpp
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#ifndef INVALIDIDEXCEPTION_HPP
|
||||||
|
#define INVALIDIDEXCEPTION_HPP
|
||||||
|
|
||||||
|
#include "tierrow.hpp"
|
||||||
|
#include "tiercard.hpp"
|
||||||
|
|
||||||
|
#include <QException>
|
||||||
|
|
||||||
|
class InvalidIdException : public QException
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
InvalidIdException();
|
||||||
|
};
|
||||||
|
|
||||||
|
class InvalidRowIdException : public InvalidIdException
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
InvalidRowIdException(TierRow::IdType id);
|
||||||
|
TierRow::IdType id() const;
|
||||||
|
const char* what() const noexcept override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const TierRow::IdType _id;
|
||||||
|
const std::string _what;
|
||||||
|
};
|
||||||
|
|
||||||
|
class InvalidCardIdException : public InvalidIdException
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
InvalidCardIdException(TierCard::IdType id);
|
||||||
|
TierCard::IdType id() const;
|
||||||
|
const char* what() const noexcept override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const TierCard::IdType _id;
|
||||||
|
const std::string _what;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // INVALIDIDEXCEPTION_HPP
|
||||||
19
main.cpp
19
main.cpp
@@ -4,6 +4,7 @@
|
|||||||
#include "tiercardlayout.hpp"
|
#include "tiercardlayout.hpp"
|
||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
#include "rowholder.hpp"
|
#include "rowholder.hpp"
|
||||||
|
#include "settings.hpp"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
@@ -56,8 +57,12 @@
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
auto settings = Settings::getSettable();
|
||||||
|
settings->setCardSize(150, 150);
|
||||||
|
settings->setRowFade(.8f);
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
|
settings->setMainWindow(&w);
|
||||||
// QDockWidget dock;
|
// QDockWidget dock;
|
||||||
QScrollArea scroll;
|
QScrollArea scroll;
|
||||||
TierRow* row = TierRow::create();
|
TierRow* row = TierRow::create();
|
||||||
@@ -67,11 +72,9 @@ int main(int argc, char *argv[])
|
|||||||
row->setStyleSheet(makeBgColorString(QColor(35,35,35)));
|
row->setStyleSheet(makeBgColorString(QColor(35,35,35)));
|
||||||
card1->setText("CARD1");
|
card1->setText("CARD1");
|
||||||
card1->setBgColor(QColor(64,255,64));
|
card1->setBgColor(QColor(64,255,64));
|
||||||
card1->setFixedSize(150,150);
|
|
||||||
TierCard* card2 = TierCard::create();
|
TierCard* card2 = TierCard::create();
|
||||||
card2->setText("CARD2");
|
card2->setText("CARD2");
|
||||||
card2->setBgColor(QColor(64,64,255));
|
card2->setBgColor(QColor(64,64,255));
|
||||||
card2->setFixedSize(150,150);
|
|
||||||
row->addCard(card1);
|
row->addCard(card1);
|
||||||
row->addCard(card2);
|
row->addCard(card2);
|
||||||
|
|
||||||
@@ -81,13 +84,10 @@ int main(int argc, char *argv[])
|
|||||||
TierCard* card3 = TierCard::create();
|
TierCard* card3 = TierCard::create();
|
||||||
card3->setText("CARD1");
|
card3->setText("CARD1");
|
||||||
card3->setBgColor(QColor(64,12,164));
|
card3->setBgColor(QColor(64,12,164));
|
||||||
card3->setFixedSize(150,150);
|
|
||||||
TierCard* card4 = TierCard::create();
|
TierCard* card4 = TierCard::create();
|
||||||
card4->setText("CARD2");
|
card4->setText("CARD2");
|
||||||
card4->setBgColor(QColor(164,64,155));
|
card4->setBgColor(QColor(164,64,155));
|
||||||
card4->setFixedSize(150,150);
|
|
||||||
auto card5 = TierCard::clone(card4);
|
auto card5 = TierCard::clone(card4);
|
||||||
card5->setFixedSize(150,150);
|
|
||||||
row->addCard(card5);
|
row->addCard(card5);
|
||||||
row2->addCard(card3);
|
row2->addCard(card3);
|
||||||
row2->addCard(card4);
|
row2->addCard(card4);
|
||||||
@@ -115,11 +115,12 @@ int main(int argc, char *argv[])
|
|||||||
// a.setFont()
|
// a.setFont()
|
||||||
// QTimer bg_changer;
|
// QTimer bg_changer;
|
||||||
// bg_changer.setTimerType(Qt::PreciseTimer);
|
// bg_changer.setTimerType(Qt::PreciseTimer);
|
||||||
// bg_changer.setSingleShot(false);
|
// bg_changer.setSingleShot(true);
|
||||||
// bg_changer.setInterval(1000);
|
// bg_changer.setInterval(2000);
|
||||||
// QObject::connect(&bg_changer, &QTimer::timeout, [&row]()
|
// QObject::connect(&bg_changer, &QTimer::timeout, [&settings]()
|
||||||
// {
|
// {
|
||||||
// row.updateGeometry();
|
// // row.updateGeometry();
|
||||||
|
// settings->setCardSize(250,100);
|
||||||
// });
|
// });
|
||||||
// bg_changer.start();
|
// bg_changer.start();
|
||||||
// w.show();
|
// w.show();
|
||||||
|
|||||||
56
settings.cpp
56
settings.cpp
@@ -1,5 +1,59 @@
|
|||||||
#include "settings.hpp"
|
#include "settings.hpp"
|
||||||
|
|
||||||
|
#include <QMutexLocker>
|
||||||
|
|
||||||
Settings::Settings(QObject *parent)
|
Settings::Settings(QObject *parent)
|
||||||
: QObject{parent}
|
: QObject{parent}
|
||||||
{}
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const Settings* Settings::get()
|
||||||
|
{
|
||||||
|
return getSettable();
|
||||||
|
}
|
||||||
|
|
||||||
|
Settings* Settings::getSettable()
|
||||||
|
{
|
||||||
|
QMutexLocker locker(&lock);
|
||||||
|
if (!instance)
|
||||||
|
instance = new Settings();
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize Settings::cardSize() const
|
||||||
|
{
|
||||||
|
return _cardSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::setCardSize(QSize newSize)
|
||||||
|
{
|
||||||
|
_cardSize = newSize;
|
||||||
|
emit cardSizeChange(newSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::setCardSize(int w, int h)
|
||||||
|
{
|
||||||
|
setCardSize(QSize(w, h));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::setMainWindow(QWidget* wid)
|
||||||
|
{
|
||||||
|
_mainWindow = wid;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget* Settings::mainWindow() const
|
||||||
|
{
|
||||||
|
return _mainWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::setRowFade(float fade)
|
||||||
|
{
|
||||||
|
_rowFade = fade;
|
||||||
|
emit rowFadeChange(fade);
|
||||||
|
}
|
||||||
|
|
||||||
|
float Settings::rowFade() const
|
||||||
|
{
|
||||||
|
return _rowFade;
|
||||||
|
}
|
||||||
|
|||||||
20
settings.hpp
20
settings.hpp
@@ -2,14 +2,34 @@
|
|||||||
#define SETTINGS_HPP
|
#define SETTINGS_HPP
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QMutex>
|
||||||
|
#include <QRect>
|
||||||
|
|
||||||
class Settings : public QObject
|
class Settings : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
static const Settings* get();
|
||||||
|
static Settings* getSettable();
|
||||||
|
QSize cardSize() const;
|
||||||
|
void setCardSize(QSize size);
|
||||||
|
void setCardSize(int w, int h);
|
||||||
|
QWidget* mainWindow() const;
|
||||||
|
void setMainWindow(QWidget* wid);
|
||||||
|
float rowFade() const;
|
||||||
|
void setRowFade(float trans);
|
||||||
|
|
||||||
|
private:
|
||||||
explicit Settings(QObject *parent = nullptr);
|
explicit Settings(QObject *parent = nullptr);
|
||||||
|
inline static Settings* instance;
|
||||||
|
inline static QMutex lock;
|
||||||
|
QSize _cardSize;
|
||||||
|
QWidget* _mainWindow = nullptr;
|
||||||
|
float _rowFade = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void cardSizeChange(QSize newSize);
|
||||||
|
void rowFadeChange(float newFade);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SETTINGS_HPP
|
#endif // SETTINGS_HPP
|
||||||
|
|||||||
48
tiercard.cpp
48
tiercard.cpp
@@ -2,40 +2,10 @@
|
|||||||
#include "fullsizelayout.hpp"
|
#include "fullsizelayout.hpp"
|
||||||
#include "qmimedata.h"
|
#include "qmimedata.h"
|
||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
|
#include "settings.hpp"
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QDrag>
|
||||||
// TierCard::TierCard(QWidget *parent)
|
|
||||||
// : QWidget{parent}
|
|
||||||
// {
|
|
||||||
// auto bg_layout= new QVBoxLayout(this);
|
|
||||||
// bg_layout->setSpacing(0);
|
|
||||||
// bg_layout->setContentsMargins(0, 0, 0, 0);
|
|
||||||
// background = new QWidget();
|
|
||||||
// bg_layout->addWidget(background);
|
|
||||||
// auto img_layout = new QVBoxLayout(background);
|
|
||||||
// img_layout->setSpacing(0);
|
|
||||||
// img_layout->setContentsMargins(0, 0, 0, 0);
|
|
||||||
// image = new AspectRatioPixmapLabel();
|
|
||||||
// img_layout->addWidget(image, 0, Qt::AlignCenter);
|
|
||||||
// image->setAttribute(Qt::WA_TranslucentBackground);
|
|
||||||
// image->setAlignment(Qt::AlignCenter);
|
|
||||||
// auto txt_layout = new QVBoxLayout(image);
|
|
||||||
// txt_layout->setSpacing(0);
|
|
||||||
// txt_layout->setContentsMargins(0, 0, 0, 0);
|
|
||||||
// text_label = new QLabel();
|
|
||||||
// id_label = new QLabel("4");
|
|
||||||
// text_label->setWordWrap(true);
|
|
||||||
// // text_label->setTextFormat(Qt::RichText);
|
|
||||||
// text_label->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
|
|
||||||
// id_label->setAlignment(Qt::AlignLeft | Qt::AlignBottom);
|
|
||||||
// text_label->setAttribute(Qt::WA_TranslucentBackground);
|
|
||||||
// id_label->setAttribute(Qt::WA_TranslucentBackground);
|
|
||||||
// txt_layout->addWidget(text_label, Qt::AlignTop | Qt::AlignHCenter);
|
|
||||||
// txt_layout->addWidget(id_label, Qt::AlignBottom, Qt::AlignLeft);
|
|
||||||
// text_label->setProperty("cssClass", "tierCardText");
|
|
||||||
// id_label->setProperty("cssClass", "tierCardId");
|
|
||||||
// }
|
|
||||||
|
|
||||||
TierCard::IdType TierCard::getAvailableId()
|
TierCard::IdType TierCard::getAvailableId()
|
||||||
{
|
{
|
||||||
@@ -72,6 +42,7 @@ TierCard* TierCard::clone(TierCard *other, QWidget* parent)
|
|||||||
card = new TierCard(id, parent);
|
card = new TierCard(id, parent);
|
||||||
card->setText(other->getText());
|
card->setText(other->getText());
|
||||||
auto img = other->getImage();
|
auto img = other->getImage();
|
||||||
|
if (!img.isNull())
|
||||||
card->setImage(img);
|
card->setImage(img);
|
||||||
card->setBgColor(other->getBgColor());
|
card->setBgColor(other->getBgColor());
|
||||||
idMap[id] = card;
|
idMap[id] = card;
|
||||||
@@ -81,6 +52,9 @@ TierCard* TierCard::clone(TierCard *other, QWidget* parent)
|
|||||||
TierCard::TierCard(IdType id, QWidget* parent)
|
TierCard::TierCard(IdType id, QWidget* parent)
|
||||||
: QWidget{parent}
|
: QWidget{parent}
|
||||||
{
|
{
|
||||||
|
auto settings = Settings::get();
|
||||||
|
connect(settings, SIGNAL(cardSizeChange(QSize)),
|
||||||
|
this, SLOT(cardResize(QSize)));
|
||||||
background = new QWidget();
|
background = new QWidget();
|
||||||
image = new AspectRatioPixmapLabel();
|
image = new AspectRatioPixmapLabel();
|
||||||
image->setAttribute(Qt::WA_TranslucentBackground);
|
image->setAttribute(Qt::WA_TranslucentBackground);
|
||||||
@@ -102,6 +76,7 @@ TierCard::TierCard(IdType id, QWidget* parent)
|
|||||||
layout->addWidget(textLabel);
|
layout->addWidget(textLabel);
|
||||||
layout->addWidget(idLabel);
|
layout->addWidget(idLabel);
|
||||||
this->setLayout(layout);
|
this->setLayout(layout);
|
||||||
|
cardResize(settings->cardSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
TierCard::~TierCard()
|
TierCard::~TierCard()
|
||||||
@@ -158,9 +133,11 @@ void TierCard::mousePressEvent(QMouseEvent* event)
|
|||||||
render(&pix);
|
render(&pix);
|
||||||
QDrag drag(this);
|
QDrag drag(this);
|
||||||
drag.setPixmap(pix);
|
drag.setPixmap(pix);
|
||||||
|
drag.setHotSpot(QPoint(pix.size().width() / 2,
|
||||||
|
pix.size().height() / 2));
|
||||||
QByteArray itemData;
|
QByteArray itemData;
|
||||||
QDataStream dataStream(&itemData, QIODevice::WriteOnly);
|
QDataStream dataStream(&itemData, QIODevice::WriteOnly);
|
||||||
auto _id = getId();
|
TierCard::IdType _id = getId();
|
||||||
dataStream.writeRawData(reinterpret_cast<char*>(&_id), sizeof(_id));
|
dataStream.writeRawData(reinterpret_cast<char*>(&_id), sizeof(_id));
|
||||||
QMimeData *mimeData = new QMimeData;
|
QMimeData *mimeData = new QMimeData;
|
||||||
mimeData->setData(MimeType, itemData);
|
mimeData->setData(MimeType, itemData);
|
||||||
@@ -183,3 +160,8 @@ TierCard* TierCard::getFromId(IdType id)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
return &(*iter->second);
|
return &(*iter->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TierCard::cardResize(QSize newSize)
|
||||||
|
{
|
||||||
|
setFixedSize(newSize);
|
||||||
|
}
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ private:
|
|||||||
static void releaseId(IdType id);
|
static void releaseId(IdType id);
|
||||||
inline static std::unordered_map<IdType, TierCard*> idMap;
|
inline static std::unordered_map<IdType, TierCard*> idMap;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void cardResize(QSize newSize);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
24
tierplaceholder.cpp
Normal file
24
tierplaceholder.cpp
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#include "tierplaceholder.hpp"
|
||||||
|
#include "settings.hpp"
|
||||||
|
|
||||||
|
TierPlaceholder::TierPlaceholder(QWidget *parent)
|
||||||
|
: QWidget{parent}
|
||||||
|
{
|
||||||
|
auto settings = Settings::get();
|
||||||
|
connect(settings, SIGNAL(cardSizeChange(QSize)),
|
||||||
|
this, SLOT(cardResize(QSize)));
|
||||||
|
QSizePolicy sp;
|
||||||
|
sp.setRetainSizeWhenHidden(true);
|
||||||
|
sp.setHorizontalPolicy(QSizePolicy::Fixed);
|
||||||
|
sp.setVerticalPolicy(QSizePolicy::Fixed);
|
||||||
|
setSizePolicy(sp);
|
||||||
|
//TODO potentially a race condition if card size is
|
||||||
|
//changed between settings->cardSize() being evaluated
|
||||||
|
//and cardResize() being called
|
||||||
|
cardResize(settings->cardSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
void TierPlaceholder::cardResize(QSize newSize)
|
||||||
|
{
|
||||||
|
setFixedSize(newSize);
|
||||||
|
}
|
||||||
18
tierplaceholder.hpp
Normal file
18
tierplaceholder.hpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef TIERPLACEHOLDER_HPP
|
||||||
|
#define TIERPLACEHOLDER_HPP
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class TierPlaceholder : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit TierPlaceholder(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void cardResize(QSize newSize);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TIERPLACEHOLDER_HPP
|
||||||
145
tierrow.cpp
145
tierrow.cpp
@@ -1,49 +1,44 @@
|
|||||||
#include "tierrow.hpp"
|
#include "tierrow.hpp"
|
||||||
#include "fullsizelayout.hpp"
|
// #include "fullsizelayout.hpp"
|
||||||
#include "qmimedata.h"
|
#include "qmimedata.h"
|
||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
|
#include "settings.hpp"
|
||||||
|
#include "invalididexception.hpp"
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
TierRow::TierRow(IdType id, QWidget *parent)
|
TierRow::TierRow(IdType id, QWidget *parent)
|
||||||
: QWidget{parent}
|
: QWidget{parent}, _id(id)
|
||||||
{
|
{
|
||||||
|
auto settings = Settings::get();
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
auto fadeLayout = new FullSizeLayout();
|
|
||||||
fadeLayout->setSizeConstraint(QLayout::SetMinimumSize);
|
|
||||||
fadeLayout->setContentsMargins(0, 0, 0, 0);
|
|
||||||
fadeLayout->setSpacing(0);
|
|
||||||
bgFadeContainer = new QWidget();
|
|
||||||
bgFadeContainer->setStyleSheet(makeBgColorString(QColor(255,255,255,100)));
|
|
||||||
bgFadeContainer->setMinimumSize(0, 0);
|
|
||||||
fadeLayout->addWidget(bgFadeContainer);
|
|
||||||
this->setLayout(fadeLayout);
|
|
||||||
auto splitLayout = new QHBoxLayout();
|
auto splitLayout = new QHBoxLayout();
|
||||||
splitLayout->setSizeConstraint(QLayout::SetMinimumSize);
|
splitLayout->setSizeConstraint(QLayout::SetMinimumSize);
|
||||||
splitLayout->setContentsMargins(0, 0, 0, 0);
|
splitLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
splitLayout->setSpacing(0);
|
splitLayout->setSpacing(0);
|
||||||
|
this->setLayout(splitLayout);
|
||||||
titleCard = new TierRowTitleCard(id);
|
titleCard = new TierRowTitleCard(id);
|
||||||
cardContainer = new QWidget();
|
cardContainer = new QWidget();
|
||||||
cardContainer->setMinimumSize(0, 0);
|
|
||||||
titleCard->setFixedSize(150, 150);
|
|
||||||
cardContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
cardContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||||
splitLayout->addWidget(titleCard, 0, Qt::AlignLeft | Qt::AlignTop);
|
splitLayout->addWidget(titleCard, 0, Qt::AlignLeft | Qt::AlignTop);
|
||||||
splitLayout->addWidget(cardContainer, 1, Qt::AlignTop);
|
splitLayout->addWidget(cardContainer, 1, Qt::AlignTop);
|
||||||
|
|
||||||
cardContainer->setStyleSheet(makeBgColorString(QColor(60,60,60,100)));
|
// cardContainer->setStyleSheet(makeBgColorString(QColor(60,60,60,100)));
|
||||||
|
cardLayout = new FlowLayout(nullptr, 0, 0, 0);
|
||||||
bgFadeContainer->setLayout(splitLayout);
|
|
||||||
cardLayout = new FlowLayout();
|
|
||||||
cardLayout->setSizeConstraint(QLayout::SetMinimumSize);
|
cardLayout->setSizeConstraint(QLayout::SetMinimumSize);
|
||||||
cardLayout->setContentsMargins(0, 0, 0, 0);
|
cardLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
cardLayout->setSpacing(0);
|
cardLayout->setSpacing(0);
|
||||||
cardContainer->setLayout(cardLayout);
|
cardContainer->setLayout(cardLayout);
|
||||||
// setMinimumSize(0, 0);
|
connect(settings, SIGNAL(cardSizeChange(QSize)),
|
||||||
|
this, SLOT(cardResize(QSize)));
|
||||||
|
connect(settings, SIGNAL(rowFadeChange(float)),
|
||||||
|
this, SLOT(fadeChange(float)));
|
||||||
|
cardResize(settings->cardSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
TierRow::~TierRow()
|
TierRow::~TierRow()
|
||||||
{
|
{
|
||||||
qDebug() << "Row destructor called " << id();
|
// qDebug() << "Row destructor called " << id();
|
||||||
if (idMap.erase(id()) == 0)
|
if (idMap.erase(id()) == 0)
|
||||||
{
|
{
|
||||||
qDebug() << "Row id not found during destructor";
|
qDebug() << "Row id not found during destructor";
|
||||||
@@ -60,12 +55,20 @@ void TierRow::addCard(TierCard* card)
|
|||||||
// }
|
// }
|
||||||
void TierRow::setColor(QColor color)
|
void TierRow::setColor(QColor color)
|
||||||
{
|
{
|
||||||
|
auto settings = Settings::get();
|
||||||
|
auto fade = settings->rowFade();
|
||||||
|
if (fade < 0)
|
||||||
|
fade = 0;
|
||||||
|
if (fade > 1)
|
||||||
|
fade = 1;
|
||||||
_color = color;
|
_color = color;
|
||||||
|
const QColor wh(255,255,255);
|
||||||
titleCard->setColor(color);
|
titleCard->setColor(color);
|
||||||
auto str = makeBgColorString(color);
|
auto fadedColor = blend(wh, color, fade);
|
||||||
|
auto str = makeBgColorString(fadedColor);
|
||||||
setStyleSheet(str);
|
setStyleSheet(str);
|
||||||
}
|
}
|
||||||
QColor TierRow::color()
|
QColor TierRow::color() const
|
||||||
{
|
{
|
||||||
return _color;
|
return _color;
|
||||||
}
|
}
|
||||||
@@ -73,13 +76,13 @@ void TierRow::setText(QString text)
|
|||||||
{
|
{
|
||||||
titleCard->setText(text);
|
titleCard->setText(text);
|
||||||
}
|
}
|
||||||
QString TierRow::text()
|
QString TierRow::text() const
|
||||||
{
|
{
|
||||||
return titleCard->text();
|
return titleCard->text();
|
||||||
}
|
}
|
||||||
uint32_t TierRow::id()
|
uint32_t TierRow::id() const
|
||||||
{
|
{
|
||||||
return titleCard->id();
|
return _id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TierRow::resizeEvent(QResizeEvent* event)
|
void TierRow::resizeEvent(QResizeEvent* event)
|
||||||
@@ -90,7 +93,8 @@ void TierRow::resizeEvent(QResizeEvent* event)
|
|||||||
|
|
||||||
void TierRow::recalcMaxHeight()
|
void TierRow::recalcMaxHeight()
|
||||||
{
|
{
|
||||||
setMaximumHeight(cardLayout->totalMinimumHeightForWidth(cardContainer->width()));
|
setMaximumHeight(cardLayout->totalMinimumHeightForWidth(
|
||||||
|
cardContainer->width()));
|
||||||
}
|
}
|
||||||
|
|
||||||
TierRow* TierRow::create(QWidget* parent)
|
TierRow* TierRow::create(QWidget* parent)
|
||||||
@@ -117,21 +121,25 @@ TierRow* TierRow::getFromId(IdType id)
|
|||||||
return iter->second;
|
return iter->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TierRow::dropEvent(QDropEvent *event)
|
void TierRow::dropEvent(QDropEvent* event)
|
||||||
{
|
{
|
||||||
qDebug() << "drop event";
|
qDebug() << "drop event";
|
||||||
|
// auto source = event->source();
|
||||||
//card dragged to this row
|
//card dragged to this row
|
||||||
if (event->mimeData()->hasFormat(TierCard::MimeType))
|
if (event->mimeData()->hasFormat(TierCard::MimeType))
|
||||||
{
|
{
|
||||||
if (event->proposedAction() == Qt::MoveAction)
|
if (event->proposedAction() == Qt::MoveAction)
|
||||||
{
|
{
|
||||||
|
clearPlaceholder();
|
||||||
auto data = event->mimeData()->data(TierCard::MimeType);
|
auto data = event->mimeData()->data(TierCard::MimeType);
|
||||||
QDataStream stream(&data, QIODevice::ReadOnly);
|
QDataStream stream(&data, QIODevice::ReadOnly);
|
||||||
TierCard::IdType cardId;
|
TierCard::IdType cardId;
|
||||||
uint dataLen = 0;
|
stream.readRawData(reinterpret_cast<char*>(&cardId), sizeof(cardId));
|
||||||
stream.readRawData(reinterpret_cast<char*>(&cardId), dataLen);
|
|
||||||
auto card = TierCard::getFromId(cardId);
|
auto card = TierCard::getFromId(cardId);
|
||||||
addCard(card);
|
if (!card)
|
||||||
|
throw InvalidCardIdException(cardId);
|
||||||
|
// addCard(card);
|
||||||
|
cardLayout->setIndex(card, calculateIndex(event->position()));
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -146,13 +154,24 @@ void TierRow::dropEvent(QDropEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TierRow::dragEnterEvent(QDragEnterEvent *event)
|
void TierRow::dragEnterEvent(QDragEnterEvent* event)
|
||||||
{
|
{
|
||||||
qDebug() << "drag enter event";
|
qDebug() << "drag enter event";
|
||||||
|
if (cardCount() == 0)
|
||||||
|
{
|
||||||
|
qDebug() << "enter empty";
|
||||||
|
}
|
||||||
if (event->mimeData()->hasFormat(TierCard::MimeType))
|
if (event->mimeData()->hasFormat(TierCard::MimeType))
|
||||||
{
|
{
|
||||||
if (event->proposedAction() == Qt::MoveAction)
|
if (event->proposedAction() == Qt::MoveAction)
|
||||||
{
|
{
|
||||||
|
if (placeholder != nullptr)
|
||||||
|
{
|
||||||
|
qDebug() << "placeholder not previously cleared";
|
||||||
|
clearPlaceholder();
|
||||||
|
}
|
||||||
|
placeholder = new TierPlaceholder();
|
||||||
|
cardLayout->setIndex(placeholder, calculateIndex(event->position()));
|
||||||
event->setDropAction(Qt::MoveAction);
|
event->setDropAction(Qt::MoveAction);
|
||||||
event->accept(cardContainer->rect());
|
event->accept(cardContainer->rect());
|
||||||
}
|
}
|
||||||
@@ -172,13 +191,18 @@ void TierRow::dragEnterEvent(QDragEnterEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TierRow::dragMoveEvent(QDragMoveEvent *event)
|
void TierRow::dragMoveEvent(QDragMoveEvent* event)
|
||||||
{
|
{
|
||||||
qDebug() << "drag move event";
|
|
||||||
if (event->mimeData()->hasFormat(TierCard::MimeType))
|
if (event->mimeData()->hasFormat(TierCard::MimeType))
|
||||||
{
|
{
|
||||||
if (event->proposedAction() == Qt::MoveAction)
|
if (event->proposedAction() == Qt::MoveAction)
|
||||||
{
|
{
|
||||||
|
if (cardCount() == 1)
|
||||||
|
{
|
||||||
|
qDebug() << "moving in empty";
|
||||||
|
}
|
||||||
|
if (placeholder)
|
||||||
|
cardLayout->setIndex(placeholder, calculateIndex(event->position()));
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -190,9 +214,62 @@ void TierRow::dragMoveEvent(QDragMoveEvent *event)
|
|||||||
else if (event->mimeData()->hasImage())
|
else if (event->mimeData()->hasImage())
|
||||||
{
|
{
|
||||||
event->setDropAction(Qt::CopyAction);
|
event->setDropAction(Qt::CopyAction);
|
||||||
event->accept();
|
//TODO event->accept();
|
||||||
|
event->ignore();
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TierRow::dragLeaveEvent(QDragLeaveEvent* event)
|
||||||
|
{
|
||||||
|
clearPlaceholder();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TierRow::clearPlaceholder()
|
||||||
|
{
|
||||||
|
placeholder->setParent(nullptr);
|
||||||
|
placeholder->deleteLater();
|
||||||
|
placeholder = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TierRow::calculateIndex(QPointF loc)
|
||||||
|
{
|
||||||
|
auto settings = Settings::get();
|
||||||
|
auto cardSize = settings->cardSize();
|
||||||
|
auto cardCenter = loc + QPointF(cardSize.width() / 2,
|
||||||
|
cardSize.height() / 2);
|
||||||
|
auto lastBefore = 0;
|
||||||
|
for (int i = 0; i < cardLayout->count(); i++)
|
||||||
|
{
|
||||||
|
auto refCard = cardLayout->itemAt(i);
|
||||||
|
auto refPos = refCard->widget()->pos();
|
||||||
|
if (cardCenter.y() > refPos.y()
|
||||||
|
&& cardCenter.x() > refPos.x())
|
||||||
|
lastBefore = i;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return lastBefore;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TierRow::cardResize(QSize newSize)
|
||||||
|
{
|
||||||
|
titleCard->setFixedSize(newSize);
|
||||||
|
cardContainer->setMinimumHeight(newSize.height());
|
||||||
|
cardContainer->updateGeometry();
|
||||||
|
updateGeometry();
|
||||||
|
Settings::get()->mainWindow()->updateGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TierRow::fadeChange(float newFade)
|
||||||
|
{
|
||||||
|
setColor(_color);
|
||||||
|
}
|
||||||
|
|
||||||
|
int TierRow::cardCount() const
|
||||||
|
{
|
||||||
|
return cardLayout->count();
|
||||||
|
}
|
||||||
|
|||||||
25
tierrow.hpp
25
tierrow.hpp
@@ -4,10 +4,13 @@
|
|||||||
#include "tiercard.hpp"
|
#include "tiercard.hpp"
|
||||||
#include "tierrowtitlecard.hpp"
|
#include "tierrowtitlecard.hpp"
|
||||||
#include "flowlayout.h"
|
#include "flowlayout.h"
|
||||||
|
#include "tierplaceholder.hpp"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QDrag>
|
#include <QDrag>
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
class TierRow : public QWidget
|
class TierRow : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -18,31 +21,37 @@ public:
|
|||||||
~TierRow();
|
~TierRow();
|
||||||
void addCard(TierCard* card);
|
void addCard(TierCard* card);
|
||||||
TierCard* takeCard(uint32_t id);
|
TierCard* takeCard(uint32_t id);
|
||||||
|
int cardCount() const;
|
||||||
void setColor(QColor color);
|
void setColor(QColor color);
|
||||||
QColor color();
|
QColor color() const;
|
||||||
void setText(QString text);
|
void setText(QString text);
|
||||||
QString text();
|
QString text() const;
|
||||||
uint32_t id();
|
uint32_t id() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent* event) override;
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
// void mousePressEvent(QMouseEvent* event) override;
|
// void mousePressEvent(QMouseEvent* event) override;
|
||||||
void dropEvent(QDropEvent *event) override;
|
void dropEvent(QDropEvent *event) override;
|
||||||
void dragEnterEvent(QDragEnterEvent *event) override;
|
void dragEnterEvent(QDragEnterEvent* event) override;
|
||||||
void dragMoveEvent(QDragMoveEvent *event) override;
|
void dragLeaveEvent(QDragLeaveEvent* event) override;
|
||||||
|
void dragMoveEvent(QDragMoveEvent* event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit TierRow(IdType id, QWidget* parent = nullptr);
|
explicit TierRow(IdType id, QWidget* parent = nullptr);
|
||||||
TierRowTitleCard* titleCard;
|
TierRowTitleCard* titleCard;
|
||||||
QWidget* bgFadeContainer;
|
|
||||||
QWidget* cardContainer;
|
QWidget* cardContainer;
|
||||||
QLayout* cardLayout;
|
FlowLayout* cardLayout;
|
||||||
QColor _color;
|
QColor _color;
|
||||||
|
const IdType _id;
|
||||||
|
TierPlaceholder* placeholder = nullptr;
|
||||||
void recalcMaxHeight();
|
void recalcMaxHeight();
|
||||||
|
void clearPlaceholder();
|
||||||
|
int calculateIndex(QPointF loc);
|
||||||
inline static std::unordered_map<IdType, TierRow*> idMap;
|
inline static std::unordered_map<IdType, TierRow*> idMap;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void cardResize(QRect newSize);
|
void cardResize(QSize newSize);
|
||||||
|
void fadeChange(float newFade);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
|
|
||||||
TierRowTitleCard::TierRowTitleCard(IdType id, QWidget *parent)
|
TierRowTitleCard::TierRowTitleCard(IdType id, QWidget *parent)
|
||||||
: QFrame{parent}
|
: QFrame{parent}, _id(id)
|
||||||
{
|
{
|
||||||
this->setFrameStyle(QFrame::Box | QFrame::Plain);
|
this->setFrameStyle(QFrame::Box | QFrame::Plain);
|
||||||
auto layout = new FullSizeLayout();
|
auto layout = new FullSizeLayout();
|
||||||
@@ -38,5 +38,5 @@ void TierRowTitleCard::setColor(QColor color)
|
|||||||
|
|
||||||
uint32_t TierRowTitleCard::id() const
|
uint32_t TierRowTitleCard::id() const
|
||||||
{
|
{
|
||||||
return static_cast<uint32_t>(idLabel->text().toUInt());
|
return _id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ private:
|
|||||||
QColor _color;
|
QColor _color;
|
||||||
QLabel* titleLabel;
|
QLabel* titleLabel;
|
||||||
QLabel* idLabel;
|
QLabel* idLabel;
|
||||||
|
const IdType _id;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
};
|
};
|
||||||
|
|||||||
13
utils.hpp
13
utils.hpp
@@ -1,7 +1,7 @@
|
|||||||
#ifndef UTILS_HPP
|
#ifndef UTILS_HPP
|
||||||
#define UTILS_HPP
|
#define UTILS_HPP
|
||||||
|
|
||||||
#include "tierrow.hpp"
|
// #include "tierrow.hpp"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@@ -53,4 +53,15 @@ T* findParentOfType(QObject* obj)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline QColor blend(QColor first, QColor second, float portionFirst)
|
||||||
|
{
|
||||||
|
const float& pf = portionFirst;
|
||||||
|
const float ps = 1 - pf;
|
||||||
|
return QColor(
|
||||||
|
first.red()*pf + second.red()*ps,
|
||||||
|
first.green()*pf + second.green()*ps,
|
||||||
|
first.blue()*pf + second.blue()*ps
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // UTILS_HPP
|
#endif // UTILS_HPP
|
||||||
|
|||||||
Reference in New Issue
Block a user