33 lines
1.2 KiB
C++
33 lines
1.2 KiB
C++
|
#include "loqtitlebar.h"
|
||
|
#include <QApplication>
|
||
|
|
||
|
LoQTitleBar::LoQTitleBar(QWidget *parent) : QWidget(parent) {
|
||
|
bn_Minimize = new QPushButton(this);
|
||
|
bn_Maximize = new QPushButton(this);
|
||
|
bn_Close = new QPushButton(this);
|
||
|
bn_Minimize->setIcon(QIcon(":/res/WndMinimize.png"));
|
||
|
bn_Maximize->setIcon(QIcon(":/res/WndMaximize.png"));
|
||
|
bn_Close->setIcon(QIcon(":/res/WndClose.png"));
|
||
|
|
||
|
bn_Minimize->setToolTip(tr("Minimize"));
|
||
|
bn_Maximize->setToolTip(tr("Maximize"));
|
||
|
bn_Close->setToolTip(tr("Close"));
|
||
|
|
||
|
connect(bn_Minimize, &QPushButton::clicked, window(), &QWidget::showMinimized);
|
||
|
connect(bn_Maximize, &QPushButton::clicked, this, [this](){
|
||
|
auto win = window();
|
||
|
if(win->isMaximized()) win->showNormal();
|
||
|
else win->showMaximized();
|
||
|
});
|
||
|
connect(bn_Close, &QPushButton::clicked, window(), &QWidget::close);
|
||
|
}
|
||
|
void LoQTitleBar::refreshLable() {
|
||
|
bn_Minimize->setToolTip(tr("Minimize"));
|
||
|
bn_Maximize->setToolTip(tr("Maximize"));
|
||
|
bn_Close->setToolTip(tr("Close"));
|
||
|
}
|
||
|
bool LoQTitleBar::eventFilter(QObject *, QEvent *e) {
|
||
|
if(e->type()==QEvent::WindowStateChange) bn_Maximize->setToolTip(window()->isMaximized() ? tr("Restore") : tr("Maximize"));
|
||
|
return false;
|
||
|
}
|