diff options
-rw-r--r-- | lumina-fm/widgets/DirWidget.cpp | 50 | ||||
-rw-r--r-- | lumina-fm/widgets/DirWidget.h | 2 | ||||
-rw-r--r-- | lumina-fm/widgets/DirWidget.ui | 26 | ||||
-rw-r--r-- | lumina-fm/widgets/SlideshowWidget.ui | 16 |
4 files changed, 91 insertions, 3 deletions
diff --git a/lumina-fm/widgets/DirWidget.cpp b/lumina-fm/widgets/DirWidget.cpp index 98589164..b13b73fa 100644 --- a/lumina-fm/widgets/DirWidget.cpp +++ b/lumina-fm/widgets/DirWidget.cpp @@ -11,6 +11,8 @@ #include <QCursor> #include <QClipboard> #include <QMimeData> +#include <QTimer> +#include <QInputDialog> #include <LuminaOS.h> #include <LuminaXDG.h> @@ -152,6 +154,8 @@ void DirWidget::LoadDir(QString dir, QList<LFileInfo> list){ //Hide the extra buttons for a moment ui->tool_goToPlayer->setVisible(false); ui->tool_goToImages->setVisible(false); + ui->tool_new_dir->setVisible(canmodify); + ui->tool_new_file->setVisible(canmodify); //Determine if this is an internal ZFS snapshot bool loadsnaps = false; if( dir.contains(ZSNAPDIR) ){ @@ -322,7 +326,9 @@ void DirWidget::UpdateIcons(){ ui->tool_snap_older->setIcon(LXDG::findIcon("go-previous-view","") ); //Bottom-Action Buttons ui->tool_goToImages->setIcon( LXDG::findIcon("fileview-preview","") ); - ui->tool_goToPlayer->setIcon( LXDG::findIcon("applications-multimedia","") ); + ui->tool_goToPlayer->setIcon( LXDG::findIcon("applications-multimedia","") ); + ui->tool_new_file->setIcon( LXDG::findIcon("document-new","") ); + ui->tool_new_dir->setIcon( LXDG::findIcon("folder-new","") ); //Side-Action Buttons ui->tool_act_run->setIcon( LXDG::findIcon("run-build-file","") ); ui->tool_act_runwith->setIcon( LXDG::findIcon("run-build-configure","") ); @@ -494,6 +500,48 @@ void DirWidget::on_tool_goToPlayer_clicked(){ } } +void DirWidget::on_tool_new_file_clicked(){ + if(!canmodify){ return; } //cannot create anything here + //Prompt for the new filename + bool ok = false; + QString newdocument = QInputDialog::getText(this, tr("New Document"), tr("Name:"), QLineEdit::Normal, "", \ + &ok, 0, Qt::ImhFormattedNumbersOnly | Qt::ImhUppercaseOnly | Qt::ImhLowercaseOnly); + if(!ok || newdocument.isEmpty()){ return; } + //Create the empty file + QString full = CDIR; + if(!full.endsWith("/")){ full.append("/"); } + QFile file(full+newdocument); + if(file.open(QIODevice::ReadWrite)){ + //If successfully opened, it has created a blank file + file.close(); + }else{ + QMessageBox::warning(this, tr("Error Creating Document"), tr("The document could not be created. Please ensure that you have the proper permissions.")); + } +} + +void DirWidget::on_tool_new_dir_clicked(){ + if(!canmodify){ return; } //cannot create anything here + //Prompt for the new dir name + bool ok = false; + QString newdir = QInputDialog::getText(this, tr("New Directory"), tr("Name:"), QLineEdit::Normal, "", \ + &ok, 0, Qt::ImhFormattedNumbersOnly | Qt::ImhUppercaseOnly | Qt::ImhLowercaseOnly); + if(!ok || newdir.isEmpty()){ return; } + //Now create the new dir + QString full = CDIR; + if(!full.endsWith("/")){ full.append("/"); } + QDir dir(full); //open the current dir + full.append(newdir); //append the new name to the current dir + //Verify that the new dir does not already exist + if(dir.exists(full)){ + QMessageBox::warning(this, tr("Invalid Name"), tr("A file or directory with that name already exists! Please pick a different name.")); + QTimer::singleShot(0,this, SLOT(on_tool_addToDir_clicked()) ); //repeat this function + }else{ + if(!dir.mkdir(newdir) ){ + QMessageBox::warning(this, tr("Error Creating Directory"), tr("The directory could not be created. Please ensure that you have the proper permissions to modify the current directory.")); + } + } +} + // -- Top Snapshot Buttons void DirWidget::on_tool_snap_newer_clicked(){ ui->slider_snap->setValue( ui->slider_snap->value()+1 ); diff --git a/lumina-fm/widgets/DirWidget.h b/lumina-fm/widgets/DirWidget.h index 193d1789..c5dab371 100644 --- a/lumina-fm/widgets/DirWidget.h +++ b/lumina-fm/widgets/DirWidget.h @@ -99,6 +99,8 @@ private slots: // -- Bottom Action Buttons void on_tool_goToImages_clicked(); void on_tool_goToPlayer_clicked(); + void on_tool_new_file_clicked(); + void on_tool_new_dir_clicked(); // -- Top Snapshot Buttons void on_tool_snap_newer_clicked(); void on_tool_snap_older_clicked(); diff --git a/lumina-fm/widgets/DirWidget.ui b/lumina-fm/widgets/DirWidget.ui index 42b4a075..a1fdca3d 100644 --- a/lumina-fm/widgets/DirWidget.ui +++ b/lumina-fm/widgets/DirWidget.ui @@ -45,6 +45,32 @@ </widget> </item> <item> + <widget class="QToolButton" name="tool_new_dir"> + <property name="statusTip"> + <string>Create a new directory</string> + </property> + <property name="text"> + <string>New Dir</string> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextBesideIcon</enum> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_new_file"> + <property name="statusTip"> + <string>Create a new file</string> + </property> + <property name="text"> + <string>New File</string> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextBesideIcon</enum> + </property> + </widget> + </item> + <item> <widget class="QToolButton" name="tool_goToImages"> <property name="statusTip"> <string>Add selected images to slideshow</string> diff --git a/lumina-fm/widgets/SlideshowWidget.ui b/lumina-fm/widgets/SlideshowWidget.ui index d262d5ec..cab4c5f9 100644 --- a/lumina-fm/widgets/SlideshowWidget.ui +++ b/lumina-fm/widgets/SlideshowWidget.ui @@ -14,6 +14,18 @@ <string>Form</string> </property> <layout class="QVBoxLayout" name="verticalLayout"> + <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> <layout class="QHBoxLayout" name="horizontalLayout_5"> <item> @@ -128,8 +140,8 @@ <rect> <x>0</x> <y>0</y> - <width>350</width> - <height>250</height> + <width>364</width> + <height>264</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_2"> |