Continues migration with DDS, Common

This commit is contained in:
torsten committed 2026-07-17 12:41:42 +02:00
1 parent 9b15cee841
commit fa48db111e
668 files changed
+111841 -2

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
#include "app.h"
#include "ui_app.h"
#include "AppChooser/app_chooser_model.h"
namespace LtsAppManager
{
CustomViewApp::CustomViewApp(QWidget *parent)
: AbstractDisplayWidget(parent)
, m_ui(new Ui::CustomViewApp)
{
m_ui->setupUi(this);
m_ui->image->setMenuEnabled(false);
}
CustomViewApp::~CustomViewApp()
{
delete m_ui;
}
bool CustomViewApp::init(const QModelIndex &idx)
{
if (!idx.isValid())
return false;
m_ui->lbAppName->setText(rowData(idx, AppChooserModel::Name).toString());
return true;
}
}
+30
View File
@@ -0,0 +1,30 @@
#pragma once
#include <Viewer/LtsDataView/abstract_display_widget.h>
namespace Ui
{
class CustomViewApp;
}
namespace LtsAppManager
{
class CustomViewApp final : public LtsDataView::AbstractDisplayWidget
{
Q_OBJECT
public:
explicit CustomViewApp(QWidget *parent = nullptr);
~CustomViewApp();
bool init(const QModelIndex &idx) override;
private:
Ui::CustomViewApp* m_ui;
};
}
+108
View File
@@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CustomViewApp</class>
<widget class="QWidget" name="CustomViewApp">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>300</width>
<height>150</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="LtsWidgets::LtsImageEditor" name="image">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>128</width>
<height>128</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>128</width>
<height>128</height>
</size>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="lbAppName">
<property name="text">
<string notr="true">&lt;App Name&gt;</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="lbDescription">
<property name="text">
<string notr="true">&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&amp;lt;Description with wordwrap&amp;gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>LtsWidgets::LtsImageEditor</class>
<extends>QWidget</extends>
<header>LtsWidgets/lts_image_editor.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
+93
View File
@@ -0,0 +1,93 @@
#include "AppChooser/app_chooser.h"
#include "ui_app_chooser.h"
#include "AppChooser/app_chooser_model.h"
#include "lts_app_manager.h"
#include "AppChooser/CustomViews/app.h"
#include <QCloseEvent>
#include <QDebug>
namespace LtsAppManager
{
AppChooser::AppChooser()
: QWidget(nullptr)
, m_ui(new Ui::AppChooser)
, m_model()
, m_madeSelection(false)
{
m_ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
connect(m_ui->widget, &LtsDataView::LtsDataView::LtsDataView::signalDoubleClicked,
this, &AppChooser::slotAppSelected);
connect(m_ui->widget, &LtsDataView::LtsDataView::LtsDataView::signalEnterPressed,
this, &AppChooser::slotAppSelected);
connect(m_ui->widget, &LtsDataView::LtsDataView::LtsDataView::signalSelectionChanged,
this, &AppChooser::enaDisa);
connect(m_ui->pbQuit, &QPushButton::clicked,
this, &QWidget::close);
connect(m_ui->pbSelect, &QPushButton::clicked,
this, &AppChooser::slotAppSelected);
m_model = new AppChooserModel(this);
m_model->initModel(LtsAppManager::getInstance()->getAvailableApps());
m_ui->widget->seamless();
m_ui->widget->setModel(m_model);
m_ui->widget->hideColumn(AppChooserModel::Columns::Visible);
}
AppChooser::~AppChooser()
{
delete m_ui;
}
void AppChooser::slotQuit()
{
if (m_alreadyCloseEmitted)
return;
m_alreadyCloseEmitted = true;
emit signalLogout();
}
void AppChooser::closeEvent(QCloseEvent *)
{
if (!m_madeSelection)
slotQuit();
}
void AppChooser::slotAppSelected()
{
const QModelIndex idx = m_ui->widget->currentIndex();
const LtsAppDescriptor::AppDescription app = m_model->getRowData(idx.row());
if (!app.active)
return;
hide();
m_madeSelection = true;
emit signalAppSelected(app.id);
close();
}
void AppChooser::enaDisa()
{
const QModelIndexList selectedRows = m_ui->widget->selectedRows();
const int cntSelectedRows = selectedRows.size();
m_ui->pbSelect->setEnabled(cntSelectedRows == 1);
}
}
+47
View File
@@ -0,0 +1,47 @@
#pragma once
#include <QWidget>
#include <LtsAppDescriptor/lts_app_descriptor.h>
namespace Ui
{
class AppChooser;
}
namespace LtsAppManager
{
class AppChooserModel;
class AppChooser : public QWidget
{
Q_OBJECT
public:
AppChooser();
~AppChooser();
private:
Ui::AppChooser *m_ui;
AppChooserModel *m_model;
bool m_madeSelection;
bool m_alreadyCloseEmitted { false };
void enaDisa();
protected:
void closeEvent(QCloseEvent *);
signals:
void signalAppSelected(LtsAppDescriptor::App appId);
void signalLogout();
private slots:
void slotAppSelected();
void slotQuit();
};
}
+92
View File
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AppChooser</class>
<widget class="QWidget" name="AppChooser">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>400</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>App Chooser</string>
</property>
<property name="windowIcon">
<iconset resource="../../LtsWidgets/resources/lts_resources.qrc">
<normaloff>:/rde_icon_256.png</normaloff>:/rde_icon_256.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Select App:</string>
</property>
</widget>
</item>
<item>
<widget class="LtsDataView::LtsDataView" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pbQuit">
<property name="text">
<string>Quit</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pbSelect">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Select</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>LtsDataView::LtsDataView</class>
<extends>QWidget</extends>
<header location="global">Viewer/LtsDataView/lts_data_view.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../LtsWidgets/resources/lts_resources.qrc"/>
</resources>
<connections/>
</ui>
+50
View File
@@ -0,0 +1,50 @@
#include "app_chooser_model.h"
#include <LtsSession/lts_session.h>
namespace LtsAppManager
{
AppChooserModel::AppChooserModel(QObject *parent)
: LtsWidgets::LtsAbstractTableModel<LtsAppDescriptor::AppDescription>({tr("Name")}, parent)
{}
bool AppChooserModel::initModel(const LtsAppDescriptor::AppDescriptionVector &availableApps)
{
for (auto i = availableApps.constBegin(); i != availableApps.constEnd(); ++i)
{
const LtsAppDescriptor::AppDescription& appDesc = *i;
if (!appDesc.visible)
continue;
insertRow(appDesc);
}
return true;
}
QVariant AppChooserModel::data(const QModelIndex &index, int role) const
{
if (role != Qt::DisplayRole || !indexIsValid(index))
return QVariant();
const LtsAppDescriptor::AppDescription &ad = m_vecData.at(index.row());
switch (index.column())
{
case Name:
return LtsSession::LtsSession::appToString(ad.id);
case Visible:
return ad.visible;
}
return QVariant();
}
}
+29
View File
@@ -0,0 +1,29 @@
#pragma once
#include <LtsAppDescriptor/lts_app_descriptor.h>
#include <LtsWidgets/lts_abstract_table_model.h>
namespace LtsAppManager
{
class AppChooserModel final : public LtsWidgets::LtsAbstractTableModel<LtsAppDescriptor::AppDescription>
{
Q_OBJECT
public:
enum Columns
{
Name = 0,
Visible,
};
explicit AppChooserModel(QObject *parent = nullptr);
bool initModel(const LtsAppDescriptor::AppDescriptionVector &availableApps);
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override final;
};
}