2019-09-29 01:40:19 +08:00
|
|
|
#include "bottombuttongroup.h"
|
|
|
|
|
2019-10-06 14:58:01 +08:00
|
|
|
#include "opacityhelper.h"
|
|
|
|
|
2019-09-30 23:02:44 +08:00
|
|
|
#include <functional>
|
|
|
|
|
2019-09-29 01:40:19 +08:00
|
|
|
#include <QPushButton>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
BottomButtonGroup::BottomButtonGroup(QWidget *parent)
|
|
|
|
: QGroupBox (parent)
|
2019-10-06 14:58:01 +08:00
|
|
|
, m_opacityHelper(new OpacityHelper(this))
|
2019-09-29 01:40:19 +08:00
|
|
|
{
|
|
|
|
QHBoxLayout * mainLayout = new QHBoxLayout(this);
|
|
|
|
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
|
|
|
this->setLayout(mainLayout);
|
|
|
|
this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
|
|
|
this->setStyleSheet("BottomButtonGroup {"
|
|
|
|
"border: 1px solid gray;"
|
|
|
|
"border-top-left-radius: 10px;"
|
|
|
|
"border-top-right-radius: 10px;"
|
2019-09-29 22:18:38 +08:00
|
|
|
"border-style: none;"
|
|
|
|
"background-color:rgba(0,0,0,120)"
|
2019-09-29 01:40:19 +08:00
|
|
|
"}"
|
|
|
|
"QPushButton {"
|
|
|
|
"background-color:rgba(225,255,255,0);"
|
|
|
|
"color: white;"
|
2019-09-30 13:11:43 +08:00
|
|
|
"border-style: none;"
|
2019-09-29 01:40:19 +08:00
|
|
|
"}");
|
|
|
|
|
2019-09-30 23:02:44 +08:00
|
|
|
auto newBtn = [](QString text, std::function<void()> func) -> QPushButton * {
|
2019-09-29 23:53:29 +08:00
|
|
|
QPushButton * btn = new QPushButton(QIcon(QStringLiteral(":/icons/") + text), "");
|
|
|
|
btn->setIconSize(QSize(40, 40));
|
2019-09-29 01:40:19 +08:00
|
|
|
btn->setFixedSize(40, 40);
|
2019-09-30 23:02:44 +08:00
|
|
|
connect(btn, &QAbstractButton::clicked, btn, func);
|
2019-09-29 01:40:19 +08:00
|
|
|
return btn;
|
|
|
|
};
|
2019-09-30 23:02:44 +08:00
|
|
|
addButton(newBtn("zoom-original", [this]() {
|
|
|
|
emit resetToOriginalBtnClicked();
|
|
|
|
}));
|
2019-10-04 21:34:20 +08:00
|
|
|
addButton(newBtn("view-fullscreen", [this]() {
|
|
|
|
emit toggleWindowMaximum();
|
|
|
|
}));
|
2019-09-30 23:02:44 +08:00
|
|
|
addButton(newBtn("zoom-in", [this]() {
|
|
|
|
emit zoomInBtnClicked();
|
|
|
|
}));
|
|
|
|
addButton(newBtn("zoom-out", [this]() {
|
|
|
|
emit zoomOutBtnClicked();
|
|
|
|
}));
|
|
|
|
addButton(newBtn("view-background-checkerboard", [this]() {
|
|
|
|
emit toggleCheckerboardBtnClicked();
|
|
|
|
}));
|
2019-10-02 14:31:24 +08:00
|
|
|
addButton(newBtn("object-rotate-right", [this]() {
|
|
|
|
emit rotateRightBtnClicked();
|
|
|
|
}));
|
2019-09-29 01:40:19 +08:00
|
|
|
}
|
|
|
|
|
2019-10-06 14:58:01 +08:00
|
|
|
void BottomButtonGroup::setOpacity(qreal opacity, bool animated)
|
|
|
|
{
|
|
|
|
m_opacityHelper->setOpacity(opacity, animated);
|
|
|
|
}
|
|
|
|
|
2019-09-29 01:40:19 +08:00
|
|
|
void BottomButtonGroup::addButton(QAbstractButton *button)
|
|
|
|
{
|
|
|
|
layout()->addWidget(button);
|
|
|
|
updateGeometry();
|
|
|
|
}
|