/*
 * Copyright (C) 2020, KylinSoft Co., Ltd.
 *
 * 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 <https://www.gnu.org/licenses/>.
 */
#ifndef SELECTION_H
#define SELECTION_H

#include <QWidget>
#include <QPushButton>
#include <QLayout>
#include <QLabel>
#include <QPropertyAnimation>
#include "mypushbutton.h"
#include "selectmorecommand.h"
#include <QDebug>
#include <QQuickWidget>
#include <QQuickItem>
#include <QMenu>
#include <QAction>
#include <QVariantList>
#include <QSettings>
#include <QDir>
#include <QAbstractListModel>
#include <QObject>
#include <QDebug>
#include <QToolTip>
#include <QEvent>

#include "commandtemplatelist.h"
#include "selectmorecommand.h"
#include "./global/kaglobal.h"
#include <kysdk/applications/kwidget.h>
#include <ukuistylehelper/ukuistylehelper.h>
#include <ukuiwindowhelper/ukuiwindowhelper.h>

using namespace kdk;

class SelectWidget : public KWidget
{
    Q_OBJECT
public:
    explicit SelectWidget(QWidget *parent = nullptr);
    void initQmlSelectWidget();
    void initSelectMoreCommandWidget();
    void initAnimation();
    void initMenu();
    void showSelectWidgetWithAnimation();
    bool isIncludeMenuPage(int x, int y);
    QString getButtonText();
    int getCurrentId();

    bool isIncludeMoreCommandWidget(int x, int y );
public slots:
    void showScribeWordsAtCursorPosition();
    void sendButtonText(const QString &currentButtonText, const int currentId);
    void slResizeRect(bool isMoreButtonPressed, const int width, const int height, const int moreCommandStartPos);
    void slShowToolTip(bool isShow);
    void slSettingButtonClicked();
    void slShowContextMenu();
    void closeWidgetAndinstructPage(int x, int y);
protected:
    bool eventFilter(QObject *o, QEvent *e);
    void moveEvent(QMoveEvent *event) override;

signals:
    void signalSendClicpText();
    void sigbuttontext();
    void sigHomePageShow();
    void sigSettingShow();
    void sigDisableScribe();
    void sigDisableMorePage();
    void sigUpdateModelAndSelectSize();

private:
    QHBoxLayout *m_hLayoutMain;
    QQuickWidget *m_quickWidget;
    QMenu *settingRightClickMenu = nullptr;
    QAction *sendAction = nullptr;
    QAction *homePageAction = nullptr;
    QAction *disableAction = nullptr;
    QAction *settingAction = nullptr;
    QAction *closeAction = nullptr;
    QAction *selectedAction = nullptr;
    QPropertyAnimation *m_animation = nullptr;
    QString buttonText;
    int promptId;
    int m_moreCommandStartPos =0;
    //更多指令
    SelectMoreCommandWidget *m_selectMoreCommandWidget = nullptr;

private:
    void insertText(const QString &text);
#ifdef UKUI_WINDOWHELPER_SUPPORT
    UkuiWindowHelper *m_ukuiWindowHelper = nullptr;
#endif



};



#endif // SELECTION_H

