From 9c20a0fa59d8d08ed9af8ccc3a89f90aab3b7616 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 21 Jan 2015 10:34:16 -0500 Subject: Clean up all the dialog usage in the notepad and audioplay desktop plugins. Now the dialogs should not prevent the desktop from updating appropriately (not modal). --- .../desktop-plugins/audioplayer/PlayerWidget.cpp | 59 ++++++++++++++++++++-- .../desktop-plugins/notepad/NotepadPlugin.cpp | 4 +- 2 files changed, 56 insertions(+), 7 deletions(-) (limited to 'lumina-desktop/desktop-plugins') diff --git a/lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.cpp b/lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.cpp index ffd5df93..cc1136f1 100644 --- a/lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.cpp +++ b/lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.cpp @@ -13,6 +13,7 @@ #include #include #include +#include PlayerWidget::PlayerWidget(QWidget *parent) : QWidget(parent), ui(new Ui::PlayerWidget()){ ui->setupUi(this); //load the designer form @@ -93,9 +94,24 @@ void PlayerWidget::prevClicked(){ void PlayerWidget::AddFilesToPlaylist(){ //Prompt the user to select multimedia files + QFileDialog dlg(0, Qt::Dialog | Qt::WindowStaysOnTopHint ); + dlg.setFileMode(QFileDialog::ExistingFiles); + dlg.setAcceptMode(QFileDialog::AcceptOpen); + dlg.setNameFilter( tr("Multimedia Files")+" ("+LXDG::findAVFileExtensions().join(" ")+")"); + dlg.setWindowTitle(tr("Select Multimedia Files")); + dlg.setWindowIcon( LXDG::findIcon("file-open","") ); + dlg.setDirectory(QDir::homePath()); //start in the home directory + //ensure it is centered on the current screen + QPoint center = QApplication::desktop()->screenGeometry(this).center(); + dlg.move( center.x()-(dlg.width()/2), center.y()-(dlg.height()/2) ); + dlg.show(); + while( dlg.isVisible() ){ + QApplication::processEvents(); + } + QList files = dlg.selectedUrls(); + if(files.isEmpty() || dlg.result()!=QDialog::Accepted){ return; } //cancelled //Make this use show/processEvents later - QList files = QFileDialog::getOpenFileUrls(0, tr("Select Multimedia Files"), QDir::homePath(), "Multimedia Files ("+LXDG::findAVFileExtensions().join(" ")+")"); - if(files.isEmpty()){ return; } //cancelled + //QList files = QFileDialog::getOpenFileUrls(0, tr("Select Multimedia Files"), QDir::homePath(), "Multimedia Files ("+LXDG::findAVFileExtensions().join(" ")+")"); QList urls; for(int i=0; iscreenGeometry(this).center(); + dlg.move( center.x()-(dlg.width()/2), center.y()-(dlg.height()/2) ); + dlg.show(); + while( dlg.isVisible() ){ + QApplication::processEvents(); + } + if(dlg.result() != QDialog::Accepted){ return; } //cancelled + QStringList sel = dlg.selectedFiles(); + if(sel.isEmpty()){ return; } //cancelled + QString dirpath = sel.first(); //QFileDialog::getExistingDirectory(0, tr("Select a Multimedia Directory"), QDir::homePath() ); if(dirpath.isEmpty()){ return; } //cancelled QDir dir(dirpath); QFileInfoList files = dir.entryInfoList(LXDG::findAVFileExtensions(), QDir::Files | QDir::NoDotAndDotDot, QDir::Name); @@ -119,8 +152,24 @@ void PlayerWidget::AddDirToPlaylist(){ } void PlayerWidget::AddURLToPlaylist(){ - QString url = QInputDialog::getText(0, tr("Multimedia URL"), tr("Enter a valid URL for a multimedia file or stream"), QLineEdit::Normal); - if(url.isEmpty()){ return; } + QInputDialog dlg(0, Qt::Dialog | Qt::WindowStaysOnTopHint ); + dlg.setInputMode(QInputDialog::TextInput); + dlg.setLabelText(tr("Enter a valid URL for a multimedia file or stream:")); + dlg.setTextEchoMode(QLineEdit::Normal); + dlg.setWindowTitle(tr("Multimedia URL")); + dlg.setWindowIcon( LXDG::findIcon("download","") ); + //ensure it is centered on the current screen + QPoint center = QApplication::desktop()->screenGeometry(this).center(); + dlg.move( center.x()-(dlg.width()/2), center.y()-(dlg.height()/2) ); + dlg.show(); + while( dlg.isVisible() ){ + QApplication::processEvents(); + } + QString url = dlg.textValue(); + if(url.isEmpty() || dlg.result()!=QDialog::Accepted){ return; } //cancelled + + //QString url = QInputDialog::getText(0, tr("Multimedia URL"), tr("Enter a valid URL for a multimedia file or stream"), QLineEdit::Normal); + //if(url.isEmpty()){ return; } QUrl newurl(url); if(!newurl.isValid()){ return; } //invalid URL PLAYLIST->addMedia(newurl); diff --git a/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.cpp b/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.cpp index 17372202..af1c78f5 100644 --- a/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.cpp +++ b/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.cpp @@ -118,7 +118,7 @@ void NotePadPlugin::openNote(){ QApplication::processEvents(); } QStringList sel = dlg.selectedFiles(); - if(sel.isEmpty()){ return; } //cancelled + if(sel.isEmpty() || dlg.result()!=QDialog::Accepted){ return; } //cancelled QString fullpath = sel.first(); QString name = fullpath.section("/",-1); //qDebug() << " - Found Note:" << name << fullpath; @@ -156,7 +156,7 @@ void NotePadPlugin::newNote(){ QApplication::processEvents(); } QString name = dlg.textValue(); - if(name.isEmpty()){ return; } //cancelled + if(name.isEmpty() || dlg.result()!=QDialog::Accepted){ return; } //cancelled QString fullpath = QDir::homePath()+"/Notes/"+name; if(!fullpath.endsWith(".note")){ fullpath.append(".note"); } //qDebug() << " - New Note:" << name << fullpath; -- cgit