QPrintDialog

Thomas Zander zander at kde.org
Fri May 30 07:51:40 BST 2008


On Thursday 29. May 2008 00:40:52 Craig Drummond wrote:
> 3. When printing to file, the QFileDialog is used to select the location. I
> noticed in qfiledialog.cpp the "_qt_filedialog_save_filename_hook" (etc.)
> variables, but these are marked as "Internal" (but are still exported). The
> attached kfiledialog.cpp.diff uses these "Internal" variables to override
> the Qt file dialog's with KDE ones. Are these safe to use? 

Yes, it is.

In Trolltech we added these to allow some companies as well as KDE to do 
exactly what you want;  show a KDE file dialog whenever some qt-only code 
shows the file dialog. (would be a great way to also get that ebn detector 
removed ;)

so, Qt has hooks for the file dialog.  Implementing those hooks in 
KApplication 
means that any and all code using QFileDialog will not actually show the Qt 
one, but do whatever KApplication implements.
Which naturally would be KFileDialog (at least on Unix).

If you are interrested in doing this, I'd be happy. I've been postponing 
looking at how to do this for some time.

Here are the signatures and dummy implementation;

typedef QString (*_qt_filedialog_existing_directory_hook)(QWidget *parent, 
const QString &caption, const QString &dir, QFileDialog::Options options);
extern Q_GUI_EXPORT _qt_filedialog_existing_directory_hook 
qt_filedialog_existing_directory_hook;
QString existing(QWidget *, const QString &, const QString &, 
QFileDialog::Options) {
    return "dir";
}

typedef QString (*_qt_filedialog_open_filename_hook)(QWidget * parent, const 
QString &caption, const QString &dir, const QString &filter, QString 
*selectedFilter, QFileDialog::Options options);
extern Q_GUI_EXPORT _qt_filedialog_open_filename_hook 
qt_filedialog_open_filename_hook;
QString openName(QWidget *, const QString &, const QString &, const QString &, 
QString *, QFileDialog::Options) {
    return "openName";
}

typedef QStringList (*_qt_filedialog_open_filenames_hook)(QWidget * parent, 
const QString &caption, const QString &dir, const QString &filter, QString 
*selectedFilter, QFileDialog::Options options);
extern Q_GUI_EXPORT _qt_filedialog_open_filenames_hook 
qt_filedialog_open_filenames_hook;
QStringList openNames(QWidget *, const QString &, const QString &, const 
QString &, QString *, QFileDialog::Options) {
    return QStringList("openNames");
}

typedef QString (*_qt_filedialog_save_filename_hook)(QWidget * parent, const 
QString &caption, const QString &dir, const QString &filter, QString 
*selectedFilter, QFileDialog::Options options);
extern Q_GUI_EXPORT _qt_filedialog_save_filename_hook 
qt_filedialog_save_filename_hook;
QString saveName(QWidget *, const QString &, const QString &, const QString &, 
QString *, QFileDialog::Options) {
    return "saveName";
}

-- 
Thomas Zander
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20080530/c8749e64/attachment.sig>


More information about the kde-core-devel mailing list