diff options
Diffstat (limited to 'src-qt5/desktop-utils/lumina-fm/widgets')
8 files changed, 229 insertions, 35 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h b/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h index 254362fd..7e4b1f22 100644 --- a/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h +++ b/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h @@ -23,6 +23,7 @@ #include <QMouseEvent> #include <QUrl> #include <QDir> +#include <QApplication> #include <LUtils.h> @@ -63,8 +64,8 @@ protected: QList<QListWidgetItem*> items = this->selectedItems(); if(items.length()<1){ return; } QList<QUrl> urilist; - for(int i=0; i<items.length(); i++){ - urilist << QUrl::fromLocalFile(items[i]->whatsThis()); + for(int i=0; i<items.length(); i++){ + urilist << QUrl::fromLocalFile(items[i]->whatsThis()); } //Create the mime data //qDebug() << "Start Drag:" << urilist; @@ -88,7 +89,7 @@ protected: ev->ignore(); } } - + void dragMoveEvent(QDragMoveEvent *ev){ if(ev->mimeData()->hasUrls() && !this->whatsThis().isEmpty() ){ //Change the drop type depending on the data/dir @@ -104,7 +105,7 @@ protected: } this->update(); } - + void dropEvent(QDropEvent *ev){ if(this->whatsThis().isEmpty() || !ev->mimeData()->hasUrls() ){ ev->ignore(); return; } //not supported //qDebug() << "Drop Event:"; @@ -125,7 +126,7 @@ protected: foreach(const QUrl &url, ev->mimeData()->urls()){ const QString filepath = url.toLocalFile(); //If the target file is modifiable, assume a move - otherwise copy - if(QFileInfo(filepath).isWritable() && (filepath.startsWith(home) && dirpath.startsWith(home))){ + if(QFileInfo(filepath).isWritable() && (filepath.startsWith(home) && dirpath.startsWith(home))){ if(filepath.section("/",0,-2)!=dirpath){ files << "cut::::"+filepath; } //don't "cut" a file into the same dir }else{ files << "copy::::"+filepath; } } @@ -133,18 +134,18 @@ protected: if(!files.isEmpty()){ emit DataDropped( dirpath, files ); } this->setCursor(Qt::ArrowCursor); } - + void mouseReleaseEvent(QMouseEvent *ev){ if(ev->button() != Qt::RightButton && ev->button() != Qt::LeftButton){ ev->ignore(); } else{ QListWidget::mouseReleaseEvent(ev); } //pass it along to the widget } void mousePressEvent(QMouseEvent *ev){ if(ev->button() != Qt::RightButton && ev->button() != Qt::LeftButton){ ev->ignore(); } - else{ QListWidget::mousePressEvent(ev); } //pass it along to the widget + else{ QListWidget::mousePressEvent(ev); } //pass it along to the widget } /*void mouseMoveEvent(QMouseEvent *ev){ if(ev->button() != Qt::RightButton && ev->button() != Qt::LeftButton){ ev->ignore(); } - else{ QListWidget::mouseMoveEvent(ev); } //pass it along to the widget + else{ QListWidget::mouseMoveEvent(ev); } //pass it along to the widget }*/ }; @@ -158,6 +159,8 @@ public: //Drag and Drop Properties this->setDragDropMode(QAbstractItemView::DragDrop); this->setDefaultDropAction(Qt::MoveAction); //prevent any built-in Qt actions - the class handles it + this->setDropIndicatorShown(true); + this->setAcceptDrops(true); //Other custom properties necessary for the FM this->setFocusPolicy(Qt::StrongFocus); this->setContextMenuPolicy(Qt::CustomContextMenu); @@ -183,8 +186,8 @@ protected: QList<QTreeWidgetItem*> items = this->selectedItems(); if(items.length()<1){ return; } QList<QUrl> urilist; - for(int i=0; i<items.length(); i++){ - urilist << QUrl::fromLocalFile(items[i]->whatsThis(0)); + for(int i=0; i<items.length(); i++){ + urilist << QUrl::fromLocalFile(items[i]->whatsThis(0)); } //Create the mime data QMimeData *mime = new QMimeData; @@ -192,35 +195,43 @@ protected: //Create the drag structure QDrag *drag = new QDrag(this); drag->setMimeData(mime); - /*if(info.first().section("::::",0,0)=="cut"){ - drag->exec(act | Qt::MoveAction); - }else{*/ + //qDebug() << "Start Drag:" << urilist; drag->exec(act | Qt::CopyAction| Qt::MoveAction); - //} + //qDebug() << " - Drag Finished"; } void dragEnterEvent(QDragEnterEvent *ev){ - //qDebug() << "Drag Enter Event:" << ev->mimeData()->hasFormat(MIME); + //qDebug() << "Drag Enter Event:" << ev->mimeData()->hasUrls() << this->whatsThis(); + //QTreeWidget::dragEnterEvent(ev); if(ev->mimeData()->hasUrls() && !this->whatsThis().isEmpty() ){ ev->acceptProposedAction(); //allow this to be dropped here }else{ ev->ignore(); - } + } } - + void dragMoveEvent(QDragMoveEvent *ev){ + //qDebug() << "Drag Move Event:" << ev->mimeData()->hasUrls() << this->whatsThis(); + //QTreeWidget::dragMoveEvent(ev); if(ev->mimeData()->hasUrls() && !this->whatsThis().isEmpty() ){ //Change the drop type depending on the data/dir QString home = QDir::homePath(); - if( this->whatsThis().startsWith(home) ){ ev->setDropAction(Qt::MoveAction); } - else{ ev->setDropAction(Qt::CopyAction); } - ev->accept(); //allow this to be dropped here + if( this->whatsThis().startsWith(home) ){ ev->setDropAction(Qt::MoveAction); this->setCursor(Qt::DragMoveCursor); } + else{ ev->setDropAction(Qt::CopyAction); this->setCursor(Qt::DragCopyCursor);} + ev->acceptProposedAction(); //allow this to be dropped here + //this->setAcceptDrops(true); }else{ + //this->setAcceptDrops(false); + this->setCursor(Qt::ForbiddenCursor); ev->ignore(); } + //this->setDropIndicatorShown(true); + //this->update(); + //QTreeWidget::dragMoveEvent(ev); } - + void dropEvent(QDropEvent *ev){ + //qDebug() << "Drop Event:" << ev->mimeData()->hasUrls() << this->whatsThis(); if(this->whatsThis().isEmpty() || !ev->mimeData()->hasUrls() ){ ev->ignore(); return; } //not supported ev->accept(); //handled here QString dirpath = this->whatsThis(); @@ -239,25 +250,25 @@ protected: foreach(const QUrl &url, ev->mimeData()->urls()){ const QString filepath = url.toLocalFile(); //If the target file is modifiable, assume a move - otherwise copy - if(QFileInfo(filepath).isWritable() && (filepath.startsWith(home) && dirpath.startsWith(home))){ + if(QFileInfo(filepath).isWritable() && (filepath.startsWith(home) && dirpath.startsWith(home))){ if(filepath.section("/",0,-2)!=dirpath){ files << "cut::::"+filepath; } //don't "cut" a file into the same dir }else{ files << "copy::::"+filepath; } } //qDebug() << "Drop Event:" << dirpath; emit DataDropped( dirpath, files ); } - + void mouseReleaseEvent(QMouseEvent *ev){ if(ev->button() != Qt::RightButton && ev->button() != Qt::LeftButton){ ev->ignore(); } else{ QTreeWidget::mouseReleaseEvent(ev); } //pass it along to the widget } void mousePressEvent(QMouseEvent *ev){ if(ev->button() != Qt::RightButton && ev->button() != Qt::LeftButton){ ev->ignore(); } - else{ QTreeWidget::mousePressEvent(ev); } //pass it along to the widget + else{ QTreeWidget::mousePressEvent(ev); } //pass it along to the widget } /*void mouseMoveEvent(QMouseEvent *ev){ if(ev->button() != Qt::RightButton && ev->button() != Qt::LeftButton){ ev->ignore(); } - else{ QTreeWidget::mouseMoveEvent(ev); } //pass it along to the widget + else{ QTreeWidget::mouseMoveEvent(ev); } //pass it along to the widget }*/ }; diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp index 8273d09c..5c6f9ef5 100644 --- a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp +++ b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp @@ -27,9 +27,12 @@ #include "../ScrollDialog.h" #define DEBUG 0 +extern bool rootmode; DirWidget::DirWidget(QString objID, QSettings *settings, QWidget *parent) : QWidget(parent), ui(new Ui::DirWidget){ ui->setupUi(this); //load the designer file + ui->label_rootmode->setVisible(rootmode); + ID = objID; //Assemble the toolbar for the widget toolbar = new QToolBar(this); @@ -59,7 +62,7 @@ DirWidget::DirWidget(QString objID, QSettings *settings, QWidget *parent) : QWid RCBW = 0; //right column browser is unavailable initially BW = new BrowserWidget("", this); ui->browser_layout->addWidget(BW); - connect(BW, SIGNAL(dirChange(QString)), this, SLOT(currentDirectoryChanged()) ); + connect(BW, SIGNAL(dirChange(QString, bool)), this, SLOT(currentDirectoryChanged()) ); connect(BW, SIGNAL(itemsActivated()), this, SLOT(runFiles()) ); connect(BW, SIGNAL(DataDropped(QString, QStringList)), this, SIGNAL(PasteFiles(QString, QStringList)) ); connect(BW, SIGNAL(contextMenuRequested()), this, SLOT(OpenContextMenu()) ); @@ -281,10 +284,11 @@ void DirWidget::createMenus(){ else{ cOpenMenu->clear(); } cOpenMenu->setTitle(tr("Launch...")); cOpenMenu->setIcon( LXDG::findIcon("quickopen","") ); - cOpenMenu->addAction(LXDG::findIcon("utilities-terminal",""), tr("Terminal"), this, SLOT(openTerminal()), kOpTerm->key()); + cOpenMenu->addAction(LXDG::findIcon("utilities-terminal",""), tr("Open Current Dir in a Terminal"), this, SLOT(openTerminal()), kOpTerm->key()); cOpenMenu->addAction(LXDG::findIcon("media-slideshow",""), tr("SlideShow"), this, SLOT(openInSlideshow()), kOpSS->key()); cOpenMenu->addAction(LXDG::findIcon("media-playback-start-circled","media-playback-start"), tr("Multimedia Player"), this, SLOT(openMultimedia()), kOpMM->key()); -/* + if(LUtils::isValidBinary("qsudo")){ cOpenMenu->addAction(LXDG::findIcon("", ""), tr("Open Current Dir as Root"), this, SLOT(openRootFM())); + /* if(cFModMenu==0){ cFModMenu = new QMenu(this); } else{ cFModMenu->clear(); } cFModMenu->setTitle(tr("Modify Files...")); @@ -319,6 +323,8 @@ void DirWidget::createMenus(){ } +} + BrowserWidget* DirWidget::currentBrowser(){ if(cBID.isEmpty() || RCBW==0){ return BW; } else{ return RCBW; } @@ -471,7 +477,7 @@ void DirWidget::on_actionDualColumn_triggered(bool checked){ if(RCBW!=0){ return; } //nothing to do RCBW = new BrowserWidget("rc", this); ui->browser_layout->addWidget(RCBW); - connect(RCBW, SIGNAL(dirChange(QString)), this, SLOT(currentDirectoryChanged()) ); + connect(RCBW, SIGNAL(dirChange(QString, bool)), this, SLOT(currentDirectoryChanged()) ); connect(RCBW, SIGNAL(itemsActivated()), this, SLOT(runFiles()) ); connect(RCBW, SIGNAL(DataDropped(QString, QStringList)), this, SIGNAL(PasteFiles(QString, QStringList)) ); connect(RCBW, SIGNAL(contextMenuRequested()), this, SLOT(OpenContextMenu()) ); @@ -482,6 +488,7 @@ void DirWidget::on_actionDualColumn_triggered(bool checked){ RCBW->showDetails(BW->hasDetails()); RCBW->showHiddenFiles( BW->hasHiddenFiles()); RCBW->setThumbnailSize( BW->thumbnailSize()); + RCBW->showThumbnails( BW->hasThumbnails()); RCBW->changeDirectory( BW->currentDirectory()); } @@ -880,3 +887,9 @@ void DirWidget::mouseReleaseEvent(QMouseEvent *ev){ ev->ignore(); //not handled here } } + +void DirWidget::openRootFM(){ + rootfmdir = "qsudo lumina-fm -new-instance " + currentDir(); + qDebug() << "rootfmdir" << rootfmdir; + ExternalProcess::launch(rootfmdir); +} diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h index 8dd367df..4377f92d 100644 --- a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h +++ b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h @@ -73,9 +73,9 @@ private: Ui::DirWidget *ui; BrowserWidget *BW, *RCBW; //Main BrowserWidget and right-column browser widget QString ID, cBID; //unique ID assigned by the parent, and currently active browser widget - QString normalbasedir, snapbasedir, snaprelpath; //for maintaining directory context while moving between snapshots + QString normalbasedir, snapbasedir, snaprelpath, rootfmdir; //for maintaining directory context while moving between snapshots QStringList snapshots, needThumbs, tmpSel; - QSettings *settings; + QSettings *settings; bool canmodify; //The Toolbar and associated items @@ -83,10 +83,10 @@ private: QLineEdit *line_dir; //The context menu and associated items - QMenu *contextMenu, *cNewMenu, *cOpenMenu, *cFModMenu, *cFViewMenu, *cOpenWithMenu; + QMenu *contextMenu, *cNewMenu, *cOpenMenu, *cFModMenu, *cFViewMenu, *cOpenWithMenu; //The keyboard shortcuts for context menu items - QShortcut *kZoomIn, *kZoomOut, *kNewFile, *kNewDir, *kNewXDG, *kCut, *kCopy, *kPaste, *kRename, \ + QShortcut *kZoomIn, *kZoomOut, *kNewFile, *kNewDir, *kNewXDG, *kCut, *kCopy, *kPaste, *kRename, \ *kFav, *kDel, *kOpSS, *kOpMM, *kOpTerm, *kExtract; //, *kArchive; //Functions for internal use @@ -129,6 +129,7 @@ private slots: void fileCheckSums(); void fileProperties(); void openTerminal(); + void openRootFM(); //Browser Functions diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.ui b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.ui index b1ba9d95..5f980c67 100644 --- a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.ui +++ b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>400</width> - <height>350</height> + <height>389</height> </rect> </property> <property name="minimumSize"> @@ -19,7 +19,32 @@ <property name="windowTitle"> <string>Form</string> </property> - <layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,1,0"> + <layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,1,0"> + <item> + <widget class="QLabel" name="label_rootmode"> + <property name="font"> + <font> + <family>Droid Sans Mono</family> + <pointsize>16</pointsize> + <weight>75</weight> + <italic>false</italic> + <bold>true</bold> + </font> + </property> + <property name="frameShape"> + <enum>QFrame::Box</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Sunken</enum> + </property> + <property name="text"> + <string> * - FILE MANAGER RUNNING AS ROOT- * </string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> <item> <layout class="QHBoxLayout" name="toolbar_layout"/> </item> 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..d0ecdecf --- /dev/null +++ b/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.cpp @@ -0,0 +1,59 @@ +#ifndef VIDNAIL_H +#define VIDNAIL_H + +extern "C" { +#include <libavcodec/avcodec.h> +#include <libavformat/avformat.h> +} + +class VidNail; + +struct vFrame { + vFrame() : *width(0), *height(0) {} + vFrame(int *width, int *height : width(width), height(height) {} + int *width; + int *height; +}; + +public: + + QString getCodec(); + void skipTo(int timeInSeconds); + void readVideoFrame(); + void getScaledVideoFrame(int scaledSize, vFrame& vFrame); + + int getWidth(); + int getHeight(); + int getLength(); + + void makeThumbnail(const QString& videoFile, QImage &image); + void setThumbnailSize(int size); + void setPercentage(int percent); + void setTime(const QString& Time); + + void writeVidNail(vFrame& frame, QImage& image); + + + private: + bool readVideoPacket(); + bool getVideoPacket(); + void scaleVideo(int scaledSize, int& scaledWidth, int& scaledHeight); + void createVFrame(AVFrame *vFrame, quint8 *frameBuffer, int width, int height); + void calculateDimensions(int size); + void generateThumbnail(const QString& videoFile, ImageWriter& imageWriter, QImage& image); + QString getMimeType(const QString& videoFile); + QString getExtension(const QString& videoFilename); + + + private: + int videoStream; + AVFormatContext *inputVideoFormatContext; + AVCodecContext *inputvideoCodecContext; + AVCodec *inputVideoCodec; + AVStream *inputVideoStream; + AVFrame *inputVideoFrame; + quint8 *inputFrameBuffer; + AVPacket *videoPacket; + + +#endif // VIDNAIL_H 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..e13894e1 --- /dev/null +++ b/src-qt5/desktop-utils/lumina-fm/widgets/vidnail.h @@ -0,0 +1,13 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2017, q5sys +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "vidnail.h" + +VidNail::VidNail(QObject *parent) : QObject(parent){ +} + +VidNail::~VidNail(){ +} |