diff options
author | Ken Moore <ken@ixsystems.com> | 2017-09-26 14:04:24 -0400 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2017-09-26 14:04:24 -0400 |
commit | a8ab0934e4782a14206cba544c846a34947cce36 (patch) | |
tree | f032428eca9b7938b43b6f06f67da554d0faf2b0 /src-qt5 | |
parent | Fix up the close event handling in lumina-textedit. Now it will actually clos... (diff) | |
parent | Merge branch 'master' of github.com:trueos/lumina (diff) | |
download | lumina-a8ab0934e4782a14206cba544c846a34947cce36.tar.gz lumina-a8ab0934e4782a14206cba544c846a34947cce36.tar.bz2 lumina-a8ab0934e4782a14206cba544c846a34947cce36.zip |
Merge branch 'master' of github.com:trueos/lumina
Diffstat (limited to 'src-qt5')
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/widgets/fmwebdav.cpp | 36 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/widgets/fmwebdav.h | 36 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp | 33 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/widgets/vidnail.h | 25 | ||||
-rw-r--r-- | src-qt5/src-glwidgets/gltest/colorchange.h | 35 | ||||
-rw-r--r-- | src-qt5/src-glwidgets/gltest/main.cpp | 26 | ||||
-rwxr-xr-x | src-qt5/src-glwidgets/gltest/test | bin | 0 -> 50927 bytes | |||
-rw-r--r-- | src-qt5/src-glwidgets/gltest/test.pro | 9 | ||||
-rw-r--r-- | src-qt5/src-glwidgets/glw-base.cpp | 63 | ||||
-rw-r--r-- | src-qt5/src-glwidgets/glw-base.h | 43 | ||||
-rw-r--r-- | src-qt5/src-glwidgets/glw-widget.cpp | 76 | ||||
-rw-r--r-- | src-qt5/src-glwidgets/glw-widget.h | 50 | ||||
-rw-r--r-- | src-qt5/src-glwidgets/glwidgets.pri | 7 |
13 files changed, 439 insertions, 0 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/fmwebdav.cpp b/src-qt5/desktop-utils/lumina-fm/widgets/fmwebdav.cpp new file mode 100644 index 00000000..6e65ebaf --- /dev/null +++ b/src-qt5/desktop-utils/lumina-fm/widgets/fmwebdav.cpp @@ -0,0 +1,36 @@ +#include "fmwebdav.h" + +fmwebdav::fmwebdav(QObject *parent) : QNetworkAccessManager(parent) ,wdRootPath(), wdUsername(), wdUassword(), wdBaseUrl(), wdCurrentConnectionType(QWebdav::HTTP){ +// typical Qnetwork connection stuff goes here +// probably ssl parts too +} + +fmwebdav::~fmwebdav(){ +} + +QString fmwebdav::hostname() const{ return wdBaseUrl.host(); } + +int fmwebdav::port() const{ return wdBaseUrl.port(); } + +QString fmwebdav::rootPath() const{ return wdRootPath;} + +QString fmwebdav::username() const{ return wdUsername; } + +QString fmwebdav::password() const{ return wdPassword; } + +fmwebdav::QWebdavConnectionType : fmwebdav::connectionType() const{ return wdCurrentConnectionType; } + +bool fmwebdav::isSSL() const{ return (wdCurrentConnectionType==QWebdav::HTTPS); } + +void QWebdav::setConnectionSettings(const QWebdavConnectionType connectionType, const QString *hostname, const QString *rootPath, const QString *username, const QString *password, int *port){ + wdRootPath = rootPath; + if ((wdRootPath.endsWith("/")){ wdRootPath.chop(1); } + wdCurrentConnectionType = connectionType; + wdBaseUrl.setScheme(); + wdBaseUrl.setHost(hostname); + wdBaseUrl.setPath(rootPath); + if (port != 0) { // use user-defined port number if not 80 or 443 + if ( ! ( ( (port == 80) && (wdCurrentConnectionType==QWebdav::HTTP) ) || ( (port == 443) && (wdCurrentConnectionType==QWebdav::HTTPS) ) ) ){ wdBaseUrl.setPort(port); } + wdUsername = username; + wdPassword = password; +} diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/fmwebdav.h b/src-qt5/desktop-utils/lumina-fm/widgets/fmwebdav.h new file mode 100644 index 00000000..04d29e3b --- /dev/null +++ b/src-qt5/desktop-utils/lumina-fm/widgets/fmwebdav.h @@ -0,0 +1,36 @@ +#ifndef FMWEBDAV_H +#define FMWEBDAV_H + +#include <QtCore> +#include <QtNetwork> +#include <QNetworkAccessManager> + +public: + + enum QWebdavConnectionType {HTTP = 1, HTTPS}; + + QString hostname() const; + int port() const; + QString rootPath() const; + QString username() const; + QString password() const; + QWebdavConnectionType connectionType() const; + bool isSSL() const; + + void setConnectionSettings( const QWebdavConnectionType connectionType, const QString *hostname, const QString *rootPath = "/", const QString *username = "", const QString *password = "", int *port = 0; + + +private: + + QString wdRootPath; + QString wdUsername; + QString wdPassword; + QUrl wdBaseUrl; + QWebdavConnectionType wdCurrentConnectionType; + + + + + + +#endif // FMWEBDAV diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp b/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp new file mode 100644 index 00000000..ee7fb9e3 --- /dev/null +++ b/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp @@ -0,0 +1,33 @@ +#include "vidnail.h" +vidnail::vidnail(QWidget *parent) : QMainWindow(parent), mplayer(parent, QMediaPlayer::VideoSurface){ //there is no UI, so not sure how to alter the constructor +} + +vidnail::~vidnail() +{ + +vidnail::grabvideothumbnail(){ + vsurface = new QAbstractVideoSurface(); + mplayer.setVideoOutput(vsurface); + mplayer.setMedia($file); // video file to get thumbnail of + imageCaptured = QPixmap(); + mplayer.setPosition(2000); // time in milliseconds + mplayer.setMuted(true); // just to make sure no sound is emited + mplayer.play(); + + currentFrame = frame; + const QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat()); + const QSize size = format.frameSize(); + + this->imageFormat = imageFormat; + QAbstractVideoSurface::start(format); + QImage image( currentFrame.bits(), currentFrame.width(), currentFrame.height(), currentFrame.bytesPerLine(), imageFormat); + imageCaptured = QPixmap::fromImage(image.copy(image.rect())); + +// Now do scaling with regular thumbnail process to make proper size + + mplayer.stop(); + vsurface.stop(); +} + + + diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.h b/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.h new file mode 100644 index 00000000..ad565749 --- /dev/null +++ b/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.h @@ -0,0 +1,25 @@ +#ifndef VIDNAIL_H +#define VIDNAIL_H + +#include <QMediaPlayer> +#include <QtMultimediaWidgets> +#include "videowidgetsurface.h" +#include <QPixmap> +#include <QAbstractVideoSurface> +#include <QImage> +#include <QRect> +#include <QVideoFrame> + +public: + + void grabvideothumbnail(); + +private: + + QAbstractVideoSurface *vsurface; + QImage::Format imageFormat; + QPixmap imageCaptured; + + +#endif // VIDNAIL_H + diff --git a/src-qt5/src-glwidgets/gltest/colorchange.h b/src-qt5/src-glwidgets/gltest/colorchange.h new file mode 100644 index 00000000..d62fcd5c --- /dev/null +++ b/src-qt5/src-glwidgets/gltest/colorchange.h @@ -0,0 +1,35 @@ +#include <QDebug> +#include <QApplication> +#include <QTimer> +#include <QColor> + +#include "../glw-base.h" + +class colorchange : public QObject{ + Q_OBJECT +private: + GLW_Base *base; + QTimer *timer; + +public slots: + void toggle(){ + static int current = 0; + if(current==0){ + base->setBackgroundColor(QColor(Qt::red)); + }else{ + base->setBackgroundColor(QColor(Qt::blue)); + current = -1; + } + current++; + } + +public: + colorchange(GLW_Base *parent) : QObject(){ + base = parent; + timer = new QTimer(this); + timer->setInterval(5000); + connect(timer, SIGNAL(timeout()), this, SLOT(toggle()) ); + timer->start(); + } + +}; diff --git a/src-qt5/src-glwidgets/gltest/main.cpp b/src-qt5/src-glwidgets/gltest/main.cpp new file mode 100644 index 00000000..041ee5ff --- /dev/null +++ b/src-qt5/src-glwidgets/gltest/main.cpp @@ -0,0 +1,26 @@ +#include <QDebug> +#include <QApplication> +#include <QTimer> +#include <QColor> + +#include "../glw-base.h" +#include "../glw-widget.h" + +#include "colorchange.h" + +int main(int argc, char** argv){ + QApplication A(argc,argv); + qDebug() << "Creating base widget"; + GLW_Base base; + qDebug() << "Resize base widget"; + base.resize(200,200); + qDebug() << "Create colorchange"; + GLW_Widget wgt(&base); + wgt.setGLBase(&base); + wgt.setGeometry(50,50,50,50); + colorchange CC(&base); + qDebug() << "Start Event loop"; + base.show(); + A.exec(); + qDebug() << " - Finished"; +} diff --git a/src-qt5/src-glwidgets/gltest/test b/src-qt5/src-glwidgets/gltest/test Binary files differnew file mode 100755 index 00000000..5a69b0c3 --- /dev/null +++ b/src-qt5/src-glwidgets/gltest/test diff --git a/src-qt5/src-glwidgets/gltest/test.pro b/src-qt5/src-glwidgets/gltest/test.pro new file mode 100644 index 00000000..cba315c3 --- /dev/null +++ b/src-qt5/src-glwidgets/gltest/test.pro @@ -0,0 +1,9 @@ +QT = core gui widgets + +TARGET = test + +SOURCES += main.cpp + +HEADERS += colorchange.h + +include(../glwidgets.pri); diff --git a/src-qt5/src-glwidgets/glw-base.cpp b/src-qt5/src-glwidgets/glw-base.cpp new file mode 100644 index 00000000..e828df7f --- /dev/null +++ b/src-qt5/src-glwidgets/glw-base.cpp @@ -0,0 +1,63 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2017, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "glw-base.h" +#include "glw-widget.h" + +GLW_Base::GLW_Base(QWidget *parent, Qt::WindowFlags f) : QOpenGLWidget(parent,f){ + bg_color = QColor(Qt::black); +} + +GLW_Base::~GLW_Base(){ + +} + +// --- PUBLIC SLOTS --- +void GLW_Base::setBackgroundColor(QColor color){ + bg_color = color; + this->update(); //repaint the entire widget (just in case you can see through the image) + +} + +void GLW_Base::setBackground(QRect geom, QImage img){ + QPainter P(&bg_img); + P.drawImage(geom, img); + this->update(); +} + +void GLW_Base::repaintArea(QRect rect){ + paintEvent(new QPaintEvent(rect)); +} + +// --- PROTECTED --- +void GLW_Base::resizeEvent(QResizeEvent *ev){ + QOpenGLWidget::resizeEvent(ev); + if(!bg_img.isNull()){ + bg_img = bg_img.scaled(ev->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + } + emit BaseResized(); +} + +void GLW_Base::paintEvent(QPaintEvent *ev){ + QStylePainter painter(this); + painter.setClipRegion(ev->rect()); + //Fill in the background color first + painter.fillRect(ev->rect(), bg_color); + //Now paint any background image over that + painter.drawImage(ev->rect(), bg_img, ev->rect(), Qt::AutoColor | Qt::PreferDither | Qt::NoOpaqueDetection); + //Now find any children widgets and paint them if they are in that area + QObjectList child = this->children(); //Note: This is returned in stacking order (lowest -> highest) + for(int i=0; i<child.length(); i++){ + if( !child[i]->isWidgetType() ){ continue; } //not a widget + GLW_Widget *glww = qobject_cast<GLW_Widget*>(child[i]); + if(glww!=0){ + if(ev->rect().contains(glww->widgetRect())){ + glww->paintYourself(&painter, ev); + glww->paintChildren(&painter,ev); + } + } + } +} diff --git a/src-qt5/src-glwidgets/glw-base.h b/src-qt5/src-glwidgets/glw-base.h new file mode 100644 index 00000000..729aa68e --- /dev/null +++ b/src-qt5/src-glwidgets/glw-base.h @@ -0,0 +1,43 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2017, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#ifndef _LUMINA_OPENGL_WIDGETS_BASE_H +#define _LUMINA_OPENGL_WIDGETS_BASE_H + +#include <QOpenGLWidget> +#include <QImage> +#include <QPaintEvent> +#include <QPainter> +#include <QResizeEvent> +#include <QStylePainter> + +class GLW_Base : public QOpenGLWidget{ + Q_OBJECT +private: + QColor bg_color; + QImage bg_img; + +public: + GLW_Base(QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()); + ~GLW_Base(); + + +private slots: + +public slots: + void setBackgroundColor(QColor color); + void setBackground(QRect geom, QImage img); + void repaintArea(QRect); + +signals: + void BaseResized(); + +protected: + void resizeEvent(QResizeEvent *ev); + void paintEvent(QPaintEvent *ev); +}; + +#endif diff --git a/src-qt5/src-glwidgets/glw-widget.cpp b/src-qt5/src-glwidgets/glw-widget.cpp new file mode 100644 index 00000000..e24d8166 --- /dev/null +++ b/src-qt5/src-glwidgets/glw-widget.cpp @@ -0,0 +1,76 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2017, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "glw-widget.h" +#include <QDebug> + +// --- PUBLIC --- +GLW_Widget::GLW_Widget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f){ + glw_base = 0; + this->setMouseTracking(true); +} + +GLW_Widget::~GLW_Widget(){ + +} + +QRect GLW_Widget::widgetRect(){ + QPoint pos = this->mapTo(glw_base, QPoint(0,0)); + return QRect(pos, this->size()); +} + +bool GLW_Widget::mouseOverWidget(){ + QPoint pos = this->mapFromGlobal(QCursor::pos()); + QRect geom(QPoint(0,0), this->size()); + return geom.contains(pos); + +} + +void GLW_Widget::setGLBase(GLW_Base *base){ + if(glw_base!=0){ this->disconnect(glw_base, SLOT(repaintArea(QRect))); } + glw_base=base; + connect(this, SIGNAL(repaintArea(QRect)), glw_base, SLOT(repaintArea(QRect)) ); +} + +void GLW_Widget::paintYourself(QStylePainter *painter, QPaintEvent *ev){ + QRect rect = widgetRect(); + rect = rect.intersected(ev->rect()); + QColor color( mouseOverWidget() ? Qt::gray : Qt::yellow); + color.setAlpha(125); + painter->fillRect(rect, color); +} + +void GLW_Widget::paintChildren(QStylePainter *painter, QPaintEvent *ev){ + QObjectList child = this->children(); //Note: This is returned in stacking order (lowest -> highest) + for(int i=0; i<child.length(); i++){ + if( !child[i]->isWidgetType() ){ continue; } //not a widget + GLW_Widget *glww = qobject_cast<GLW_Widget*>(child[i]); + if(glww!=0){ + if(ev->rect().contains(glww->widgetRect())){ + glww->paintYourself(painter, ev); + glww->paintChildren(painter,ev); + } + } + } +} + + +// --- PROTECTED --- +void GLW_Widget::resizeEvent(QResizeEvent *ev){ + if(glw_base==0){ return; } + QPoint pos = this->mapTo(glw_base, QPoint(0,0)); + QSize sz = ev->oldSize(); + if(ev->size().width() > sz.width()){ sz.setWidth(ev->size().width()); } + if(ev->size().height() > sz.height()){ sz.setHeight(ev->size().height()); } + emit repaintArea(QRect(pos, sz)); +} + +void GLW_Widget::paintEvent(QPaintEvent *ev){ + //qDebug() << "Got paint event:" << ev->rect(); + QPoint pos = this->mapTo(glw_base, ev->rect().topLeft()); + emit repaintArea(QRect(pos, ev->rect().size()) ); + return; +} diff --git a/src-qt5/src-glwidgets/glw-widget.h b/src-qt5/src-glwidgets/glw-widget.h new file mode 100644 index 00000000..1d6caa77 --- /dev/null +++ b/src-qt5/src-glwidgets/glw-widget.h @@ -0,0 +1,50 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2017, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#ifndef _LUMINA_OPENGL_WIDGETS_WIDGET_H +#define _LUMINA_OPENGL_WIDGETS_WIDGET_H + +#include <QWidget> +#include <QPaintEvent> +#include <QStylePainter> +#include <QResizeEvent> +#include <QStylePainter> + +#include "glw-base.h" + +class GLW_Widget : public QWidget{ + Q_OBJECT +private: + GLW_Base *glw_base; + +public: + GLW_Widget(QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()); + ~GLW_Widget(); + + QRect widgetRect(); //converts to the coordinate scheme of the base widget + bool mouseOverWidget(); + + void setGLBase(GLW_Base *base); + + virtual void paintYourself(QStylePainter *painter, QPaintEvent *ev); + void paintChildren(QStylePainter *painter, QPaintEvent *ev); + +private slots: + +public slots: + +protected: + void enterEvent(QEvent*){ this->update(); } + void leaveEvent(QEvent*){ this->update(); } + void resizeEvent(QResizeEvent *ev); + void paintEvent(QPaintEvent *ev); + +signals: + void repaintArea(QRect); +}; + +Q_DECLARE_INTERFACE(GLW_Widget, "GLW_Widget"); +#endif diff --git a/src-qt5/src-glwidgets/glwidgets.pri b/src-qt5/src-glwidgets/glwidgets.pri new file mode 100644 index 00000000..e391aef0 --- /dev/null +++ b/src-qt5/src-glwidgets/glwidgets.pri @@ -0,0 +1,7 @@ +QT *= widgets + +SOURCES *= $${PWD}/glw-base.cpp \ + $${PWD}/glw-widget.cpp + +HEADERS *= $${PWD}/glw-base.h \ + $${PWD}/glw-widget.h |