From dd2e7baadb28a60b8581c7cc61a04a7699a94cea Mon Sep 17 00:00:00 2001 From: william os4y Date: Sun, 22 Feb 2015 19:56:13 +0100 Subject: add "New file" on lumina-fm --- lumina-fm/MainUI.cpp | 16 ++++++++++++++++ lumina-fm/MainUI.h | 3 ++- lumina-fm/MainUI.ui | 19 +++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) (limited to 'lumina-fm') diff --git a/lumina-fm/MainUI.cpp b/lumina-fm/MainUI.cpp index 1b01a855..72176e55 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","") ); @@ -442,6 +443,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 ); @@ -788,6 +790,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 ccc85f72..ba390cb0 100644 --- a/lumina-fm/MainUI.h +++ b/lumina-fm/MainUI.h @@ -157,7 +157,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 9dae7a56..5cdb35e8 100644 --- a/lumina-fm/MainUI.ui +++ b/lumina-fm/MainUI.ui @@ -421,6 +421,25 @@ + + + + Create a new file + + + New &file + + + QToolButton::InstantPopup + + + Qt::ToolButtonTextBesideIcon + + + true + + + -- cgit