Continues migration with DDS, Common
This commit is contained in:
1 parent
9b15cee841
commit
fa48db111e
668 files changed
+111841
-2
No files matched your search
+93
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user