Partial fix for #9 - now the position is good
This commit is contained in:
parent
159720d9fa
commit
698d123815
@ -7,6 +7,7 @@
|
|||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <screenshotutil.hpp>
|
||||||
#include <settings.hpp>
|
#include <settings.hpp>
|
||||||
|
|
||||||
CropEditor::CropEditor(QPixmap image, QObject *parent) : QObject(parent) {
|
CropEditor::CropEditor(QPixmap image, QObject *parent) : QObject(parent) {
|
||||||
@ -20,7 +21,8 @@ CropEditor::CropEditor(QPixmap image, QObject *parent) : QObject(parent) {
|
|||||||
scene->setSceneRect(image.rect());
|
scene->setSceneRect(image.rect());
|
||||||
view->resize(image.width(), image.height());
|
view->resize(image.width(), image.height());
|
||||||
view->setMinimumSize(image.size());
|
view->setMinimumSize(image.size());
|
||||||
view->move(settings::settings().value("cropx", 0).toInt(), settings::settings().value("cropy", 0).toInt());
|
QPoint p = screenshotutil::smallestScreenCoordinate();
|
||||||
|
view->move(p.x() + settings::settings().value("cropx", 0).toInt(), p.y() + settings::settings().value("cropy", 0).toInt());
|
||||||
view->setWindowTitle("KShare Crop Editor");
|
view->setWindowTitle("KShare Crop Editor");
|
||||||
view->show();
|
view->show();
|
||||||
|
|
||||||
|
@ -28,17 +28,17 @@ void hotkeying::load(QString seqName, std::function<void()> func, QString def) {
|
|||||||
QString name = seqName;
|
QString name = seqName;
|
||||||
name.prepend("hotkey_");
|
name.prepend("hotkey_");
|
||||||
if (hotkeys.contains(seqName)) return;
|
if (hotkeys.contains(seqName)) return;
|
||||||
if (settings::settings().contains(name)) {
|
QString k = settings::settings().value(name).toString();
|
||||||
QString k = settings::settings().value(name).toString();
|
if (!k.isEmpty()) {
|
||||||
if (!k.isEmpty())
|
if (!k.isEmpty())
|
||||||
h = new QHotkey(QKeySequence(settings::settings().value(k).toString()), true);
|
h = new QHotkey(QKeySequence(settings::settings().value(k).toString()), true);
|
||||||
else
|
else
|
||||||
h = new QHotkey(def.isNull() ? "" : def, true);
|
h = new QHotkey(def.isEmpty() ? "" : def, true);
|
||||||
} else
|
} else
|
||||||
h = new QHotkey(def.isNull() ? "" : def, true);
|
h = new QHotkey(def.isEmpty() ? "" : def, true);
|
||||||
QObject::connect(h, &QHotkey::activated, func);
|
QObject::connect(h, &QHotkey::activated, func);
|
||||||
hotkeys.insert(seqName, h);
|
hotkeys.insert(seqName, h);
|
||||||
if (!h->isRegistered() && (settings::settings().contains(name) || !def.isEmpty()))
|
if (!h->isRegistered() && !h->shortcut().toString().isEmpty())
|
||||||
qWarning().noquote().nospace()
|
qWarning().noquote().nospace()
|
||||||
<< "Could not bind the hotkey " << seqName << "! Is the keybind already registered?";
|
<< "Could not bind the hotkey " << seqName << "! Is the keybind already registered?";
|
||||||
}
|
}
|
||||||
|
@ -11,16 +11,17 @@
|
|||||||
QPixmap screenshotutil::fullscreen(bool cursor) {
|
QPixmap screenshotutil::fullscreen(bool cursor) {
|
||||||
QPixmap image;
|
QPixmap image;
|
||||||
QPainter painter;
|
QPainter painter;
|
||||||
|
QPoint smallestCoordinate = smallestScreenCoordinate();
|
||||||
|
|
||||||
// Hack for https://bugreports.qt.io/browse/QTBUG-58110
|
// Hack for https://bugreports.qt.io/browse/QTBUG-58110
|
||||||
static QStringList qVer = QString(qVersion()).split('.');
|
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
|
static QStringList qVer = QString(qVersion()).split('.');
|
||||||
if (qVer.at(0).toInt() == 5 && qVer.at(1).toInt() < 9) {
|
if (qVer.at(0).toInt() == 5 && qVer.at(1).toInt() < 9) {
|
||||||
image = window(0);
|
image = window(0);
|
||||||
painter.begin(&image);
|
painter.begin(&image);
|
||||||
} else {
|
} else {
|
||||||
#endif
|
#endif
|
||||||
int height = 0, width = 0;
|
int height = qAbs(smallestCoordinate.y()), width = qAbs(smallestCoordinate.x()); // qute abs
|
||||||
for (QScreen *screen : QApplication::screens()) {
|
for (QScreen *screen : QApplication::screens()) {
|
||||||
QRect geo = screen->geometry();
|
QRect geo = screen->geometry();
|
||||||
width = qMax(geo.left() + geo.width(), width);
|
width = qMax(geo.left() + geo.width(), width);
|
||||||
@ -30,6 +31,7 @@ QPixmap screenshotutil::fullscreen(bool cursor) {
|
|||||||
image.fill(Qt::transparent);
|
image.fill(Qt::transparent);
|
||||||
width = 0;
|
width = 0;
|
||||||
painter.begin(&image);
|
painter.begin(&image);
|
||||||
|
painter.translate(qAbs(smallestCoordinate.x()), qAbs(smallestCoordinate.y()));
|
||||||
|
|
||||||
for (QScreen *screen : QApplication::screens()) {
|
for (QScreen *screen : QApplication::screens()) {
|
||||||
QPixmap currentScreen = window(0, screen);
|
QPixmap currentScreen = window(0, screen);
|
||||||
@ -61,3 +63,12 @@ void screenshotutil::toClipboard(QString value) {
|
|||||||
QPixmap screenshotutil::fullscreenArea(bool cursor, qreal x, qreal y, qreal w, qreal h) {
|
QPixmap screenshotutil::fullscreenArea(bool cursor, qreal x, qreal y, qreal w, qreal h) {
|
||||||
return fullscreen(cursor).copy(x, y, w, h);
|
return fullscreen(cursor).copy(x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPoint screenshotutil::smallestScreenCoordinate() {
|
||||||
|
QPoint smallestCoordinate;
|
||||||
|
for (QScreen *screen : QApplication::screens()) {
|
||||||
|
smallestCoordinate.rx() = qMin(smallestCoordinate.x(), screen->geometry().left());
|
||||||
|
smallestCoordinate.ry() = qMin(smallestCoordinate.y(), screen->geometry().top());
|
||||||
|
}
|
||||||
|
return smallestCoordinate;
|
||||||
|
}
|
||||||
|
@ -9,6 +9,7 @@ QPixmap fullscreen(bool cursor = true);
|
|||||||
QPixmap fullscreenArea(bool cursor = true, qreal x = 0, qreal y = 0, qreal w = -1, qreal h = -1);
|
QPixmap fullscreenArea(bool cursor = true, qreal x = 0, qreal y = 0, qreal w = -1, qreal h = -1);
|
||||||
QPixmap window(WId wid, QScreen *w = QApplication::primaryScreen());
|
QPixmap window(WId wid, QScreen *w = QApplication::primaryScreen());
|
||||||
void toClipboard(QString value);
|
void toClipboard(QString value);
|
||||||
|
QPoint smallestScreenCoordinate();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SCREENSHOTUTIL_HPP
|
#endif // SCREENSHOTUTIL_HPP
|
||||||
|
Loading…
Reference in New Issue
Block a user