Sayonara Player
LineInputDialog.h
1 /* LineInputDialog.h */
2 
3 /* Copyright (C) 2011-2020 Michael Lugmair (Lucio Carreras)
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef LINEINPUTDIALOG_H
22 #define LINEINPUTDIALOG_H
23 
24 #include "Gui/Utils/Widgets/Dialog.h"
25 #include "Utils/Pimpl.h"
26 
27 UI_FWD(LineInputDialog)
28 
29 namespace Gui
30 {
31  class Completer;
32 
40  public Dialog
41  {
42  Q_OBJECT
43  UI_CLASS(LineInputDialog)
44  PIMPL(LineInputDialog)
45 
46  public:
47  enum ReturnValue
48  {
49  Ok=0,
50  Cancelled
51  };
52 
53  LineInputDialog(const QString& title, const QString& infoText, const QString& inputText, QWidget* parent=nullptr);
54  LineInputDialog(const QString& title, const QString& infoText, QWidget* parent=nullptr);
55  virtual ~LineInputDialog() override;
56 
57  void setHeaderText(const QString& text);
58  void setInfoText(const QString& text);
59  void setCompleterText(const QStringList& lst);
60 
65  ReturnValue returnValue() const;
66 
71  QString text() const;
72 
77  void setText(const QString& text);
78 
79  void setPlaceholderText(const QString& text);
80 
81  void showInfo(bool b, const QString& infoPrefix=QString());
82 
87  bool wasAccepted() const;
88  void setInvalidChars(const QList<QChar>& chars);
89 
90  private slots:
91  void okClicked();
92  void cancelClicked();
93  void textEdited(const QString& text);
94 
95  protected:
96  void showEvent(QShowEvent* e) override;
97  void closeEvent(QCloseEvent* e) override;
98 
99  public:
100  static QString getRenameFilename(QWidget* parent, const QString& oldName, const QString& parentPath=QString());
101  static QString getNewFilename(QWidget* parent, const QString& info, const QString& parentPath=QString());
102  };
103 }
104 
105 #endif // LINEINPUTDIALOG_H
Gui::LineInputDialog::text
QString text() const
Return the entered text.
Gui::LineInputDialog::wasAccepted
bool wasAccepted() const
Convenience method for return_value() method.
Gui::LineInputDialog::returnValue
ReturnValue returnValue() const
returns if the dialog was closes by cancel or ok button
Gui::Dialog
Dialog with Settings connection. Also contains triggers for language_changed() and skin_changed()....
Definition: Dialog.h:37
QList
Definition: EngineUtils.h:33
Gui::LineInputDialog::setText
void setText(const QString &text)
Prefill the QLineEdit widget.
Gui::LineInputDialog
Dialog for entering one line. Listen for the sig_closed() signal for the Gui::Dialog class and reques...
Definition: LineInputDialog.h:41