diff options
Diffstat (limited to 'src-qt5/desktop-utils')
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/Browser.cpp | 35 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/Browser.h | 5 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp | 16 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h | 24 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.ui | 62 |
5 files changed, 80 insertions, 62 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.cpp b/src-qt5/desktop-utils/lumina-fm/Browser.cpp index b7eb9709..010196a4 100644 --- a/src-qt5/desktop-utils/lumina-fm/Browser.cpp +++ b/src-qt5/desktop-utils/lumina-fm/Browser.cpp @@ -20,7 +20,7 @@ Browser::Browser(QObject *parent) : QObject(parent){ showHidden = false; showThumbs = false; imageFormats = LUtils::imageExtensions(false); //lowercase suffixes - connect(this, SIGNAL(threadDone(QString, QByteArray)), this, SLOT(futureFinished(QString, QByteArray))); //will always be between different threads + connect(this, SIGNAL(threadDone(QString, QImage)), this, SLOT(futureFinished(QString, QImage))); //will always be between different threads } Browser::~Browser(){ @@ -53,20 +53,25 @@ bool Browser::showingThumbnails(){ // PRIVATE void Browser::loadItem(QString info, Browser *obj){ //qDebug() << "LoadItem:" << info; - QByteArray bytes; + QImage pix; if(imageFormats.contains(info.section(".",-1).toLower()) ){ QFile file(info); if(file.open(QIODevice::ReadOnly)){ - bytes = file.readAll(); + QByteArray bytes = file.readAll(); file.close(); + pix.loadFromData(bytes); + if(bytes.size() > (512*1024) ){ //more than 512 KB + pix = pix.scaled(256,256, Qt::KeepAspectRatio, Qt::SmoothTransformation); + } } } + //qDebug() << " - done with item:" << info; - obj->emit threadDone(info, bytes); + obj->emit threadDone(info, pix); } QIcon Browser::loadIcon(QString icon){ - if(!mimeIcons.contains(icon)){ + if(!mimeIcons.contains(icon)){ mimeIcons.insert(icon, LXDG::findIcon(icon, "unknown")); } @@ -76,7 +81,7 @@ QIcon Browser::loadIcon(QString icon){ // PRIVATE SLOTS void Browser::fileChanged(QString file){ - if(file.startsWith(currentDir+"/") ){ + if(file.startsWith(currentDir+"/") ){ if(QFile::exists(file) ){ QtConcurrent::run(this, &Browser::loadItem, file, this); } //file modified but not removed else{ QTimer::singleShot(0, this, SLOT(loadDirectory()) ); } //file removed - need to update entire dir }else if(file==currentDir){ QTimer::singleShot(0, this, SLOT(loadDirectory()) ); } @@ -87,20 +92,20 @@ void Browser::dirChanged(QString dir){ else if(dir.startsWith(currentDir)){ QtConcurrent::run(this, &Browser::loadItem, dir, this ); } } -void Browser::futureFinished(QString name, QByteArray icon){ +void Browser::futureFinished(QString name, QImage icon){ //Note: this will be called once for every item that loads qDebug() << "Future Finished:" << name; QIcon ico; LFileInfo info(name); - if(!icon.isEmpty()){ + if(!icon.isNull()){ //qDebug() << " -- Data:"; - QPixmap pix; - if(pix.loadFromData(icon) ){ ico.addPixmap(pix); } + QPixmap pix = QPixmap::fromImage(icon); + ico.addPixmap(pix); }else if(info.isDir()){ //qDebug() << " -- Folder:"; - ico = loadIcon("folder"); + ico = loadIcon("folder"); } - if(ico.isNull()){ + if(ico.isNull()){ //qDebug() << " -- MimeType:" << info.fileName() << info.mimetype(); ico = loadIcon(info.iconfile()); } @@ -116,8 +121,8 @@ void Browser::loadDirectory(QString dir){ qDebug() << "Load Directory" << dir; if(currentDir != dir){ //let the main widget know to clear all current items (completely different dir) oldFiles.clear(); - emit clearItems(); - } + emit clearItems(); + } currentDir = dir; //save this for later //clean up the watcher first QStringList watched; watched << watcher->files() << watcher->directories(); @@ -141,7 +146,7 @@ void Browser::loadDirectory(QString dir){ QtConcurrent::run(this, &Browser::loadItem, path, this); }else{ //No special icon loading - just skip the file read step - futureFinished(path, QByteArray()); //loadItem(path, this); + futureFinished(path, QImage()); //loadItem(path, this); } } watcher->addPath(directory.absolutePath()); diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.h b/src-qt5/desktop-utils/lumina-fm/Browser.h index b96a7281..40e98753 100644 --- a/src-qt5/desktop-utils/lumina-fm/Browser.h +++ b/src-qt5/desktop-utils/lumina-fm/Browser.h @@ -46,7 +46,6 @@ private: bool showHidden, showThumbs; QStringList imageFormats, oldFiles; QHash<QString, QIcon> mimeIcons; //cache for quickly re-using QIcons - void loadItem(QString info, Browser *obj); //this is the main loader class - multiple instances each run in a separate thread QIcon loadIcon(QString icon); //simplification for using/populating the mimIcons cache @@ -55,7 +54,7 @@ private slots: void fileChanged(QString); //tied into the watcher - for file change notifications void dirChanged(QString); // tied into the watcher - for new/removed files in the current dir - void futureFinished(QString, QByteArray); + void futureFinished(QString, QImage); public slots: void loadDirectory(QString dir = ""); @@ -70,7 +69,7 @@ signals: void itemsLoading(int); //number of items which are getting loaded //Internal signal for the alternate threads - void threadDone(QString, QByteArray); + void threadDone(QString, QImage); }; #endif diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp index e5004742..23269ec2 100644 --- a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp +++ b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.cpp @@ -72,8 +72,8 @@ dirtreeModel = new QFileSystemModel(this); dirtreeModel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs); // remove extraneous dirs dirtreeModel->setRootPath(folderTreePath); - //ui->folderViewPane->setModel(dirtreeModel) - + ui->folderViewPane->setModel(dirtreeModel); + ui->splitter->setSizes( QList<int>() << this->width()/3 << 2*this->width()/3); //---------------------------------------------------// //Now update the rest of the UI @@ -158,12 +158,11 @@ return showdirtree; } - /* void DirWidget::on_folderViewPane_clicked(const QModelIndex &index){ - QString tPath = dirtreeModel->fileInfo(index).absoluteFilePath(); // get what was clicked - ChangeDir(tPath); + QString tPath = dirtreeModel->fileInfo(index).absoluteFilePath(); // get what was clicked + ChangeDir(tPath); } - */ + //---------------------------------------------------// @@ -574,7 +573,7 @@ contextMenu->addAction(LXDG::findIcon("edit-cut",""), tr("Cut Selection"), this, SLOT(cutFiles()), kCut->key() )->setEnabled(canmodify); contextMenu->addAction(LXDG::findIcon("edit-copy",""), tr("Copy Selection"), this, SLOT(copyFiles()), kCopy->key() )->setEnabled(canmodify); //---------------------------------------------------// - contextMenu->addAction(LXDG::findIcon("archive",""), tr("Auto-Extract"), this, SLOT(autoExtractFiles()), kExtract->key() )->setEnabled(canmodify); + if(LUtils::isValidBinary("lumina-archiver") && sel.length() ==1){ contextMenu->addAction(LXDG::findIcon("archive",""), tr("Auto-Extract"), this, SLOT(autoExtractFiles()), kExtract->key() )->setEnabled(canmodify); } //---------------------------------------------------// } if( QApplication::clipboard()->mimeData()->hasFormat("x-special/lumina-copied-files") ){ @@ -617,6 +616,9 @@ ui->actionBack->setEnabled( currentBrowser()->history().length()>1 ); line_dir->setText(normalbasedir); emit TabNameChanged(ID, normalbasedir.section("/",-1)); + QModelIndex index = dirtreeModel->index(cur,0); + ui->folderViewPane->setCurrentIndex( index ); + ui->folderViewPane->scrollTo(index); } void DirWidget::dirStatusChanged(QString stat){ diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h index c586e3e9..20b677d7 100644 --- a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h +++ b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.h @@ -34,13 +34,13 @@ public: enum DETAILTYPES{ NAME, SIZE, TYPE, DATEMOD, DATECREATE}; DirWidget(QString objID, QWidget *parent = 0); //needs a unique ID (to distinguish from other DirWidgets) ~DirWidget(); - + void cleanup(); //called before the browser is closed down - + //Directory Managment void ChangeDir(QString dirpath); void setDirCompleter(QCompleter *comp); - + //Information QString id(); QString currentDir(); @@ -61,7 +61,7 @@ public: public slots: //void LoadDir(QString dir, LFileInfoList list); void LoadSnaps(QString basedir, QStringList snaps); - + //Refresh options void refresh(); //Refresh current directory @@ -109,14 +109,14 @@ private slots: // -- Bottom Action Buttons void on_tool_zoom_in_clicked(); - void on_tool_zoom_out_clicked(); + void on_tool_zoom_out_clicked(); // -- Top Snapshot Buttons void on_tool_snap_newer_clicked(); void on_tool_snap_older_clicked(); void on_slider_snap_valueChanged(int val = -1); void direct_snap_selected(QAction*); - + //Top Toolbar buttons void on_actionBack_triggered(); void on_actionUp_triggered(); @@ -130,16 +130,16 @@ private slots: void fileCheckSums(); void fileProperties(); void openTerminal(); - + //Browser Functions void OpenContextMenu(); void UpdateContextMenu(); void currentDirectoryChanged(bool widgetonly = false); void dirStatusChanged(QString); - void setCurrentBrowser(QString); -// void on_folderViewPane_clicked(); - + void setCurrentBrowser(QString); + void on_folderViewPane_clicked(const QModelIndex &index); + //Context Menu Functions // - DIRECTORY operations void createNewFile(); @@ -156,7 +156,7 @@ private slots: void removeFiles(); void runFiles(); void runWithFiles(); - //void attachToNewEmail(); + //void attachToNewEmail(); void autoExtractFiles(); // - Context-specific operations @@ -169,7 +169,7 @@ signals: void OpenDirectories(QStringList); //Directories to open in other tabs/columns void findSnaps(QString, QString); //ID, dirpath (Request snapshot information for a directory) void CloseBrowser(QString); //ID (Request that this browser be closed) - + //External App/Widget launching void PlayFiles(LFileInfoList); //open in multimedia player void ViewFiles(LFileInfoList); //open in slideshow diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.ui b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.ui index 29660ad4..c49e99ac 100644 --- a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.ui +++ b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget2.ui @@ -19,29 +19,11 @@ <property name="windowTitle"> <string>Form</string> </property> - <layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0" columnstretch="0,1"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <property name="horizontalSpacing"> - <number>1</number> - </property> - <property name="verticalSpacing"> - <number>2</number> - </property> - <item row="0" column="0" rowspan="2" colspan="2"> + <layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,1,0"> + <item> <layout class="QHBoxLayout" name="toolbar_layout"/> </item> - <item row="2" column="1"> + <item> <layout class="QVBoxLayout" name="browser_layout_main"> <property name="spacing"> <number>1</number> @@ -122,12 +104,42 @@ </layout> </widget> </item> - <item> - <layout class="QHBoxLayout" name="browser_layout"/> - </item> </layout> </item> - <item row="3" column="0" colspan="2"> + <item> + <widget class="QWidget" name="widget" native="true"> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> + <widget class="QSplitter" name="splitter"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <widget class="QTreeView" name="folderViewPane"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="indentation"> + <number>15</number> + </property> + <property name="uniformRowHeights"> + <bool>true</bool> + </property> + <property name="allColumnsShowFocus"> + <bool>true</bool> + </property> + </widget> + <widget class="QWidget" name="horizontalLayoutWidget"> + <layout class="QHBoxLayout" name="browser_layout"/> + </widget> + </widget> + </item> + </layout> + </widget> + </item> + <item> <layout class="QHBoxLayout" name="horizontalLayout"> <item> <widget class="QLabel" name="label_status"> |