From 88507c36076b100e26a8e2c85533d667675f9daa Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Tue, 25 Aug 2015 15:43:53 -0400 Subject: 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 --- lumina-fm/widgets/DirWidget.cpp | 269 +++++++++++++++++++++----- lumina-fm/widgets/DirWidget.h | 49 ++++- lumina-fm/widgets/DirWidget.ui | 336 ++++++++++++++++++++++----------- lumina-fm/widgets/MultimediaWidget.cpp | 5 +- lumina-fm/widgets/MultimediaWidget.h | 1 + lumina-fm/widgets/SlideshowWidget.cpp | 43 ++++- lumina-fm/widgets/SlideshowWidget.h | 8 +- lumina-fm/widgets/SlideshowWidget.ui | 115 ++++++++--- 8 files changed, 627 insertions(+), 199 deletions(-) (limited to 'lumina-fm/widgets') 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 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; tsetText(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 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 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 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 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; tsetText(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; iactionStopLoad->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 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 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 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 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; ttreeWidget->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; igroup_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 #include #include +#include +#include +#include +#include + #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 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 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 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 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); //open in multimedia player - void ViewFiles(QList); //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 @@ 0 0 400 - 333 + 334 Form - + - 1 + 0 - 1 + 0 - 1 + 0 + 0 + + 1 - + 2 - + + + + + + + 1 + + + + + + + + true + + + + 1 + + + 1 + + + 1 + + + 1 + + + + + Snap + + + + + + + 1 + + + 1 + + + Qt::Horizontal + + + false + + + false + + + QSlider::TicksAbove + + + + + + + ... + + + + + + + ... + + + + + + + + + + Qt::CustomContextMenu + + + QAbstractItemView::ExtendedSelection + + + 0 + + + true + + + true + + + 30 + + + + 1 + + + + + + + + Qt::CustomContextMenu + + + QAbstractItemView::ExtendedSelection + + + QAbstractItemView::SelectItems + + + QListView::TopToBottom + + + true + + + + + + @@ -269,109 +395,7 @@ - - - - 1 - - - - - Snapshots Available - - - true - - - - 1 - - - 1 - - - 1 - - - 1 - - - - - Snap - - - - - - - 1 - - - 1 - - - Qt::Horizontal - - - false - - - false - - - QSlider::TicksAbove - - - - - - - ... - - - - - - - ... - - - - - - - - - - Qt::CustomContextMenu - - - QAbstractItemView::ExtendedSelection - - - - 1 - - - - - - - - Qt::CustomContextMenu - - - QAbstractItemView::ExtendedSelection - - - QAbstractItemView::SelectItems - - - - - - + @@ -382,21 +406,109 @@ + + Add selected images to slideshow + - img + Slideshow + + + + 20 + 20 + + + + Qt::ToolButtonTextBesideIcon + + Enqueue selection in multimedia player + - play + Play + + + + 20 + 20 + + + + Qt::ToolButtonTextBesideIcon + + + Back + + + Back + + + Go back to previous directory + + + Go back to previous directory + + + + + Up + + + Up + + + Go to parent directory + + + Go to parent directory + + + + + Home + + + Home + + + Go to home directory + + + Go to home directory + + + + + + + + Stopl loading the directory + + + + + Close Browser + + + Close Browser + + + Close this browser + + + Close this browser + + 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 list){ +void MultimediaWidget::ClearPlaylist(){ mediaObj->stop(); ui->combo_player_list->clear(); +} + +void MultimediaWidget::LoadMultimedia(QList list){ for(int i=0; icombo_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 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 list){ - ui->combo_image_name->clear(); + int cmax = ui->combo_image_name->count(); //current number of items for(int i=0; icombo_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 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 @@ -64,6 +64,45 @@ + + + + Qt::Horizontal + + + + + + + Zoom in + + + Zoom in + + + ... + + + true + + + + + + + Zoom out + + + Zoom out + + + ... + + + true + + + @@ -80,31 +119,59 @@ - - - - 0 - 0 - - - - QLabel{ background: grey; } - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - false - - - Qt::AlignCenter + + + true + + + + 0 + 0 + 350 + 250 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Raised + + + + + + false + + + Qt::AlignCenter + + + + + -- cgit