Skip to content

Instantly share code, notes, and snippets.

template <typename T>
class LambdaAndroidActivityResultReceiver : public QObject, public QAndroidActivityResultReceiver
{
public:
LambdaAndroidActivityResultReceiver(T callback) : m_callback{callback} {}
void handleActivityResult(int receiverRequestCode, int resultCode, const QAndroidJniObject &data) override {
Q_UNUSED(receiverRequestCode)
m_callback(resultCode, data);
deleteLater();
@oKcerG
oKcerG / colattachedtype.cpp
Last active April 5, 2017 10:53
Bootstrap grid system PoC in QML
#include "colattachedtype.h"
#include <QQuickItem>
#include <QQuickWindow>
#include <QQmlInfo>
ColAttachedType::ColAttachedType(QObject* parent) :
QObject{parent},
m_item{qobject_cast<QQuickItem*>(parent)}
{
if (!m_item) {
import QtQuick 2.0
SequentialAnimation {
id: root
property QtObject target
property string fadeProperty: "scale"
property int fadeDuration: 150
property alias outValue: outAnimation.to
property alias inValue: inAnimation.to
property alias outEasingType: outAnimation.easing.type
@oKcerG
oKcerG / main.qml
Last active March 27, 2017 14:19
MouseProxy
import QtQuick 2.6
import QtQuick.Layouts 1.0
import Qt.labs.controls 1.0
import QtQuick.Layouts 1.3
import MouseProxy 0.1
ApplicationWindow {
visible: true
width: 640
height: 480
@oKcerG
oKcerG / main.qml
Last active November 3, 2016 23:47
Boostrap Grid Test in QML
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Window 2.2
ApplicationWindow {
visible: true
width: 640
height: 480
title: "Bootstrap test : " + ["xs", "sm", "md", "lg"][thresholdIndex(this)]
import QtQuick 2.0
/*!
\qmltype AreaTester
\brief A component that highlights the aera of a given component.
The AreaTester component is a simple component to troubleshoot what area occupies an other component.
You can use this component like this to highlights its parent's area.
\qml
Item {
id: itemToHighlight
import QtQuick 2.0
Item {
id: root
height: 0
default property alias data: contentItem.data
property ListView _listView: parent.parent
property Item _adjacentItem: { _listView.contentY; return _listView.itemAt(0, y); }
property bool _adjacentItemIsLastOfSection: _adjacentItem ? _adjacentItem.ListView.section !== _adjacentItem.ListView.nextSection && _adjacentItem !== _listView.contentItem.children[0] : false
@oKcerG
oKcerG / ContactList.qml
Last active December 13, 2022 22:38
An experiment trying to recreate Google's Android contact list in QML
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQml 2.2
import QtQuick.Controls.Material 2.0
import QtQuick.Layouts 1.3
// DEMO VIDEO : https://gfycat.com/WarlikeImportantAmericanrobin
ApplicationWindow {
visible: true
@oKcerG
oKcerG / scrolling-indicator.qml
Last active December 13, 2022 22:38
QML Alphabet Scrolling indicator POC
import QtQuick 2.7
import QtQuick.Controls 2.0
ApplicationWindow {
visible: true
width: 640
height: 480
ListView {
id: listView
var sections = document.querySelectorAll(".sg-section");
var ul = document.createElement('ul');
sections[0].parentNode.insertBefore(ul, sections[0]);
for (var i=0; i < sections.length; ++i) { var elem = sections[i].children[0]; var li = document.createElement('li'); li.innerHTML='<a href="#'+elem.id+'">'+elem.textContent+'</a>'; ul.appendChild(li); }