114 lines
3.3 KiB
C++
114 lines
3.3 KiB
C++
#ifndef BASEWIN_H
|
|
#define BASEWIN_H
|
|
|
|
#include <QDialog>
|
|
#include <QBoxLayout>
|
|
#include <QPen>
|
|
|
|
class BaseWinBase {
|
|
public:
|
|
explicit BaseWinBase(QWidget *that);
|
|
QHBoxLayout *addBtns(QHBoxLayout *);
|
|
QWidget *center{0};
|
|
QPen borderPenAct{QColor{0x0077cc}};
|
|
QPen borderPenUnact{Qt::gray};
|
|
qreal borderRadius{4.0};
|
|
QPointF titlePos{36, 26};
|
|
QRect iconRect{13, 13, 16, 16};
|
|
protected:
|
|
void paintEvent();
|
|
void mousePressEvent(QMouseEvent *);
|
|
void mouseReleaseEvent(QMouseEvent *);
|
|
void mouseMoveEvent(QMouseEvent *);
|
|
void leaveEvent();
|
|
void mouseDoubleClickEvent(QMouseEvent *);
|
|
bool eventFilter(QObject *, QEvent *);
|
|
void changeEvent(QEvent *);
|
|
#ifdef _MSC_VER
|
|
bool nativeEvent(const QByteArray &, void *);
|
|
#endif
|
|
void setFrmSec(const QPoint &pos);
|
|
void setFrmSecIfNeed(Qt::WindowFrameSection frmSec, Qt::CursorShape cursor);
|
|
|
|
QPoint mPressRel{INT_MIN, INT_MIN};
|
|
QSize mSize;
|
|
Qt::WindowFrameSection mFrmSec{Qt::NoSection};
|
|
bool isActive{false};
|
|
QWidget *that{0};
|
|
};
|
|
|
|
class BaseWin : public QWidget, public BaseWinBase {
|
|
Q_OBJECT
|
|
public:
|
|
explicit BaseWin(QWidget *parent = nullptr) : QWidget{parent, Qt::Window}, BaseWinBase{this} {}
|
|
protected:
|
|
void paintEvent(QPaintEvent *e) override {
|
|
QWidget::paintEvent(e);
|
|
BaseWinBase::paintEvent();
|
|
}
|
|
void mousePressEvent(QMouseEvent *e) override {
|
|
BaseWinBase::mousePressEvent(e);
|
|
}
|
|
void mouseReleaseEvent(QMouseEvent *e) override {
|
|
BaseWinBase::mouseReleaseEvent(e);
|
|
}
|
|
void mouseMoveEvent(QMouseEvent *e) override {
|
|
BaseWinBase::mouseMoveEvent(e);
|
|
}
|
|
void leaveEvent(QEvent *) override {
|
|
BaseWinBase::leaveEvent();
|
|
}
|
|
void mouseDoubleClickEvent(QMouseEvent *e) override {
|
|
BaseWinBase::mouseDoubleClickEvent(e);
|
|
}
|
|
bool eventFilter(QObject *watched, QEvent *e) override {
|
|
return BaseWinBase::eventFilter(watched, e);
|
|
}
|
|
void changeEvent(QEvent *e) override {
|
|
BaseWinBase::changeEvent(e);
|
|
}
|
|
#ifdef _MSC_VER
|
|
bool nativeEvent(const QByteArray &eventType, void *message, long *) override {
|
|
return BaseWinBase::nativeEvent(eventType, message);
|
|
}
|
|
#endif
|
|
};
|
|
|
|
class BaseDlg : public QDialog, public BaseWinBase {
|
|
Q_OBJECT
|
|
public:
|
|
explicit BaseDlg(QWidget *parent = nullptr) : QDialog{parent}, BaseWinBase{this} {}
|
|
protected:
|
|
void paintEvent(QPaintEvent *e) override {
|
|
QDialog::paintEvent(e);
|
|
BaseWinBase::paintEvent();
|
|
}
|
|
void mousePressEvent(QMouseEvent *e) override {
|
|
BaseWinBase::mousePressEvent(e);
|
|
}
|
|
void mouseReleaseEvent(QMouseEvent *e) override {
|
|
BaseWinBase::mouseReleaseEvent(e);
|
|
}
|
|
void mouseMoveEvent(QMouseEvent *e) override {
|
|
BaseWinBase::mouseMoveEvent(e);
|
|
}
|
|
void leaveEvent(QEvent *) override {
|
|
BaseWinBase::leaveEvent();
|
|
}
|
|
void mouseDoubleClickEvent(QMouseEvent *e) override {
|
|
BaseWinBase::mouseDoubleClickEvent(e);
|
|
}
|
|
bool eventFilter(QObject *watched, QEvent *e) override {
|
|
return BaseWinBase::eventFilter(watched, e);
|
|
}
|
|
void changeEvent(QEvent *e) override {
|
|
BaseWinBase::changeEvent(e);
|
|
}
|
|
#ifdef _MSC_VER
|
|
bool nativeEvent(const QByteArray &eventType, void *message, long *) override {
|
|
return BaseWinBase::nativeEvent(eventType, message);
|
|
}
|
|
#endif
|
|
};
|
|
#endif // BASEWIN_H
|