/*
 * Copyright (C) 2008  Martin Hostettler
 *
 * 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 2
 * 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 <https://www.gnu.org/licenses/>.
 *
 */

// simple UI integration for mini command system.

#include "mcmdsimplesite.h"

#include <QLabel>
#include <QPalette>
#include <QString>
#include <QTextEdit>
#include <QToolTip>

MCmdSimpleSite::MCmdSimpleSite(QLabel *p, QTextEdit *i) : promptWidget(p), inputWidget(i), open(false) { }

MCmdSimpleSite::MCmdSimpleSite() : promptWidget(nullptr), inputWidget(nullptr), open(false) { }

void MCmdSimpleSite::mCmdReady(const QString prompt, const QString def)
{
    if (!open)
        mini_msg_swap = inputWidget->toPlainText();
    open = true;
    promptWidget->setText(prompt);
    inputWidget->setText(def);
    promptWidget->show();
}

void MCmdSimpleSite::mCmdClose()
{
    open = false;
    inputWidget->setText(mini_msg_swap);
    promptWidget->hide();
}

bool MCmdSimpleSite::isActive() const { return open; }

void MCmdSimpleSite::setPrompt(QLabel *p) { promptWidget = p; }

void MCmdSimpleSite::setInput(QTextEdit *i) { inputWidget = i; }
