summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorTitta Heikkala <EXT-Titta.2.Heikkala@nokia.com>2010-11-15 10:19:59 (GMT)
committerJanne Koskinen <janne.p.koskinen@digia.com>2010-11-15 10:22:05 (GMT)
commit1f7ddb0525f7de24e195b2dd1a9f0374d19b2a05 (patch)
tree27618558799edffa2b55664f201403a37763c822 /src/gui
parentc7ad2de8f653c82ed26275d9a1791ebf2bb38644 (diff)
downloadQt-1f7ddb0525f7de24e195b2dd1a9f0374d19b2a05.zip
Qt-1f7ddb0525f7de24e195b2dd1a9f0374d19b2a05.tar.gz
Qt-1f7ddb0525f7de24e195b2dd1a9f0374d19b2a05.tar.bz2
Native file dialog on Symbian^3
The static functions in QFileDialog use native file dialog and not QFileDialog on Symbian^3. Task-number: QT-3917 Reviewed-by: Sami Merila Merge-request: 918 Reviewed-by: Sami Merila
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/dialogs/dialogs.pri13
-rw-r--r--src/gui/dialogs/qfiledialog.cpp72
-rw-r--r--src/gui/dialogs/qfiledialog_symbian.cpp202
3 files changed, 278 insertions, 9 deletions
diff --git a/src/gui/dialogs/dialogs.pri b/src/gui/dialogs/dialogs.pri
index 4e1b9a7..483e9aa 100644
--- a/src/gui/dialogs/dialogs.pri
+++ b/src/gui/dialogs/dialogs.pri
@@ -108,6 +108,19 @@ SOURCES += \
dialogs/qwizard.cpp \
dialogs/qprintpreviewdialog.cpp
+contains(QT_CONFIG, s60) {
+ LIBS += -lcommondialogs \
+ -lavkon \
+ -lplatformenv \
+ -lefsrv \
+ -lgdi
+ SOURCES += dialogs/qfiledialog_symbian.cpp \
+ dialogs/qcolordialog_symbian.cpp
+}
+
FORMS += dialogs/qpagesetupwidget.ui
RESOURCES += dialogs/qprintdialog.qrc
RESOURCES += dialogs/qmessagebox.qrc
+
+# Compensate for lack of platform defines in Symbian3
+symbian: DEFINES += SYMBIAN_VERSION_$$upper($$replace(SYMBIAN_VERSION,\\.,_))
diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp
index fc3c186..a5bff02 100644
--- a/src/gui/dialogs/qfiledialog.cpp
+++ b/src/gui/dialogs/qfiledialog.cpp
@@ -1616,6 +1616,25 @@ extern QStringList qt_win_get_open_file_names(const QFileDialogArgs &args,
extern QString qt_win_get_existing_directory(const QFileDialogArgs &args);
#endif
+/*
+ For Symbian file dialogs
+*/
+#if defined(Q_WS_S60) && defined(SYMBIAN_VERSION_SYMBIAN3)
+extern QString qtSymbianGetOpenFileName(const QString &caption,
+ const QString &dir,
+ const QString &filter);
+
+extern QStringList qtSymbianGetOpenFileNames(const QString &caption,
+ const QString &dir,
+ const QString &filter);
+
+extern QString qtSymbianGetSaveFileName(const QString &caption,
+ const QString &dir);
+
+extern QString qtSymbianGetExistingDirectory(const QString &caption,
+ const QString &dir);
+#endif
+
/*!
This is a convenience static function that returns an existing file
selected by the user. If the user presses Cancel, it returns a null string.
@@ -1644,8 +1663,8 @@ extern QString qt_win_get_existing_directory(const QFileDialogArgs &args);
The dialog's caption is set to \a caption. If \a caption is not specified
then a default caption will be used.
- On Windows and Mac OS X, this static function will use the native file
- dialog and not a QFileDialog.
+ On Windows, Mac OS X and Symbian^3, this static function will use the
+ native file dialog and not a QFileDialog.
On Windows the dialog will spin a blocking modal event loop that will not
dispatch any QTimers, and if \a parent is not 0 then it will position the
@@ -1657,6 +1676,10 @@ extern QString qt_win_get_existing_directory(const QFileDialogArgs &args);
\a options includes DontResolveSymlinks, the file dialog will treat
symlinks as regular directories.
+ On Symbian^3 the parameter \a selectedFilter has no meaning and the
+ \a options parameter is only used to define if the native file dialog is
+ used.
+
\warning Do not delete \a parent during the execution of the dialog. If you
want to do this, you should create the dialog yourself using one of the
QFileDialog constructors.
@@ -1672,6 +1695,11 @@ QString QFileDialog::getOpenFileName(QWidget *parent,
{
if (qt_filedialog_open_filename_hook && !(options & DontUseNativeDialog))
return qt_filedialog_open_filename_hook(parent, caption, dir, filter, selectedFilter, options);
+#if defined(Q_WS_S60)
+ if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0 && !(options & DontUseNativeDialog)) {
+ return qtSymbianGetOpenFileName(caption, dir, filter);
+ }
+#endif
QFileDialogArgs args;
args.parent = parent;
args.caption = caption;
@@ -1722,8 +1750,8 @@ QString QFileDialog::getOpenFileName(QWidget *parent,
The dialog's caption is set to \a caption. If \a caption is not specified
then a default caption will be used.
- On Windows and Mac OS X, this static function will use the native file
- dialog and not a QFileDialog.
+ On Windows, Mac OS X and Symbian^3, this static function will use the
+ native file dialog and not a QFileDialog.
On Windows the dialog will spin a blocking modal event loop that will not
dispatch any QTimers, and if \a parent is not 0 then it will position the
@@ -1741,6 +1769,10 @@ QString QFileDialog::getOpenFileName(QWidget *parent,
\snippet doc/src/snippets/code/src_gui_dialogs_qfiledialog.cpp 10
+ On Symbian^3 the parameter \a selectedFilter has no meaning and the
+ \a options parameter is only used to define if the native file dialog is
+ used.
+
\warning Do not delete \a parent during the execution of the dialog. If you
want to do this, you should create the dialog yourself using one of the
QFileDialog constructors.
@@ -1756,6 +1788,11 @@ QStringList QFileDialog::getOpenFileNames(QWidget *parent,
{
if (qt_filedialog_open_filenames_hook && !(options & DontUseNativeDialog))
return qt_filedialog_open_filenames_hook(parent, caption, dir, filter, selectedFilter, options);
+#if defined(Q_WS_S60)
+ if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0 && !(options & DontUseNativeDialog)) {
+ return qtSymbianGetOpenFileNames(caption, dir, filter);
+ }
+#endif
QFileDialogArgs args;
args.parent = parent;
args.caption = caption;
@@ -1813,8 +1850,8 @@ QStringList QFileDialog::getOpenFileNames(QWidget *parent,
The dialog's caption is set to \a caption. If \a caption is not specified,
a default caption will be used.
- On Windows and Mac OS X, this static function will use the native file
- dialog and not a QFileDialog.
+ On Windows, Mac OS X and Symbian^3, this static function will use the
+ native file dialog and not a QFileDialog.
On Windows the dialog will spin a blocking modal event loop that will not
dispatch any QTimers, and if \a parent is not 0 then it will position the
@@ -1827,6 +1864,10 @@ QStringList QFileDialog::getOpenFileNames(QWidget *parent,
\a options includes DontResolveSymlinks the file dialog will treat symlinks
as regular directories.
+ On Symbian^3 the parameters \a filter and \a selectedFilter have no
+ meaning. The \a options parameter is only used to define if the native file
+ dialog is used.
+
\warning Do not delete \a parent during the execution of the dialog. If you
want to do this, you should create the dialog yourself using one of the
QFileDialog constructors.
@@ -1842,6 +1883,11 @@ QString QFileDialog::getSaveFileName(QWidget *parent,
{
if (qt_filedialog_save_filename_hook && !(options & DontUseNativeDialog))
return qt_filedialog_save_filename_hook(parent, caption, dir, filter, selectedFilter, options);
+#if defined(Q_WS_S60)
+ if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0 && !(options & DontUseNativeDialog)) {
+ return qtSymbianGetSaveFileName(caption, dir);
+ }
+#endif
QFileDialogArgs args;
args.parent = parent;
args.caption = caption;
@@ -1890,9 +1936,9 @@ QString QFileDialog::getSaveFileName(QWidget *parent,
pass. To ensure a native file dialog, \l{QFileDialog::}{ShowDirsOnly} must
be set.
- On Windows and Mac OS X, this static function will use the native file
- dialog and not a QFileDialog. On Windows CE, if the device has no native
- file dialog, a QFileDialog will be used.
+ On Windows, Mac OS X and Symbian^3, this static function will use the
+ native file dialog and not a QFileDialog. On Windows CE, if the device has
+ no native file dialog, a QFileDialog will be used.
On Unix/X11, the normal behavior of the file dialog is to resolve and
follow symlinks. For example, if \c{/usr/tmp} is a symlink to \c{/var/tmp},
@@ -1904,6 +1950,9 @@ QString QFileDialog::getSaveFileName(QWidget *parent,
dispatch any QTimers, and if \a parent is not 0 then it will position the
dialog just below the parent's title bar.
+ On Symbian^3 the \a options parameter is only used to define if the native
+ file dialog is used.
+
\warning Do not delete \a parent during the execution of the dialog. If you
want to do this, you should create the dialog yourself using one of the
QFileDialog constructors.
@@ -1917,6 +1966,11 @@ QString QFileDialog::getExistingDirectory(QWidget *parent,
{
if (qt_filedialog_existing_directory_hook && !(options & DontUseNativeDialog))
return qt_filedialog_existing_directory_hook(parent, caption, dir, options);
+#if defined(Q_WS_S60)
+ if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0 && !(options & DontUseNativeDialog)) {
+ return qtSymbianGetExistingDirectory(caption, dir);
+ }
+#endif
QFileDialogArgs args;
args.parent = parent;
args.caption = caption;
diff --git a/src/gui/dialogs/qfiledialog_symbian.cpp b/src/gui/dialogs/qfiledialog_symbian.cpp
new file mode 100644
index 0000000..bd937a1
--- /dev/null
+++ b/src/gui/dialogs/qfiledialog_symbian.cpp
@@ -0,0 +1,202 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qfiledialog.h"
+
+#ifndef QT_NO_FILEDIALOG
+
+#include <private/qfiledialog_p.h>
+#if defined(Q_WS_S60) && defined(SYMBIAN_VERSION_SYMBIAN3)
+#include <driveinfo.h>
+#include <AknCommonDialogsDynMem.h>
+#include <CAknMemorySelectionDialogMultiDrive.h>
+#include <MAknFileFilter.h>
+#endif
+#include "private/qcore_symbian_p.h"
+
+QT_BEGIN_NAMESPACE
+
+enum DialogMode { DialogOpen, DialogSave, DialogFolder };
+#if defined(Q_WS_S60) && defined(SYMBIAN_VERSION_SYMBIAN3)
+class CExtensionFilter : public MAknFileFilter
+{
+public:
+ void setFilter(const QString filter)
+ {
+ filterList.clear();
+ if (filter.left(2) == "*.") {
+ //Filter has only extensions
+ filterList << filter.split(" ");
+ return;
+ }
+ else {
+ //Extensions are in parenthesis and there may be several filters
+ QStringList separatedFilters(filter.split(";;"));
+ for (int i = 0; i < separatedFilters.size(); i++) {
+ if (separatedFilters.at(i) == QFileDialog::tr("All Files (*)")){
+ filterList << QFileDialog::tr("All Files (*)");
+ return;
+ }
+ }
+ QRegExp rx("\\(([^\\)]*)\\)");
+ int pos = 0;
+ while ((pos = rx.indexIn(filter, pos)) != -1) {
+ filterList << rx.cap(1).split(" ");
+ pos += rx.matchedLength();
+ }
+ }
+ }
+
+ TBool Accept(const TDesC &/*aDriveAndPath*/, const TEntry &aEntry) const
+ {
+ if (aEntry.IsDir()) {
+ return ETrue;
+ }
+ if (filterList.isEmpty()) {
+ //No filter for files, all can be accepted
+ return ETrue;
+ }
+ if (filterList == QStringList(QFileDialog::tr("All Files (*)"))) {
+ return ETrue;
+ }
+ for (int i = 0; i < filterList.size(); ++i) {
+ QString extension = filterList.at(i);
+ //remove '*' from the beginning of the extension
+ if (extension.left(1) == "*"){
+ extension = extension.right(extension.size() - 1);
+ }
+ QString fileName = qt_TDesC2QString(aEntry.iName);
+ if (fileName.right(extension.size()) == extension) {
+ return ETrue;
+ }
+ }
+ return EFalse;
+ }
+
+private:
+ QStringList filterList;
+};
+#endif
+
+static QString launchSymbianDialog(const QString dialogCaption, const QString startDirectory,
+ const QString filter, DialogMode dialogMode)
+{
+ QString selection;
+#if defined(Q_WS_S60) && defined(SYMBIAN_VERSION_SYMBIAN3)
+ QT_TRAP_THROWING(
+ TFileName startFolder;
+ if (!startDirectory.isEmpty()) {
+ QString dir = QDir::toNativeSeparators(startDirectory);
+ startFolder = qt_QString2TPtrC(dir);
+ }
+ TInt types = AknCommonDialogsDynMem::EMemoryTypeMMCExternal|
+ AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage|
+ AknCommonDialogsDynMem::EMemoryTypePhone;
+
+ TPtrC titlePtr(qt_QString2TPtrC(dialogCaption));
+ TFileName target;
+ bool select = false;
+ if (dialogMode == DialogOpen) {
+ CExtensionFilter* extensionFilter = new (ELeave) CExtensionFilter;
+ CleanupStack::PushL(extensionFilter);
+ extensionFilter->setFilter(filter);
+ select = AknCommonDialogsDynMem::RunSelectDlgLD(types, target,
+ startFolder, NULL, NULL, titlePtr, extensionFilter);
+ CleanupStack::Pop(extensionFilter);
+ }
+ else if (dialogMode == DialogSave){
+ select = AknCommonDialogsDynMem::RunSaveDlgLD(types, target,
+ startFolder, NULL, NULL, titlePtr);
+ }
+ else if (dialogMode == DialogFolder){
+ select = AknCommonDialogsDynMem::RunFolderSelectDlgLD(types, target, startFolder,
+ 0, 0, titlePtr, NULL, NULL);
+ }
+ if (select) {
+ selection.append(qt_TDesC2QString(target));
+ }
+ );
+#endif
+ return selection;
+}
+
+QString qtSymbianGetOpenFileName(const QString &caption,
+ const QString &dir,
+ const QString &filter)
+{
+ return launchSymbianDialog(caption, dir, filter, DialogOpen);
+}
+
+QStringList qtSymbianGetOpenFileNames(const QString &caption,
+ const QString &dir,
+ const QString &filter)
+{
+ QString fileName;
+ fileName.append(launchSymbianDialog(caption, dir, filter, DialogOpen));
+ QStringList fileList;
+ fileList << fileName;
+
+ return fileList;
+}
+
+QString qtSymbianGetSaveFileName(const QString &caption,
+ const QString &dir)
+{
+ return launchSymbianDialog(caption, dir, QString(), DialogSave);
+}
+
+QString qtSymbianGetExistingDirectory(const QString &caption,
+ const QString &dir)
+{
+ QString folderCaption;
+ if (!caption.isEmpty()) {
+ folderCaption.append(caption);
+ }
+ else {
+ // Title for folder selection dialog is mandatory
+ folderCaption.append(QFileDialog::tr("Find Directory"));
+ }
+ return launchSymbianDialog(folderCaption, dir, QString(), DialogFolder);
+}
+
+QT_END_NAMESPACE
+
+#endif