From 74b22318b8df6c1e9355b73a16bb755a5178b8d6 Mon Sep 17 00:00:00 2001 From: Mavridis Philippe Date: Tue, 30 Mar 2021 13:58:33 +0300 Subject: Initial commit (KDE3 version) Signed-off-by: Mavridis Philippe --- src/komposegldesktopwidget.cpp | 116 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 src/komposegldesktopwidget.cpp (limited to 'src/komposegldesktopwidget.cpp') diff --git a/src/komposegldesktopwidget.cpp b/src/komposegldesktopwidget.cpp new file mode 100644 index 0000000..2c33135 --- /dev/null +++ b/src/komposegldesktopwidget.cpp @@ -0,0 +1,116 @@ +// +// C++ Implementation: komposegldesktopwidget +// +// Description: +// +// +// Author: Hans Oischinger , (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include "komposegldesktopwidget.h" + +#include "komposetask.h" +#include "komposegltaskwidget.h" +#include "komposetaskmanager.h" + +#include +#include +#include + +#include + +KomposeGLDesktopWidget::KomposeGLDesktopWidget(int desktop, QObject *parent, const char *name) + : KomposeGLWidget( parent ), + deskNum( desktop ) +{ + // Retrieve geometry + QDesktopWidget *deskwidget = new QDesktopWidget(); + deskRect = deskwidget->availableGeometry(); + delete deskwidget; + + createTaskWidgets(); + + //connect( KomposeTaskManager::instance(), SIGNAL( newTask( KomposeTask* ) ), this, SLOT( createTaskWidget( KomposeTask* ) ) ); +} + + +KomposeGLDesktopWidget::~KomposeGLDesktopWidget() +{} + +void KomposeGLDesktopWidget::createTaskWidgets() +{ + TaskList tl = KomposeTaskManager::instance()->getTasks(); + qDebug("KomposeGLDesktopWidget::createTaskWidgets() on %d tasks", tl.count()); + QPtrListIterator it( tl ); + KomposeTask *task; + while ( (task = it.current()) != 0 ) + { + ++it; + Q_CHECK_PTR(task); + createTaskWidget( task ); + } +} + + +void KomposeGLDesktopWidget::createTaskWidget( KomposeTask* task ) +{ + if (deskNum == task->onDesktop()-1 ) + { + qDebug("KomposeGLDesktopWidget::createTaskWidget()" ); + KomposeGLTaskWidget *taskwidget = new KomposeGLTaskWidget( task, this, 0, "" ); + } +} + +int KomposeGLDesktopWidget::getHeightForWidth( int w ) const +{ + qDebug("KomposeGLDesktopWidget::getHeightForWidth()"); + return ((double)w / (double)deskRect.width()) * deskRect.height(); +} + +int KomposeGLDesktopWidget::getWidthForHeight( int h ) const +{ + qDebug("KomposeGLDesktopWidget::getWidthForHeight()"); + return ((double)h / (double)deskRect.height()) * deskRect.width(); +} + +double KomposeGLDesktopWidget::getAspectRatio() +{ + qDebug("KomposeGLDesktopWidget::getAspectRatio()"); + return (double)deskRect.width() / (double)deskRect.height(); +} + + +void KomposeGLDesktopWidget::draw() +{ + KomposeGLWidget::draw(); + qDebug("KomposeGLDesktopWidget::draw() - %d,%d %dx%d", getRect().x(), getRect().y(), getRect().width(), getRect().height()); + glColor3f(0.0f, 0.0f, 1.0f); + + glBegin( GL_QUADS ); + glVertex2i( getRect().x() + getRect().width(), getRect().y() ); + glVertex2i( getRect().x(), getRect().y() ); + glVertex2i( getRect().x(), getRect().y() + getRect().height() ); + glVertex2i( getRect().x() + getRect().width(), getRect().y() + getRect().height() ); + glEnd(); + + // Draw Task Widgets + QPtrListIterator it( list ); + + // Check or empty list + if (it.count() == 0) + { + qDebug("KomposeGLDesktopWidget::draw() - empty list... skipping!"); + return; + } + + KomposeGLWidget *widget; + while ( (widget = (KomposeGLWidget*)it.current()) != 0 ) + { + ++it; + widget->draw(); + } +} + +#include "komposegldesktopwidget.moc" -- cgit v1.2.1