Ref T264, UI element to display other swift versions

This commit is contained in:
Klaus Basan
2018-05-19 07:45:22 +02:00
parent a7a1674faa
commit 0e2cb19303
6 changed files with 374 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
/* Copyright (C) 2018
* 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 and at http://www.swift-project.org/license.html. 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 "otherswiftversionscomponent.h"
#include "ui_otherswiftversionscomponent.h"
#include "blackmisc/directoryutils.h"
#include "guiapplication.h"
#include <QUrl>
#include <QDesktopServices>
using namespace BlackMisc;
namespace BlackGui
{
namespace Components
{
COtherSwiftVersionsComponent::COtherSwiftVersionsComponent(QWidget *parent) :
QFrame(parent),
ui(new Ui::COtherSwiftVersionsComponent)
{
ui->setupUi(this);
connect(ui->tb_DataDir, &QToolButton::clicked, this, &COtherSwiftVersionsComponent::openDataDirectory);
ui->tvp_ApplicationInfo->otherSwiftVersionsFromDataDirectories();
ui->le_ThisVersion->setText(sGui->getApplicationInfo().asOtherSwiftVersionString());
ui->le_ThisVersion->home(false);
}
COtherSwiftVersionsComponent::~COtherSwiftVersionsComponent()
{ }
bool COtherSwiftVersionsComponent::hasSelection() const
{
return (ui->tvp_ApplicationInfo->hasSelection());
}
BlackMisc::CApplicationInfo COtherSwiftVersionsComponent::selectedOtherVersion() const
{
if (!this->hasSelection()) { return CApplicationInfo::null(); }
return ui->tvp_ApplicationInfo->selectedObject();
}
void COtherSwiftVersionsComponent::openDataDirectory()
{
const QString dir = CDirectoryUtils::applicationDataDirectory();
const QUrl url = QUrl::fromLocalFile(dir);
QDesktopServices::openUrl(url);
}
} // ns
} // ns

View File

@@ -0,0 +1,53 @@
/* Copyright (C) 2018
* 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 and at http://www.swift-project.org/license.html. 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_OTHERSWIFTVERSIONS_H
#define BLACKGUI_COMPONENTS_OTHERSWIFTVERSIONS_H
#include "blackmisc/applicationinfo.h"
#include <QFrame>
#include <QScopedPointer>
namespace Ui { class COtherSwiftVersionsComponent; }
namespace BlackGui
{
namespace Components
{
/**
* Overview about other "swift" versions
*/
class COtherSwiftVersionsComponent : public QFrame
{
Q_OBJECT
public:
//! Constructor
explicit COtherSwiftVersionsComponent(QWidget *parent = nullptr);
//! Destructor
virtual ~COtherSwiftVersionsComponent();
//! Any version selected?
bool hasSelection() const;
//! Get the selected other version
BlackMisc::CApplicationInfo selectedOtherVersion() const;
private:
QScopedPointer<Ui::COtherSwiftVersionsComponent> ui;
//! Data directory
void openDataDirectory();
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>COtherSwiftVersionsComponent</class>
<widget class="QFrame" name="COtherSwiftVersionsComponent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>362</width>
<height>238</height>
</rect>
</property>
<property name="windowTitle">
<string>Other swift versions</string>
</property>
<layout class="QFormLayout" name="fl_OtherSwiftVersions">
<item row="0" column="0">
<widget class="QLabel" name="lbl_ThisVersion">
<property name="text">
<string>This version:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="le_ThisVersion">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QWidget" name="wi_OtherVersions" native="true">
<layout class="QVBoxLayout" name="vl_OtherVersions">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="lbl_OtherVersions">
<property name="text">
<string>Other versions:</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="tb_DataDir">
<property name="toolTip">
<string>data directory</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../blackmisc/blackmisc.qrc">
<normaloff>:/diagona/icons/diagona/icons/folder--plus.png</normaloff>:/diagona/icons/diagona/icons/folder--plus.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="vs_OtherVersions">
<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>
</widget>
</item>
<item row="1" column="1">
<widget class="BlackGui::Views::CApplicationInfoView" name="tvp_ApplicationInfo">
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Views::CApplicationInfoView</class>
<extends>QTableView</extends>
<header>blackgui/views/applicationinfoview.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>tb_DataDir</tabstop>
<tabstop>le_ThisVersion</tabstop>
<tabstop>tvp_ApplicationInfo</tabstop>
</tabstops>
<resources>
<include location="../../blackmisc/blackmisc.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -0,0 +1,27 @@
/* Copyright (C) 2018
* 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 and at http://www.swift-project.org/license.html. 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 "otherswiftversionsdialog.h"
#include "ui_otherswiftversionsdialog.h"
namespace BlackGui
{
namespace Components
{
COtherSwiftVersionsDialog::COtherSwiftVersionsDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::COtherSwiftVersionsDialog)
{
ui->setupUi(this);
}
COtherSwiftVersionsDialog::~COtherSwiftVersionsDialog()
{ }
} // ns
} // ns

View File

@@ -0,0 +1,43 @@
/* Copyright (C) 2018
* 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 and at http://www.swift-project.org/license.html. 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_OTHERSWIFTVERSIONSDIALOG_H
#define BLACKGUI_COMPONENTS_OTHERSWIFTVERSIONSDIALOG_H
#include <QDialog>
#include <QScopedPointer>
namespace Ui { class COtherSwiftVersionsDialog; }
namespace BlackGui
{
namespace Components
{
/**
* COtherVersionsComponent as dialog
*/
class COtherSwiftVersionsDialog : public QDialog
{
Q_OBJECT
public:
//! Constructor
explicit COtherSwiftVersionsDialog(QWidget *parent = nullptr);
//! Destructor
virtual ~COtherSwiftVersionsDialog();
private:
QScopedPointer<Ui::COtherSwiftVersionsDialog> ui;
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>COtherSwiftVersionsDialog</class>
<widget class="QDialog" name="COtherSwiftVersionsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>480</height>
</rect>
</property>
<property name="windowTitle">
<string>Other swift versions</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="BlackGui::Components::COtherSwiftVersionsComponent" name="comp_OtherSwiftVersions">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="bb_OtherSwiftVersions">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Components::COtherSwiftVersionsComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/otherswiftversionscomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>bb_OtherSwiftVersions</sender>
<signal>accepted()</signal>
<receiver>COtherSwiftVersionsDialog</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_OtherSwiftVersions</sender>
<signal>rejected()</signal>
<receiver>COtherSwiftVersionsDialog</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>