diff options
Diffstat (limited to 'lumina-fm/widgets')
-rw-r--r-- | lumina-fm/widgets/DirWidget.ui | 497 | ||||
-rw-r--r-- | lumina-fm/widgets/MultimediaWidget.cpp | 216 | ||||
-rw-r--r-- | lumina-fm/widgets/MultimediaWidget.h | 69 | ||||
-rw-r--r-- | lumina-fm/widgets/MultimediaWidget.ui | 181 | ||||
-rw-r--r-- | lumina-fm/widgets/SlideshowWidget.cpp | 146 | ||||
-rw-r--r-- | lumina-fm/widgets/SlideshowWidget.h | 51 | ||||
-rw-r--r-- | lumina-fm/widgets/SlideshowWidget.ui | 267 |
7 files changed, 1427 insertions, 0 deletions
diff --git a/lumina-fm/widgets/DirWidget.ui b/lumina-fm/widgets/DirWidget.ui new file mode 100644 index 00000000..8c683041 --- /dev/null +++ b/lumina-fm/widgets/DirWidget.ui @@ -0,0 +1,497 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>DirView</class> + <widget class="QWidget" name="DirView"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QGridLayout" name="gridLayout" columnstretch="0,1"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item row="0" column="0"> + <widget class="QStackedWidget" name="stackedWidget"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="page_dir"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <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="QGroupBox" name="group_actions"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string/> + </property> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <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="QToolButton" name="tool_act_run"> + <property name="toolTip"> + <string>Open item</string> + </property> + <property name="statusTip"> + <string>Open item</string> + </property> + <property name="text"> + <string notr="true"/> + </property> + <property name="iconSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonIconOnly</enum> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_act_runwith"> + <property name="toolTip"> + <string>Open item (select application)</string> + </property> + <property name="statusTip"> + <string>Open item (select application)</string> + </property> + <property name="text"> + <string notr="true"/> + </property> + <property name="iconSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="Line" name="line_5"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_act_fav"> + <property name="toolTip"> + <string>Add item to personal favorites</string> + </property> + <property name="statusTip"> + <string>Add item to personal favorites</string> + </property> + <property name="text"> + <string notr="true"/> + </property> + <property name="iconSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_act_rename"> + <property name="toolTip"> + <string>Rename item</string> + </property> + <property name="statusTip"> + <string>Rename item</string> + </property> + <property name="text"> + <string notr="true"/> + </property> + <property name="iconSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="Line" name="line_7"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_act_cut"> + <property name="toolTip"> + <string>Cut items</string> + </property> + <property name="statusTip"> + <string>Cut items (add to the clipboard)</string> + </property> + <property name="text"> + <string notr="true"/> + </property> + <property name="iconSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_act_copy"> + <property name="toolTip"> + <string>Copy items</string> + </property> + <property name="statusTip"> + <string>Copy items to the clipboard</string> + </property> + <property name="text"> + <string/> + </property> + <property name="iconSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_act_paste"> + <property name="toolTip"> + <string>Paste items from clipboard</string> + </property> + <property name="statusTip"> + <string>Paste items from clipboard</string> + </property> + <property name="text"> + <string notr="true"/> + </property> + <property name="iconSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="Line" name="line_6"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_act_rm"> + <property name="toolTip"> + <string>Delete Items</string> + </property> + <property name="statusTip"> + <string>Delete Items</string> + </property> + <property name="text"> + <string/> + </property> + <property name="iconSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <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> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="page_restore"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <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="QGroupBox" name="groupBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string/> + </property> + <layout class="QVBoxLayout" name="verticalLayout_5"> + <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="QToolButton" name="tool_restore"> + <property name="statusTip"> + <string>Restore File(s)</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_restore_over"> + <property name="statusTip"> + <string>Restore Files(s) (Overwrite any conflicting files)</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> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + <item row="0" column="1"> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <property name="spacing"> + <number>1</number> + </property> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <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>...</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_snap_newer"> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QTreeWidget" name="treeWidget"> + <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="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"> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QLabel" name="label_status"> + <property name="text"> + <string notr="true">Status</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="toolButton_5"> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="toolButton_6"> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/lumina-fm/widgets/MultimediaWidget.cpp b/lumina-fm/widgets/MultimediaWidget.cpp new file mode 100644 index 00000000..9622a97b --- /dev/null +++ b/lumina-fm/widgets/MultimediaWidget.cpp @@ -0,0 +1,216 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2015, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "MultimediaWidget.h" +#include "ui_MultimediaWidget.h" + +#include <QTimer> + +MultimediaWidget::MultimediaWidget(QWidget *parent) : QWidget(parent), ui(new Ui::MultimediaWidget){ + ui->setupUi(this); //load the designer file + + //Add in the special QMultimediaWidgets + mediaObj = new QMediaPlayer(this); + mediaObj->setVolume(100); + mediaObj->setNotifyInterval(500); //only every 1/2 second update + videoDisplay = new QVideoWidget(this); + videoDisplay->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + ui->videoLayout->addWidget(videoDisplay); + mediaObj->setVideoOutput(videoDisplay); + videoDisplay->setVisible(false); + + UpdateIcons(); + UpdateText(); + + //Connect the special signals/slots for the media object + connect(mediaObj, SIGNAL(durationChanged(qint64)), this, SLOT(playerDurationChanged(qint64)) ); + connect(mediaObj, SIGNAL(seekableChanged(bool)), ui->playerSlider, SLOT(setEnabled(bool)) ); + connect(mediaObj, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(playerStatusChanged(QMediaPlayer::MediaStatus)) ); + connect(mediaObj, SIGNAL(positionChanged(qint64)), this, SLOT(playerTimeChanged(qint64)) ); + connect(mediaObj, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(playerStateChanged(QMediaPlayer::State)) ); + connect(mediaObj, SIGNAL(videoAvailableChanged(bool)), this, SLOT(playerVideoAvailable(bool)) ); + connect(mediaObj, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(playerError()) ); + + //Disable some of the initial states + ui->tool_player_stop->setEnabled(false); //nothing to stop yet + ui->tool_player_pause->setVisible(false); //nothing to pause yet + ui->playerSlider->setEnabled(false); //nothing to seek yet +} + +MultimediaWidget::~MultimediaWidget(){ + +} + +// ================ +// PUBLIC SLOTS +// ================ +void MultimediaWidget::LoadMultimedia(QList<LFileInfo> list){ + mediaObj->stop(); + ui->combo_player_list->clear(); + for(int i=0; i<list.length(); i++){ + if(list[i].isAVFile()){ ui->combo_player_list->addItem(list[i].fileName(), list[i].absoluteFilePath() ); } + } +} + +//Theme change functions +void MultimediaWidget::UpdateIcons(){ + ui->tool_player_next->setIcon( LXDG::findIcon("media-skip-forward","") ); + ui->tool_player_prev->setIcon( LXDG::findIcon("media-skip-backward","") ); + ui->tool_player_pause->setIcon( LXDG::findIcon("media-playback-pause","") ); + ui->tool_player_play->setIcon( LXDG::findIcon("media-playback-start","") ); + ui->tool_player_stop->setIcon( LXDG::findIcon("media-playback-stop","") ); +} + +void MultimediaWidget::UpdateText(){ + ui->retranslateUi(this); +} + + +// ================= +// PRIVATE +// ================= +QString MultimediaWidget::msToText(qint64 ms){ + QString disp; + if(ms>3600000){ + disp.append( QString::number(ms/3600000)+":" ); + ms = ms%3600000; + } + if(ms>60000){ + disp.append( QString::number(ms/60000)+":" ); + ms = ms%60000; + }else{ + disp.append("0:"); + } + if(ms>1000){ + if(ms>=10000){ disp.append( QString::number(ms/1000) ); } + else{ disp.append( "0"+QString::number(ms/1000) ); } + }else{ + disp.append("00"); + } + return disp; +} + +// ================= +// PRIVATE SLOTS +// ================= +void MultimediaWidget::playerStatusChanged(QMediaPlayer::MediaStatus stat){ + //Only use this for end-of-file detection - use the state detection otherwise + if(stat == QMediaPlayer::EndOfMedia){ + if(!mediaObj->isMuted()){ playerFinished(); } //make sure it is not being seeked right now + } +} + +void MultimediaWidget::playerStateChanged(QMediaPlayer::State newstate){ + //This function keeps track of updating the visuals of the player + bool running = false; + bool showVideo = false; + QString msg; + switch(newstate){ + case QMediaPlayer::PlayingState: + running=true; + showVideo = mediaObj->isVideoAvailable(); + msg = "";//mediaObj->metaData(Phonon::TitleMetaData).join(" "); + if(msg.simplified().isEmpty()){ msg = ui->combo_player_list->currentText(); } + ui->label_player_novideo->setText(tr("Playing:")+"\n"+msg); + break; + case QMediaPlayer::PausedState: + showVideo=videoDisplay->isVisible(); //don't change the screen + break; + case QMediaPlayer::StoppedState: + ui->label_player_novideo->setText(tr("Stopped")); + break; + } + ui->tool_player_play->setVisible(!running); + ui->tool_player_pause->setVisible(running); + ui->tool_player_stop->setEnabled(running); + ui->label_player_novideo->setVisible(!showVideo); + videoDisplay->setVisible(showVideo); +} + +void MultimediaWidget::playerVideoAvailable(bool showVideo){ + ui->label_player_novideo->setVisible(!showVideo); + videoDisplay->setVisible(showVideo); +} + +void MultimediaWidget::playerDurationChanged(qint64 dur){ + if(dur < 0){ return; } //not ready yet + ui->playerSlider->setMaximum(mediaObj->duration()); + playerTTime = msToText(dur); +} + +void MultimediaWidget::playerTimeChanged(qint64 ctime){ + if(mediaObj->isMuted() || playerTTime.isEmpty() ){ return; } //currently being moved + ui->playerSlider->setSliderPosition(ctime); +} + +void MultimediaWidget::playerError(){ + QString msg = QString(tr("Error Playing File: %1")); + msg = msg.arg( mediaObj->currentMedia().canonicalUrl().fileName() ); + msg.append("\n"+mediaObj->errorString()); + ui->label_player_novideo->setText(msg); +} + +void MultimediaWidget::playerFinished(){ + if(ui->combo_player_list->currentIndex()<(ui->combo_player_list->count()-1) && ui->check_player_gotonext->isChecked()){ + ui->combo_player_list->setCurrentIndex( ui->combo_player_list->currentIndex()+1 ); + QTimer::singleShot(0,this,SLOT(playerStart())); + }else{ + ui->label_player_novideo->setText(tr("Finished")); + } +} + +void MultimediaWidget::on_tool_player_play_clicked(){ + if(mediaObj->state()==QMediaPlayer::PausedState \ + && mediaObj->currentMedia().canonicalUrl().fileName()==ui->combo_player_list->currentText() ){ + mediaObj->play(); + }else{ + mediaObj->stop(); + //Get the selected file path + QString filePath = ui->combo_player_list->currentData().toString(); + mediaObj->setMedia( QUrl::fromLocalFile(filePath) ); + playerTTime.clear(); + ui->playerSlider->setEnabled(mediaObj->isSeekable()); + mediaObj->play(); + } +} + +void MultimediaWidget::on_combo_player_list_currentIndexChanged(int index){ + ui->tool_player_next->setEnabled( ui->combo_player_list->count() > (index+1) ); + ui->tool_player_prev->setEnabled( (index-1) >= 0 ); +} + +void MultimediaWidget::on_tool_player_next_clicked(){ + ui->combo_player_list->setCurrentIndex( ui->combo_player_list->currentIndex()+1); + if(mediaObj->state()!=QMediaPlayer::StoppedState){ on_tool_player_play_clicked(); } +} + +void MultimediaWidget::on_tool_player_prev_clicked(){ + ui->combo_player_list->setCurrentIndex( ui->combo_player_list->currentIndex()-1); + if(mediaObj->state()!=QMediaPlayer::StoppedState){ on_tool_player_play_clicked(); } +} + +void MultimediaWidget::on_tool_player_pause_clicked(){ + mediaObj->pause(); +} + +void MultimediaWidget::on_tool_player_stop_clicked(){ + mediaObj->stop(); +} + +//Slider controls +void MultimediaWidget::on_playerSlider_sliderPressed(){ + mediaObj->setMuted(true); + mediaObj->pause(); +} +void MultimediaWidget::on_playerSlider_sliderReleased(){ + if(mediaObj->state()==QMediaPlayer::PausedState){ mediaObj->play(); } + mediaObj->setMuted(false); +} +void MultimediaWidget::on_playerSlider_valueChanged(int val){ + ui->label_player_runstats->setText( msToText(val)+"/"+playerTTime ); + if(mediaObj->isMuted()){ mediaObj->setPosition(val); } //currently seeking +} +
\ No newline at end of file diff --git a/lumina-fm/widgets/MultimediaWidget.h b/lumina-fm/widgets/MultimediaWidget.h new file mode 100644 index 00000000..65769d77 --- /dev/null +++ b/lumina-fm/widgets/MultimediaWidget.h @@ -0,0 +1,69 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2015, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#ifndef _LUMINA_FM_MULTIMEDIA_WIDGET_H +#define _LUMINA_FM_MULTIMEDIA_WIDGET_H + +#include <QList> +#include <QWidget> +#include <QObject> +#include <QMediaObject> +#include <QMediaPlayer> +#include <QVideoWidget> + +#include "../DirData.h" + +namespace Ui{ + class MultimediaWidget; +}; + +class MultimediaWidget : public QWidget{ + Q_OBJECT +public: + MultimediaWidget(QWidget *parent = 0); + ~MultimediaWidget(); + +public slots: + void LoadMultimedia(QList<LFileInfo> list); + + //Theme change functions + void UpdateIcons(); + void UpdateText(); + +private: + Ui::MultimediaWidget *ui; + QMediaPlayer *mediaObj; + QVideoWidget *videoDisplay; + QString playerTTime; //total time - to prevent recalculation every tick + + QString msToText(qint64 ms); + +private slots: + //Media Object functions + void playerStatusChanged(QMediaPlayer::MediaStatus stat); + void playerStateChanged(QMediaPlayer::State newstate); + void playerVideoAvailable(bool showVideo); + void playerDurationChanged(qint64 dur); + void playerTimeChanged(qint64 ctime); + void playerError(); + void playerFinished(); + + //The UI functions + void on_tool_player_play_clicked(); + void on_combo_player_list_currentIndexChanged(int index); + void on_tool_player_next_clicked(); + void on_tool_player_prev_clicked(); + void on_tool_player_pause_clicked(); + void on_tool_player_stop_clicked(); + + //Slider controls + void on_playerSlider_sliderPressed(); + void on_playerSlider_sliderReleased(); + void on_playerSlider_valueChanged(int val); + + +}; +#endif
\ No newline at end of file diff --git a/lumina-fm/widgets/MultimediaWidget.ui b/lumina-fm/widgets/MultimediaWidget.ui new file mode 100644 index 00000000..67805e13 --- /dev/null +++ b/lumina-fm/widgets/MultimediaWidget.ui @@ -0,0 +1,181 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MultimediaWidget</class> + <widget class="QWidget" name="MultimediaWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QCheckBox" name="check_player_gotonext"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Go To Next</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="Line" name="line_3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>30</width> + <height>0</height> + </size> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_player_prev"> + <property name="text"> + <string notr="true">prev</string> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="combo_player_list"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_player_next"> + <property name="text"> + <string notr="true">next</string> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="videoLayout"> + <item> + <widget class="QLabel" name="label_player_novideo"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="font"> + <font> + <pointsize>13</pointsize> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="styleSheet"> + <string notr="true">background: black; color: white;</string> + </property> + <property name="text"> + <string>(No Running Video)</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="videoControlLayout"> + <item> + <widget class="QToolButton" name="tool_player_play"> + <property name="text"> + <string notr="true">play</string> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_player_pause"> + <property name="text"> + <string notr="true">pause</string> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_player_stop"> + <property name="text"> + <string notr="true">stop</string> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="Line" name="line_4"> + <property name="minimumSize"> + <size> + <width>30</width> + <height>0</height> + </size> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QSlider" name="playerSlider"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_player_runstats"> + <property name="text"> + <string notr="true">?/?</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/lumina-fm/widgets/SlideshowWidget.cpp b/lumina-fm/widgets/SlideshowWidget.cpp new file mode 100644 index 00000000..ff7113b6 --- /dev/null +++ b/lumina-fm/widgets/SlideshowWidget.cpp @@ -0,0 +1,146 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2015, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "SlideshowWidget.h" +#include "ui_SlideshowWidget.h" + +#include <QImageWriter> +#include <QMessageBox> + +SlideshowWidget::SlideshowWidget(QWidget *parent) : QWidget(parent), ui(new Ui::SlideshowWidget){ + ui->setupUi(this); //load the designer file + + UpdateIcons(); + UpdateText(); +} + +SlideshowWidget::~SlideshowWidget(){ + +} + +// ================ +// PUBLIC SLOTS +// ================ +void SlideshowWidget::LoadImages(QList<LFileInfo> list){ + ui->combo_image_name->clear(); + for(int i=0; i<list.length(); i++){ + if(list[i].isImage()){ ui->combo_image_name->addItem(list[i].fileName(), list[i].absoluteFilePath() ); } + } +} + +//Theme change functions +void SlideshowWidget::UpdateIcons(){ + ui->tool_image_goBegin->setIcon( LXDG::findIcon("go-first-view","") ); + 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","") ); +} + +void SlideshowWidget::UpdateText(){ + ui->retranslateUi(this); +} + + +// ================= +// 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; + 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); + } + ui->label_image->setPixmap(pix); + //Now set/load the buttons + ui->tool_image_goBegin->setEnabled(ui->combo_image_name->currentIndex()>0); + ui->tool_image_goPrev->setEnabled(ui->combo_image_name->currentIndex()>0); + 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).toLower().toLocal8Bit()); //compare the suffix with the list + bool isUserWritable = QFileInfo(file).isWritable(); + ui->tool_image_remove->setEnabled(isUserWritable); + ui->tool_image_rotateleft->setEnabled(isUserWritable && canwrite); + ui->tool_image_rotateright->setEnabled(isUserWritable && canwrite); +} + + +// ================= +// PRIVATE SLOTS +// ================= +// Picture rotation options +void SlideshowWidget::on_combo_image_name_indexChanged(int index){ + if(index>=0 && !ui->combo_image_name->currentData().toString().isEmpty()){ + UpdateImage(); + } +} + +void SlideshowWidget::on_tool_image_goEnd_clicked(){ + ui->combo_image_name->setCurrentIndex( ui->combo_image_name->count()-1 ); +} + +void SlideshowWidget::on_tool_image_goNext_clicked(){ + ui->combo_image_name->setCurrentIndex( ui->combo_image_name->currentIndex()+1 ); +} + +void SlideshowWidget::on_tool_image_goPrev_clicked(){ + ui->combo_image_name->setCurrentIndex( ui->combo_image_name->currentIndex()-1 ); +} + +void SlideshowWidget::on_tool_image_goBegin_clicked(){ + ui->combo_image_name->setCurrentIndex(0); +} + +// Picture modification options +void SlideshowWidget::on_tool_image_remove_clicked(){ + QString file = ui->combo_image_name->currentData().toString(); + //Verify permanent removal of file/dir + if(QMessageBox::Yes != QMessageBox::question(this, tr("Verify Removal"), tr("WARNING: This will permanently delete the file from the system!")+"\n"+tr("Are you sure you want to continue?")+"\n\n"+file, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ){ + return; //cancelled + } + if( QFile::remove(file) ){ + int index = ui->combo_image_name->currentIndex(); + ui->combo_image_name->removeItem( index ); + } +} + +void SlideshowWidget::on_tool_image_rotateleft_clicked(){ + //First load the file fresh (not the scaled version in the UI) + QString file = ui->combo_image_name->currentData().toString(); + 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 + UpdateImage(); +} + +void SlideshowWidget::on_tool_image_rotateright_clicked(){ + //First load the file fresh (not the scaled version in the UI) + QString file = ui->combo_image_name->currentData().toString(); + 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 + UpdateImage(); +} diff --git a/lumina-fm/widgets/SlideshowWidget.h b/lumina-fm/widgets/SlideshowWidget.h new file mode 100644 index 00000000..70f9a29b --- /dev/null +++ b/lumina-fm/widgets/SlideshowWidget.h @@ -0,0 +1,51 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2015, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#ifndef _LUMINA_FM_SLIDWSHOW_WIDGET_H +#define _LUMINA_FM_SLIDWSHOW_WIDGET_H + +#include <QList> +#include <QWidget> +#include <QObject> + +#include "../DirData.h" + +namespace Ui{ + class SlideshowWidget; +}; + +class SlideshowWidget : public QWidget{ + Q_OBJECT +public: + SlideshowWidget(QWidget *parent = 0); + ~SlideshowWidget(); + +public slots: + void LoadImages(QList<LFileInfo> list); + + //Theme change functions + void UpdateIcons(); + void UpdateText(); + +private: + Ui::SlideshowWidget *ui; + void UpdateImage(); + +private slots: + // Picture rotation options + void on_combo_image_name_indexChanged(int index); + void on_tool_image_goEnd_clicked(); + void on_tool_image_goNext_clicked(); + void on_tool_image_goPrev_clicked(); + void on_tool_image_goBegin_clicked(); + + // Picture modification options + void on_tool_image_remove_clicked(); + void on_tool_image_rotateleft_clicked(); + void on_tool_image_rotateright_clicked(); + +}; +#endif
\ No newline at end of file diff --git a/lumina-fm/widgets/SlideshowWidget.ui b/lumina-fm/widgets/SlideshowWidget.ui new file mode 100644 index 00000000..82e203fd --- /dev/null +++ b/lumina-fm/widgets/SlideshowWidget.ui @@ -0,0 +1,267 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>SlideshowWidget</class> + <widget class="QWidget" name="SlideshowWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <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"> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QToolButton" name="tool_image_goBegin"> + <property name="focusPolicy"> + <enum>Qt::NoFocus</enum> + </property> + <property name="toolTip"> + <string>Go to Beginning</string> + </property> + <property name="text"> + <string>...</string> + </property> + <property name="shortcut"> + <string>Shift+Left</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_image_goPrev"> + <property name="focusPolicy"> + <enum>Qt::NoFocus</enum> + </property> + <property name="toolTip"> + <string>Go to Previous</string> + </property> + <property name="text"> + <string>...</string> + </property> + <property name="shortcut"> + <string>Left</string> + </property> + </widget> + </item> + <item> + <widget class="Line" name="line"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="combo_image_name"> + <property name="font"> + <font> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="focusPolicy"> + <enum>Qt::StrongFocus</enum> + </property> + <property name="frame"> + <bool>true</bool> + </property> + <item> + <property name="text"> + <string>File Name</string> + </property> + </item> + </widget> + </item> + <item> + <widget class="QLabel" name="label_image_index"> + <property name="text"> + <string notr="true">1/10</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="Line" name="line_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_image_goNext"> + <property name="focusPolicy"> + <enum>Qt::NoFocus</enum> + </property> + <property name="toolTip"> + <string>Go to Next</string> + </property> + <property name="text"> + <string>...</string> + </property> + <property name="shortcut"> + <string>Right</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_image_goEnd"> + <property name="focusPolicy"> + <enum>Qt::NoFocus</enum> + </property> + <property name="toolTip"> + <string>Go to End</string> + </property> + <property name="text"> + <string>...</string> + </property> + <property name="shortcut"> + <string>Shift+Right</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> |