File indexing completed on 2024-11-10 04:55:56

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 #include <QClipboard>
0010 #include <QGuiApplication>
0011 #include <QPainter>
0012 #include <QRasterWindow>
0013 #include <QTimer>
0014 
0015 class Window : public QRasterWindow
0016 {
0017     Q_OBJECT
0018 public:
0019     explicit Window();
0020     ~Window() override;
0021 
0022 protected:
0023     void paintEvent(QPaintEvent *event) override;
0024 };
0025 
0026 Window::Window()
0027     : QRasterWindow()
0028 {
0029 }
0030 
0031 Window::~Window() = default;
0032 
0033 void Window::paintEvent(QPaintEvent *event)
0034 {
0035     QPainter p(this);
0036     p.fillRect(0, 0, width(), height(), Qt::blue);
0037 }
0038 
0039 int main(int argc, char *argv[])
0040 {
0041     QGuiApplication app(argc, argv);
0042     QObject::connect(app.clipboard(), &QClipboard::changed, &app,
0043                      [] {
0044                          if (qApp->clipboard()->text() == QLatin1String("test")) {
0045                              QTimer::singleShot(100, qApp, &QCoreApplication::quit);
0046                          }
0047                      });
0048     std::unique_ptr<Window> w(new Window);
0049     w->setGeometry(QRect(0, 0, 100, 200));
0050     w->show();
0051 
0052     return app.exec();
0053 }
0054 
0055 #include "paste.moc"