[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: [PATCH]: getOpen[Save]FileNameWId
From: Taj Morton <taj-kde () wildgardenseed ! com>
Date: 2004-10-01 3:40:44
Message-ID: 415CD1BC.5090408 () wildgardenseed ! com
[Download RAW message or body]
Taj Morton wrote:
> This is my first patch, and don't know very much about Doxygen, sorry!
> I was copying the docs from KMessageBox::informationWId. Should I need
> to include the @param lines too (KMessageBox::informationWId doesn't).
>
> Thanks for the heads up. I'll wait little while and see if I get any
> more suggestions, then send another patch.
Find the patch attached.
Let me know if you have any more suggestions!
--
Taj
["kfiledialog.patch" (text/plain)]
? kfiledialog.patch
Index: kfiledialog.cpp
===================================================================
RCS file: /home/kde/kdelibs/kio/kfile/kfiledialog.cpp,v
retrieving revision 1.379
diff -u -r1.379 kfiledialog.cpp
--- kfiledialog.cpp 13 Sep 2004 11:48:26 -0000 1.379
+++ kfiledialog.cpp 1 Oct 2004 03:39:56 -0000
@@ -1318,6 +1318,26 @@
return dlg.selectedFile();
}
+QString KFileDialog::getOpenFileNameWId(const QString& startDir,
+ const QString& filter,
+ WId parent_id, const QString& caption)
+{
+ QWidget* parent = QWidget::find( parent_id );
+ KFileDialog dlg(startDir, filter, parent, "filedialog", true);
+ if( parent == NULL && parent_id != 0 )
+ XSetTransientForHint( qt_xdisplay(), dlg.winId(), parent_id );
+
+ dlg.setOperationMode( KFileDialog::Opening );
+
+ dlg.setMode( KFile::File | KFile::LocalOnly );
+ dlg.setCaption(caption.isNull() ? i18n("Open") : caption);
+
+ dlg.ops->clearHistory();
+ dlg.exec();
+
+ return dlg.selectedFile();
+}
+
QStringList KFileDialog::getOpenFileNames(const QString& startDir,
const QString& filter,
QWidget *parent,
@@ -1562,6 +1582,31 @@
return filename;
}
+QString KFileDialog::getSaveFileNameWId(const QString& dir, const QString& filter,
+ WId parent_id,
+ const QString& caption)
+{
+ bool specialDir = dir.at(0) == ':';
+ QWidget* parent = QWidget::find( parent_id );
+ KFileDialog dlg( specialDir ? dir : QString::null, filter, parent, "filedialog", true);
+ if( parent == NULL && parent_id != 0 )
+ XSetTransientForHint(qt_xdisplay(), dlg.winId(), parent_id);
+
+ if ( !specialDir )
+ dlg.setSelection( dir ); // may also be a filename
+
+ dlg.setOperationMode( KFileDialog::Saving);
+ dlg.setCaption(caption.isNull() ? i18n("Save As") : caption);
+
+ dlg.exec();
+
+ QString filename = dlg.selectedFile();
+ if (!filename.isEmpty())
+ KRecentDocument::add(filename);
+
+ return filename;
+}
+
KURL KFileDialog::getSaveURL(const QString& dir, const QString& filter,
QWidget *parent, const QString& caption)
{
Index: kfiledialog.h
===================================================================
RCS file: /home/kde/kdelibs/kio/kfile/kfiledialog.h,v
retrieving revision 1.153
diff -u -r1.153 kfiledialog.h
--- kfiledialog.h 10 Sep 2004 19:46:25 -0000 1.153
+++ kfiledialog.h 1 Oct 2004 03:39:57 -0000
@@ -408,6 +408,17 @@
const QString& caption = QString::null);
+ /**
+ * Use this version only if you have no QWidget available as
+ * parent widget. This can be the case if the parent widget is
+ * a widget in another process or if the parent widget is a
+ * non-Qt widget. For example, in a GTK program.
+ *
+ * @since 3.4
+ */
+ static QString getOpenFileNameWId(const QString& startDir,
+ const QString& filter,
+ WId parent_id=0, const QString& caption)
/**
* Creates a modal file dialog and returns the selected
@@ -536,6 +547,16 @@
const QString& filter= QString::null,
QWidget *parent= 0,
const QString& caption = QString::null);
+
+
+ /**
+ * This function accepts the window id of the parent window, instead
+ * of QWidget*. It should be used only when necessary.
+ * @since 3.4
+ */
+ static QString getSaveFileNameWId(const QString& dir, const QString& filter,
+ WId parent_id,
+ const QString& caption)
/**
* Creates a modal file dialog and returns the selected
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic