bool QQnxFileDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) { Q_UNUSED(flags); Q_UNUSED(parent); Q_UNUSED(modality); qFileDialogHelperDebug() << Q_FUNC_INFO; // Create dialog const QSharedPointer<QFileDialogOptions> &opts = options(); if (opts->acceptMode() == QFileDialogOptions::AcceptOpen) { // Select one or many files? const QQnxFilePicker::Mode mode = (opts->fileMode() == QFileDialogOptions::ExistingFiles) ? QQnxFilePicker::PickerMultiple : QQnxFilePicker::Picker; m_dialog->setMode(mode); // Set the actual list of extensions if (!opts->nameFilters().isEmpty()) setNameFilters(opts->nameFilters()); else setNameFilter(tr("All files (*.*)")); } else { const QQnxFilePicker::Mode mode = (opts->initiallySelectedFiles().count() >= 2) ? QQnxFilePicker::SaverMultiple : QQnxFilePicker::Saver; m_dialog->setMode(mode); if (!opts->initiallySelectedFiles().isEmpty()) { QStringList files; Q_FOREACH ( const QUrl &url, opts->initiallySelectedFiles() ) files.append(url.toLocalFile()); m_dialog->setDefaultSaveFileNames(files); } }
void Commander::nameFilterChanged_(const std::string *str) { auto current = selections_.current(); if (!current) return; current->setNameFilter(*str); updated_(0, str); }
QNapiOpenDialog::QNapiOpenDialog(QWidget* parent, const QString& caption, const QString& init_path, FilterMode filterMode) : QFileDialog(parent), staticConfig(LibQNapi::staticConfig()) { setAttribute(Qt::WA_QuitOnClose, false); setWindowTitle(caption); if (filterMode == Movies) { setNameFilter(tr("Video files (%1);;All files (*.*)") .arg(staticConfig->movieExtensionsFilter())); } else if (filterMode == Subtitles) { setNameFilter(tr("Subtitles files (%1);;All files (*.*)") .arg(staticConfig->subtitleExtensionsFilter())); } if (QFileInfo(init_path).isDir()) setDirectory(init_path); else setDirectory(QDir::currentPath()); QStringList sideUrls; #ifdef Q_OS_MAC sideUrls << "/Volumes"; #endif sideUrls << QString(QDir::homePath() + "/Movies") << QString(QDir::homePath() + "/movies") << QString(QDir::homePath() + "/Video") << QString(QDir::homePath() + "/video") << QString(QDir::homePath() + "/Videos") << QString(QDir::homePath() + "/videos") << QString(QDir::homePath() + "/Filmy") << QString(QDir::homePath() + "/wideo"); QList<QUrl> urls = sidebarUrls(); foreach (QString sideUrl, sideUrls) { if (!QDir().exists(sideUrl)) continue; QUrl url = QUrl::fromLocalFile(sideUrl); if (!urls.contains(url)) urls << url; } setSidebarUrls(urls); }
FilesystemWidget::FilesystemWidget(QWidget *parent) { setParent(parent); // Create the toolbar QToolBar *fsToolbar = new QToolBar(); fsToolbar->setMovable(false); goUpAction = new QAction(IconFactory::fromTheme("go-up"), tr("Go up"), this); connect(goUpAction, SIGNAL(triggered()), this, SLOT(goUp())); fsToolbar->addAction(goUpAction); goHomeAction = new QAction(IconFactory::fromTheme("go-home"), tr("Go to the home folder"), this); connect(goHomeAction, SIGNAL(triggered()), this, SLOT(goHome())); fsToolbar->addAction(goHomeAction); // TODO: use placeholderText in Qt 4.7. filterEdit = new QLineEdit(); QLabel* filterLabel = new QLabel(tr("Filter:")); filterLabel->setContentsMargins(5, 0, 5, 0); fsToolbar->addSeparator(); fsToolbar->addWidget(filterLabel); fsToolbar->addWidget(filterEdit); connect(filterEdit, SIGNAL(textChanged(QString)), this, SLOT(setNameFilter(QString))); // Create the filesystem view fsWidgetModel = new QFileSystemModel(); fsWidgetModel->setNameFilterDisables(false); fsWidgetModel->setFilter(QDir::AllDirs|QDir::Files|QDir::NoDotAndDotDot); fsListView = new QListView(); fsListView->setSelectionMode(QAbstractItemView::ExtendedSelection); fsListView->setDragEnabled(true); fsListView->setModel(fsWidgetModel); // We shall use this to filter available file extensions from Phonon //fsWidgetModel->setFilter(getPhononExtensions()); connect(fsWidgetModel, SIGNAL(rootPathChanged(QString)), this, SLOT(pathChanged())); connect(fsListView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(doubleClickAt(QModelIndex))); // Create a new horizontal box QVBoxLayout *vlayout = new QVBoxLayout(); vlayout->addWidget(fsToolbar); vlayout->addWidget(fsListView); goHome(); this->setLayout(vlayout); }
void QQnxFileDialogHelper::selectNameFilter(const QString &filter) { qFileDialogHelperDebug() << Q_FUNC_INFO << "filter =" << filter; setNameFilter(filter); }
bool QQnxFileDialogHelper::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent) { Q_UNUSED(flags); qFileDialogHelperDebug() << Q_FUNC_INFO; QQnxBpsEventFilter *eventFilter = m_integration->bpsEventFilter(); // We *really* need the bps event filter ;) if (!eventFilter) return false; // Native dialogs can only handle application modal use cases so far if (modality != Qt::ApplicationModal) return false; // Tear down any existing dialog and start again as dialog mode may have changed if (m_dialog) { dialog_destroy(m_dialog); m_dialog = 0; } // Create dialog const QSharedPointer<QFileDialogOptions> &opts = options(); if (opts->acceptMode() == QFileDialogOptions::AcceptOpen) { if (dialog_create_filebrowse(&m_dialog) != BPS_SUCCESS) { qWarning("dialog_create_filebrowse failed"); return false; } // Select one or many files? bool multiSelect = (opts->fileMode() == QFileDialogOptions::ExistingFiles); dialog_set_filebrowse_multiselect(m_dialog, multiSelect); // Set the actual list of extensions if (!opts->nameFilters().isEmpty()) { qFileDialogHelperDebug() << "nameFilters =" << opts->nameFilters(); setNameFilter(opts->nameFilters().first()); } else { QString defaultNameFilter = QStringLiteral("*.*"); setNameFilter(defaultNameFilter); } } else { if (dialog_create_filesave(&m_dialog) != BPS_SUCCESS) { qWarning("dialog_create_filesave failed"); return false; } // Maybe pre-select a filename if (!opts->initiallySelectedFiles().isEmpty()) { QString fileName = opts->initiallySelectedFiles().first().toLocalFile(); dialog_set_filesave_filename(m_dialog, QFile::encodeName(fileName).constData()); } // Add OK and Cancel buttons. We add the buttons in the order "CANCEL" followed by "OK // such that they have indices matching the buttons on the file open dialog which // is automatically populated with buttons. if (dialog_add_button(m_dialog, tr("CANCEL").toLocal8Bit().constData(), true, 0, true) != BPS_SUCCESS) { qWarning("dialog_add_button failed"); return false; } if (dialog_add_button(m_dialog, tr("OK").toLocal8Bit().constData(), true, 0, true) != BPS_SUCCESS) { qWarning("dialog_add_button failed"); return false; } } // Cache the accept mode so we know which functions to use to get the results back m_acceptMode = opts->acceptMode(); // Set the libscreen window group and common properties QQnxScreen *nativeScreen = parent ? static_cast<QQnxScreen *>(parent->screen()->handle()) : m_integration->primaryDisplay(); Q_ASSERT(nativeScreen); dialog_set_group_id(m_dialog, nativeScreen->windowGroupName()); dialog_set_title_text(m_dialog, opts->windowTitle().toLocal8Bit().constData()); // Register ourselves for dialog domain events from bps eventFilter->registerForDialogEvents(this); // Show the dialog dialog_show(m_dialog); return true; }
void FilesystemWidget::setNameFilter() { setNameFilter(filterEdit->text()); }
void FilesystemWidget::updateWidget() { fsWidgetModel->setRootPath(dir.absolutePath()); fsListView->setRootIndex(fsWidgetModel->index(dir.absolutePath())); setNameFilter(); }