summaryrefslogtreecommitdiffstats
path: root/toolwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'toolwindow.cpp')
-rw-r--r--toolwindow.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/toolwindow.cpp b/toolwindow.cpp
new file mode 100644
index 0000000..f32c15e
--- /dev/null
+++ b/toolwindow.cpp
@@ -0,0 +1,45 @@
+#include <QLabel>
+#include <QTimer>
+#include <QHBoxLayout>
+#include <QDesktopWidget>
+#include <QApplication>
+#include <kwindowsystem.h>
+
+#include "toolwindow.h"
+
+ToolWindow::ToolWindow(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f){
+ setWindowOpacity(0.9);
+ mLabel = new QLabel;
+ mLabel->setFrameStyle(QFrame::Panel | QFrame::Plain);
+ mLabel->setFont(QFont("courier", 16, QFont::Bold));
+ mLabel->setAlignment(Qt::AlignCenter);
+ QHBoxLayout *mainLayout = new QHBoxLayout;
+ mainLayout->addWidget(mLabel);
+ mHideTimer = new QTimer(this);
+ connect(mHideTimer, &QTimer::timeout, this, &QWidget::hide);
+ setLayout(mainLayout);
+ KWindowSystem::setOnAllDesktops(winId(), true);
+}
+
+void ToolWindow::setText(const QString &text){
+ mLabel->setText(text);
+}
+
+void ToolWindow::toHTML(const QString &text){
+ QString html;
+ html.append(QString("<p style=\"margin:7px;\"><span style=\"font-weight: bold; font-size: large;\">%1</span></p>").arg(text));
+ mLabel->setText(html);
+}
+
+void ToolWindow::showMe(){
+ QDesktopWidget *dw = QApplication::desktop();
+ QRect screenRect = dw->screenGeometry(QCursor::pos());
+ QPoint screenCenter = screenRect.center();
+ QPoint where(screenCenter.x() - width() / 2, 150);
+ move(where);
+ KWindowSystem::setOnDesktop(winId(), KWindowSystem::currentDesktop());
+ mHideTimer->stop();
+ mHideTimer->start(5000);
+ show();
+ raise();
+}