2018-09-01 01:04:15 +00:00
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
#include "assetlist.h"
|
|
|
|
|
2018-09-02 01:47:40 +00:00
|
|
|
#include <QAbstractButton>
|
2018-09-01 01:04:15 +00:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QBitmap>
|
|
|
|
#include <QComboBox>
|
2018-09-06 03:41:34 +00:00
|
|
|
#include <QDir>
|
2018-09-01 01:04:15 +00:00
|
|
|
#include <QFile>
|
2018-09-06 03:41:34 +00:00
|
|
|
#include <QFileInfo>
|
|
|
|
#include <QJsonDocument>
|
|
|
|
#include <QJsonObject>
|
2018-09-01 01:04:15 +00:00
|
|
|
#include <QTextStream>
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::EnableThemeDark()
|
|
|
|
{
|
|
|
|
ui->actionToggleDark->setIcon(QIcon(":/icons/data/icons/alexandru.stoica/sun_star [#1268].svg"));
|
|
|
|
|
2018-09-02 01:47:40 +00:00
|
|
|
//QFile file(":/css/data/css/style.qss");
|
|
|
|
//QFile file(":/css/data/css/DarkMonokai.qss");
|
|
|
|
QFile file(":/css/data/css/darkorange.qss");
|
|
|
|
//QFile file(":/css/data/css/darkstyle.qss");
|
|
|
|
//QFile file(":/css/data/css/QTDark.qss");
|
|
|
|
//QFile file(":/dark.qss");
|
|
|
|
file.open(QFile::ReadOnly | QFile::Text);
|
|
|
|
QTextStream stream(&file);
|
|
|
|
qApp->setStyleSheet(stream.readAll());
|
2018-09-01 01:04:15 +00:00
|
|
|
|
|
|
|
auto& children = this->children();
|
2018-09-02 01:47:40 +00:00
|
|
|
for( auto& child : children ) {
|
2018-09-01 01:04:15 +00:00
|
|
|
QAction* action = qobject_cast<QAction*>(child);
|
2018-09-02 01:47:40 +00:00
|
|
|
QAbstractButton* button = qobject_cast<QAbstractButton*>(child);
|
|
|
|
if( action ) {
|
2018-09-01 01:04:15 +00:00
|
|
|
auto icon = action->icon();
|
|
|
|
auto pixmap = icon.pixmap(icon.actualSize(QSize(32,32)));
|
|
|
|
const auto& mask = pixmap.createMaskFromColor(QColor("transparent"), Qt::MaskInColor);
|
|
|
|
pixmap.fill(QColor("white"));
|
|
|
|
pixmap.setMask(mask);
|
|
|
|
action->setIcon(QIcon(pixmap));
|
2018-09-02 01:47:40 +00:00
|
|
|
} else if( button ) {
|
|
|
|
auto icon = button->icon();
|
|
|
|
auto pixmap = icon.pixmap(icon.actualSize(QSize(32,32)));
|
|
|
|
const auto& mask = pixmap.createMaskFromColor(QColor("transparent"), Qt::MaskInColor);
|
|
|
|
pixmap.fill(QColor("white"));
|
|
|
|
pixmap.setMask(mask);
|
|
|
|
button->setIcon(QIcon(pixmap));
|
2018-09-01 01:04:15 +00:00
|
|
|
}
|
|
|
|
}
|
2018-09-02 01:47:40 +00:00
|
|
|
|
|
|
|
//this->setWindowState(Qt::WindowMaximized);
|
2018-09-01 01:04:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::EnableThemeLight()
|
|
|
|
{
|
|
|
|
ui->actionToggleDark->setIcon(QIcon(":/icons/data/icons/alexandru.stoica/moon [#1248].svg"));
|
|
|
|
|
|
|
|
qApp->setStyleSheet("");
|
|
|
|
|
2018-09-02 01:47:40 +00:00
|
|
|
//QFile file(":/light.qss");
|
|
|
|
//file.open(QFile::ReadOnly | QFile::Text);
|
|
|
|
//QTextStream stream(&file);
|
|
|
|
//qApp->setStyleSheet(stream.readAll());
|
|
|
|
|
2018-09-01 01:04:15 +00:00
|
|
|
auto& children = this->children();
|
|
|
|
for( auto& child : children )
|
|
|
|
{
|
|
|
|
QAction* action = qobject_cast<QAction*>(child);
|
|
|
|
if( action )
|
|
|
|
{
|
|
|
|
auto icon = action->icon();
|
|
|
|
auto pixmap = icon.pixmap(icon.actualSize(QSize(32,32)));
|
|
|
|
const auto& mask = pixmap.createMaskFromColor(QColor("transparent"), Qt::MaskInColor);
|
|
|
|
pixmap.fill(QColor("black"));
|
|
|
|
pixmap.setMask(mask);
|
|
|
|
action->setIcon(QIcon(pixmap));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
2018-09-06 03:41:34 +00:00
|
|
|
|
|
|
|
void MainWindow::SetupDefineList()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::SetupDeclareList()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::LoadDefines( const QJsonDocument& document )
|
|
|
|
{
|
|
|
|
const QJsonValue& value = document.object()["defines"];
|
|
|
|
if( value.isArray()) {
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::LoadDeclarations( const QJsonDocument& document )
|
|
|
|
{
|
|
|
|
const QJsonValue& value = document.object()["declarations"];
|
|
|
|
if( value.isArray()) {
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::LoadConfigFile( const QString& configPath )
|
|
|
|
{
|
|
|
|
// If no initial config should run through a setup process.
|
|
|
|
// configPath should be stored in a project location, so shouldn't be created into a user specific directory.
|
|
|
|
QFileInfo fileInfo( configPath );
|
|
|
|
QFile file( configPath );
|
|
|
|
if( /*file.exists()*/ fileInfo.exists() && fileInfo.isFile() ) {
|
|
|
|
file.open(QFile::ReadOnly);
|
|
|
|
QJsonDocument document(QJsonDocument::fromJson(file.readAll()));
|
|
|
|
//QJsonObject object = document.object();
|
|
|
|
LoadDefines( document );
|
|
|
|
LoadDeclarations( document );
|
|
|
|
} else {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::SaveConfigFile( const QJsonDocument& jsonDocument, const QString& configPath )
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent) :
|
|
|
|
QMainWindow(parent),
|
|
|
|
ui(new Ui::MainWindow)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
/*connect( comboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [=](int index){
|
|
|
|
ui->stackedWidget_2->setCurrentIndex(index);
|
|
|
|
});
|
|
|
|
|
|
|
|
const int currentIndex = 0;
|
|
|
|
comboBox->setCurrentIndex(currentIndex);
|
|
|
|
ui->stackedWidget_2->setCurrentIndex(currentIndex);*/
|
|
|
|
|
|
|
|
/*const auto pOutputDock = new OutputDock();
|
|
|
|
pOutputDock->setMinimumHeight(50);
|
|
|
|
this->addDockWidget(Qt::BottomDockWidgetArea, pOutputDock->GetDock());
|
|
|
|
pOutputDock->setMinimumHeight(0);*/
|
|
|
|
|
|
|
|
//const QDir& dir = QDir::current();
|
|
|
|
const QString& path = QCoreApplication::applicationDirPath();
|
|
|
|
if( path.length() ) {
|
|
|
|
|
|
|
|
}
|
|
|
|
LoadConfigFile("bin/projectName.json");
|
|
|
|
|
|
|
|
const auto pDefineList = new AssetList();
|
|
|
|
pDefineList->setMinimumWidth(150);
|
|
|
|
this->addDockWidget(Qt::LeftDockWidgetArea, pDefineList);
|
|
|
|
pDefineList->setMinimumHeight(0);
|
|
|
|
pDefineList->setWindowTitle("Define");
|
|
|
|
|
|
|
|
const auto pDeclareList = new AssetList();
|
|
|
|
pDeclareList->setMinimumWidth(150);
|
|
|
|
this->addDockWidget(Qt::LeftDockWidgetArea, pDeclareList);
|
|
|
|
pDeclareList->setMinimumHeight(0);
|
|
|
|
pDeclareList->setWindowTitle("Declare");
|
|
|
|
|
|
|
|
QMainWindow::tabifyDockWidget(pDefineList, pDeclareList);
|
|
|
|
|
|
|
|
connect( ui->actionToggleDark, &QAction::triggered, [=](bool checked){
|
|
|
|
if( checked ) {
|
|
|
|
EnableThemeDark();
|
|
|
|
} else {
|
|
|
|
EnableThemeLight();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|