parent
15ca46f3d0
commit
ce75426552
@ -17,6 +17,7 @@ ColorPickerScene::ColorPickerScene(QPixmap pixmap, QWidget *parentWidget)
|
|||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
setWindowTitle("KShare Color Picker");
|
setWindowTitle("KShare Color Picker");
|
||||||
setGeometry(pixmap.rect());
|
setGeometry(pixmap.rect());
|
||||||
|
move(screenshotutil::smallestScreenCoordinate());
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
pItem = addPixmap(pixmap);
|
pItem = addPixmap(pixmap);
|
||||||
|
@ -13,10 +13,8 @@
|
|||||||
CropEditor::CropEditor(QPixmap image, QObject *parent) : QObject(parent) {
|
CropEditor::CropEditor(QPixmap image, QObject *parent) : QObject(parent) {
|
||||||
scene = new CropScene(parent, image);
|
scene = new CropScene(parent, image);
|
||||||
view = new CropView(scene);
|
view = new CropView(scene);
|
||||||
qreal ratio = QApplication::primaryScreen()->devicePixelRatio();
|
|
||||||
QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem(image);
|
QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem(image);
|
||||||
pixmapItem->setZValue(-1);
|
pixmapItem->setZValue(-1);
|
||||||
pixmapItem->setScale(1 / ratio);
|
|
||||||
scene->addItem(pixmapItem);
|
scene->addItem(pixmapItem);
|
||||||
scene->setSceneRect(image.rect());
|
scene->setSceneRect(image.rect());
|
||||||
view->resize(image.width(), image.height());
|
view->resize(image.width(), image.height());
|
||||||
|
@ -103,6 +103,7 @@ CropScene::CropScene(QObject *parent, QPixmap pixmap)
|
|||||||
polyItem = new QGraphicsPolygonItem(poly);
|
polyItem = new QGraphicsPolygonItem(poly);
|
||||||
polyItem->setBrush(QBrush(QColor(0, 0, 0, 191)));
|
polyItem->setBrush(QBrush(QColor(0, 0, 0, 191)));
|
||||||
polyItem->setPen(QPen(Qt::NoPen));
|
polyItem->setPen(QPen(Qt::NoPen));
|
||||||
|
polyItem->setZValue(1);
|
||||||
addItem(polyItem);
|
addItem(polyItem);
|
||||||
QTimer::singleShot(0, [&] {
|
QTimer::singleShot(0, [&] {
|
||||||
auto pf = views()[0]->mapFromGlobal(QCursor::pos());
|
auto pf = views()[0]->mapFromGlobal(QCursor::pos());
|
||||||
|
@ -62,7 +62,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
QAction *recabort = new QAction("Abort recording", this);
|
QAction *recabort = new QAction("Abort recording", this);
|
||||||
menu->addActions({ quit, shtoggle, picker });
|
menu->addActions({ quit, shtoggle, picker });
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
menu->addActions({ fullscreen, area, active });
|
menu->addActions({ fullscreen, area });
|
||||||
#ifdef PLATFORM_CAPABILITY_ACTIVEWINDOW
|
#ifdef PLATFORM_CAPABILITY_ACTIVEWINDOW
|
||||||
menu->addAction(area);
|
menu->addAction(area);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include "macbackend.hpp"
|
#include "macbackend.hpp"
|
||||||
|
|
||||||
QPixmap PlatformBackend::getCursor() {
|
#include <unistd.h>
|
||||||
|
|
||||||
|
std::tuple<QPoint, QPixmap> PlatformBackend::getCursor() {
|
||||||
#warning "TODO: Mac backend"
|
#warning "TODO: Mac backend"
|
||||||
return std::tuple<QPoint, QPixmap>(QPoint(0, 0), QPixmap());
|
return std::tuple<QPoint, QPixmap>(QPoint(0, 0), QPixmap());
|
||||||
// Not Monday: https://developer.apple.com/reference/appkit/nscursor/1527062-image
|
// Not Monday: https://developer.apple.com/reference/appkit/nscursor/1527062-image
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
class PlatformBackend {
|
class PlatformBackend {
|
||||||
public:
|
public:
|
||||||
QPixmap getCursor();
|
std::tuple<QPoint, QPixmap> getCursor();
|
||||||
pid_t pid();
|
pid_t pid();
|
||||||
static PlatformBackend &inst() {
|
static PlatformBackend &inst() {
|
||||||
static PlatformBackend inst;
|
static PlatformBackend inst;
|
||||||
|
@ -26,7 +26,7 @@ QPixmap screenshotutil::fullscreen(bool cursor) {
|
|||||||
for (QScreen *screen : QApplication::screens()) {
|
for (QScreen *screen : QApplication::screens()) {
|
||||||
QRect geo = screen->geometry();
|
QRect geo = screen->geometry();
|
||||||
width = qMax(ox + geo.left() + geo.width(), width);
|
width = qMax(ox + geo.left() + geo.width(), width);
|
||||||
height = qMax(oy + geo.top() + geo.height(), height); // qute abs
|
height = qMax(oy + geo.top() + geo.height(), height);
|
||||||
}
|
}
|
||||||
image = QPixmap(width, height);
|
image = QPixmap(width, height);
|
||||||
image.fill(Qt::transparent);
|
image.fill(Qt::transparent);
|
||||||
@ -36,7 +36,8 @@ QPixmap screenshotutil::fullscreen(bool cursor) {
|
|||||||
|
|
||||||
for (QScreen *screen : QApplication::screens()) {
|
for (QScreen *screen : QApplication::screens()) {
|
||||||
QPixmap currentScreen = window(0, screen);
|
QPixmap currentScreen = window(0, screen);
|
||||||
painter.drawPixmap(screen->geometry().topLeft(), currentScreen);
|
QRect geo = screen->geometry();
|
||||||
|
painter.drawPixmap(geo.left(), geo.top(), geo.width(), geo.height(), currentScreen);
|
||||||
width += screen->size().width();
|
width += screen->size().width();
|
||||||
}
|
}
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
@ -73,3 +74,6 @@ QPoint screenshotutil::smallestScreenCoordinate() {
|
|||||||
}
|
}
|
||||||
return smallestCoordinate;
|
return smallestCoordinate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPixmap screenshotutil::renderText(QString toRender, QColor background, QFont font) {
|
||||||
|
}
|
||||||
|
@ -10,6 +10,7 @@ QPixmap fullscreenArea(bool cursor = true, qreal x = 0, qreal y = 0, qreal w = -
|
|||||||
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();
|
QPoint smallestScreenCoordinate();
|
||||||
|
QPixmap renderText(QString toRender, QColor background = Qt::transparent, QFont font = QFont());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SCREENSHOTUTIL_HPP
|
#endif // SCREENSHOTUTIL_HPP
|
||||||
|
Loading…
x
Reference in New Issue
Block a user