Ref T561, string list dialog, select from "a list of strings"

This commit is contained in:
Klaus Basan
2019-03-20 16:04:17 +01:00
committed by Mat Sutcliffe
parent 2b68fe80da
commit 76e34d05ab
4 changed files with 158 additions and 1 deletions

View File

@@ -0,0 +1,41 @@
/* Copyright (C) 2019
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
* or distributed except according to the terms contained in the LICENSE file.
*/
#include "stringlistdialog.h"
#include "ui_stringlistdialog.h"
namespace BlackGui
{
namespace Components
{
CStringListDialog::CStringListDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::CStringListDialog)
{
ui->setupUi(this);
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
ui->lw_StringList->setSelectionMode(QAbstractItemView::SingleSelection);
}
CStringListDialog::~CStringListDialog()
{ }
void CStringListDialog::setStrings(const QStringList &strings)
{
ui->lw_StringList->clear();
ui->lw_StringList->addItems(strings);
}
QString CStringListDialog::getSelectedValue() const
{
const QList<QListWidgetItem *> selectedItems = ui->lw_StringList->selectedItems();
if (selectedItems.isEmpty()) { return {}; }
return selectedItems.front()->text();
}
} // ns
} // ns

View File

@@ -0,0 +1,48 @@
/* Copyright (C) 2019
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
* or distributed except according to the terms contained in the LICENSE file.
*/
//! \file
#ifndef BLACKGUI_COMPONENTS_STRINGLISTDIALOG_H
#define BLACKGUI_COMPONENTS_STRINGLISTDIALOG_H
#include <QDialog>
#include <QScopedPointer>
namespace Ui { class CStringListDialog; }
namespace BlackGui
{
namespace Components
{
/**
* Select from a list of string
*/
class CStringListDialog : public QDialog
{
Q_OBJECT
public:
//! Ctor
explicit CStringListDialog(QWidget *parent = nullptr);
//! Destructor
virtual ~CStringListDialog() override;
//! Strings
void setStrings(const QStringList &strings);
//! Selected value
QString getSelectedValue() const;
private:
QScopedPointer<Ui::CStringListDialog> ui;
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CStringListDialog</class>
<widget class="QDialog" name="CStringListDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>270</width>
<height>229</height>
</rect>
</property>
<property name="windowTitle">
<string>Select from list</string>
</property>
<layout class="QVBoxLayout" name="vl_StringListDialog">
<item>
<widget class="QListWidget" name="lw_StringList"/>
</item>
<item>
<widget class="QDialogButtonBox" name="bb_StringListDialog">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>bb_StringListDialog</sender>
<signal>accepted()</signal>
<receiver>CStringListDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>bb_StringListDialog</sender>
<signal>rejected()</signal>
<receiver>CStringListDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -193,7 +193,8 @@ BlackGui--Components--CFirstModelSetComponent,
BlackGui--Components--CDbAircraftIcaoComponent,
BlackGui--Components--CDbLiveryComponent,
BlackGui--Components--CDbDistributorComponent,
BlackGui--Components--CLegalInfoComponent
BlackGui--Components--CLegalInfoComponent,
BlackGui--Components--CStringListDialog
{
background: black; /* background is background color here */
background-image: url(:/textures/icons/textures/texture-inner.jpg);