Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F34123898
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
4 KB
Subscribers
None
View Options
diff --git a/src/util/overlay.cpp b/src/util/overlay.cpp
new file mode 100644
index 0000000..4ef6e33
--- /dev/null
+++ b/src/util/overlay.cpp
@@ -0,0 +1,128 @@
+/* Copyright (C) 2018 by Intevation GmbH <info@intevation.de>
+ *
+ * This file is Free Software under the GNU GPL (v>=2)
+ * and comes with ABSOLUTELY NO WARRANTY!
+ * See LICENSE.txt for details.
+ */
+
+#include "overlay.h"
+
+#include <QProgressBar>
+#include <QVBoxLayout>
+#include <QLabel>
+#include <QMouseEvent>
+#include <QWindow>
+#include <QTimer>
+#include <QPainter>
+#include <QBrush>
+#include <QLinearGradient>
+#include <QStyle>
+#include <QPushButton>
+#include <QApplication>
+
+#include <iostream>
+
+#ifdef Q_OS_WIN
+
+#include <windows.h>
+
+class Overlay::Private
+{
+public:
+ Private(Overlay *qq, WId id, const QString &text):
+ q(qq)
+ {
+ auto window = QWindow::fromWinId(id);
+ m_target = (HWND) id;
+
+ auto parentHandle = q->windowHandle();
+ if (parentHandle) {
+ parentHandle->setTransientParent(window);
+ }
+
+ q->setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog | Qt::Tool | Qt::CustomizeWindowHint);
+ q->setAttribute(Qt::WA_TransparentForMouseEvents);
+ q->setAttribute(Qt::WA_TranslucentBackground);
+
+ auto vLay = new QVBoxLayout(q);
+ auto bar = new QProgressBar;
+ auto label = new QLabel;
+ label->setText(QStringLiteral("<h3>%1</h3>").arg(text));
+ bar->setRange(0, 0);
+ vLay->addStretch(1);
+
+ auto cancelBtn = new QPushButton;
+ cancelBtn->setIcon(q->style()->standardPixmap(QStyle::SP_TitleBarCloseButton));
+ cancelBtn->setFlat(true);
+
+ auto subLay1 = new QVBoxLayout;
+ auto subLay3 = new QHBoxLayout;
+ subLay3->addStretch(0.5);
+ subLay3->addWidget(label);
+ subLay3->addStretch(1);
+ subLay3->addWidget(cancelBtn);
+ subLay1->addLayout(subLay3);
+ subLay1->addWidget(bar);
+
+ auto subLay2 = new QHBoxLayout;
+ subLay2->addStretch(0.1);
+ subLay2->addLayout(subLay1);
+ subLay2->addStretch(0.1);
+
+ vLay->addLayout(subLay2);
+
+ vLay->addStretch(1);
+
+ connect(cancelBtn, &QPushButton::clicked, q, [this] () {
+ std::cout << "cancel" << std::endl;
+ qApp->quit();
+ });
+
+ auto refreshTimer = new QTimer(q);
+ connect(refreshTimer, &QTimer::timeout, q, [this] () {
+ RECT rect;
+ if (GetWindowRect(m_target, &rect)) {
+ q->setGeometry(rect.left, rect.top, rect.right - rect.left,
+ rect.bottom - rect.top);
+ } else {
+ //maybe window was closed
+ OutputDebugStringA ("Overlay GetWindowRect failed.");
+ std::cout << "cancel" << std::endl;
+ qApp->quit();
+ }
+ });
+ refreshTimer->start(50); // update interval in milliseconds
+ q->show();
+ }
+ HWND m_target;
+
+ Overlay *q;
+};
+
+Overlay::Overlay (WId id, const QString &text):
+ d(new Private(this, id, text))
+{
+}
+
+#else
+Overlay::Overlay (WId id, const QString &text)
+{
+}
+#endif
+
+void Overlay::paintEvent(QPaintEvent *e) {
+ QPainter painter(this);
+
+ int width = size().width();
+ int height = size().height();
+
+ QLinearGradient gradient(0, 0, 0, height);
+ gradient.setColorAt(0, Qt::transparent);
+ gradient.setColorAt(0.5, Qt::white);
+ gradient.setColorAt(1, Qt::transparent);
+
+ QBrush brush(gradient);
+
+ painter.fillRect(0, 0, width, height, gradient);
+ QWidget::paintEvent(e);
+}
diff --git a/src/util/overlay.h b/src/util/overlay.h
new file mode 100644
index 0000000..6fb1cae
--- /dev/null
+++ b/src/util/overlay.h
@@ -0,0 +1,27 @@
+#ifndef OVERLAY_H
+#define OVERLAY_H
+/* Copyright (C) 2018 by Intevation GmbH <info@intevation.de>
+ *
+ * This file is Free Software under the GNU GPL (v>=2)
+ * and comes with ABSOLUTELY NO WARRANTY!
+ * See LICENSE.txt for details.
+ */
+
+#include <QWidget>
+#include <memory>
+class QPaintEvent;
+
+class Overlay: public QWidget
+{
+ Q_OBJECT
+public:
+ Overlay (WId id, const QString &text);
+
+protected:
+ virtual void paintEvent (QPaintEvent *event) override;
+
+private:
+ class Private;
+ std::shared_ptr<Private> d;
+};
+#endif
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Dec 7, 12:06 AM (2 h, 25 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
07/82/df76c9b7cf7a50b8ed93080e02df
Attached To
rGTO Gpg4win-Tools
Event Timeline
Log In to Comment