| 1 |
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* |
| 3 |
* This file is part of the LibreOffice project. |
| 4 |
* |
| 5 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 6 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 7 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 8 |
* |
| 9 |
* This file incorporates work covered by the following license notice: |
| 10 |
* |
| 11 |
* Licensed to the Apache Software Foundation (ASF) under one or more |
| 12 |
* contributor license agreements. See the NOTICE file distributed |
| 13 |
* with this work for additional information regarding copyright |
| 14 |
* ownership. The ASF licenses this file to you under the Apache |
| 15 |
* License, Version 2.0 (the "License"); you may not use this file |
| 16 |
* except in compliance with the License. You may obtain a copy of |
| 17 |
* the License at http://www.apache.org/licenses/LICENSE-2.0 . |
| 18 |
*/ |
| 19 |
|
| 20 |
#pragma once |
| 21 |
|
| 22 |
#include <QtCore/QObject> |
| 23 |
#include <QtCore/QString> |
| 24 |
#include <QtCore/QStringList> |
| 25 |
#include <QtCore/QHash> |
| 26 |
|
| 27 |
#include <sal/types.h> |
| 28 |
|
| 29 |
class QFileDialog; |
| 30 |
class QWidget; |
| 31 |
class QGridLayout; |
| 32 |
|
| 33 |
class KDE5FilePicker : public QObject |
| 34 |
{ |
| 35 |
Q_OBJECT |
| 36 |
protected: |
| 37 |
//the dialog to display |
| 38 |
QFileDialog* _dialog; |
| 39 |
|
| 40 |
//running filter string to add to dialog |
| 41 |
QStringList _filters; |
| 42 |
// map of filter titles to full filter for selection |
| 43 |
QHash<QString, QString> _titleToFilters; |
| 44 |
// string to set the current filter |
| 45 |
QString _currentFilter; |
| 46 |
|
| 47 |
//mapping of SAL control ID's to created custom controls |
| 48 |
QHash<sal_Int16, QWidget*> _customWidgets; |
| 49 |
|
| 50 |
//widget to contain extra custom controls |
| 51 |
QWidget* _extraControls; |
| 52 |
|
| 53 |
//layout for extra custom controls |
| 54 |
QGridLayout* _layout; |
| 55 |
|
| 56 |
sal_uInt64 _winId; |
| 57 |
|
| 58 |
public: |
| 59 |
explicit KDE5FilePicker(QObject* parent = nullptr); |
| 60 |
~KDE5FilePicker() override; |
| 61 |
|
| 62 |
void enableFolderMode(); |
| 63 |
|
| 64 |
// XExecutableDialog functions |
| 65 |
void setTitle(const QString& rTitle); |
| 66 |
bool execute(); |
| 67 |
|
| 68 |
// XFilePicker functions |
| 69 |
void setMultiSelectionMode(bool bMode); |
| 70 |
void setDefaultName(const QString& rName); |
| 71 |
void setDisplayDirectory(const QString& rDirectory); |
| 72 |
QString getDisplayDirectory() const; |
| 73 |
|
| 74 |
// XFilterManager functions |
| 75 |
void appendFilter(const QString& rTitle, const QString& rFilter); |
| 76 |
void setCurrentFilter(const QString& rTitle); |
| 77 |
QString getCurrentFilter() const; |
| 78 |
|
| 79 |
// XFilePickerControlAccess functions |
| 80 |
void setValue(sal_Int16 nControlId, sal_Int16 nControlAction, bool rValue); |
| 81 |
bool getValue(sal_Int16 nControlId, sal_Int16 nControlAction) const; |
| 82 |
void enableControl(sal_Int16 nControlId, bool bEnable); |
| 83 |
void setLabel(sal_Int16 nControlId, const QString& rLabel); |
| 84 |
QString getLabel(sal_Int16 nControlId) const; |
| 85 |
|
| 86 |
// XFilePicker2 functions |
| 87 |
QList<QUrl> getSelectedFiles() const; |
| 88 |
|
| 89 |
// XInitialization |
| 90 |
void initialize(bool saveDialog); |
| 91 |
|
| 92 |
//add a custom control widget to the file dialog |
| 93 |
void addCheckBox(sal_Int16 nControlId, const QString& label, bool hidden); |
| 94 |
|
| 95 |
void setWinId(sal_uInt64 winId); |
| 96 |
|
| 97 |
private: |
| 98 |
Q_DISABLE_COPY(KDE5FilePicker) |
| 99 |
// adds the custom controls to the dialog |
| 100 |
void setupCustomWidgets(); |
| 101 |
|
| 102 |
protected: |
| 103 |
bool eventFilter(QObject* watched, QEvent* event) override; |
| 104 |
|
| 105 |
Q_SIGNALS: |
| 106 |
void filterChanged(); |
| 107 |
void selectionChanged(); |
| 108 |
}; |
| 109 |
|
| 110 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |