user32 hurts
This commit is contained in:
parent
c2f35e9189
commit
1961a67653
20
KShare.pro
20
KShare.pro
@ -70,7 +70,25 @@ HEADERS += mainwindow.hpp \
|
|||||||
cropeditor/settings/blurdialog.hpp \
|
cropeditor/settings/blurdialog.hpp \
|
||||||
cropeditor/drawing/pathitem.hpp \
|
cropeditor/drawing/pathitem.hpp \
|
||||||
cropeditor/drawing/lineitem.hpp \
|
cropeditor/drawing/lineitem.hpp \
|
||||||
cropeditor/drawing/textitem.hpp
|
cropeditor/drawing/textitem.hpp \
|
||||||
|
platformbackend.hpp
|
||||||
|
mac {
|
||||||
|
SOURCES += $$PWD/platformspecifics/mac/macbackend.cpp
|
||||||
|
HEADERS += $$PWD/platformspecifics/mac/macbackend.hpp
|
||||||
|
LIBS += -framework Carbon
|
||||||
|
} else:win32 {
|
||||||
|
SOURCES += $$PWD/platformspecifics/u32/u32backend.cpp
|
||||||
|
HEADERS += $$PWD/platformspecifics/u32/u32backend.hpp
|
||||||
|
LIBS += -luser32
|
||||||
|
QT += winextras
|
||||||
|
} else:unix {
|
||||||
|
SOURCES += $$PWD/platformspecifics/x11/x11backend.cpp
|
||||||
|
HEADERS += $$PWD/platformspecifics/x11/x11backend.hpp
|
||||||
|
QT += x11extras
|
||||||
|
LIBS += -lxcb-cursor -lxcb-xfixes
|
||||||
|
} else {
|
||||||
|
error(Unsupported platform);
|
||||||
|
}
|
||||||
|
|
||||||
FORMS += mainwindow.ui \
|
FORMS += mainwindow.ui \
|
||||||
cropeditor/settings/brushpenselection.ui \
|
cropeditor/settings/brushpenselection.ui \
|
||||||
|
2
main.cpp
2
main.cpp
@ -3,6 +3,7 @@
|
|||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
#include <platformbackend.hpp>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
@ -44,6 +45,7 @@ int main(int argc, char *argv[]) {
|
|||||||
parser.addOption(v);
|
parser.addOption(v);
|
||||||
parser.process(a);
|
parser.process(a);
|
||||||
verbose = parser.isSet(v);
|
verbose = parser.isSet(v);
|
||||||
|
PlatformBackend::inst().getCursor().save("test.png", "PNG");
|
||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
w.show();
|
w.show();
|
||||||
|
14
platformbackend.hpp
Normal file
14
platformbackend.hpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#ifndef PLATFORMBACKEND_HPP
|
||||||
|
#define PLATFORMBACKEND_HPP
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include <platformspecifics/mac/macbackend.hpp>
|
||||||
|
#endif
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <platformspecifics/u32/u32backend.hpp>
|
||||||
|
#endif
|
||||||
|
#ifdef __unix__
|
||||||
|
#include <platformspecifics/x11/x11backend.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // PLATFORMBACKEND_HPP
|
6
platformspecifics/mac/macbackend.cpp
Normal file
6
platformspecifics/mac/macbackend.cpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include "macbackend.hpp"
|
||||||
|
|
||||||
|
QPixmap PlatformBackend::getCursor() {
|
||||||
|
#warning "TODO: Mac backend"
|
||||||
|
return QPixmap();
|
||||||
|
}
|
15
platformspecifics/mac/macbackend.hpp
Normal file
15
platformspecifics/mac/macbackend.hpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#ifndef MACBACKEND_HPP
|
||||||
|
#define MACBACKEND_HPP
|
||||||
|
|
||||||
|
#include <QPixmap>
|
||||||
|
|
||||||
|
class PlatformBackend {
|
||||||
|
public:
|
||||||
|
QPixmap getCursor();
|
||||||
|
static PlatformBackend &inst() {
|
||||||
|
static PlatformBackend inst;
|
||||||
|
return inst;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MACBACKEND_HPP
|
21
platformspecifics/u32/u32backend.cpp
Normal file
21
platformspecifics/u32/u32backend.cpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#include "u32backend.hpp"
|
||||||
|
|
||||||
|
#include <QCursor>
|
||||||
|
#include <QtWin>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
QPixmap PlatformBackend::getCursor() {
|
||||||
|
CURSORINFO cursorInfo;
|
||||||
|
cursorInfo.cbSize = sizeof(cursorInfo);
|
||||||
|
if (GetCursorInfo(&cursorInfo)) {
|
||||||
|
if (cursorInfo.flags == CURSOR_SHOWING) {
|
||||||
|
ICONINFO info; // It took me 5 hours to get to here
|
||||||
|
if (GetIconInfo(cursorInfo.hCursor, &info)) {
|
||||||
|
return QtWin::fromHBITMAP(info.hbmColor);
|
||||||
|
} else
|
||||||
|
return QPixmap();
|
||||||
|
} else
|
||||||
|
return QPixmap();
|
||||||
|
} else
|
||||||
|
return QPixmap();
|
||||||
|
}
|
15
platformspecifics/u32/u32backend.hpp
Normal file
15
platformspecifics/u32/u32backend.hpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#ifndef U32BACKEND_HPP
|
||||||
|
#define U32BACKEND_HPP
|
||||||
|
|
||||||
|
#include <QPixmap>
|
||||||
|
|
||||||
|
class PlatformBackend {
|
||||||
|
public:
|
||||||
|
QPixmap getCursor();
|
||||||
|
static PlatformBackend &inst() {
|
||||||
|
static PlatformBackend inst;
|
||||||
|
return inst;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // U32BACKEND_HPP
|
22
platformspecifics/x11/x11backend.cpp
Normal file
22
platformspecifics/x11/x11backend.cpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#include "x11backend.hpp"
|
||||||
|
|
||||||
|
#include <QPixmap>
|
||||||
|
#include <QX11Info>
|
||||||
|
#include <xcb/xcb_cursor.h>
|
||||||
|
#include <xcb/xcb_util.h>
|
||||||
|
#include <xcb/xfixes.h>
|
||||||
|
|
||||||
|
QPixmap PlatformBackend::getCursor() {
|
||||||
|
xcb_connection_t *connection = QX11Info::connection();
|
||||||
|
xcb_xfixes_get_cursor_image_cookie_t cursorCookie = xcb_xfixes_get_cursor_image_unchecked(connection);
|
||||||
|
QScopedPointer<xcb_xfixes_get_cursor_image_reply_t> cursorReply(xcb_xfixes_get_cursor_image_reply(connection, cursorCookie, NULL));
|
||||||
|
if (cursorReply.isNull()) {
|
||||||
|
return QPixmap();
|
||||||
|
}
|
||||||
|
|
||||||
|
quint32 *pixels = xcb_xfixes_get_cursor_image_cursor_image(cursorReply.data());
|
||||||
|
if (!pixels) {
|
||||||
|
return QPixmap();
|
||||||
|
}
|
||||||
|
return QPixmap::fromImage(QImage((quint8 *)pixels, cursorReply->width, cursorReply->height, QImage::Format_ARGB32_Premultiplied));
|
||||||
|
}
|
15
platformspecifics/x11/x11backend.hpp
Normal file
15
platformspecifics/x11/x11backend.hpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#ifndef X11BACKEND_HPP
|
||||||
|
#define X11BACKEND_HPP
|
||||||
|
|
||||||
|
#include <QPixmap>
|
||||||
|
|
||||||
|
class PlatformBackend {
|
||||||
|
public:
|
||||||
|
QPixmap getCursor();
|
||||||
|
static PlatformBackend &inst() {
|
||||||
|
static PlatformBackend inst;
|
||||||
|
return inst;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // X11BACKEND_HPP
|
Loading…
Reference in New Issue
Block a user