1 /***************************************************************************** 2 * Copyright (C) 2000 Shie Erlich <erlich@users.sourceforge.net> * 3 * Copyright (C) 2000 Rafi Yanai <yanai@users.sourceforge.net> * 4 * Copyright (C) 2004-2019 Krusader Krew [https://krusader.org] * 5 * * 6 * This file is part of Krusader [https://krusader.org]. * 7 * * 8 * Krusader is free software: you can redistribute it and/or modify * 9 * it under the terms of the GNU General Public License as published by * 10 * the Free Software Foundation, either version 2 of the License, or * 11 * (at your option) any later version. * 12 * * 13 * Krusader is distributed in the hope that it will be useful, * 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 * GNU General Public License for more details. * 17 * * 18 * You should have received a copy of the GNU General Public License * 19 * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * 20 *****************************************************************************/ 21 22 #ifndef KRDIALOGS_H 23 #define KRDIALOGS_H 24 25 // QtCore 26 #include <QDateTime> 27 #include <QUrl> 28 // QtWidgets 29 #include <QLineEdit> 30 #include <QCheckBox> 31 #include <QComboBox> 32 #include <QDialog> 33 #include <QLabel> 34 #include <QLayout> 35 #include <QPushButton> 36 // QtGui 37 #include <QPixmap> 38 39 #include <KWidgetsAddons/KAnimatedButton> 40 #include <KIOWidgets/KFile> 41 #include <KIOWidgets/KUrlRequesterDialog> 42 #include <KWidgetsAddons/KDatePicker> 43 44 /** \class KChooseDir 45 * Used for asking the user for a folder. 46 * example: 47 * \code 48 * QUrl u = KChooseDir::getDir("target folder", "/suggested/path", ACTIVE_PANEL->virtualPath()); 49 * if (u.isEmpty()) { 50 * // user canceled (either by pressing cancel, or esc 51 * } else { 52 * // do you thing here: you've got a safe url to use 53 * } 54 * \endcode 55 */ 56 class KChooseDir 57 { 58 public: 59 struct ChooseResult { 60 QUrl url; 61 bool enqueue; 62 }; 63 64 /** 65 * \param text - description of the info requested from the user 66 * \param url - a suggested url to appear in the box as a default choice 67 * \param cwd - a path which is the current working directory (usually ACTIVE_PANEL->virtualPath()). 68 * this is used for completion of partial urls 69 */ 70 static QUrl getFile(const QString &text, const QUrl &url, const QUrl &cwd); 71 static QUrl getDir(const QString &text, const QUrl &url, const QUrl &cwd); 72 static ChooseResult getCopyDir(const QString &text, const QUrl &url, const QUrl &cwd); 73 74 75 private: 76 static QUrl get(const QString &text, const QUrl &url, const QUrl &cwd, KFile::Modes mode); 77 }; 78 79 class KUrlRequesterDlgForCopy : public QDialog 80 { 81 Q_OBJECT 82 public: 83 KUrlRequesterDlgForCopy(const QUrl& url, const QString& text, QWidget *parent, 84 bool modal = true); 85 86 QUrl selectedURL() const; isQueued()87 bool isQueued() { return queueStart; } 88 89 KUrlRequester *urlRequester(); 90 91 protected: 92 virtual void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; 93 94 private slots: 95 void slotQueueButtonClicked(); 96 void slotTextChanged(const QString &); 97 98 private: 99 KUrlRequester *urlRequester_; 100 QPushButton *okButton; 101 bool queueStart = false; 102 }; 103 104 class KRGetDate : public QDialog 105 { 106 Q_OBJECT 107 public: 108 explicit KRGetDate(QDate date = QDate::currentDate(), QWidget *parent = 0); 109 QDate getDate(); 110 111 private slots: 112 void setDate(QDate); 113 114 private: 115 KDatePicker *dateWidget; 116 QDate chosenDate, originalDate; 117 }; 118 119 #endif 120