Fix ScreenAreaSelector on Windows

This commit is contained in:
ArsenArsen 2017-07-26 21:37:10 +02:00
parent 09507ec2c9
commit b5becd4386
No known key found for this signature in database
GPG Key ID: C631EC9C50708CF4

View File

@ -6,12 +6,15 @@
#include <QTimer>
#include <settings.hpp>
static QString hintPattern("Set the recording region by resizing this.\n%1x%2");
ScreenAreaSelector::ScreenAreaSelector() {
setAttribute(Qt::WA_TranslucentBackground);
setAttribute(Qt::WA_DeleteOnClose);
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
setStyleSheet("background-color: rgba(0, 0, 0, 0.5);");
setWindowTitle("KShare: Select Area (By resizing this window)");
setAutoFillBackground(true);
QTimer::singleShot(0, [&] {
QVariant val = settings::settings().value("screenareaselector/rect");
if (val.canConvert<QRect>()) {
@ -19,7 +22,7 @@ ScreenAreaSelector::ScreenAreaSelector() {
resize(rect.size());
move(rect.topLeft());
}
hintLabel->setText(QString::number(width()) + "x" + QString::number(height()));
hintLabel->setText(hintPattern.arg(QString::number(width()), QString::number(height())));
show();
});
setLayout(new QStackedLayout());
@ -43,7 +46,7 @@ void ScreenAreaSelector::keyPressEvent(QKeyEvent *event) {
}
void ScreenAreaSelector::resizeEvent(QResizeEvent *) {
hintLabel->setText(QString::number(width()) + "x" + QString::number(height()));
hintLabel->setText(hintPattern.arg(QString::number(width()), QString::number(height())));
}
void ScreenAreaSelector::closeEvent(QCloseEvent *) {