From 76e34d05ab5e217ecd230fa9fc46148d39771bf1 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 20 Mar 2019 16:04:17 +0100 Subject: [PATCH] Ref T561, string list dialog, select from "a list of strings" --- src/blackgui/components/stringlistdialog.cpp | 41 ++++++++++++ src/blackgui/components/stringlistdialog.h | 48 ++++++++++++++ src/blackgui/components/stringlistdialog.ui | 67 ++++++++++++++++++++ src/blackgui/share/qss/stdwidget.qss | 3 +- 4 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 src/blackgui/components/stringlistdialog.cpp create mode 100644 src/blackgui/components/stringlistdialog.h create mode 100644 src/blackgui/components/stringlistdialog.ui diff --git a/src/blackgui/components/stringlistdialog.cpp b/src/blackgui/components/stringlistdialog.cpp new file mode 100644 index 000000000..a20faee18 --- /dev/null +++ b/src/blackgui/components/stringlistdialog.cpp @@ -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 selectedItems = ui->lw_StringList->selectedItems(); + if (selectedItems.isEmpty()) { return {}; } + return selectedItems.front()->text(); + } + } // ns +} // ns diff --git a/src/blackgui/components/stringlistdialog.h b/src/blackgui/components/stringlistdialog.h new file mode 100644 index 000000000..b32022471 --- /dev/null +++ b/src/blackgui/components/stringlistdialog.h @@ -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 +#include + +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; + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/stringlistdialog.ui b/src/blackgui/components/stringlistdialog.ui new file mode 100644 index 000000000..99770d648 --- /dev/null +++ b/src/blackgui/components/stringlistdialog.ui @@ -0,0 +1,67 @@ + + + CStringListDialog + + + + 0 + 0 + 270 + 229 + + + + Select from list + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + bb_StringListDialog + accepted() + CStringListDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + bb_StringListDialog + rejected() + CStringListDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/blackgui/share/qss/stdwidget.qss b/src/blackgui/share/qss/stdwidget.qss index 7ce42afb4..cafa64b00 100644 --- a/src/blackgui/share/qss/stdwidget.qss +++ b/src/blackgui/share/qss/stdwidget.qss @@ -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);