Browse Source

todo cleanup

pull/2/head
Skycoder42 7 years ago
parent
commit
618581d207
  1. 3
      examples/mvvmcore/SampleCore/samplecoreapp.cpp
  2. 3
      src/imports/mvvmquick/ActionButton.qml
  3. 1
      src/imports/mvvmquick/plugins.qmltypes
  4. 22
      src/imports/mvvmquick/qqmlquickpresenter.cpp
  5. 2
      src/imports/mvvmquick/qqmlquickpresenter.h
  6. 2
      src/mvvmcore/ipresenter.h
  7. 4
      src/mvvmcore/qtmvvmcore_global.cpp
  8. 12
      src/mvvmcore/serviceregistry.cpp
  9. 2
      src/mvvmwidgets/widgetspresenter.cpp

3
examples/mvvmcore/SampleCore/samplecoreapp.cpp

@ -2,6 +2,7 @@
#include "sampleviewmodel.h"
#include "drawerviewmodel.h"
#include <QtCore/QLoggingCategory>
#include <QtCore/QCommandLineParser>
#include <QtMvvmCore/QtMvvmCoreVersion>
@ -33,6 +34,8 @@ void SampleCoreApp::performRegistrations()
Q_INIT_RESOURCE(sample_core);
QtMvvm::registerInterfaceConverter<IEventService>();
QLoggingCategory::setFilterRules(QStringLiteral("qtmvvm.debug=true"));
}
int SampleCoreApp::startApp(const QStringList &arguments)

3
src/imports/mvvmquick/ActionButton.qml

@ -1,6 +1,7 @@
import QtQuick 2.10
import QtQuick.Controls 2.3
import QtQuick.Controls.Material 2.3
import de.skycoder42.QtMvvm.Quick 1.0
ToolButton {
id: _toolButton
@ -23,7 +24,7 @@ ToolButton {
}
onPressAndHold: {
//TODO QuickExtras.hapticLongPress();
QuickPresenter.hapticLongPress();
_backToolTip.visible = true;
}
onCanceled: _backToolTip.visible = false

1
src/imports/mvvmquick/plugins.qmltypes

@ -88,6 +88,7 @@ Module {
}
Method { name: "toggleDrawer" }
Method { name: "popView" }
Method { name: "hapticLongPress" }
Method {
name: "mimeTypeFilters"
type: "QStringList"

22
src/imports/mvvmquick/qqmlquickpresenter.cpp

@ -8,6 +8,10 @@
#include <QtMvvmQuick/private/quickpresenter_p.h>
#ifdef Q_OS_ANDROID
#include <QtAndroidExtras/QtAndroid>
#endif
using namespace QtMvvm;
QQmlQuickPresenter::QQmlQuickPresenter(QQmlEngine *engine) :
@ -74,6 +78,24 @@ void QQmlQuickPresenter::popView()
QMetaObject::invokeMethod(_qmlPresenter, "closeAction");
}
void QQmlQuickPresenter::hapticLongPress()
{
#ifdef Q_OS_ANDROID
QtAndroid::runOnAndroidThread([](){
const auto content = QAndroidJniObject::getStaticField<jint>("android/R$id", "content");
const auto LONG_PRESS = QAndroidJniObject::getStaticField<jint>("android/view/HapticFeedbackConstants", "LONG_PRESS");
auto activity = QtAndroid::androidActivity();
auto view = activity.callObjectMethod("findViewById",
"(I)Landroid/view/View;",
content);
view.callMethod<jboolean>("performHapticFeedback",
"(I)Z",
LONG_PRESS);
});
#endif
}
void QQmlQuickPresenter::present(ViewModel *viewModel, const QVariantHash &params, const QUrl &viewUrl, QPointer<ViewModel> parent)
{
auto component = _componentCache.object(viewUrl);

2
src/imports/mvvmquick/qqmlquickpresenter.h

@ -44,6 +44,8 @@ public Q_SLOTS:
void toggleDrawer();
void popView();
void hapticLongPress();
Q_SIGNALS:
void qmlPresenterChanged(QObject* qmlPresenter);
void viewLoadingChanged(bool viewLoading);

2
src/mvvmcore/ipresenter.h

@ -25,7 +25,7 @@ protected:
const QByteArray _what;
};
class Q_MVVMCORE_EXPORT IPresenter //TODO use via service registry EVERYWHERE
class Q_MVVMCORE_EXPORT IPresenter
{
public:
inline virtual ~IPresenter() = default;

4
src/mvvmcore/qtmvvmcore_global.cpp

@ -25,10 +25,6 @@ Q_COREAPP_STARTUP_FUNCTION(qtMvvmCoreStartup)
namespace QtMvvm {
#ifdef QT_NO_DEBUG //TODO always info only
Q_LOGGING_CATEGORY(mvvmLoggingCat, "qtmvvm", QtInfoMsg)
#else
Q_LOGGING_CATEGORY(mvvmLoggingCat, "qtmvvm", QtDebugMsg)
#endif
}

12
src/mvvmcore/serviceregistry.cpp

@ -5,6 +5,8 @@
#include <QtCore/QGlobalStatic>
#include <QtCore/QRegularExpression>
#include <QtCore/QMetaProperty>
#include <QtCore/QCoreApplication>
#include <QtCore/QThread>
using namespace QtMvvm;
@ -135,8 +137,12 @@ ServiceRegistryPrivate::ServiceInfo::ServiceInfo(bool weak) :
ServiceRegistryPrivate::ServiceInfo::~ServiceInfo()
{
if(_instance)
QMetaObject::invokeMethod(_instance, "deleteLater"); //TODO doesnt work out of eventloop, maybe test first?
if(_instance) {
if(QCoreApplication::closingDown())
delete _instance;
else
QMetaObject::invokeMethod(_instance, "deleteLater");
}
}
bool ServiceRegistryPrivate::ServiceInfo::replaceable() const
@ -153,6 +159,8 @@ QObject *ServiceRegistryPrivate::ServiceInfo::instance(ServiceRegistryPrivate *d
throw ServiceConstructionException("Failed to construct service of type " +
iid +
" with unknown error");
if(_instance->thread() != qApp->thread())
_instance->moveToThread(qApp->thread());
}
return _instance;
}

2
src/mvvmwidgets/widgetspresenter.cpp

@ -304,7 +304,7 @@ void WidgetsPresenter::presentInputDialog(const MessageConfig &config, QPointer<
if(text.isNull())
text = config.title();
else
dialog->setWindowTitle(config.title());//TODO as header better?
dialog->setWindowTitle(config.title());
if(!text.isNull()) {
auto label = new QLabel(text, dialog);
layout->addWidget(label);

Loading…
Cancel
Save