Skip to content

Commit

Permalink
Add ALTNavigation
Browse files Browse the repository at this point in the history
  • Loading branch information
boutinb committed Jan 14, 2025
1 parent 769d232 commit 104ca01
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 26 deletions.
14 changes: 7 additions & 7 deletions Desktop/components/JASP/Widgets/MainPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ Item
onXChanged: checkPosition(false)
onDraggingChanged: checkPosition(true)

ALTNavigation.enabled: true
ALTNavigation.onTagMatch: { arrowClicked(); }
ALTNavigation.requestedPostfix: "D"
ALTNavigation.y: height / 2 - 25 * jaspTheme.uiScale
JC.ALTNavigation.enabled: true
JC.ALTNavigation.onTagMatch: { arrowClicked(); }
JC.ALTNavigation.requestedPostfix: "D"
JC.ALTNavigation.y: height / 2 - 25 * jaspTheme.uiScale

function checkPosition(forceCheck)
{
Expand Down Expand Up @@ -230,9 +230,9 @@ Item
visible: hasAnalysis && !ribbonModel.dataMode
color: analysesModel.currentAnalysisIndex !== -1 ? jaspTheme.uiBackground : jaspTheme.white

ALTNavigation.enabled: true
ALTNavigation.requestedPostfix: "R"
ALTNavigation.onTagMatch: { resultsView.nextItemInFocusChain().forceActiveFocus(); }
JC.ALTNavigation.enabled: true
JC.ALTNavigation.requestedPostfix: "R"
JC.ALTNavigation.onTagMatch: { resultsView.nextItemInFocusChain().forceActiveFocus(); }

Rectangle
{
Expand Down
1 change: 1 addition & 0 deletions Desktop/components/JASP/Widgets/Ribbon/RibbonBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import QtQuick
import JASP
import JASP.Controls


FocusScope
Expand Down
2 changes: 1 addition & 1 deletion Desktop/components/JASP/Widgets/Ribbon/Ribbons.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import QtQuick
import QtQuick.Controls
import JASP
import JASP.Controls

Item
{
Expand Down
2 changes: 0 additions & 2 deletions Desktop/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ MainWindow::MainWindow(QApplication * application) : QObject(application), _appl

makeConnections();

qmlRegisterUncreatableType<JASPControl> ("JASP", 1, 0, "JASP", "Impossible to create JASP Object" ); //This is here to keep JASP.enum short I guess?
qmlRegisterUncreatableType<MessageForwarder> ("JASP", 1, 0, "MessageForwarder", "You can't touch this" );

qmlRegisterType<DataSetView> ("JASP", 1, 0, "DataSetView" );
Expand All @@ -150,7 +149,6 @@ MainWindow::MainWindow(QApplication * application) : QObject(application), _appl
qmlRegisterUncreatableType<PlotEditor::AxisModel> ("JASP.PlotEditor", 1, 0, "AxisModel", "Can't make it");
qmlRegisterUncreatableType<PlotEditor::PlotEditorModel> ("JASP.PlotEditor", 1, 0, "PlotEditorModel", "Can't make it");

ALTNavigation::registerQMLTypes("JASP");
ALTNavControl::ctrl()->enableAlTNavigation(_preferences->ALTNavModeActive());
QmlUtils::setGlobalPropertiesInQMLContext(_qml->rootContext());

Expand Down
9 changes: 0 additions & 9 deletions QMLComponents/ALTNavigation/altnavigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,3 @@ ALTNavScope* ALTNavigation::qmlAttachedProperties(QObject *object)
ALTNavControl::ctrl()->registrate(scope, object);
return scope;
}

//Could parameterize module
void ALTNavigation::registerQMLTypes(QString uri)
{
std::string u = uri.toStdString();
qmlRegisterType<ALTNavigation> (u.c_str(), 1, 0, "ALTNavigation" );
qmlRegisterType<ALTNavTagBase> (u.c_str(), 1, 0, "ALTNavTagBase" );
qmlRegisterUncreatableType<ALTNavPostfixAssignmentStrategy> (u.c_str(), 1, 0, "AssignmentStrategy", "Can't make it" );
}
6 changes: 1 addition & 5 deletions QMLComponents/ALTNavigation/altnavigation.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
class ALTNavigation : public QObject
{
Q_OBJECT
QML_ELEMENT
QML_ATTACHED(ALTNavScope)

public:
Expand All @@ -94,11 +95,6 @@ class ALTNavigation : public QObject
*/
static ALTNavScope* qmlAttachedProperties(QObject *object);

/*!
* \brief registers the QML types related to this subsystem under JASP
*/
static void registerQMLTypes(QString uri);

};

#endif // ALTNAVIGATION_H
4 changes: 3 additions & 1 deletion QMLComponents/ALTNavigation/altnavscope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include <QQmlProperty>
#include <QMetaObject>
#include <QDirIterator>
#include "log.h"

ALTNavScope::ALTNavScope(QObject* attachee)
: QObject{attachee}
Expand All @@ -15,7 +17,7 @@ ALTNavScope::ALTNavScope(QObject* attachee)
if(_attachee) //is a visual item
{
//create a visual tag
QQmlComponent component(qmlEngine(_attachee), QUrl("qrc:///components/JASP/Widgets/ALTNavTag.qml"), _attachee);
QQmlComponent component(qmlEngine(_attachee), QUrl("qrc:/jasp-stats.org/imports/JASP/Controls/components/JASP/Controls/ALTNavTag.qml"), _attachee);
_attachedTag = qobject_cast<ALTNavTagBase*>(component.create());
_attachedTag->setParentItem(_attachee);
_attachedTag->setParent(_attachee);
Expand Down
1 change: 1 addition & 0 deletions QMLComponents/ALTNavigation/altnavtag.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ALTNavScope;
class ALTNavTagBase : public QQuickItem
{
Q_OBJECT
QML_ELEMENT

Q_PROPERTY( QString tagText READ getTagText NOTIFY tagTextChanged );
Q_PROPERTY( bool active READ getActive NOTIFY activeChanged );
Expand Down
1 change: 1 addition & 0 deletions QMLComponents/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ target_include_directories(
${PROJECT_SOURCE_DIR}/Common/jaspColumnEncoder
${CMAKE_CURRENT_LIST_DIR}/controls
${CMAKE_CURRENT_LIST_DIR}/rsyntax
${CMAKE_CURRENT_LIST_DIR}/ALTNavigation
)


Expand Down
2 changes: 1 addition & 1 deletion QMLComponents/analysisform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ void AnalysisForm::addControlError(JASPControl* control, QString message, bool t
// Cannot instantiate _controlErrorMessageComponent in the constructor (it crashes), and it might be too late in the formCompletedHandler since error can be generated earlier
// So create it when it is needed for the first time.
if (!_controlErrorMessageComponent)
_controlErrorMessageComponent = new QQmlComponent(qmlEngine(this), "qrc:///components/JASP/Controls/ControlErrorMessage.qml");
_controlErrorMessageComponent = new QQmlComponent(qmlEngine(this), "qrc:/jasp-stats.org/imports/JASP/Controls/components/JASP/Controls/ControlErrorMessage.qml");

controlErrorMessageItem = qobject_cast<QQuickItem*>(_controlErrorMessageComponent->create(QQmlEngine::contextForObject(this)));
if (!controlErrorMessageItem)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import QtQuick
import QtQuick.Controls
import JASP
import JASP.Controls

//Tag shown when alt navigation mode is enabled.
ALTNavTagBase
Expand Down
5 changes: 5 additions & 0 deletions QMLComponents/utilities/qmlutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "log.h"
#include "columnencoder.h"
#include "models/term.h"
#include "jaspcontrol.h"
#include "altnavpostfixassignmentstrategy.h"

#ifdef linux
#include <QtGlobal>
Expand Down Expand Up @@ -196,4 +198,7 @@ void QmlUtils::setGlobalPropertiesInQMLContext(QQmlContext * ctxt)
ctxt->setContextProperty("LINUX", isLinux);
ctxt->setContextProperty("WINDOWS", isWindows);
ctxt->setContextProperty("INTERACTION_SEPARATOR", Term::separator);

qmlRegisterUncreatableType<JASPControl>( "JASP", 1, 0, "JASP", "Impossible to create JASP Object");
qmlRegisterUncreatableType<ALTNavPostfixAssignmentStrategy>("JASP", 1, 0, "AssignmentStrategy", "Can't make it" );
}

0 comments on commit 104ca01

Please sign in to comment.