#pragma once

#include <QWidget>
#include "sqlitehelper.h"
#include "buttonstruct.h"
#include  <QVBoxLayout>
#include <QTableWidget>
#include <QTableWidgetItem>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QSvgWidget>
#include <QPushButton>
#include "minibutton.h"
#include <QLabel>
#include "qminiblink.h"
#include "ui_applicationmanager.h"
#include <QTabBar>
#include <QCheckBox>
class ApplicationManagerPage;

struct Record2
{
	/*QLabel *name;
	QLabel *orig_name;
	QLabel *dev;
	QLabel *use_time;*/
	QSvgWidget* icon;
	MiniButton* settings;
	MiniButton * open;
	QString orig_name;
	QString exe_file;
	QCheckBox *check_box;
	int sort;
	QString url;
	bool categories[8];
};

struct Title
{
	QLabel* name;
	QLabel* orig_name;
	QLabel* dev;
	QLabel* use_time;
	QLabel* op;
};
class ApplicationManager : public QWidget
{
	Q_OBJECT
signals:
	void changeUrl(QString url);
	void refresh();
public:
	ApplicationManager(QWidget *parent = nullptr);
	~ApplicationManager();
private:
	QHash<QHBoxLayout*,ApplicationManagerPage*> pages;
	QVBoxLayout* layout;
	QTabBar *tab_bar;
	QMap<int, ApplicationManagerPage*> map;
	QHBoxLayout* layout_top;
	QHBoxLayout* layout_bottom;
	QMiniBlink* miniblink;
	QList<MiniButton*> buttons;
	QList<Record> softwares;
	QList<ButtonStruct> button_structs;
	ApplicationManagerPage* application_manager_page_all;
	Ui::ApplicationManagerClass ui;
	SQLiteHelper sqlite_helper;
	QVBoxLayout *layout_bottom_top;
	QTableWidget *table;
	Title title;
public slots:
	void onclick1(QString op, QString func, QString path, QString url);
	void onclick2(QString orig_name, QString op);
	void tabChange(int index);
};
