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