Add C++ clipboard image provider
Will be used to show a preview before uploading image from clipboard. Transforming the clipboard image to PNG (or any other real format) is slow and freezes the GUI, with the provider we can display it directly.
This commit is contained in:
parent
cc8d552adc
commit
74c4d63c16
26
TODO.md
26
TODO.md
|
@ -1,24 +1,28 @@
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
- power control focus
|
- global presence control
|
||||||
|
- power level control keyboard focus
|
||||||
- idlemanager: what if setPresence call fails due to network?
|
- idlemanager: what if setPresence call fails due to network?
|
||||||
- block power level change when offline
|
- disable member power level change control when offline
|
||||||
- fix power level control button layout when apply button is loading
|
- fix power level control button layout when apply button is loading
|
||||||
|
|
||||||
- joining new DM, not loading past events the first time?
|
- joining new DM → not loading past events the first time?
|
||||||
- fix HLabeledItem disabled opacity
|
- fix HLabeledItem disabled opacity
|
||||||
|
(visible for the topic area in room settings)
|
||||||
|
|
||||||
- save and restore status in accounts.json
|
- ~~save and restore status message in accounts.json~~
|
||||||
- mark accounts as offline when closing mirage
|
- mark accounts as offline when closing mirage
|
||||||
- document new x11 dependnecy (auto-idle)
|
- document new libXScreenSaver-devel dependency (for auto-idle)
|
||||||
- auto-idle for Windows and OSX
|
- retrieve last seen time for offline members on hover/in profile/automatically
|
||||||
- open context menus centered on touch screens
|
- retry if media retrieval request ends up with a 404
|
||||||
- retrieve last seen time for offline members on hover/in profile
|
|
||||||
- status based on process detection
|
|
||||||
- retry if media not found
|
|
||||||
- fix members not synced bug
|
- fix members not synced bug
|
||||||
- fix local unread counters order
|
- fix local unread counters order
|
||||||
- warn about no E2E room shared if no devices
|
- member profile: if no devices show up, warn about no E2E rooms shared or
|
||||||
|
no E2E-aware devices for that member
|
||||||
|
|
||||||
|
- open context menus centered on touch screens
|
||||||
|
- auto-idle for Windows and OSX
|
||||||
|
- status based on process detection
|
||||||
|
|
||||||
## Refactoring
|
## Refactoring
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void contentChanged();
|
||||||
void textChanged();
|
void textChanged();
|
||||||
void imageChanged();
|
void imageChanged();
|
||||||
void hasImageChanged();
|
void hasImageChanged();
|
||||||
|
@ -91,6 +92,7 @@ private:
|
||||||
QClipboard *clipboard = QGuiApplication::clipboard();
|
QClipboard *clipboard = QGuiApplication::clipboard();
|
||||||
|
|
||||||
void mainClipboardChanged() {
|
void mainClipboardChanged() {
|
||||||
|
contentChanged();
|
||||||
this->hasImage() ? this->imageChanged() : this->textChanged();
|
this->hasImage() ? this->imageChanged() : this->textChanged();
|
||||||
this->hasImageChanged();
|
this->hasImageChanged();
|
||||||
};
|
};
|
||||||
|
|
38
src/clipboard_image_provider.h
Normal file
38
src/clipboard_image_provider.h
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
|
||||||
|
#ifndef CLIPBOARD_IMAGE_PROVIDER_H
|
||||||
|
#define CLIPBOARD_IMAGE_PROVIDER_H
|
||||||
|
|
||||||
|
#include <QClipboard>
|
||||||
|
#include <QImage>
|
||||||
|
#include <QQuickImageProvider>
|
||||||
|
|
||||||
|
|
||||||
|
class ClipboardImageProvider : public QQuickImageProvider {
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ClipboardImageProvider()
|
||||||
|
: QQuickImageProvider(QQuickImageProvider::Image) {}
|
||||||
|
|
||||||
|
QImage requestImage(
|
||||||
|
const QString &id, QSize *size, const QSize &requestSize
|
||||||
|
) {
|
||||||
|
Q_UNUSED(id);
|
||||||
|
|
||||||
|
QImage image = this->clipboard->image();
|
||||||
|
|
||||||
|
if (size) *size = image.size();
|
||||||
|
|
||||||
|
if (requestSize.width() > 0 && requestSize.height() > 0)
|
||||||
|
image = image.scaled(
|
||||||
|
requestSize.width(), requestSize.height(), Qt::KeepAspectRatio
|
||||||
|
);
|
||||||
|
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QClipboard *clipboard = QGuiApplication::clipboard();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "clipboard.h"
|
#include "clipboard.h"
|
||||||
|
#include "clipboard_image_provider.h"
|
||||||
|
|
||||||
|
|
||||||
void loggingHandler(
|
void loggingHandler(
|
||||||
|
@ -125,6 +126,11 @@ int main(int argc, char *argv[]) {
|
||||||
objectContext->setContextProperty("debugMode", false);
|
objectContext->setContextProperty("debugMode", false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Register out custom image providers.
|
||||||
|
// QML will be able to request an image from them by setting an
|
||||||
|
// `Image`'s `source` to `image://<providerId>/<id>`
|
||||||
|
engine.addImageProvider("clipboard", new ClipboardImageProvider);
|
||||||
|
|
||||||
// Register our custom non-visual QObject singletons,
|
// Register our custom non-visual QObject singletons,
|
||||||
// that will be importable anywhere in QML. Example:
|
// that will be importable anywhere in QML. Example:
|
||||||
// import Clipboard 0.1
|
// import Clipboard 0.1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user