diff options
-rw-r--r-- | lumina-fm/MainUI.cpp | 16 | ||||
-rw-r--r-- | lumina-fm/MainUI.h | 3 | ||||
-rw-r--r-- | lumina-fm/MainUI.ui | 19 |
3 files changed, 37 insertions, 1 deletions
diff --git a/lumina-fm/MainUI.cpp b/lumina-fm/MainUI.cpp index 76b0d7d4..298c3ee6 100644 --- a/lumina-fm/MainUI.cpp +++ b/lumina-fm/MainUI.cpp @@ -159,6 +159,7 @@ void MainUI::setupIcons(){ ui->actionScan->setIcon( LXDG::findIcon("system-search","") ); //Browser page + ui->tool_addNewFile->setIcon( LXDG::findIcon("document-new","")); ui->tool_addToDir->setIcon( LXDG::findIcon("folder-new","") ); ui->tool_goToImages->setIcon( LXDG::findIcon("fileview-preview","") ); ui->tool_goToPlayer->setIcon( LXDG::findIcon("applications-multimedia","") ); @@ -445,6 +446,7 @@ void MainUI::setCurrentDir(QString dir){ if(isUserWritable){ ui->label_dir_stats->setText(""); } else{ ui->label_dir_stats->setText(tr("Limited Access Directory")); } ui->tool_addToDir->setVisible(isUserWritable); + ui->tool_addNewFile->setVisible(isUserWritable); ui->actionUpDir->setEnabled(dir!="/"); ui->actionBack->setEnabled(history.length() > 1); ui->actionBookMark->setEnabled( rawdir!=QDir::homePath() && settings->value("bookmarks", QStringList()).toStringList().filter("::::"+rawdir).length()<1 ); @@ -848,6 +850,20 @@ void MainUI::on_tool_addToDir_clicked(){ } } +void MainUI::on_tool_addNewFile_clicked(){ + 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; } + QString full = getCurrentDir(); + if(!full.endsWith("/")){ full.append("/"); } + QDir dir(full); //open the current dir + QFile file(dir.filePath(newdocument)); + if (!file.open(QIODevice::ReadWrite)){ + QMessageBox::warning(this, tr("Error Creating Document"), tr("The document could not be created. Please ensure that you have the proper permissions.")); + } +} + void MainUI::tabChanged(int tab){ //Load the directory contained in the new tab qDebug() << "Change to Tab:" << tab << tabBar->tabText(tab); diff --git a/lumina-fm/MainUI.h b/lumina-fm/MainUI.h index d5775220..9b93b1d7 100644 --- a/lumina-fm/MainUI.h +++ b/lumina-fm/MainUI.h @@ -159,7 +159,8 @@ private slots: void reloadDirectory(); //Update the widget with the dir contents void currentDirectoryLoaded(); //The file system model re-loaded the directory void on_tool_addToDir_clicked(); - void tabChanged(int tab); + void on_tool_addNewFile_clicked(); + void tabChanged(int tab); void tabClosed(int tab = -1); void prevTab(); void nextTab(); diff --git a/lumina-fm/MainUI.ui b/lumina-fm/MainUI.ui index 66685532..8c954061 100644 --- a/lumina-fm/MainUI.ui +++ b/lumina-fm/MainUI.ui @@ -422,6 +422,25 @@ </widget> </item> <item> + <widget class="QToolButton" name="tool_addNewFile"> + <property name="statusTip"> + <string>Create a new file</string> + </property> + <property name="text"> + <string>New &file</string> + </property> + <property name="popupMode"> + <enum>QToolButton::InstantPopup</enum> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextBesideIcon</enum> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> <widget class="QToolButton" name="tool_addToDir"> <property name="focusPolicy"> <enum>Qt::NoFocus</enum> |