mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-30 22:29:13 +08:00
refs #935, resizing for message frame
also avoid showing overlay message too soon (ie when not full initialized)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
f34e80ea62
commit
be24d069fe
@@ -12,21 +12,25 @@
|
||||
#include "blackgui/stylesheetutility.h"
|
||||
#include "blackgui/guiutility.h"
|
||||
#include "blackmisc/network/textmessage.h"
|
||||
#include "blackmisc/verify.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QPoint>
|
||||
#include <QRect>
|
||||
#include <QStyle>
|
||||
#include <Qt>
|
||||
#include <algorithm>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
COverlayMessagesFrame::COverlayMessagesFrame(QWidget *parent) :
|
||||
QFrame(parent)
|
||||
{ }
|
||||
{
|
||||
// void
|
||||
}
|
||||
|
||||
COverlayMessagesFrame::~COverlayMessagesFrame()
|
||||
{}
|
||||
{ }
|
||||
|
||||
void COverlayMessagesFrame::showStatusMessagesFrame()
|
||||
{
|
||||
@@ -42,11 +46,6 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void COverlayMessagesFrame::hideStatusMessagesFrame()
|
||||
{
|
||||
if (!m_overlayMessages) { return; }
|
||||
}
|
||||
|
||||
void COverlayMessagesFrame::showOverlayMessagesWithConfirmation(const BlackMisc::CStatusMessageList &messages, const QString &confirmationMessage, std::function<void ()> okLambda, int defaultButton, int timeOutMs)
|
||||
{
|
||||
if (messages.isEmpty()) { return; }
|
||||
@@ -106,10 +105,21 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void COverlayMessagesFrame::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QFrame::resizeEvent(event);
|
||||
if (this->m_overlayMessages && this->m_overlayMessages->isVisible())
|
||||
{
|
||||
this->initInnerFrame();
|
||||
}
|
||||
}
|
||||
|
||||
QSize COverlayMessagesFrame::innerFrameSize() const
|
||||
{
|
||||
const int w = this->width();
|
||||
const int h = this->height();
|
||||
// check against minimum if widget is initialized, but not yet resized
|
||||
const int w = std::max(this->width(), this->minimumWidth());
|
||||
const int h = std::max(this->height(), this->minimumHeight());
|
||||
|
||||
int wInner = this->m_widthFactor * w;
|
||||
int hInner = this->m_heightFactor * h;
|
||||
if (wInner > this->maximumWidth()) wInner = this->maximumWidth();
|
||||
@@ -122,6 +132,7 @@ namespace BlackGui
|
||||
const QSize inner(innerFrameSize());
|
||||
if (!this->m_overlayMessages)
|
||||
{
|
||||
// lazy init
|
||||
this->m_overlayMessages = new COverlayMessages(inner.width(), inner.height(), this);
|
||||
this->m_overlayMessages->addShadow();
|
||||
this->m_overlayMessages->showKillButton(m_showKillButton);
|
||||
|
||||
@@ -55,9 +55,6 @@ namespace BlackGui
|
||||
//! Show kill button
|
||||
void showKillButton(bool killButton);
|
||||
|
||||
//! Hide the inner frame
|
||||
void hideStatusMessagesFrame();
|
||||
|
||||
//! Inner frame factors 0..1
|
||||
//! \remarks can also be restricted by maximumHeight() / maximumWidth()
|
||||
void setInnerFrameFactor(double xFactor, double yFactor);
|
||||
@@ -91,6 +88,9 @@ namespace BlackGui
|
||||
//! \copydoc QFrame::keyPressEvent
|
||||
virtual void keyPressEvent(QKeyEvent *event) override;
|
||||
|
||||
//! \copydoc QFrame::resizeEvent
|
||||
virtual void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
COverlayMessages *m_overlayMessages = nullptr; //!< embedded QFrame with Status messages
|
||||
|
||||
private:
|
||||
|
||||
@@ -201,7 +201,6 @@ bool SwiftGuiStd::isMainPageSelected(SwiftGuiStd::MainPageIndex mainPage) const
|
||||
return ui->sw_MainMiddle->currentIndex() == static_cast<int>(mainPage);
|
||||
}
|
||||
|
||||
|
||||
void SwiftGuiStd::ps_loginRequested()
|
||||
{
|
||||
if (ui->sw_MainMiddle->currentIndex() == static_cast<int>(MainPageLogin))
|
||||
@@ -403,6 +402,7 @@ void SwiftGuiStd::ps_verifyDataAvailability()
|
||||
void SwiftGuiStd::ps_sharedFilesHeadersLoaded()
|
||||
{
|
||||
Q_ASSERT_X(sGui && sGui->hasWebDataServices(), Q_FUNC_INFO, "Missing web services");
|
||||
Q_ASSERT_X(CThreadUtils::isCurrentThreadApplicationThread(), Q_FUNC_INFO, "Wrong thread");
|
||||
const CEntityFlags::Entity newEntities = sGui->getWebDataServices()->getEntitiesWithNewerHeaderTimestamp(CEntityFlags::AllDbEntities);
|
||||
if (newEntities == CEntityFlags::NoEntity) { return; }
|
||||
CStatusMessage sm = CStatusMessage(this).info("New data for shared files:");
|
||||
@@ -413,11 +413,18 @@ void SwiftGuiStd::ps_sharedFilesHeadersLoaded()
|
||||
sm = CStatusMessage(this).info("Load data for '%1'?") << CEntityFlags::flagToString(newSingleEntity);
|
||||
sms.push_back(sm);
|
||||
}
|
||||
auto lambda = [newEntities]()
|
||||
|
||||
// allow to init GUI completely
|
||||
const int delay = 2500;
|
||||
QTimer::singleShot(delay, this, [ = ]
|
||||
{
|
||||
sGui->getWebDataServices()->triggerLoadingDirectlyFromSharedFiles(newEntities, false);
|
||||
};
|
||||
ui->fr_CentralFrameInside->showOverlayMessagesWithConfirmation(sms, "Load data?", lambda);
|
||||
// delayed call
|
||||
auto lambda = [newEntities]()
|
||||
{
|
||||
sGui->getWebDataServices()->triggerLoadingDirectlyFromSharedFiles(newEntities, false);
|
||||
};
|
||||
ui->fr_CentralFrameInside->showOverlayMessagesWithConfirmation(sms, "Load data?", lambda);
|
||||
});
|
||||
}
|
||||
|
||||
void SwiftGuiStd::playNotifcationSound(CNotificationSounds::Notification notification) const
|
||||
|
||||
Reference in New Issue
Block a user