refs #497 login component integrated with settings (GUI)

This commit is contained in:
Klaus Basan
2015-10-21 18:56:41 +02:00
committed by Mathew Sutcliffe
parent a9fc21af2f
commit a0a03d230c
7 changed files with 344 additions and 2 deletions

View File

@@ -244,7 +244,7 @@
<set>Qt::TopDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Settings</string>
<string>Settings and login</string>
</property>
<attribute name="dockWidgetArea">
<number>4</number>
@@ -291,7 +291,7 @@
<number>0</number>
</property>
<item>
<widget class="QFrame" name="comp_Settings">
<widget class="BlackGui::Components::CDataSettingsComponent" name="comp_Settings">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
@@ -411,6 +411,12 @@
<header>blackgui/components/dbstashcomponent.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CDataSettingsComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/datasettingscomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@@ -0,0 +1,30 @@
/* Copyright (C) 2015
* 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 "datasettingscomponent.h"
#include "ui_datasettingscomponent.h"
using namespace BlackGui;
namespace BlackGui
{
namespace Components
{
CDataSettingsComponent::CDataSettingsComponent(QWidget *parent) :
COverlayMessagesFrame(parent),
ui(new Ui::CDataSettingsComponent)
{
ui->setupUi(this);
}
CDataSettingsComponent::~CDataSettingsComponent()
{ }
} // ns
} // ns

View File

@@ -0,0 +1,46 @@
/* Copyright (C) 2015
* 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_SETTINGS_DATASETTINGSCOMPONENT_H
#define BLACKGUI_SETTINGS_DATASETTINGSCOMPONENT_H
#include "blackgui/blackguiexport.h"
#include "blackgui/overlaymessagesframe.h"
#include <QFrame>
#include <QScopedPointer>
namespace Ui { class CDataSettingsComponent; }
namespace BlackGui
{
namespace Components
{
/**
* Settings
*/
class BLACKGUI_EXPORT CDataSettingsComponent : public BlackGui::COverlayMessagesFrame
{
Q_OBJECT
public:
//! Constructor
explicit CDataSettingsComponent(QWidget *parent = nullptr);
//! Destructor
~CDataSettingsComponent();
private:
QScopedPointer<Ui::CDataSettingsComponent> ui;
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CDataSettingsComponent</class>
<widget class="QFrame" name="CDataSettingsComponent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="BlackGui::Components::CDbLoginComponent" name="comp_LoginComponent">
<property name="geometry">
<rect>
<x>59</x>
<y>29</y>
<width>151</width>
<height>101</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Components::CDbLoginComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/dblogincomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,67 @@
/* Copyright (C) 2015
* 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 "dblogincomponent.h"
#include "ui_dblogincomponent.h"
#include "blackgui/overlaymessagesframe.h"
#include "blackmisc/network/url.h"
#include "blackmisc/logmessage.h"
using namespace BlackMisc;
using namespace BlackMisc::Network;
namespace BlackGui
{
namespace Components
{
CDbLoginComponent::CDbLoginComponent(QWidget *parent) :
QFrame(parent),
ui(new Ui::CDbLoginComponent)
{
ui->setupUi(this);
CUrl url(m_setup.get().dbHomePage());
ui->lbl_SwiftDB->setText("<a href=\"" + url.getFullUrl() + "\">swift DB@" + url.getHost() + "</a>");
ui->lbl_SwiftDB->setTextFormat(Qt::RichText);
ui->lbl_SwiftDB->setTextInteractionFlags(Qt::TextBrowserInteraction);
ui->lbl_SwiftDB->setOpenExternalLinks(true);
connect(ui->pb_Login, &QPushButton::clicked, this, &CDbLoginComponent::ps_onLoginClicked);
}
CDbLoginComponent::~CDbLoginComponent()
{ }
void CDbLoginComponent::displayOverlayMessages(const CStatusMessageList &msgs)
{
if (msgs.isEmpty()) { return; }
COverlayMessagesFrame *mf = qobject_cast<COverlayMessagesFrame *>(parentWidget());
Q_ASSERT_X(mf, Q_FUNC_INFO, "No overlay widget");
if (!mf) { return; }
mf->showMessages(msgs);
}
void CDbLoginComponent::ps_onLoginClicked()
{
CStatusMessageList msgs;
static const CLogCategoryList cats(CLogCategoryList(this).join({ CLogCategory::validation()}));
QString un(ui->le_Username->text().trimmed());
QString pw(ui->le_Password->text().trimmed());
if (un.isEmpty()) { msgs.push_back(CStatusMessage::CStatusMessage(cats, CStatusMessage::SeverityError, "No user name")); }
if (pw.isEmpty()) { msgs.push_back(CStatusMessage::CStatusMessage(cats, CStatusMessage::SeverityError, "No password")); }
if (msgs.hasWarningOrErrorMessages())
{
CLogMessage::preformatted(msgs);
displayOverlayMessages(msgs);
return;
}
}
} // ns
} // ns

View File

@@ -0,0 +1,56 @@
/* Copyright (C) 2015
* 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_DBLOGINCOMPONENT_H
#define BLACKGUI_COMPONENTS_DBLOGINCOMPONENT_H
#include "blackgui/blackguiexport.h"
#include "blackcore/data/globalsetup.h"
#include <QFrame>
#include <QScopedPointer>
namespace Ui { class CDbLoginComponent; }
namespace BlackGui
{
namespace Components
{
/**
* Login to DB
*/
class BLACKGUI_EXPORT CDbLoginComponent : public QFrame
{
Q_OBJECT
public:
//! Constructor
explicit CDbLoginComponent(QWidget *parent = nullptr);
//! Destructor
~CDbLoginComponent();
private:
QScopedPointer<Ui::CDbLoginComponent> ui;
BlackCore::CData<BlackCore::Data::GlobalSetup> m_setup {this}; //!< data cache
//! Overlay messages
void displayOverlayMessages(const BlackMisc::CStatusMessageList &msgs);
private slots:
//! Login
void ps_onLoginClicked();
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CDbLoginComponent</class>
<widget class="QFrame" name="CDbLoginComponent">
<property name="minimumSize">
<size>
<width>300</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>DB login</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="2">
<widget class="QLineEdit" name="le_Username">
<property name="maxLength">
<number>40</number>
</property>
<property name="placeholderText">
<string>user name or id</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_SwiftDBIcon">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../blackmisc/blackmisc.qrc">:/own/icons/own/swift/swift32Database.png</pixmap>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="pb_Login">
<property name="text">
<string>login</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_Password">
<property name="text">
<string>Password:</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="le_Password">
<property name="placeholderText">
<string>password</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_User">
<property name="text">
<string>User:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="lbl_SwiftDB">
<property name="text">
<string>DB</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../blackmisc/blackmisc.qrc"/>
</resources>
<connections/>
</ui>