aboutsummaryrefslogtreecommitdiff
path: root/lumina-fm
diff options
context:
space:
mode:
authorKen Moore <ken@pcbsd.org>2015-01-20 09:44:16 -0500
committerKen Moore <ken@pcbsd.org>2015-01-20 09:44:16 -0500
commitfbe891b0965c9ce786581df36ac67c95e3fceff5 (patch)
treedc07c948db770e4be39115a7127b8bc8048d9193 /lumina-fm
parentFix the global->local coordinates transformation for calculating whether the ... (diff)
downloadlumina-fbe891b0965c9ce786581df36ac67c95e3fceff5.tar.gz
lumina-fbe891b0965c9ce786581df36ac67c95e3fceff5.tar.bz2
lumina-fbe891b0965c9ce786581df36ac67c95e3fceff5.zip
Add a couple new features to how image files are handles in lumina-fm:
1) Add the ability to remove the current file loaded into the slideshow 2) Add the ability to rotate the current slideshow image by 90 degrees (clockwise or counterclockwise) and will re-save the file itself.
Diffstat (limited to 'lumina-fm')
-rw-r--r--lumina-fm/MainUI.cpp67
-rw-r--r--lumina-fm/MainUI.h3
-rw-r--r--lumina-fm/MainUI.ui169
3 files changed, 206 insertions, 33 deletions
diff --git a/lumina-fm/MainUI.cpp b/lumina-fm/MainUI.cpp
index f77d8290..289f2bb5 100644
--- a/lumina-fm/MainUI.cpp
+++ b/lumina-fm/MainUI.cpp
@@ -7,6 +7,8 @@
#include "MainUI.h"
#include "ui_MainUI.h"
+#include <QImageWriter>
+
MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){
ui->setupUi(this);
//Be careful about the QSettings setup, it must match the lumina-desktop setup
@@ -163,6 +165,9 @@ void MainUI::setupIcons(){
ui->tool_image_goEnd->setIcon( LXDG::findIcon("go-last-view","") );
ui->tool_image_goPrev->setIcon( LXDG::findIcon("go-previous-view","") );
ui->tool_image_goNext->setIcon( LXDG::findIcon("go-next-view","") );
+ 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","") );
//ZFS Restore page
ui->tool_zfs_nextSnap->setIcon( LXDG::findIcon("go-next-view","") );
@@ -218,6 +223,9 @@ void MainUI::setupConnections(){
connect(ui->tool_image_goEnd, SIGNAL(clicked()), this, SLOT(lastPicture()) );
connect(ui->tool_image_goNext, SIGNAL(clicked()), this, SLOT(nextPicture()) );
connect(ui->tool_image_goPrev, SIGNAL(clicked()), this, SLOT(prevPicture()) );
+ connect(ui->tool_image_remove, SIGNAL(clicked()), this, SLOT(removePicture()) );
+ connect(ui->tool_image_rotateleft, SIGNAL(clicked()), this, SLOT(rotatePictureLeft()) );
+ connect(ui->tool_image_rotateright, SIGNAL(clicked()), this, SLOT(rotatePictureRight()) );
//ZFS Restore page
connect(ui->slider_zfs_snapshot, SIGNAL(valueChanged(int)), this, SLOT(showSnapshot()) );
@@ -397,9 +405,9 @@ void MainUI::setCurrentDir(QString dir){
ui->tool_goToPlayer->setVisible(false);
ui->tool_goToRestore->setVisible(false);
ui->tool_goToImages->setVisible(false);
- if(olddir!=rawdir){
+ //if(olddir!=rawdir){
emit DirChanged(rawdir); //This will be automatically run when a new dir is loaded
- }
+ //}
if(isUserWritable){ ui->label_dir_stats->setText(""); }
else{ ui->label_dir_stats->setText(tr("Limited Access Directory")); }
ui->tool_addToDir->setVisible(isUserWritable);
@@ -556,7 +564,8 @@ void MainUI::goToBrowserPage(){
ui->menuExternal_Devices->setEnabled(true);
//Now go to the browser
if(ui->stackedWidget->currentWidget()==ui->page_audioPlayer){ mediaObj->stop(); }
- ui->stackedWidget->setCurrentWidget(ui->page_browser);
+ ui->stackedWidget->setCurrentWidget(ui->page_browser);
+ reloadDirectory();
}
//---------------------
@@ -715,6 +724,7 @@ void MainUI::currentDirectoryLoaded(){
ui->tool_goToRestore->setVisible(false);
ui->tool_goToImages->setVisible(false);
emit DirChanged(getCurrentDir());
+ ItemSelectionChanged();
}
void MainUI::on_tool_addToDir_clicked(){
@@ -863,6 +873,15 @@ void MainUI::showNewPicture(){
ui->tool_image_goEnd->setEnabled(ui->combo_image_name->currentIndex()<(ui->combo_image_name->count()-1));
ui->tool_image_goNext->setEnabled(ui->combo_image_name->currentIndex()<(ui->combo_image_name->count()-1));
ui->label_image_index->setText( QString::number(ui->combo_image_name->currentIndex()+1)+"/"+QString::number(ui->combo_image_name->count()) );
+ static QList<QByteArray> writeableformats;
+ if(writeableformats.isEmpty()){
+ writeableformats = QImageWriter::supportedImageFormats();
+ qDebug() << "Writeable image formats:" << writeableformats;
+ }
+ bool canwrite = writeableformats.contains(file.section(".",-1).toLocal8Bit()); //compare the suffix with the list
+ ui->tool_image_remove->setEnabled(isUserWritable);
+ ui->tool_image_rotateleft->setEnabled(isUserWritable && canwrite);
+ ui->tool_image_rotateright->setEnabled(isUserWritable && canwrite);
}
void MainUI::firstPicture(){
@@ -881,6 +900,46 @@ void MainUI::lastPicture(){
ui->combo_image_name->setCurrentIndex( ui->combo_image_name->count()-1 );
}
+void MainUI::removePicture(){
+ QString file = getCurrentDir();
+ if(!file.endsWith("/")){ file.append("/"); }
+ file.append(ui->combo_image_name->currentText());
+ if( QFile::remove(file) ){
+ ui->combo_image_name->removeItem( ui->combo_image_name->currentIndex() );
+ showNewPicture();
+ }
+}
+
+void MainUI::rotatePictureLeft(){
+ //First load the file fresh (not the scaled version in the UI)
+ QString file = getCurrentDir();
+ if(!file.endsWith("/")){ file.append("/"); }
+ file.append(ui->combo_image_name->currentText());
+ QPixmap pix(file);
+ //Now rotate the image 90 degrees counter-clockwise
+ QTransform trans;
+ pix = pix.transformed( trans.rotate(-90) , Qt::SmoothTransformation);
+ //Now save the image back to the same file
+ pix.save(file);
+ //Now re-load the image in the UI
+ showNewPicture();
+}
+
+void MainUI::rotatePictureRight(){
+ //First load the file fresh (not the scaled version in the UI)
+ QString file = getCurrentDir();
+ if(!file.endsWith("/")){ file.append("/"); }
+ file.append(ui->combo_image_name->currentText());
+ QPixmap pix(file);
+ //Now rotate the image 90 degrees counter-clockwise
+ QTransform trans;
+ pix = pix.transformed( trans.rotate(90) , Qt::SmoothTransformation);
+ //Now save the image back to the same file
+ pix.save(file);
+ //Now re-load the image in the UI
+ showNewPicture();
+}
+
//----------------------------------
//ZFS Restore Functions
//----------------------------------
@@ -1170,6 +1229,8 @@ void MainUI::RenameItem(){
dlg.show();
dlg.exec();
CItem.clear();
+
+ ItemSelectionChanged();
}
void MainUI::FavoriteItem(){
diff --git a/lumina-fm/MainUI.h b/lumina-fm/MainUI.h
index 7efc9faa..9dab45ed 100644
--- a/lumina-fm/MainUI.h
+++ b/lumina-fm/MainUI.h
@@ -170,6 +170,9 @@ private slots:
void prevPicture();
void nextPicture();
void lastPicture();
+ void removePicture();
+ void rotatePictureLeft();
+ void rotatePictureRight();
//ZFS Restore Functions
void snapshotLoaded();
diff --git a/lumina-fm/MainUI.ui b/lumina-fm/MainUI.ui
index 3102915a..9dae7a56 100644
--- a/lumina-fm/MainUI.ui
+++ b/lumina-fm/MainUI.ui
@@ -15,13 +15,22 @@
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout_2">
- <property name="margin">
+ <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="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
- <number>0</number>
+ <number>2</number>
</property>
<widget class="QWidget" name="page_browser">
<layout class="QGridLayout" name="gridLayout">
@@ -53,6 +62,18 @@
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
+ <property name="showDropIndicator" stdset="0">
+ <bool>true</bool>
+ </property>
+ <property name="dragEnabled">
+ <bool>true</bool>
+ </property>
+ <property name="dragDropMode">
+ <enum>QAbstractItemView::NoDragDrop</enum>
+ </property>
+ <property name="defaultDropAction">
+ <enum>Qt::IgnoreAction</enum>
+ </property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
@@ -96,6 +117,18 @@
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
+ <property name="showDropIndicator" stdset="0">
+ <bool>true</bool>
+ </property>
+ <property name="dragEnabled">
+ <bool>true</bool>
+ </property>
+ <property name="dragDropMode">
+ <enum>QAbstractItemView::NoDragDrop</enum>
+ </property>
+ <property name="defaultDropAction">
+ <enum>Qt::IgnoreAction</enum>
+ </property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
@@ -136,7 +169,16 @@
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
- <property name="margin">
+ <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>
@@ -643,32 +685,99 @@
<widget class="QWidget" name="page_image_view">
<layout class="QVBoxLayout" name="verticalLayout">
<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>
- </property>
- </widget>
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_4">
+ <item>
+ <widget class="QToolButton" name="tool_image_remove">
+ <property name="toolTip">
+ <string>Delete this image file</string>
+ </property>
+ <property name="text">
+ <string notr="true">...</string>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="Line" name="line_8">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="tool_image_rotateleft">
+ <property name="toolTip">
+ <string>Rotate this image file counter-clockwise</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_rotateright">
+ <property name="toolTip">
+ <string>Rotate this image file clockwise</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>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </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>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
@@ -977,7 +1086,7 @@
<x>0</x>
<y>0</y>
<width>567</width>
- <height>20</height>
+ <height>18</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
bgstack15