File indexing completed on 2024-04-28 17:05:53

0001 /*
0002     SPDX-FileCopyrightText: 2000 Shie Erlich <erlich@users.sourceforge.net>
0003     SPDX-FileCopyrightText: 2000 Rafi Yanai <yanai@users.sourceforge.net>
0004     SPDX-FileCopyrightText: 2004-2022 Krusader Krew <https://krusader.org>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #ifndef KRDIALOGS_H
0010 #define KRDIALOGS_H
0011 
0012 // QtCore
0013 #include <QDateTime>
0014 #include <QUrl>
0015 // QtWidgets
0016 #include <QCheckBox>
0017 #include <QComboBox>
0018 #include <QDialog>
0019 #include <QLabel>
0020 #include <QLayout>
0021 #include <QLineEdit>
0022 #include <QPushButton>
0023 // QtGui
0024 #include <QPixmap>
0025 
0026 #include <KIOWidgets/KFile>
0027 #include <KIOWidgets/KUrlRequesterDialog>
0028 #include <KWidgetsAddons/KAnimatedButton>
0029 #include <KWidgetsAddons/KDatePicker>
0030 
0031 /** \class KChooseDir
0032  * Used for asking the user for a folder.
0033  * example:
0034  * \code
0035  * QUrl u = KChooseDir::getDir("target folder", "/suggested/path", ACTIVE_PANEL->virtualPath());
0036  * if (u.isEmpty()) {
0037  *   // user canceled (either by pressing cancel, or esc
0038  * } else {
0039  *   // do you thing here: you've got a safe url to use
0040  * }
0041  * \endcode
0042  */
0043 class KChooseDir
0044 {
0045 public:
0046     struct ChooseResult {
0047         QUrl url;
0048         bool enqueue;
0049     };
0050 
0051     /**
0052      * \param text - description of the info requested from the user
0053      * \param url - a suggested url to appear in the box as a default choice
0054      * \param cwd - a path which is the current working directory (usually ACTIVE_PANEL->virtualPath()).
0055      *              this is used for completion of partial urls
0056      */
0057     static QUrl getFile(const QString &text, const QUrl &url, const QUrl &cwd);
0058     static QUrl getDir(const QString &text, const QUrl &url, const QUrl &cwd);
0059     static ChooseResult getCopyDir(const QString &text, const QUrl &url, const QUrl &cwd);
0060 
0061 private:
0062     static QUrl get(const QString &text, const QUrl &url, const QUrl &cwd, KFile::Modes mode);
0063 };
0064 
0065 class KUrlRequesterDlgForCopy : public QDialog
0066 {
0067     Q_OBJECT
0068 public:
0069     KUrlRequesterDlgForCopy(const QUrl &url, const QString &text, QWidget *parent, bool modal = true);
0070 
0071     QUrl selectedURL() const;
0072     bool isQueued()
0073     {
0074         return queueStart;
0075     }
0076 
0077     KUrlRequester *urlRequester();
0078 
0079 protected:
0080     void keyPressEvent(QKeyEvent *e) override;
0081 
0082 private slots:
0083     void slotQueueButtonClicked();
0084     void slotTextChanged(const QString &);
0085 
0086 private:
0087     KUrlRequester *urlRequester_;
0088     QPushButton *okButton;
0089     bool queueStart = false;
0090 };
0091 
0092 class KrGetDate : public QDialog
0093 {
0094     Q_OBJECT
0095 public:
0096     explicit KrGetDate(QDate date = QDate::currentDate(), QWidget *parent = nullptr);
0097     QDate getDate();
0098 
0099 private slots:
0100     void setDate(QDate);
0101 
0102 private:
0103     KDatePicker *dateWidget;
0104     QDate chosenDate, originalDate;
0105 };
0106 
0107 #endif