Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "joker.h"
- joker::joker(QObject *parent) :
- QObject(parent)
- {
- window = new gui;
- hide_timer = new QTimer;
- is_msg_showing = false;
- msg_pull = new QQueue<QString>;
- window->setWindowFlags(Qt::Widget | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
- window->setParent(0);
- window->setAttribute(Qt::WA_NoSystemBackground, true);
- window->setAttribute(Qt::WA_TranslucentBackground, true);
- // window->setAttribute(Qt::WA_PaintOnScreen);
- QLabel* label = window->findChild<QLabel*>("label");
- QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect(this);
- effect->setBlurRadius(0);
- effect->setColor(QColor("#424242"));
- effect->setOffset(3, 2);
- label->setGraphicsEffect(effect);
- QObject::connect(hide_timer, SIGNAL(timeout()), this, SLOT(hide_window()));
- }
- joker::~joker()
- {
- delete window;
- delete hide_timer;
- }
- void joker::start()
- {
- show_msg("test");
- }
- void joker::show_window()
- {
- if (window->isHidden())
- window->show();
- }
- void joker::hide_window()
- {
- if (!window->isHidden())
- window->hide();
- }
- void joker::center_window()
- {
- window->adjustSize();
- window->move(QApplication::desktop()->screen()->rect().center() - window->rect().center());
- }
- void joker::show_msg(QString msg)
- {
- if (msg.length() == 0)
- return;
- int duration = msg.length() * 80;
- show_msg(msg, duration);
- }
- void joker::show_msg(QString msg, int dur)
- {
- QLabel* label = window->findChild<QLabel*>("label");
- label->setText(msg);
- center_window();
- show_window();
- hide_timer->start(dur);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement