#include "ExpandInput.h"
#include "../BackEnd/MainWidget.h"
#include "Widget/base/export.h"
#include <QAction>
#include <QPainter>
Expand_Input::Expand_Input(QWidget *parent) : QLineEdit(parent) {
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    setMinimumSize(0, 0);
    setFrame(false);
    font.setBold(true);
    renderive::Virtual_Keyboard::instance()->set_edit(this);
}

void Expand_Input::paintEvent(QPaintEvent *event) {
//    QPainter painter(this);
//    painter.fillRect(rect(), Qt::red);
//    painter.end();
    QLineEdit::paintEvent(event);
}

void Expand_Input::resizeEvent(QResizeEvent *event) {
    int pixel_size =  Global::instance()->adapt_height(60);
    QFont font = font;
    font.setPixelSize(pixel_size);
    setFont(font);
    QWidget::resizeEvent(event);
}

void Expand_Input::focusInEvent(QFocusEvent *event) {
    setStyleSheet("QLineEdit { border: 4px dashed gray; }");
    update();
    event->accept();
}

void Expand_Input::focusOutEvent(QFocusEvent *event) {
    setStyleSheet("QLineEdit { border: 0px dashed gray; }");
    QLineEdit::focusOutEvent(event);
}

void Expand_Input::keyPressEvent(QKeyEvent *event) {
    QLineEdit::keyPressEvent(event);
    event->ignore();
}

