aboutsummaryrefslogtreecommitdiff
path: root/lumina-fm
diff options
context:
space:
mode:
Diffstat (limited to 'lumina-fm')
-rw-r--r--lumina-fm/DDFileSystemModel.h36
-rw-r--r--lumina-fm/MainUI.cpp87
-rw-r--r--lumina-fm/MainUI.h11
-rw-r--r--lumina-fm/MainUI.ui43
-rw-r--r--lumina-fm/MimeIconProvider.h6
-rw-r--r--lumina-fm/lumina-fm.pro3
6 files changed, 172 insertions, 14 deletions
diff --git a/lumina-fm/DDFileSystemModel.h b/lumina-fm/DDFileSystemModel.h
new file mode 100644
index 00000000..caa83b0e
--- /dev/null
+++ b/lumina-fm/DDFileSystemModel.h
@@ -0,0 +1,36 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2014, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+// This is a simple subclassed QFileSystemModel to enable drag and drop
+// (and moving) but disable all the other filesystem modifications
+//===========================================
+#ifndef _LUMINA_FILE_MANAGER_DDFILESYSTEMMODEL_H
+#define _LUMINA_FILE_MANAGER_DDFILESYSTEMMODEL_H
+
+#include <QFileSystemModel>
+#include <QObject>
+
+class DDFileSystemModel : public QFileSystemModel{
+ Q_OBJECT
+public:
+ DDFileSystemModel(QObject *parent = 0) : QFileSystemModel(parent){
+ this->setReadOnly(false); //need this to enable DnD
+ }
+ ~DDFileSystemModel(){}
+
+ virtual Qt::ItemFlags flags(const QModelIndex &index) const {
+ //First get all the flags from the standard QFileSystemModel
+ Qt::ItemFlags defaultflags = QFileSystemModel::flags(index);
+ //Now if it has the "Editable" flag set - remove it
+ if(defaultflags & Qt::ItemIsEditable){
+ defaultflags ^= Qt::ItemIsEditable;
+ }
+
+ return defaultflags;
+ }
+};
+
+#endif \ No newline at end of file
diff --git a/lumina-fm/MainUI.cpp b/lumina-fm/MainUI.cpp
index 1b01a855..fe3240dc 100644
--- a/lumina-fm/MainUI.cpp
+++ b/lumina-fm/MainUI.cpp
@@ -44,8 +44,10 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){
worker = new BackgroundWorker;
worker->moveToThread(workThread);
if(DEBUG){ qDebug() << " - File System Model"; }
- fsmod = new QFileSystemModel(this);
+ fsmod = new DDFileSystemModel(this);
fsmod->setRootPath("/");
+ //fsmod->setReadOnly(false); //required for DnD, but also enables a lot of other stuff
+ //qDebug() << "DnD options:" << fsmod->supportedDropActions();
ui->tree_dir_view->setModel(fsmod);
ui->tree_dir_view->sortByColumn(0, Qt::AscendingOrder);
ui->tree_dir_view->setColumnWidth(0,200);
@@ -159,6 +161,7 @@ void MainUI::setupIcons(){
ui->actionScan->setIcon( LXDG::findIcon("system-search","") );
//Browser page
+ ui->tool_addNewFile->setIcon( LXDG::findIcon("document-new",""));
ui->tool_addToDir->setIcon( LXDG::findIcon("folder-new","") );
ui->tool_goToImages->setIcon( LXDG::findIcon("fileview-preview","") );
ui->tool_goToPlayer->setIcon( LXDG::findIcon("applications-multimedia","") );
@@ -282,9 +285,11 @@ void MainUI::loadSettings(){
//Note: make sure this is run after all the UI elements are created and connected to slots
// but before the first directory gets loaded
ui->actionView_Hidden_Files->setChecked( settings->value("showhidden", false).toBool() );
- on_actionView_Hidden_Files_triggered(); //make sure to update the models too
+ on_actionView_Hidden_Files_triggered(); //make sure to update the models too
ui->actionShow_Action_Buttons->setChecked(settings->value("showactions", true).toBool() );
- on_actionShow_Action_Buttons_triggered(); //make sure to update the UI
+ on_actionShow_Action_Buttons_triggered(); //make sure to update the UI
+ ui->actionShow_Thumbnails->setChecked( settings->value("showthumbnails", true).toBool() );
+ iconProv->showthumbnails = ui->actionShow_Thumbnails->isChecked();
QString view = settings->value("viewmode","details").toString();
if(view=="icons"){ radio_view_icons->setChecked(true); }
else if(view=="list"){ radio_view_list->setChecked(true); }
@@ -417,6 +422,7 @@ void MainUI::setCurrentDir(QString dir){
//Update the directory viewer and update the line edit
keepFocus = !currentDir->hasFocus();
currentDir->setWhatsThis(dir); //save the full path internally
+ fsmod->setRootPath(rawdir);
if(radio_view_details->isChecked()){
ui->tree_dir_view->setRootIndex(fsmod->index(dir));
ui->tree_dir_view->selectionModel()->clearSelection();
@@ -442,6 +448,7 @@ void MainUI::setCurrentDir(QString dir){
if(isUserWritable){ ui->label_dir_stats->setText(""); }
else{ ui->label_dir_stats->setText(tr("Limited Access Directory")); }
ui->tool_addToDir->setVisible(isUserWritable);
+ ui->tool_addNewFile->setVisible(isUserWritable);
ui->actionUpDir->setEnabled(dir!="/");
ui->actionBack->setEnabled(history.length() > 1);
ui->actionBookMark->setEnabled( rawdir!=QDir::homePath() && settings->value("bookmarks", QStringList()).toStringList().filter("::::"+rawdir).length()<1 );
@@ -469,6 +476,40 @@ QFileInfoList MainUI::getSelectedItems(){
return out;
}
+/*QModelIndexList MainUI::getVisibleItems(){
+ QModelIndexList out;
+ if(radio_view_details->isChecked()){
+ QModelIndex index = ui->tree_dir_view->indexAt(QPoint(0,0));
+ while( index.isValid()){
+ if(index.column()!=0){
+ //move on - multiple index's per row when we only need one
+ }else if(ui->tree_dir_view->viewport()->rect().contains( ui->tree_dir_view->visualRect(index) ) ){
+ //index within the viewport - add it to the list
+ out << index;
+ }else{
+ break; //index not in the viewport
+ }
+ index = ui->tree_dir_view->indexBelow(index); //go to the next
+ if(out.contains(index)){ break; } //end of the list
+ }
+
+ }else{
+ QModelIndex index = ui->list_dir_view->indexAt(QPoint(0,0));
+ while( index.isValid()){
+ if(ui->list_dir_view->viewport()->rect().contains( ui->list_dir_view->visualRect(index) ) ){
+ //index within the viewport - add it to the list
+ out << index;
+ }else{
+ break; //index not in the viewport
+ }
+ index = ui->list_dir_view->indexBelow(index); //go to the next
+ if(out.contains(index)){ break; } //end of the list
+ }
+
+ }
+ return out;
+}*/
+
//==============
// PRIVATE SLOTS
//==============
@@ -646,6 +687,18 @@ void MainUI::on_actionShow_Action_Buttons_triggered(){
ui->group_actions->setVisible(ui->actionShow_Action_Buttons->isChecked());
settings->setValue("showactions", ui->actionShow_Action_Buttons->isChecked());
}
+
+void MainUI::on_actionShow_Thumbnails_triggered(){
+ //Now save this setting for later
+ settings->setValue("showthumbnails", ui->actionShow_Thumbnails->isChecked());
+ //Set the value in the icon provider
+ iconProv->showthumbnails = ui->actionShow_Thumbnails->isChecked();
+ //Now make sure the filesystem model knows to re-load the image data
+ fsmod->revert();
+ //Re-load the view widget
+ setCurrentDir(getCurrentDir());
+}
+
void MainUI::goToBookmark(QAction *act){
if(act==ui->actionManage_Bookmarks){
BMMDialog dlg(this);
@@ -759,6 +812,17 @@ void MainUI::reloadDirectory(){
setCurrentDir( getCurrentDir() );
}
+/*void MainUI::viewportChanged(){
+ if( !ui->actionsShow_Thumbnails->isChecked()){ return; }
+ QModelIndexList list = getVisibleItems();
+ for(int i=0; i<list.length(); i++){
+ if( !ui->actionsShow_Thumbnails->isChecked()){ return; } //break out as necessary
+ if( imgFilter.contains("*."+fsmod->filePath(list[i]).section("/",-1).section(".",-1).toLower()){
+ fmod->
+ }
+ }
+}*/
+
void MainUI::currentDirectoryLoaded(){
//The directory was just loaded: refresh the action buttons as neccesary
ui->tool_goToPlayer->setVisible(false);
@@ -788,6 +852,23 @@ void MainUI::on_tool_addToDir_clicked(){
}
}
+void MainUI::on_tool_addNewFile_clicked(){
+ bool ok = false;
+ QString newdocument = QInputDialog::getText(this, tr("New Document"), tr("Name:"), QLineEdit::Normal, "", \
+ &ok, 0, Qt::ImhFormattedNumbersOnly | Qt::ImhUppercaseOnly | Qt::ImhLowercaseOnly);
+ if(!ok || newdocument.isEmpty()){ return; }
+ QString full = getCurrentDir();
+ if(!full.endsWith("/")){ full.append("/"); }
+ QFile file(full+newdocument);
+ if(file.open(QIODevice::ReadWrite)){
+ //If successfully opened, it has created a blank file
+ file.close();
+ }else{
+ QMessageBox::warning(this, tr("Error Creating Document"), tr("The document could not be created. Please ensure that you have the proper permissions."));
+ }
+
+}
+
void MainUI::tabChanged(int tab){
//Load the directory contained in the new tab
qDebug() << "Change to Tab:" << tab << tabBar->tabText(tab);
diff --git a/lumina-fm/MainUI.h b/lumina-fm/MainUI.h
index ccc85f72..40ef25ff 100644
--- a/lumina-fm/MainUI.h
+++ b/lumina-fm/MainUI.h
@@ -53,6 +53,7 @@
#include "BMMDialog.h" //bookmark manager dialog
#include "MimeIconProvider.h" //icon provider for the view widgets
#include "BackgroundWorker.h"
+#include "DDFileSystemModel.h"
namespace Ui{
class MainUI;
@@ -76,7 +77,8 @@ private:
//Internal non-ui widgets
QTabBar *tabBar;
QLineEdit *currentDir;
- QFileSystemModel *fsmod, *snapmod;
+ DDFileSystemModel *fsmod;
+ QFileSystemModel *snapmod;
//QFileSystemWatcher *fswatcher;
MimeIconProvider *iconProv;
QMenu *contextMenu;
@@ -115,7 +117,8 @@ private:
QString getCurrentDir();
void setCurrentDir(QString);
QFileInfoList getSelectedItems();
-
+ //QModelIndexList getVisibleItems();
+
private slots:
void slotSingleInstance(QStringList in){
this->show();
@@ -141,6 +144,7 @@ private slots:
void on_actionClose_triggered();
void on_actionView_Hidden_Files_triggered();
void on_actionShow_Action_Buttons_triggered();
+ void on_actionShow_Thumbnails_triggered();
void goToBookmark(QAction*);
void goToDevice(QAction*);
void viewModeChanged(bool);
@@ -157,7 +161,8 @@ private slots:
void reloadDirectory(); //Update the widget with the dir contents
void currentDirectoryLoaded(); //The file system model re-loaded the directory
void on_tool_addToDir_clicked();
- void tabChanged(int tab);
+ void on_tool_addNewFile_clicked();
+ void tabChanged(int tab);
void tabClosed(int tab = -1);
void prevTab();
void nextTab();
diff --git a/lumina-fm/MainUI.ui b/lumina-fm/MainUI.ui
index 9dae7a56..4b2156c2 100644
--- a/lumina-fm/MainUI.ui
+++ b/lumina-fm/MainUI.ui
@@ -30,7 +30,7 @@
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
- <number>2</number>
+ <number>0</number>
</property>
<widget class="QWidget" name="page_browser">
<layout class="QGridLayout" name="gridLayout">
@@ -69,10 +69,10 @@
<bool>true</bool>
</property>
<property name="dragDropMode">
- <enum>QAbstractItemView::NoDragDrop</enum>
+ <enum>QAbstractItemView::InternalMove</enum>
</property>
<property name="defaultDropAction">
- <enum>Qt::IgnoreAction</enum>
+ <enum>Qt::MoveAction</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
@@ -124,10 +124,10 @@
<bool>true</bool>
</property>
<property name="dragDropMode">
- <enum>QAbstractItemView::NoDragDrop</enum>
+ <enum>QAbstractItemView::InternalMove</enum>
</property>
<property name="defaultDropAction">
- <enum>Qt::IgnoreAction</enum>
+ <enum>Qt::MoveAction</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
@@ -422,6 +422,25 @@
</widget>
</item>
<item>
+ <widget class="QToolButton" name="tool_addNewFile">
+ <property name="statusTip">
+ <string>Create a new file</string>
+ </property>
+ <property name="text">
+ <string>New &amp;file</string>
+ </property>
+ <property name="popupMode">
+ <enum>QToolButton::InstantPopup</enum>
+ </property>
+ <property name="toolButtonStyle">
+ <enum>Qt::ToolButtonTextBesideIcon</enum>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QToolButton" name="tool_addToDir">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
@@ -1086,7 +1105,7 @@
<x>0</x>
<y>0</y>
<width>567</width>
- <height>18</height>
+ <height>19</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@@ -1101,6 +1120,7 @@
<property name="title">
<string>View</string>
</property>
+ <addaction name="actionShow_Thumbnails"/>
<addaction name="actionView_Hidden_Files"/>
<addaction name="actionShow_Action_Buttons"/>
<addaction name="separator"/>
@@ -1266,6 +1286,17 @@
<string>Show Action Buttons</string>
</property>
</action>
+ <action name="actionShow_Thumbnails">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Load Thumbnails</string>
+ </property>
+ </action>
</widget>
<resources/>
<connections/>
diff --git a/lumina-fm/MimeIconProvider.h b/lumina-fm/MimeIconProvider.h
index 044ff7eb..344d6801 100644
--- a/lumina-fm/MimeIconProvider.h
+++ b/lumina-fm/MimeIconProvider.h
@@ -19,15 +19,19 @@
class MimeIconProvider : public QFileIconProvider{
public:
+ bool showthumbnails;
MimeIconProvider() : QFileIconProvider(){
+ showthumbnails = false;
}
~MimeIconProvider(){}
+
+
QIcon icon(const QFileInfo &info) const{
if(info.isDir()){
return LXDG::findIcon("folder","");
}else if(info.isFile()){
- if(info.suffix().toLower()=="png" || info.suffix().toLower()=="jpg"){
+ if(showthumbnails && (info.suffix().toLower()=="png" || info.suffix().toLower()=="jpg") ){
//make sure to only load small versions of the files into memory: could have hundreds of them...
return QIcon( QPixmap(info.absoluteFilePath()).scaledToHeight(64) );
}else{
diff --git a/lumina-fm/lumina-fm.pro b/lumina-fm/lumina-fm.pro
index 8f01a93c..53e2dd2d 100644
--- a/lumina-fm/lumina-fm.pro
+++ b/lumina-fm/lumina-fm.pro
@@ -24,7 +24,8 @@ HEADERS += MainUI.h \
FODialog.h \
BMMDialog.h \
MimeIconProvider.h \
- BackgroundWorker.h
+ BackgroundWorker.h \
+ DDFileSystemModel.h
FORMS += MainUI.ui \
FODialog.ui \
bgstack15