KShare/platformspecifics/u32/u32backend.cpp

46 lines
1.6 KiB
C++
Raw Normal View History

2017-05-13 11:03:46 +02:00
#include "u32backend.hpp"
#include <QCursor>
#include <QtWin>
#include <windows.h>
2017-05-15 11:19:52 +02:00
std::tuple<QPoint, QPixmap> PlatformBackend::getCursor() {
2017-05-13 11:03:46 +02:00
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 std::tuple<QPoint, QPixmap>(QPoint(info.xHotspot, info.yHotspot),
QtWin::fromHBITMAP(info.hbmColor, QtWin::HBitmapAlpha));
2017-05-13 11:03:46 +02:00
} else
2017-05-13 23:33:36 +02:00
return std::tuple<QPoint, QPixmap>(QPoint(0, 0), QPixmap());
2017-05-13 11:03:46 +02:00
} else
2017-05-13 23:33:36 +02:00
return std::tuple<QPoint, QPixmap>(QPoint(0, 0), QPixmap());
2017-05-13 11:03:46 +02:00
} else
2017-05-13 23:33:36 +02:00
return std::tuple<QPoint, QPixmap>(QPoint(0, 0), QPixmap());
2017-05-13 11:03:46 +02:00
}
2017-06-25 10:14:44 +02:00
DWORD PlatformBackend::pid() {
return GetCurrentProcessId();
}
WId PlatformBackend::getActiveWID() {
return (WId)GetForegroundWindow();
}
2017-07-05 12:41:09 +02:00
QString illegal(QStringLiteral("<>:\"/\\|?*"));
2017-07-05 12:36:44 +02:00
QStringList illegalNames({ "CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7",
"COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9" });
2017-07-05 12:41:09 +02:00
bool PlatformBackend::filenameValid(QString name) {
int periods = 0;
2017-07-05 12:36:44 +02:00
for (QChar c : name) {
if (c == '.') periods++;
if (illegal.contains(c)) return false;
if (c < 32) return false;
}
if (periods == name.length()) return false;
return !illegalNames.contains(name);
}