diff options
author | Ken Moore <moorekou@gmail.com> | 2015-08-25 15:43:53 -0400 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2015-08-25 15:43:53 -0400 |
commit | 88507c36076b100e26a8e2c85533d667675f9daa (patch) | |
tree | 53fc42d5b8b83924e19aa5d6618dae446ba698a4 /lumina-fm/widgets | |
parent | Disable the "size" output of a directory in lumina-fm: this needs some better... (diff) | |
download | lumina-88507c36076b100e26a8e2c85533d667675f9daa.tar.gz lumina-88507c36076b100e26a8e2c85533d667675f9daa.tar.bz2 lumina-88507c36076b100e26a8e2c85533d667675f9daa.zip |
Commit a major overhaul of lumina-fm: PLEASE TEST!!
1) Seemlessly embed the ZFS rollback options into the main dir browser (simple time slider at the top).
2) Take all the main widgets and put them into separate classes/files (widgets/*)
3) Add support for both tabs and columns for multiple directory viewing
4) Remove the "icon" view mode, and replace it with an icon sizing option (larger/smaller)
5) Add the ability for the multimedia player and slideshow viewer to be running within separate tabs while still browsing the system (new files will be added to the queue instead of replacing it)
6) Ensure that only selected files are added to the player/slideshow on demand.
7) Add the ability to zoom in/out on a slideshow image.
KNOWN ISSUES:
1) The new file/dir functionality has not been replaced/re-implemented yet.
2) The drag and drop functionality has been removed until a new implementation is put in.
PLEASE TEST:
ZFS snapshot use, multimedia file player, browsing and other UI changes
Diffstat (limited to 'lumina-fm/widgets')
-rw-r--r-- | lumina-fm/widgets/DirWidget.cpp | 269 | ||||
-rw-r--r-- | lumina-fm/widgets/DirWidget.h | 49 | ||||
-rw-r--r-- | lumina-fm/widgets/DirWidget.ui | 336 | ||||
-rw-r--r-- | lumina-fm/widgets/MultimediaWidget.cpp | 5 | ||||
-rw-r--r-- | lumina-fm/widgets/MultimediaWidget.h | 1 | ||||
-rw-r--r-- | lumina-fm/widgets/SlideshowWidget.cpp | 43 | ||||
-rw-r--r-- | lumina-fm/widgets/SlideshowWidget.h | 8 | ||||
-rw-r--r-- | lumina-fm/widgets/SlideshowWidget.ui | 115 |
8 files changed, 627 insertions, 199 deletions
diff --git a/lumina-fm/widgets/DirWidget.cpp b/lumina-fm/widgets/DirWidget.cpp index b32e5c20..775a252b 100644 --- a/lumina-fm/widgets/DirWidget.cpp +++ b/lumina-fm/widgets/DirWidget.cpp @@ -19,9 +19,36 @@ DirWidget::DirWidget(QString objID, QWidget *parent) : QWidget(parent), ui(new Ui::DirWidget){ ui->setupUi(this); //load the designer file ID = objID; + //Assemble the toolbar for the widget + toolbar = new QToolBar(this); + toolbar->setContextMenuPolicy(Qt::CustomContextMenu); + toolbar->setFloatable(false); + toolbar->setMovable(false); + toolbar->setOrientation(Qt::Horizontal); + toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly); + //toolbar->setIconSize(QSize(32,32)); + ui->toolbar_layout->addWidget(toolbar); + // - Add the buttons to the toolbar + toolbar->addAction(ui->actionBack); + toolbar->addAction(ui->actionUp); + toolbar->addAction(ui->actionHome); + line_dir = new QLineEdit(this); + toolbar->addWidget(line_dir); + toolbar->addAction(ui->actionStopLoad); + toolbar->addAction(ui->actionClose_Browser); + //Create the keyboard shortcuts + copyFilesShort = new QShortcut( QKeySequence(tr("Ctrl+C")), this); + pasteFilesShort = new QShortcut( QKeySequence(tr("Ctrl+V")), this); + cutFilesShort = new QShortcut( QKeySequence(tr("Ctrl+X")), this); + deleteFilesShort = new QShortcut( QKeySequence(tr("Delete")), this); + refreshShort = new QShortcut( QKeySequence(tr("F5")), this); + //Create the filesystem watcher + watcher = new QFileSystemWatcher(this); + //Now update the rest of the UI canmodify = false; //initial value contextMenu = new QMenu(this); setShowDetails(true); + setShowThumbnails(true); UpdateIcons(); UpdateText(); setupConnections(); @@ -31,24 +58,71 @@ DirWidget::~DirWidget(){ } +void DirWidget::ChangeDir(QString dirpath){ + emit LoadDirectory(ID, dirpath); +} + +void DirWidget::setDirCompleter(QCompleter *comp){ + line_dir->setCompleter(comp); +} + QString DirWidget::id(){ return ID; } +QString DirWidget::currentDir(){ + return CDIR; +} + void DirWidget::setShowDetails(bool show){ showDetails = show; ui->listWidget->setVisible(!showDetails); ui->treeWidget->setVisible(showDetails); + this->refresh(); } void DirWidget::setShowSidebar(bool show){ ui->group_actions->setVisible(show); } +void DirWidget::setShowThumbnails(bool show){ + showThumbs = show; + this->refresh(); +} + void DirWidget::setDetails(QList<DETAILTYPES> list){ listDetails = list; + //Need to re-create the header item as well + QTreeWidgetItem *it = new QTreeWidgetItem(); + int nmcol = -1; int typecol = -1; + for(int t=0; t<listDetails.length(); t++){ + switch(listDetails[t]){ + case NAME: + it->setText(t,tr("Name")); + nmcol = t; + break; + case SIZE: + it->setText(t,tr("Size")); + break; + case TYPE: + it->setText(t, tr("Type")); + typecol = t; + break; + case DATEMOD: + it->setText(t, tr("Date Modified") ); + break; + case DATECREATE: + it->setText(t, tr("Date Created") ); + break; + } + } + ui->treeWidget->setHeaderItem(it); + //Now reset the sorting (alphabetically, dirs first) + if(nmcol>=0){ ui->treeWidget->sortItems(nmcol, Qt::AscendingOrder); } // sort by name + if(typecol>=0){ ui->treeWidget->sortItems(typecol, Qt::AscendingOrder); } //sort by type first + if(CDIR.isEmpty() || !showDetails){ return; } //don't need to reload dir if details are not visible - emit LoadDirectory(ID, CDIR); + this->refresh(); } void DirWidget::setThumbnailSize(int px){ @@ -56,17 +130,25 @@ void DirWidget::setThumbnailSize(int px){ ui->listWidget->setIconSize(QSize(px,px)); ui->treeWidget->setIconSize(QSize(px,px)); if(CDIR.isEmpty() || !larger ){ return; } //don't need to reload icons unless the new size is larger - emit LoadDirectory(ID, CDIR); + this->refresh(); +} + +void DirWidget::setShowCloseButton(bool show){ + ui->actionClose_Browser->setVisible(show); } + // ================ // PUBLIC SLOTS // ================ void DirWidget::LoadDir(QString dir, QList<LFileInfo> list){ if(dir.isEmpty()){ return; } //nothing to do + qDebug() << "Load Dir:" << dir; QString lastdir = CDIR; //for some checks later - canmodify = QFileInfo(CDIR).isWritable(); - CLIST = list; //save for later + QString lastbasedir = normalbasedir; CDIR = dir; + if(CDIR.endsWith("/")){ CDIR.chop(1); } + CLIST = list; //save for laterr + canmodify = QFileInfo(CDIR).isWritable(); //Hide the extra buttons for a moment ui->tool_goToPlayer->setVisible(false); ui->tool_goToImages->setVisible(false); @@ -75,7 +157,10 @@ void DirWidget::LoadDir(QString dir, QList<LFileInfo> list){ if( dir.contains(ZSNAPDIR) ){ //This is a zfs snapshot - only update the saved paths necessary to rotate between snapshots/system snaprelpath = dir.section(ZSNAPDIR,1,1000).section("/",1,1000); //the relative path inside the snapshot + if(snaprelpath.endsWith("/")){ snaprelpath.chop(1); } normalbasedir = dir.section(ZSNAPDIR,0,0)+"/"+snaprelpath; //Update the new base directory + if(normalbasedir.endsWith("/")){ normalbasedir.chop(1); } + line_dir->setText(normalbasedir); //See if this was a manual move to the directory, or an internal move QString tmp = dir.section(ZSNAPDIR,0,0); if(tmp != snapbasedir.section(ZSNAPDIR,0,0)){ @@ -83,7 +168,8 @@ void DirWidget::LoadDir(QString dir, QList<LFileInfo> list){ } }else{ //This is a normal directory - prompt for snapshot information - normalbasedir = dir; + line_dir->setText(CDIR); + normalbasedir = CDIR; snapbasedir.clear(); loadsnaps = true; } @@ -94,37 +180,32 @@ void DirWidget::LoadDir(QString dir, QList<LFileInfo> list){ ui->slider_snap->setRange(1,1); emit findSnaps(ID, normalbasedir); } + //Now update the history for this browser + if(!history.isEmpty() && history.last() == normalbasedir && lastbasedir!=normalbasedir ){ + //We went back one - remove this from the history + history.takeLast(); + ui->actionBack->setEnabled(!history.isEmpty()); + }else if(lastbasedir!=normalbasedir){ //not a refresh or internal snapshot change + history << normalbasedir; + ui->actionBack->setEnabled(history.length()>1); + } + //Clear the current watcher + if(!watcher->directories().isEmpty()){ watcher->removePaths(watcher->directories()); } + if(!watcher->files().isEmpty()){ watcher->removePaths(watcher->files()); } + watcher->addPath(CDIR); + ui->actionStopLoad->setVisible(true); + stopload = false; //Clear the display widget - if(showDetails){ - ui->treeWidget->clear(); - //Need to re-create the header item as well - QTreeWidgetItem *it = new QTreeWidgetItem(); - for(int t=0; t<listDetails.length(); t++){ - switch(listDetails[t]){ - case NAME: - it->setText(t,tr("Name")); - break; - case SIZE: - it->setText(t,tr("Size")); - break; - case TYPE: - it->setText(t, tr("Type")); - case DATEMOD: - it->setText(t, tr("Date Modified") ); - break; - case DATECREATE: - it->setText(t, tr("Date Created") ); - break; - } - } - ui->treeWidget->setHeaderItem(it); - }else{ ui->listWidget->clear(); } + if(showDetails){ ui->treeWidget->clear(); } + else{ ui->listWidget->clear(); } //Now fill the display widget bool hasimages, hasmultimedia; hasimages = hasmultimedia = false; for(int i=0; i<list.length(); i++){ + if(stopload){ ui->actionStopLoad->setVisible(false); return; } //stop right now hasimages = hasimages || list[i].isImage(); hasmultimedia = hasmultimedia || list[i].isAVFile(); + //watcher->addPath(list[i].absoluteFilePath()); if(showDetails){ //Now create all the individual items for the details tree QTreeWidgetItem *it = new QTreeWidgetItem(); @@ -133,8 +214,10 @@ void DirWidget::LoadDir(QString dir, QList<LFileInfo> list){ switch(listDetails[t]){ case NAME: it->setText(t,list[i].fileName()); + it->setStatusTip(t, list[i].fileName()); if(list[i].isImage()){ - it->setIcon(t, QIcon( QPixmap(list[i].absoluteFilePath()).scaledToHeight(ui->treeWidget->iconSize().height()) ) ); + if(showThumbs){ it->setIcon(t, QIcon( QPixmap(list[i].absoluteFilePath()).scaledToHeight(ui->treeWidget->iconSize().height()) ) ); } + else{ it->setIcon(t, LXDG::findIcon(list[i].iconfile(),"image-x-generic") ); } }else{ it->setIcon(t, LXDG::findIcon(list[i].iconfile(),"unknown") ); } @@ -146,6 +229,7 @@ void DirWidget::LoadDir(QString dir, QList<LFileInfo> list){ break; case TYPE: it->setText(t, list[i].mimetype()); + break; case DATEMOD: it->setText(t, list[i].lastModified().toString(Qt::DefaultLocaleShortDate) ); break; @@ -164,8 +248,10 @@ void DirWidget::LoadDir(QString dir, QList<LFileInfo> list){ QListWidgetItem *it = new QListWidgetItem(); it->setWhatsThis(list[i].fileName()); it->setText(list[i].fileName()); + it->setStatusTip(list[i].fileName()); if(list[i].isImage()){ - it->setIcon(QIcon( QPixmap(list[i].absoluteFilePath()).scaledToHeight(ui->listWidget->iconSize().height()) ) ); + if(showThumbs){ it->setIcon(QIcon( QPixmap(list[i].absoluteFilePath()).scaledToHeight(ui->treeWidget->iconSize().height()) ) ); } + else{ it->setIcon(LXDG::findIcon(list[i].iconfile(),"image-x-generic") ); } }else{ it->setIcon(LXDG::findIcon(list[i].iconfile(),"unknown") ); } @@ -177,15 +263,19 @@ void DirWidget::LoadDir(QString dir, QList<LFileInfo> list){ } QApplication::processEvents(); //keep the UI snappy while loading a directory } + ui->actionStopLoad->setVisible(false); //Another check to ensure the current item is visible if(showDetails){ if(ui->treeWidget->currentItem()!=0){ ui->treeWidget->scrollToItem(ui->treeWidget->currentItem()); } + for(int t=0; t<ui->treeWidget->columnCount(); t++){ui->treeWidget->resizeColumnToContents(t); } }else{ if(ui->listWidget->currentItem()!=0){ ui->listWidget->scrollToItem(ui->listWidget->currentItem()); } } //Now Re-enable buttons as necessary - ui->tool_goToPlayer->setVisible(hasimages); - ui->tool_goToImages->setVisible(hasmultimedia); + ui->tool_goToPlayer->setVisible(hasmultimedia); + ui->tool_goToImages->setVisible(hasimages); + if(canmodify){ ui->label_status->setText(""); } + else{ ui->label_status->setText(tr("Restricted Access")); } } void DirWidget::LoadSnaps(QString basedir, QStringList snaps){ @@ -211,6 +301,17 @@ void DirWidget::LoadSnaps(QString basedir, QStringList snaps){ } +void DirWidget::refresh(){ + if(!CDIR.isEmpty() && ~ID.isEmpty()){ + stopload = true; //just in case it is still loading + emit LoadDirectory(ID, CDIR); + } +} + +void DirWidget::refreshButtons(){ + SelectionChanged(); +} + //Theme change functions void DirWidget::UpdateIcons(){ //ui->tool_addNewFile->setIcon( LXDG::findIcon("document-new","")); @@ -231,6 +332,12 @@ void DirWidget::UpdateIcons(){ ui->tool_act_rename->setIcon( LXDG::findIcon("edit-rename","") ); ui->tool_act_rm->setIcon( LXDG::findIcon("edit-delete","") ); ui->tool_act_fav->setIcon( LXDG::findIcon("bookmark-toolbar","") ); + //ToolBar Buttons + ui->actionBack->setIcon( LXDG::findIcon("go-previous","") ); + ui->actionUp->setIcon( LXDG::findIcon("go-up","") ); + ui->actionHome->setIcon( LXDG::findIcon("go-home","") ); + ui->actionStopLoad->setIcon( LXDG::findIcon("dialog-cancel","") ); + ui->actionClose_Browser->setIcon( LXDG::findIcon("dialog-close","") ); } void DirWidget::UpdateText(){ @@ -252,13 +359,19 @@ void DirWidget::setupConnections(){ connect(ui->listWidget, SIGNAL(itemSelectionChanged()), this, SLOT(SelectionChanged()) ); //Activation routines - connect(ui->treeWidget, SIGNAL(itemActivated(QTreeWidgetItem*)), this, SLOT(on_tool_act_run_clicked()) ); + connect(ui->treeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(on_tool_act_run_clicked()) ); connect(ui->listWidget, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(on_tool_act_run_clicked()) ); - connect(ui->treeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*)), this, SLOT(on_tool_act_run_clicked()) ); - connect(ui->listWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(on_tool_act_run_clicked()) ); + connect(line_dir, SIGNAL(returnPressed()), this, SLOT(dir_changed()) ); - - + //Keyboard Shortcuts + connect(copyFilesShort, SIGNAL(activated()), this, SLOT( on_tool_act_copy_clicked() ) ); + connect(cutFilesShort, SIGNAL(activated()), this, SLOT( on_tool_act_cut_clicked() ) ); + connect(pasteFilesShort, SIGNAL(activated()), this, SLOT( on_tool_act_paste_clicked() ) ); + connect(deleteFilesShort, SIGNAL(activated()), this, SLOT( on_tool_act_rm_clicked() ) ); + connect(refreshShort, SIGNAL(activated()), this, SLOT( refresh()) ); + //Filesystem Watcher + connect(watcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(refresh()) ); + connect(watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(refresh()) ); //just in case } QStringList DirWidget::currentSelection(){ @@ -352,11 +465,33 @@ void DirWidget::on_tool_act_runwith_clicked(){ // -- Bottom Action Buttons void DirWidget::on_tool_goToImages_clicked(){ - emit ViewFiles(CLIST); + QStringList sel = currentSelection(); + if(sel.isEmpty()){ emit ViewFiles(CLIST); } + else{ + //Just use the files from the current selection + LFileInfoList list; + for(int i=0; i<CLIST.length(); i++){ + if(CLIST[i].isImage() && sel.contains(CLIST[i].fileName()) ){ + list << CLIST[i]; //add to the list + } + } + if(!list.isEmpty()){ emit ViewFiles(list); } + } } void DirWidget::on_tool_goToPlayer_clicked(){ - emit PlayFiles(CLIST); + QStringList sel = currentSelection(); + if(sel.isEmpty()){ emit PlayFiles(CLIST); } + else{ + //Just use the files from the current selection + LFileInfoList list; + for(int i=0; i<CLIST.length(); i++){ + if(CLIST[i].isAVFile() && sel.contains(CLIST[i].fileName()) ){ + list << CLIST[i]; //add to the list + } + } + if(!list.isEmpty()){ emit PlayFiles(list); } + } } // -- Top Snapshot Buttons @@ -381,29 +516,73 @@ void DirWidget::on_slider_snap_valueChanged(int val){ if(!ui->group_snaps->isEnabled()){ return; } //internal change - do not try to change the actual info //Determine which snapshot is now selected QString dir; - qDebug() << "Changing snapshot:" << CDIR << val; + //qDebug() << "Changing snapshot:" << CDIR << val; + stopload = true; //stop any currently-loading procedures if(val >= snapshots.length() || val < 0){ //active system selected - qDebug() << " - Load Active system:" << normalbasedir; + //qDebug() << " - Load Active system:" << normalbasedir; dir = normalbasedir; }else{ dir = snapbasedir+snapshots[val]+"/"; if(snaprelpath.isEmpty()){ //Need to figure out the relative path within the snapshot snaprelpath = CDIR.section(snapbasedir.section(ZSNAPDIR,0,0), 1,1000); - qDebug() << " - new snapshot-relative path:" << snaprelpath; + //qDebug() << " - new snapshot-relative path:" << snaprelpath; } dir.append(snaprelpath); - qDebug() << " - Load Snapshot:" << dir; + dir.replace("//","/"); //just in case any duplicate slashes from all the split/combining + //qDebug() << " - Load Snapshot:" << dir; } //Make sure this directory exists, and back up as necessary + while(!QFile::exists(dir) && !dir.isEmpty()){ - dir = dir.section("/",0,-1); //back up one dir + dir = dir.section("/",0,-2); //back up one dir } if(dir.isEmpty()){ return; } //Load the newly selected snapshot emit LoadDirectory(ID, dir); } +//Top Toolbar buttons +void DirWidget::on_actionBack_triggered(){ + if(history.isEmpty()){ return; } //cannot do anything + QString dir = history.takeLast(); + if(dir == normalbasedir){ + dir = history.last(); + } + emit LoadDirectory(ID, dir); +} + +void DirWidget::on_actionUp_triggered(){ + QString dir = CDIR.section("/",0,-2); + //Quick check to ensure the directory exists + while(!QFile::exists(dir) && !dir.isEmpty()){ + dir = dir.section("/",0,-2); //back up one additional dir + } + emit LoadDirectory(ID, dir); +} + +void DirWidget::on_actionHome_triggered(){ + emit LoadDirectory(ID, QDir::homePath()); +} + +void DirWidget::on_actionStopLoad_triggered(){ + stopload = true; + ui->actionStopLoad->setVisible(false); +} + +void DirWidget::dir_changed(){ + QString dir = line_dir->text(); + //Quick check to ensure the directory exists + while(!QFile::exists(dir) && !dir.isEmpty()){ + dir = dir.section("/",0,-2); //back up one additional dir + } + emit LoadDirectory(ID, dir); +} + +void DirWidget::on_actionClose_Browser_triggered(){ + emit CloseBrowser(ID); +} + // - Other Actions without a specific button on the side void DirWidget::fileCheckSums(){ QStringList files = currentSelection(); diff --git a/lumina-fm/widgets/DirWidget.h b/lumina-fm/widgets/DirWidget.h index 646df309..193d1789 100644 --- a/lumina-fm/widgets/DirWidget.h +++ b/lumina-fm/widgets/DirWidget.h @@ -11,6 +11,11 @@ #include <QWidget> #include <QObject> #include <QMenu> +#include <QToolBar> +#include <QLineEdit> +#include <QShortcut> +#include <QFileSystemWatcher> + #include "../DirData.h" @@ -26,16 +31,30 @@ public: enum DETAILTYPES{ NAME, SIZE, TYPE, DATEMOD, DATECREATE}; DirWidget(QString objID, QWidget *parent = 0); //needs a unique ID (to distinguish from other DirWidgets) ~DirWidget(); - + + //Directory Managment + void ChangeDir(QString dirpath); + void setDirCompleter(QCompleter *comp); + + //Information QString id(); + QString currentDir(); + + //View Settings void setShowDetails(bool show); void setShowSidebar(bool show); + void setShowThumbnails(bool show); void setDetails(QList<DETAILTYPES> list); //Which details to show and in which order (L->R) void setThumbnailSize(int px); + void setShowCloseButton(bool show); public slots: - void LoadDir(QString dir, QList<LFileInfo> list); + void LoadDir(QString dir, LFileInfoList list); void LoadSnaps(QString basedir, QStringList snaps); + + //Refresh options + void refresh(); //Refresh current directory + void refreshButtons(); //Refresh action buttons only //Theme change functions void UpdateIcons(); @@ -47,13 +66,22 @@ public slots: private: Ui::DirWidget *ui; QString ID, CDIR; //unique ID assigned by the parent and the current dir path - QList<LFileInfo> CLIST; //current item list (snap or not) + LFileInfoList CLIST; //current item list (snap or not) QString normalbasedir, snapbasedir, snaprelpath; //for maintaining direcoty context while moving between snapshots QStringList snapshots; - bool showDetails, canmodify; //which widget to use for showing items + bool showDetails, showThumbs, canmodify, stopload; //which widget to use for showing items QList<DETAILTYPES> listDetails; QMenu *contextMenu; + //The Toolbar and associated items + QToolBar *toolbar; + QLineEdit *line_dir; + QStringList history; + //Keyboard Shortcuts + QShortcut *copyFilesShort, *cutFilesShort, *pasteFilesShort, *deleteFilesShort, *refreshShort; + //Watcher to determine when the dir changes + QFileSystemWatcher *watcher; + //Functions for internal use void setupConnections(); QStringList currentSelection(); @@ -75,6 +103,14 @@ private slots: void on_tool_snap_newer_clicked(); void on_tool_snap_older_clicked(); void on_slider_snap_valueChanged(int); + //Top Toolbar buttons + void on_actionBack_triggered(); + void on_actionUp_triggered(); + void on_actionHome_triggered(); + void on_actionStopLoad_triggered(); + void dir_changed(); //user manually changed the directory + void on_actionClose_Browser_triggered(); + // - Other Actions without a specific button on the side void fileCheckSums(); void fileProperties(); @@ -91,10 +127,11 @@ signals: void OpenDirectories(QStringList); //Directories to open in other tabs/columns void LoadDirectory(QString, QString); //ID, dirpath (Directory to load here) 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(QList<LFileInfo>); //open in multimedia player - void ViewFiles(QList<LFileInfo>); //open in slideshow + void PlayFiles(LFileInfoList); //open in multimedia player + void ViewFiles(LFileInfoList); //open in slideshow void LaunchTerminal(QString); //dirpath //System Interactions diff --git a/lumina-fm/widgets/DirWidget.ui b/lumina-fm/widgets/DirWidget.ui index 2be5515d..9355d21e 100644 --- a/lumina-fm/widgets/DirWidget.ui +++ b/lumina-fm/widgets/DirWidget.ui @@ -7,29 +7,155 @@ <x>0</x> <y>0</y> <width>400</width> - <height>333</height> + <height>334</height> </rect> </property> <property name="windowTitle"> <string>Form</string> </property> - <layout class="QGridLayout" name="gridLayout" columnstretch="0,1"> + <layout class="QGridLayout" name="gridLayout"> <property name="leftMargin"> - <number>1</number> + <number>0</number> </property> <property name="topMargin"> - <number>1</number> + <number>0</number> </property> <property name="rightMargin"> - <number>1</number> + <number>0</number> </property> <property name="bottomMargin"> + <number>0</number> + </property> + <property name="horizontalSpacing"> <number>1</number> </property> - <property name="spacing"> + <property name="verticalSpacing"> <number>2</number> </property> - <item row="0" column="0"> + <item row="0" column="0" rowspan="2" colspan="2"> + <layout class="QHBoxLayout" name="toolbar_layout"/> + </item> + <item row="1" column="1" rowspan="2"> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <property name="spacing"> + <number>1</number> + </property> + <item> + <widget class="QGroupBox" name="group_snaps"> + <property name="title"> + <string notr="true"/> + </property> + <property name="flat"> + <bool>true</bool> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <property name="leftMargin"> + <number>1</number> + </property> + <property name="topMargin"> + <number>1</number> + </property> + <property name="rightMargin"> + <number>1</number> + </property> + <property name="bottomMargin"> + <number>1</number> + </property> + <item> + <widget class="QLabel" name="label_snap"> + <property name="text"> + <string notr="true">Snap</string> + </property> + </widget> + </item> + <item> + <widget class="QSlider" name="slider_snap"> + <property name="minimum"> + <number>1</number> + </property> + <property name="value"> + <number>1</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="invertedAppearance"> + <bool>false</bool> + </property> + <property name="invertedControls"> + <bool>false</bool> + </property> + <property name="tickPosition"> + <enum>QSlider::TicksAbove</enum> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_snap_older"> + <property name="text"> + <string notr="true">...</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_snap_newer"> + <property name="text"> + <string notr="true">...</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QTreeWidget" name="treeWidget"> + <property name="contextMenuPolicy"> + <enum>Qt::CustomContextMenu</enum> + </property> + <property name="selectionMode"> + <enum>QAbstractItemView::ExtendedSelection</enum> + </property> + <property name="indentation"> + <number>0</number> + </property> + <property name="sortingEnabled"> + <bool>true</bool> + </property> + <property name="allColumnsShowFocus"> + <bool>true</bool> + </property> + <attribute name="headerMinimumSectionSize"> + <number>30</number> + </attribute> + <column> + <property name="text"> + <string notr="true">1</string> + </property> + </column> + </widget> + </item> + <item> + <widget class="QListWidget" name="listWidget"> + <property name="contextMenuPolicy"> + <enum>Qt::CustomContextMenu</enum> + </property> + <property name="selectionMode"> + <enum>QAbstractItemView::ExtendedSelection</enum> + </property> + <property name="selectionBehavior"> + <enum>QAbstractItemView::SelectItems</enum> + </property> + <property name="flow"> + <enum>QListView::TopToBottom</enum> + </property> + <property name="isWrapping" stdset="0"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item row="2" column="0"> <widget class="QGroupBox" name="group_actions"> <property name="sizePolicy"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> @@ -269,109 +395,7 @@ </layout> </widget> </item> - <item row="0" column="1"> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <property name="spacing"> - <number>1</number> - </property> - <item> - <widget class="QGroupBox" name="group_snaps"> - <property name="title"> - <string>Snapshots Available</string> - </property> - <property name="flat"> - <bool>true</bool> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <property name="leftMargin"> - <number>1</number> - </property> - <property name="topMargin"> - <number>1</number> - </property> - <property name="rightMargin"> - <number>1</number> - </property> - <property name="bottomMargin"> - <number>1</number> - </property> - <item> - <widget class="QLabel" name="label_snap"> - <property name="text"> - <string notr="true">Snap</string> - </property> - </widget> - </item> - <item> - <widget class="QSlider" name="slider_snap"> - <property name="minimum"> - <number>1</number> - </property> - <property name="value"> - <number>1</number> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="invertedAppearance"> - <bool>false</bool> - </property> - <property name="invertedControls"> - <bool>false</bool> - </property> - <property name="tickPosition"> - <enum>QSlider::TicksAbove</enum> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="tool_snap_older"> - <property name="text"> - <string notr="true">...</string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="tool_snap_newer"> - <property name="text"> - <string notr="true">...</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QTreeWidget" name="treeWidget"> - <property name="contextMenuPolicy"> - <enum>Qt::CustomContextMenu</enum> - </property> - <property name="selectionMode"> - <enum>QAbstractItemView::ExtendedSelection</enum> - </property> - <column> - <property name="text"> - <string notr="true">1</string> - </property> - </column> - </widget> - </item> - <item> - <widget class="QListWidget" name="listWidget"> - <property name="contextMenuPolicy"> - <enum>Qt::CustomContextMenu</enum> - </property> - <property name="selectionMode"> - <enum>QAbstractItemView::ExtendedSelection</enum> - </property> - <property name="selectionBehavior"> - <enum>QAbstractItemView::SelectItems</enum> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0" colspan="2"> + <item row="3" column="0" colspan="2"> <layout class="QHBoxLayout" name="horizontalLayout_2"> <item> <widget class="QLabel" name="label_status"> @@ -382,21 +406,109 @@ </item> <item> <widget class="QToolButton" name="tool_goToImages"> + <property name="statusTip"> + <string>Add selected images to slideshow</string> + </property> <property name="text"> - <string notr="true">img</string> + <string>Slideshow</string> + </property> + <property name="iconSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextBesideIcon</enum> </property> </widget> </item> <item> <widget class="QToolButton" name="tool_goToPlayer"> + <property name="statusTip"> + <string>Enqueue selection in multimedia player</string> + </property> <property name="text"> - <string notr="true">play</string> + <string>Play</string> + </property> + <property name="iconSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextBesideIcon</enum> </property> </widget> </item> </layout> </item> </layout> + <action name="actionBack"> + <property name="text"> + <string notr="true">Back</string> + </property> + <property name="iconText"> + <string>Back</string> + </property> + <property name="toolTip"> + <string>Go back to previous directory</string> + </property> + <property name="statusTip"> + <string>Go back to previous directory</string> + </property> + </action> + <action name="actionUp"> + <property name="text"> + <string notr="true">Up</string> + </property> + <property name="iconText"> + <string>Up</string> + </property> + <property name="toolTip"> + <string>Go to parent directory</string> + </property> + <property name="statusTip"> + <string>Go to parent directory</string> + </property> + </action> + <action name="actionHome"> + <property name="text"> + <string notr="true">Home</string> + </property> + <property name="iconText"> + <string>Home</string> + </property> + <property name="toolTip"> + <string>Go to home directory</string> + </property> + <property name="statusTip"> + <string>Go to home directory</string> + </property> + </action> + <action name="actionStopLoad"> + <property name="text"> + <string notr="true"/> + </property> + <property name="statusTip"> + <string>Stopl loading the directory</string> + </property> + </action> + <action name="actionClose_Browser"> + <property name="text"> + <string notr="true">Close Browser</string> + </property> + <property name="iconText"> + <string notr="true">Close Browser</string> + </property> + <property name="toolTip"> + <string>Close this browser</string> + </property> + <property name="statusTip"> + <string>Close this browser</string> + </property> + </action> </widget> <resources/> <connections/> diff --git a/lumina-fm/widgets/MultimediaWidget.cpp b/lumina-fm/widgets/MultimediaWidget.cpp index 9622a97b..406f9098 100644 --- a/lumina-fm/widgets/MultimediaWidget.cpp +++ b/lumina-fm/widgets/MultimediaWidget.cpp @@ -47,9 +47,12 @@ MultimediaWidget::~MultimediaWidget(){ // ================ // PUBLIC SLOTS // ================ -void MultimediaWidget::LoadMultimedia(QList<LFileInfo> list){ +void MultimediaWidget::ClearPlaylist(){ mediaObj->stop(); ui->combo_player_list->clear(); +} + +void MultimediaWidget::LoadMultimedia(QList<LFileInfo> list){ for(int i=0; i<list.length(); i++){ if(list[i].isAVFile()){ ui->combo_player_list->addItem(list[i].fileName(), list[i].absoluteFilePath() ); } } diff --git a/lumina-fm/widgets/MultimediaWidget.h b/lumina-fm/widgets/MultimediaWidget.h index 65769d77..4dc92e39 100644 --- a/lumina-fm/widgets/MultimediaWidget.h +++ b/lumina-fm/widgets/MultimediaWidget.h @@ -27,6 +27,7 @@ public: ~MultimediaWidget(); public slots: + void ClearPlaylist(); void LoadMultimedia(QList<LFileInfo> list); //Theme change functions diff --git a/lumina-fm/widgets/SlideshowWidget.cpp b/lumina-fm/widgets/SlideshowWidget.cpp index ff7113b6..a9028d2b 100644 --- a/lumina-fm/widgets/SlideshowWidget.cpp +++ b/lumina-fm/widgets/SlideshowWidget.cpp @@ -12,7 +12,7 @@ SlideshowWidget::SlideshowWidget(QWidget *parent) : QWidget(parent), ui(new Ui::SlideshowWidget){ ui->setupUi(this); //load the designer file - + zoom = 1; UpdateIcons(); UpdateText(); } @@ -24,11 +24,21 @@ SlideshowWidget::~SlideshowWidget(){ // ================ // PUBLIC SLOTS // ================ +void SlideshowWidget::ClearImages(){ + ui->combo_image_name->clear(); +} + void SlideshowWidget::LoadImages(QList<LFileInfo> list){ - ui->combo_image_name->clear(); + int cmax = ui->combo_image_name->count(); //current number of items for(int i=0; i<list.length(); i++){ if(list[i].isImage()){ ui->combo_image_name->addItem(list[i].fileName(), list[i].absoluteFilePath() ); } } + //Now automatically show the first item from the batch of new ones + if(cmax < ui->combo_image_name->count()){ ui->combo_image_name->setCurrentIndex(cmax); } +} + +void SlideshowWidget::refresh(){ + UpdateImage(); } //Theme change functions @@ -40,6 +50,8 @@ void SlideshowWidget::UpdateIcons(){ ui->tool_image_remove->setIcon( LXDG::findIcon("edit-delete","") ); ui->tool_image_rotateleft->setIcon( LXDG::findIcon("object-rotate-left","") ); ui->tool_image_rotateright->setIcon( LXDG::findIcon("object-rotate-right","") ); + ui->tool_image_zoomin->setIcon( LXDG::findIcon("zoom-in","") ); + ui->tool_image_zoomout->setIcon( LXDG::findIcon("zoom-out","") ); } void SlideshowWidget::UpdateText(){ @@ -51,15 +63,12 @@ void SlideshowWidget::UpdateText(){ // PRIVATE // ================= void SlideshowWidget::UpdateImage(){ - if( !ui->label_image->isVisible() ){ return; } //don't update if not visible - can cause strange resizing issues QString file = ui->combo_image_name->currentData().toString(); - /*if(!file.endsWith("/")){ file.append("/"); } - file.append(ui->combo_image_name->currentText());*/ - //qDebug() << "Show Image:" << file; + qDebug() << "Show Image:" << file << "Zoom:" << zoom; QPixmap pix(file); - if(pix.size().width() > ui->label_image->contentsRect().width() || pix.size().height() > ui->label_image->contentsRect().height()){ - pix = pix.scaled(ui->label_image->contentsRect().size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); - } + QSize sz = ui->scrollArea->contentsRect().size(); + if( sz.width()>pix.size().width() || sz.height()>pix.size().height()){ sz = pix.size(); } //100% size already - apply zoom after this + pix = pix.scaled(sz*zoom, Qt::KeepAspectRatio, Qt::SmoothTransformation); ui->label_image->setPixmap(pix); //Now set/load the buttons ui->tool_image_goBegin->setEnabled(ui->combo_image_name->currentIndex()>0); @@ -77,6 +86,8 @@ void SlideshowWidget::UpdateImage(){ ui->tool_image_remove->setEnabled(isUserWritable); ui->tool_image_rotateleft->setEnabled(isUserWritable && canwrite); ui->tool_image_rotateright->setEnabled(isUserWritable && canwrite); + ui->tool_image_zoomin->setEnabled(zoom<2); + ui->tool_image_zoomout->setEnabled(zoom>0.25); } @@ -84,8 +95,9 @@ void SlideshowWidget::UpdateImage(){ // PRIVATE SLOTS // ================= // Picture rotation options -void SlideshowWidget::on_combo_image_name_indexChanged(int index){ +void SlideshowWidget::on_combo_image_name_currentIndexChanged(int index){ if(index>=0 && !ui->combo_image_name->currentData().toString().isEmpty()){ + zoom = 1; //always reset the zoom level when changing images UpdateImage(); } } @@ -144,3 +156,14 @@ void SlideshowWidget::on_tool_image_rotateright_clicked(){ //Now re-load the image in the UI UpdateImage(); } + +void SlideshowWidget::on_tool_image_zoomin_clicked(){ + zoom+=0.25; //change 25% every time + UpdateImage(); +} + +void SlideshowWidget::on_tool_image_zoomout_clicked(){ + zoom-=0.25; //change 25% every time + UpdateImage(); +} + diff --git a/lumina-fm/widgets/SlideshowWidget.h b/lumina-fm/widgets/SlideshowWidget.h index bd8a671d..3b9c70fd 100644 --- a/lumina-fm/widgets/SlideshowWidget.h +++ b/lumina-fm/widgets/SlideshowWidget.h @@ -24,8 +24,11 @@ public: ~SlideshowWidget(); public slots: + void ClearImages(); void LoadImages(QList<LFileInfo> list); + void refresh(); //Note: This should be called right after the widget becomes visible + //Theme change functions void UpdateIcons(); void UpdateText(); @@ -33,10 +36,11 @@ public slots: private: Ui::SlideshowWidget *ui; void UpdateImage(); + double zoom; private slots: // Picture rotation options - void on_combo_image_name_indexChanged(int index); + void on_combo_image_name_currentIndexChanged(int index); void on_tool_image_goEnd_clicked(); void on_tool_image_goNext_clicked(); void on_tool_image_goPrev_clicked(); @@ -46,6 +50,8 @@ private slots: void on_tool_image_remove_clicked(); void on_tool_image_rotateleft_clicked(); void on_tool_image_rotateright_clicked(); + void on_tool_image_zoomin_clicked(); + void on_tool_image_zoomout_clicked(); }; #endif
\ No newline at end of file diff --git a/lumina-fm/widgets/SlideshowWidget.ui b/lumina-fm/widgets/SlideshowWidget.ui index 82e203fd..d262d5ec 100644 --- a/lumina-fm/widgets/SlideshowWidget.ui +++ b/lumina-fm/widgets/SlideshowWidget.ui @@ -65,6 +65,45 @@ </widget> </item> <item> + <widget class="Line" name="line_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_image_zoomin"> + <property name="toolTip"> + <string>Zoom in</string> + </property> + <property name="statusTip"> + <string>Zoom in</string> + </property> + <property name="text"> + <string notr="true">...</string> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_image_zoomout"> + <property name="toolTip"> + <string>Zoom out</string> + </property> + <property name="statusTip"> + <string>Zoom out</string> + </property> + <property name="text"> + <string notr="true">...</string> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> <spacer name="verticalSpacer_2"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -80,31 +119,59 @@ </layout> </item> <item> - <widget class="QLabel" name="label_image"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="styleSheet"> - <string notr="true">QLabel{ background: grey; }</string> - </property> - <property name="frameShape"> - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Raised</enum> - </property> - <property name="text"> - <string notr="true"/> - </property> - <property name="scaledContents"> - <bool>false</bool> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> + <widget class="QScrollArea" name="scrollArea"> + <property name="widgetResizable"> + <bool>true</bool> </property> + <widget class="QWidget" name="scrollAreaWidgetContents"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>350</width> + <height>250</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <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> + <item> + <widget class="QLabel" name="label_image"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>QFrame::NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <property name="text"> + <string notr="true"/> + </property> + <property name="scaledContents"> + <bool>false</bool> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + </layout> + </widget> </widget> </item> </layout> |