improved splits
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
//#include "dropoverlay.hpp"
|
||||
|
||||
// namespace chatterino {
|
||||
// namespace widgets {
|
||||
// namespace helper {
|
||||
|
||||
// DropOverlay::DropOverlay()
|
||||
//{
|
||||
//}
|
||||
|
||||
//} // namespace helper
|
||||
//} // namespace widgets
|
||||
//} // namespace chatterino
|
||||
@@ -0,0 +1,11 @@
|
||||
//#pragma once
|
||||
|
||||
//#include "widgets/helper/splitnode.hpp"
|
||||
|
||||
// namespace chatterino {
|
||||
// namespace widgets {
|
||||
// namespace helper {
|
||||
|
||||
//} // namespace helper
|
||||
//} // namespace widgets
|
||||
//} // namespace chatterino
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "splitnode.hpp"
|
||||
|
||||
SplitNode::SplitNode()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef SPLITNODE_HPP
|
||||
#define SPLITNODE_HPP
|
||||
|
||||
|
||||
class SplitNode
|
||||
{
|
||||
public:
|
||||
SplitNode();
|
||||
};
|
||||
|
||||
#endif // SPLITNODE_HPP
|
||||
@@ -19,6 +19,7 @@ SplitOverlay::SplitOverlay(Split *parent)
|
||||
, split(parent)
|
||||
{
|
||||
QGridLayout *layout = new QGridLayout(this);
|
||||
this->_layout = layout;
|
||||
layout->setMargin(1);
|
||||
layout->setSpacing(1);
|
||||
|
||||
@@ -28,10 +29,11 @@ SplitOverlay::SplitOverlay(Split *parent)
|
||||
layout->setColumnStretch(3, 1);
|
||||
|
||||
QPushButton *move = new QPushButton(getApp()->resources->split.move, QString());
|
||||
QPushButton *left = new QPushButton(getApp()->resources->split.left, QString());
|
||||
QPushButton *right = new QPushButton(getApp()->resources->split.right, QString());
|
||||
QPushButton *up = new QPushButton(getApp()->resources->split.up, QString());
|
||||
QPushButton *down = new QPushButton(getApp()->resources->split.down, QString());
|
||||
QPushButton *left = this->_left = new QPushButton(getApp()->resources->split.left, QString());
|
||||
QPushButton *right = this->_right =
|
||||
new QPushButton(getApp()->resources->split.right, QString());
|
||||
QPushButton *up = this->_up = new QPushButton(getApp()->resources->split.up, QString());
|
||||
QPushButton *down = this->_down = new QPushButton(getApp()->resources->split.down, QString());
|
||||
|
||||
move->setGraphicsEffect(new QGraphicsOpacityEffect(this));
|
||||
left->setGraphicsEffect(new QGraphicsOpacityEffect(this));
|
||||
@@ -108,6 +110,18 @@ void SplitOverlay::paintEvent(QPaintEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
void SplitOverlay::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
float scale = this->getScale();
|
||||
bool wideEnough = event->size().width() > 150 * scale;
|
||||
bool highEnough = event->size().height() > 150 * scale;
|
||||
|
||||
this->_left->setVisible(wideEnough);
|
||||
this->_right->setVisible(wideEnough);
|
||||
this->_up->setVisible(highEnough);
|
||||
this->_down->setVisible(highEnough);
|
||||
}
|
||||
|
||||
SplitOverlay::ButtonEventFilter::ButtonEventFilter(SplitOverlay *_parent, HoveredElement _element)
|
||||
: QObject(_parent)
|
||||
, parent(_parent)
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "pajlada/signals/signalholder.hpp"
|
||||
#include "widgets/basewidget.hpp"
|
||||
|
||||
@@ -15,12 +18,18 @@ public:
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
private:
|
||||
// fourtf: !!! preserve the order of left, up, right and down
|
||||
enum HoveredElement { None, SplitMove, SplitLeft, SplitUp, SplitRight, SplitDown };
|
||||
HoveredElement hoveredElement = None;
|
||||
Split *split;
|
||||
QGridLayout *_layout;
|
||||
QPushButton *_left;
|
||||
QPushButton *_up;
|
||||
QPushButton *_right;
|
||||
QPushButton *_down;
|
||||
|
||||
class ButtonEventFilter : public QObject
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user