/* LineInputDialog.h */

/* Copyright (C) 2011-2024 Michael Lugmair (Lucio Carreras)
 *
 * This file is part of sayonara player
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef LINEINPUTDIALOG_H
#define LINEINPUTDIALOG_H

#include "Gui/Utils/Widgets/Dialog.h"
#include "Utils/Pimpl.h"

UI_FWD(LineInputDialog)

namespace Gui
{
	class Completer;

	class LineInputDialog :
		public Dialog
	{
			Q_OBJECT
			UI_CLASS(LineInputDialog)
			PIMPL(LineInputDialog)

		public:
			enum ReturnValue
			{
				Ok = 0,
				Cancelled
			};

			LineInputDialog(const QString& title, const QString& infoText, const QString& inputText,
			                QWidget* parent = nullptr);
			LineInputDialog(const QString& title, const QString& infoText, QWidget* parent = nullptr);
			~LineInputDialog() override;

			void setHeaderText(const QString& text);
			void setInfoText(const QString& text);
			void setCompleterText(const QStringList& lst);

			[[nodiscard]] ReturnValue returnValue() const;

			[[nodiscard]] QString text() const;

			void setText(const QString& text);

			void setPlaceholderText(const QString& text);

			void showInfo(bool b, const QString& infoPrefix = QString());

			[[nodiscard]] bool wasAccepted() const;
			void setInvalidChars(const QList<QChar>& chars);

		private slots:
			void okClicked();
			void cancelClicked();
			void textEdited(const QString& text);

		protected:
			void showEvent(QShowEvent* e) override;
			void closeEvent(QCloseEvent* e) override;

		public:
			static QString getRenameFilename(QWidget* parent, const QString& oldName,
			                                 const QString& parentPath = QString());
			static QString getNewFilename(QWidget* parent, const QString& info, const QString& parentPath = QString());
	};
}

#endif // LINEINPUTDIALOG_H
