File indexing completed on 2024-03-24 05:01:35
0001 /* 0002 SPDX-FileCopyrightText: 2008 Urs Wolfer <uwolfer@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "testview.h" 0008 0009 #include <QEvent> 0010 #include <QTimer> 0011 0012 TestView::TestView(QWidget *parent, const QUrl &url, KConfigGroup configGroup) 0013 : RemoteView(parent) 0014 { 0015 m_hostPreferences = new TestHostPreferences(configGroup, this); 0016 0017 Q_UNUSED(url); 0018 } 0019 0020 TestView::~TestView() 0021 { 0022 Q_EMIT disconnected(); 0023 setStatus(Disconnected); 0024 } 0025 0026 bool TestView::eventFilter(QObject *obj, QEvent *event) 0027 { 0028 if (m_viewOnly) { 0029 if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease || event->type() == QEvent::MouseButtonDblClick 0030 || event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonRelease || event->type() == QEvent::MouseMove) 0031 return true; 0032 } 0033 return RemoteView::eventFilter(obj, event); 0034 } 0035 0036 void TestView::asyncConnect() 0037 { 0038 QPalette pal = palette(); 0039 pal.setColor(QPalette::Window, Qt::yellow); 0040 setPalette(pal); 0041 setAutoFillBackground(true); 0042 0043 const QSize size = QSize(640, 480); 0044 setFixedSize(size); 0045 resize(size); 0046 setStatus(Connected); 0047 Q_EMIT framebufferSizeChanged(size.width(), size.height()); 0048 Q_EMIT connected(); 0049 setFocus(); 0050 } 0051 0052 QSize TestView::framebufferSize() 0053 { 0054 return minimumSizeHint(); 0055 } 0056 0057 QSize TestView::sizeHint() const 0058 { 0059 return maximumSize(); 0060 } 0061 0062 bool TestView::isQuitting() 0063 { 0064 return false; 0065 } 0066 0067 bool TestView::start() 0068 { 0069 setStatus(Connecting); 0070 // call it async in order to simulate real world behavior 0071 QTimer::singleShot(1000, this, SLOT(asyncConnect())); 0072 return true; 0073 } 0074 0075 HostPreferences *TestView::hostPreferences() 0076 { 0077 return m_hostPreferences; 0078 } 0079 0080 void TestView::switchFullscreen(bool on) 0081 { 0082 Q_UNUSED(on); 0083 }