Ref T286, signal for "other swift version"

This commit is contained in:
Klaus Basan
2018-07-03 19:32:17 +02:00
parent 50858a33e4
commit 61e2ffb7da
3 changed files with 21 additions and 5 deletions

View File

@@ -15,6 +15,7 @@
#include <QDesktopServices> #include <QDesktopServices>
using namespace BlackMisc; using namespace BlackMisc;
using namespace BlackGui::Views;
namespace BlackGui namespace BlackGui
{ {
@@ -25,10 +26,11 @@ namespace BlackGui
ui(new Ui::COtherSwiftVersionsComponent) ui(new Ui::COtherSwiftVersionsComponent)
{ {
ui->setupUi(this); ui->setupUi(this);
connect(ui->tb_DataDir, &QToolButton::clicked, this, &COtherSwiftVersionsComponent::openDataDirectory);
ui->tvp_ApplicationInfo->otherSwiftVersionsFromDataDirectories(); ui->tvp_ApplicationInfo->otherSwiftVersionsFromDataDirectories();
ui->le_ThisVersion->setText(sGui->getApplicationInfo().asOtherSwiftVersionString()); ui->le_ThisVersion->setText(sGui->getApplicationInfo().asOtherSwiftVersionString());
ui->le_ThisVersion->home(false); ui->le_ThisVersion->home(false);
connect(ui->tb_DataDir, &QToolButton::clicked, this, &COtherSwiftVersionsComponent::openDataDirectory);
connect(ui->tvp_ApplicationInfo, &CApplicationInfoView::objectSelected, this, &COtherSwiftVersionsComponent::onObjectSelected);
} }
COtherSwiftVersionsComponent::~COtherSwiftVersionsComponent() COtherSwiftVersionsComponent::~COtherSwiftVersionsComponent()
@@ -51,5 +53,12 @@ namespace BlackGui
const QUrl url = QUrl::fromLocalFile(dir); const QUrl url = QUrl::fromLocalFile(dir);
QDesktopServices::openUrl(url); QDesktopServices::openUrl(url);
} }
void COtherSwiftVersionsComponent::onObjectSelected(const CVariant &object)
{
if (!object.canConvert<CApplicationInfo>()) { return; }
const CApplicationInfo info(object.value<CApplicationInfo>());
emit this->versionChanged(info);
}
} // ns } // ns
} // ns } // ns

View File

@@ -41,11 +41,18 @@ namespace BlackGui
//! Get the selected other version //! Get the selected other version
BlackMisc::CApplicationInfo selectedOtherVersion() const; BlackMisc::CApplicationInfo selectedOtherVersion() const;
signals:
//! Selection changed
void versionChanged(const BlackMisc::CApplicationInfo &info);
private: private:
QScopedPointer<Ui::COtherSwiftVersionsComponent> ui; QScopedPointer<Ui::COtherSwiftVersionsComponent> ui;
//! Data directory //! Data directory
void openDataDirectory(); void openDataDirectory();
//! Object has been selected
void onObjectSelected(const BlackMisc::CVariant &object);
}; };
} // ns } // ns
} // ns } // ns

View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>362</width> <width>305</width>
<height>238</height> <height>233</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -17,7 +17,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="lbl_ThisVersion"> <widget class="QLabel" name="lbl_ThisVersion">
<property name="text"> <property name="text">
<string>This version:</string> <string>This:</string>
</property> </property>
</widget> </widget>
</item> </item>
@@ -46,7 +46,7 @@
<item> <item>
<widget class="QLabel" name="lbl_OtherVersions"> <widget class="QLabel" name="lbl_OtherVersions">
<property name="text"> <property name="text">
<string>Other versions:</string> <string>Others:</string>
</property> </property>
</widget> </widget>
</item> </item>