diff --git a/src/blackgui/components/datamaininfoareacomponent.ui b/src/blackgui/components/datamaininfoareacomponent.ui index 60ca3f99e..11c93b19b 100644 --- a/src/blackgui/components/datamaininfoareacomponent.ui +++ b/src/blackgui/components/datamaininfoareacomponent.ui @@ -244,7 +244,7 @@ Qt::TopDockWidgetArea - Settings + Settings and login 4 @@ -291,7 +291,7 @@ 0 - + QFrame::StyledPanel @@ -411,6 +411,12 @@
blackgui/components/dbstashcomponent.h
1 + + BlackGui::Components::CDataSettingsComponent + QFrame +
blackgui/components/datasettingscomponent.h
+ 1 +
diff --git a/src/blackgui/components/datasettingscomponent.cpp b/src/blackgui/components/datasettingscomponent.cpp new file mode 100644 index 000000000..fb5667308 --- /dev/null +++ b/src/blackgui/components/datasettingscomponent.cpp @@ -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 diff --git a/src/blackgui/components/datasettingscomponent.h b/src/blackgui/components/datasettingscomponent.h new file mode 100644 index 000000000..70765bd07 --- /dev/null +++ b/src/blackgui/components/datasettingscomponent.h @@ -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 +#include + +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; + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/datasettingscomponent.ui b/src/blackgui/components/datasettingscomponent.ui new file mode 100644 index 000000000..bf38a21e3 --- /dev/null +++ b/src/blackgui/components/datasettingscomponent.ui @@ -0,0 +1,49 @@ + + + CDataSettingsComponent + + + + 0 + 0 + 400 + 300 + + + + Frame + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 59 + 29 + 151 + 101 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + BlackGui::Components::CDbLoginComponent + QFrame +
blackgui/components/dblogincomponent.h
+ 1 +
+
+ + +
diff --git a/src/blackgui/components/dblogincomponent.cpp b/src/blackgui/components/dblogincomponent.cpp new file mode 100644 index 000000000..81cdc6a91 --- /dev/null +++ b/src/blackgui/components/dblogincomponent.cpp @@ -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("swift DB@" + url.getHost() + ""); + 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(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 diff --git a/src/blackgui/components/dblogincomponent.h b/src/blackgui/components/dblogincomponent.h new file mode 100644 index 000000000..ba6e71a42 --- /dev/null +++ b/src/blackgui/components/dblogincomponent.h @@ -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 +#include + +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; + BlackCore::CData m_setup {this}; //!< data cache + + //! Overlay messages + void displayOverlayMessages(const BlackMisc::CStatusMessageList &msgs); + + private slots: + //! Login + void ps_onLoginClicked(); + + }; + + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/dblogincomponent.ui b/src/blackgui/components/dblogincomponent.ui new file mode 100644 index 000000000..70583dc99 --- /dev/null +++ b/src/blackgui/components/dblogincomponent.ui @@ -0,0 +1,88 @@ + + + CDbLoginComponent + + + + 300 + 0 + + + + DB login + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + 40 + + + user name or id + + + true + + + + + + + + + + :/own/icons/own/swift/swift32Database.png + + + + + + + login + + + + + + + Password: + + + + + + + password + + + true + + + + + + + User: + + + + + + + DB + + + + + + + + + +