Add a size hint
Noone saw the typo. Right?
This commit is contained in:
parent
09e670bf23
commit
b064f795ff
@ -1,13 +1,15 @@
|
||||
#include "screenareaselector.hpp"
|
||||
#include <QCloseEvent>
|
||||
#include <QLabel>
|
||||
#include <QPalette>
|
||||
#include <QStackedLayout>
|
||||
#include <QTimer>
|
||||
#include <settings.hpp>
|
||||
|
||||
ScreenAreaSelector::ScreenAreaSelector() {
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setStyleSheet("background:transparent;");
|
||||
setStyleSheet("background-color: rgba(0, 0, 0, 0.5);");
|
||||
setWindowTitle("KShare: Select Area (By resizig this window)");
|
||||
QTimer::singleShot(0, [&] {
|
||||
QVariant val = settings::settings().value("screenareaselector/rect");
|
||||
@ -16,10 +18,16 @@ ScreenAreaSelector::ScreenAreaSelector() {
|
||||
resize(rect.size());
|
||||
move(rect.topLeft());
|
||||
}
|
||||
hintLabel->setText(QString::number(width()) + "x" + QString::number(height()));
|
||||
});
|
||||
setLayout(new QStackedLayout());
|
||||
hintLabel = new QLabel();
|
||||
hintLabel->setAlignment(Qt::AlignCenter);
|
||||
layout()->addWidget(hintLabel);
|
||||
}
|
||||
|
||||
ScreenAreaSelector::~ScreenAreaSelector() {
|
||||
delete hintLabel;
|
||||
}
|
||||
|
||||
void ScreenAreaSelector::keyPressEvent(QKeyEvent *event) {
|
||||
@ -32,6 +40,10 @@ void ScreenAreaSelector::keyPressEvent(QKeyEvent *event) {
|
||||
close();
|
||||
}
|
||||
|
||||
void ScreenAreaSelector::resizeEvent(QResizeEvent *) {
|
||||
hintLabel->setText(QString::number(width()) + "x" + QString::number(height()));
|
||||
}
|
||||
|
||||
void ScreenAreaSelector::closeEvent(QCloseEvent *) {
|
||||
QRect r = QRect(pos(), rect().size());
|
||||
settings::settings().setValue("screenareaselector/rect", r);
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef SCREENAREASELECTOR_HPP
|
||||
#define SCREENAREASELECTOR_HPP
|
||||
|
||||
#include <QLabel>
|
||||
#include <QWidget>
|
||||
|
||||
class ScreenAreaSelector : public QWidget {
|
||||
@ -12,8 +13,12 @@ public:
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
void keyPressEvent(QKeyEvent *) override;
|
||||
void resizeEvent(QResizeEvent *) override;
|
||||
signals:
|
||||
void selectedArea(QRect area);
|
||||
|
||||
private:
|
||||
QLabel *hintLabel;
|
||||
};
|
||||
|
||||
#endif // SCREENAREASELECTOR_HPP
|
||||
|
Loading…
Reference in New Issue
Block a user