Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
v1.2 dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
HZZcode authored Sep 28, 2024
1 parent 2c19be1 commit 46dedfd
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 87 deletions.
56 changes: 28 additions & 28 deletions CMakeLists.txt.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 14.0.1, 2024-09-27T17:51:07. -->
<!-- Written by QtCreator 14.0.1, 2024-09-28T22:29:41. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down Expand Up @@ -101,22 +101,22 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.7.2 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.7.2 MinGW 64-bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt6.672.win64_mingw_kit</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="CMake.Build.Type">Debug</value>
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_BUILD_TYPE:STRING=Debug
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_GENERATOR:STRING=Ninja</value>
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_BUILD_TYPE:STRING=Debug</value>
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\14354\Documents\Qt Projects\MicrologicIDE\build\Desktop_Qt_6_7_2_MinGW_64_bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
Expand Down Expand Up @@ -166,14 +166,14 @@
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_BUILD_TYPE:STRING=Release
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_GENERATOR:STRING=Ninja</value>
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_BUILD_TYPE:STRING=Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\14354\Documents\Qt Projects\MicrologicIDE\build\Desktop_Qt_6_7_2_MinGW_64_bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
Expand Down Expand Up @@ -222,14 +222,14 @@
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_GENERATOR:STRING=Ninja</value>
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\14354\Documents\Qt Projects\MicrologicIDE\build\Desktop_Qt_6_7_2_MinGW_64_bit-RelWithDebInfo</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
Expand Down Expand Up @@ -276,14 +276,14 @@
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_GENERATOR:STRING=Ninja</value>
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo</value>
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\14354\Documents\Qt Projects\MicrologicIDE\build\Desktop_Qt_6_7_2_MinGW_64_bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
Expand Down Expand Up @@ -331,14 +331,14 @@
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_BUILD_TYPE:STRING=MinSizeRel
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_GENERATOR:STRING=Ninja</value>
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_BUILD_TYPE:STRING=MinSizeRel</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\14354\Documents\Qt Projects\MicrologicIDE\build\Desktop_Qt_6_7_2_MinGW_64_bit-MinSizeRel</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
Expand Down Expand Up @@ -413,7 +413,7 @@
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">C:/Users/14354/Documents/Qt Projects/MicrologicIDE/build/Desktop_Qt_6_7_2_MinGW_64_bit-Debug</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">C:/Users/14354/Documents/Qt Projects/MicrologicIDE/build/Desktop_Qt_6_7_2_MinGW_64_bit-Release</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
Expand Down
119 changes: 79 additions & 40 deletions MicrologicIDE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@

std::string exepath="";

MicrologicIDE::MicrologicIDE(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MicrologicIDE)
{
MicrologicIDE::MicrologicIDE(QWidget *parent) : QMainWindow(parent), ui(new Ui::MicrologicIDE){
currentContent="";
path="";

ui->setupUi(this);
ui->textEdit->setDocumentTitle("untitled -- MicrologicIDE");
setWindowTitle(ui->textEdit->documentTitle());

lightMode();

debugger = new QFileSystemWatcher();
QByteArray b=(QString::fromStdString(exepath+"\\debug.log")+currentfileName).toLatin1();
debugger->addPath(b.data());
Expand All @@ -50,20 +49,21 @@ MicrologicIDE::MicrologicIDE(QWidget *parent) :
connect(ui->undoAction, &QAction::triggered, ui->textEdit, &QTextEdit::undo);
connect(ui->selectAllAction, &QAction::triggered, ui->textEdit, &QTextEdit::selectAll);

connect(ui->darkModeAction, &QAction::triggered, this, &MicrologicIDE::darkMode);
connect(ui->lightModeAction, &QAction::triggered, this, &MicrologicIDE::lightMode);

connect(ui->runAction, &QAction::triggered, this, &MicrologicIDE::runFile);
connect(debugger, SIGNAL(fileChanged(QString)), this, SLOT(updateDebug()));

connect(ui->textEdit, &QTextEdit::textChanged, this, &MicrologicIDE::makeMarks);

}

MicrologicIDE::~MicrologicIDE()
{
MicrologicIDE::~MicrologicIDE(){
delete ui;
}

void MicrologicIDE::newFile(void)
{
void MicrologicIDE::newFile(void){
switch (requestIsSave())
{
case QMessageBox::Yes :
Expand All @@ -88,8 +88,7 @@ void MicrologicIDE::newFile(void)
}
}

void MicrologicIDE::openFile(void)
{
void MicrologicIDE::openFile(void){
//saveDocumentText();
getDocumentText();
setDocumentTitile(currentfileName);
Expand All @@ -99,23 +98,20 @@ void MicrologicIDE::openFile(void)
}catch(...){}
}

void MicrologicIDE::saveFile(void)
{
void MicrologicIDE::saveFile(void){
QString tmpFileName = saveDocumentText();
setDocumentTitile(tmpFileName);
currentfileName = tmpFileName;
}

void MicrologicIDE::saveAsFile()
{
void MicrologicIDE::saveAsFile(){
QString tmpFileName = currentfileName;
currentfileName.clear();
saveDocumentText();
currentfileName = tmpFileName;
}

void MicrologicIDE::exitNotepad()
{
void MicrologicIDE::exitNotepad(){
switch (requestIsSave())
{
case QMessageBox::Yes :
Expand All @@ -133,8 +129,7 @@ void MicrologicIDE::exitNotepad()
}
}

void MicrologicIDE::doForAboutAction()
{
void MicrologicIDE::doForAboutAction(){
AboutDialog about;
about.exec();
}
Expand All @@ -144,15 +139,13 @@ void MicrologicIDE::setDateTime()
ui->textEdit->append(QDateTime::currentDateTime().toString());
}

void MicrologicIDE::seeHelp(void)
{
void MicrologicIDE::seeHelp(void){
QUrl url("https://github.com/HZZcode/MicrologicIDE");
QDesktopServices::openUrl(url);
}


QString MicrologicIDE::saveDocumentText(void)
{
QString MicrologicIDE::saveDocumentText(void){
QString fileName;
QFile file;
QTextStream *out;
Expand All @@ -177,8 +170,7 @@ QString MicrologicIDE::saveDocumentText(void)
return fileName;
}

void MicrologicIDE::getDocumentText()
{
void MicrologicIDE::getDocumentText(){
QString fileName;
QFile file;
QTextStream *in;
Expand All @@ -194,21 +186,18 @@ void MicrologicIDE::getDocumentText()
}
}

int MicrologicIDE::requestIsSave()
{
int MicrologicIDE::requestIsSave(){
int answer = QMessageBox::question(this, tr("MicrologicIDE"), tr("是否将更改保存?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
return answer;
}


void MicrologicIDE::setDocumentTitile(QString title)
{
void MicrologicIDE::setDocumentTitile(QString title){
ui->textEdit->setDocumentTitle(title);
setWindowTitle(ui->textEdit->documentTitle());
}

void MicrologicIDE::runFile()
{
void MicrologicIDE::runFile(){
qDebug()<<currentfileName;
QByteArray b=(QString::fromStdString("start /d \""+exepath+"\" Micrologic.exe ")+currentfileName).toLatin1();
system(b.data());
Expand All @@ -231,8 +220,7 @@ std::vector<std::string> MicrologicIDE::content(){
return lines;
}

void MicrologicIDE::mark(std::vector<int> errorList={})
{
void MicrologicIDE::mark(std::vector<int> errorList={}){
std::string text{};
std::vector<std::string> lines=content();

Expand Down Expand Up @@ -312,8 +300,7 @@ void MicrologicIDE::mark(std::vector<int> errorList={})
ui->textEdit->setText(text.c_str());
}

void MicrologicIDE::unmark()
{
void MicrologicIDE::unmark(){
std::string text=ui->textEdit->document()->toPlainText().toStdString();
ui->textEdit->setText(text.c_str());
}
Expand All @@ -334,6 +321,44 @@ void MicrologicIDE::makeMarks(){
}
}

void MicrologicIDE::lightMode(){
this->setStyleSheet("background-color: white; color: black;");
ui->textEdit->setStyleSheet("border-top-style: solid; border-bottom-style: solid; border-width: 1px; border-color: black;");
ui->debugText->setStyleSheet("border-bottom-style: solid; border-width: 1px; border-color: black;");

errorStart="<span style=\"text-decoration: underline; text-decoration-color: red; white-space: pre;\">";errorEnd="</span>";
keyStart="<span style=\"color: orange; white-space: pre;\">";keyEnd="</span>";
numStart="<span style=\"color: aqua; white-space: pre;\">";numEnd="</span>";
modStart="<span style=\"color: purple; white-space: pre;\">";modEnd="</span>";

debugStart="<span style=\"white-space: pre;\">";debugEnd="</span>";
IStart="<span style=\"color: red; white-space: pre;\">";IEnd="</span>";
OStart="<span style=\"color: blue; white-space: pre;\">";OEnd="</span>";
IOStart="<span style=\"color: purple; white-space: pre;\">";IOEnd="</span>";
debugInfo="====[DEBUG INFO] "+IStart+"input "+IEnd+OStart+"output "+OEnd+IOStart+"input&output "+IOEnd+"====";

blankChars={" ","\n",errorStart,errorEnd,"<br>"};
}

void MicrologicIDE::darkMode(){
this->setStyleSheet("background-color: black; color: white;");
ui->textEdit->setStyleSheet("border-top-style: solid; border-bottom-style: solid; border-width: 1px; border-color: white;");
ui->debugText->setStyleSheet("border-bottom-style: solid; border-width: 1px; border-color: white;");

errorStart="<span style=\"text-decoration: underline; text-decoration-color: red; white-space: pre;\">";errorEnd="</span>";
keyStart="<span style=\"color: orange; white-space: pre;\">";keyEnd="</span>";
numStart="<span style=\"color: aqua; white-space: pre;\">";numEnd="</span>";
modStart="<span style=\"color: purple; white-space: pre;\">";modEnd="</span>";

debugStart="<span style=\"white-space: pre;\">";debugEnd="</span>";
IStart="<span style=\"color: red; white-space: pre;\">";IEnd="</span>";
OStart="<span style=\"color: blue; white-space: pre;\">";OEnd="</span>";
IOStart="<span style=\"color: purple; white-space: pre;\">";IOEnd="</span>";
debugInfo="====[DEBUG INFO] "+IStart+"input "+IEnd+OStart+"output "+OEnd+IOStart+"input&output "+IOEnd+"====";

blankChars={" ","\n",errorStart,errorEnd,"<br>"};
}

int countInput(std::vector<std::string> lines){
int ans=0;
for(int i=0;i<lines.size();i++){
Expand Down Expand Up @@ -415,8 +440,7 @@ std::map<std::string,std::pair<int,int>> MicrologicIDE::findMods(std::vector<std
return mods;
}

std::vector<bool> MicrologicIDE::grammarCheck(std::vector<std::string> lines)
{
std::vector<bool> MicrologicIDE::grammarCheck(std::vector<std::string> lines){
std::vector<bool> ans(lines.size());
std::vector<bool> Ls{}; //line order->is wide
std::vector<bool> ins{}; //input line order->is wide
Expand Down Expand Up @@ -573,6 +597,23 @@ std::vector<bool> MicrologicIDE::grammarCheck(std::vector<std::string> lines)
}
else ans[i]=false;
}
else if((args[0]=="type"||args[0]=="tag")&&args.size()==2){
if(isNumber(args[1])){
if(atoi(args[1].c_str())<Ls.size()) ans[i]=true;
else ans[i]=false;
}
else ans[i]=false;
}
else if((args[0]=="check-input"||args[0]=="check-output")&&args.size()==1){
ans[i]=true;
}
else if((args[0]=="check-input"||args[0]=="check-output")&&args.size()==2){
if(isNumber(args[1])){
if(args[0]=="check-input"&&atoi(args[1].c_str())<ins.size()) ans[i]=true;
else if(args[0]=="check-output"&&atoi(args[1].c_str())<outs.size()) ans[i]=true;
else ans[i]=false;
}
}
else if(args[0]=="inspect"&&args.size()==3){
if(mods.count(args[1])!=0||args[1]=="N"||args[1]=="A"||args[1]=="R"||args[1]=="T"||args[1]=="C"||args[1]=="P"){
if(isNumber(args[2])&&atoi(args[2].c_str())<modBlock[args[1]]) ans[i]=true;
Expand Down Expand Up @@ -601,13 +642,11 @@ std::vector<bool> MicrologicIDE::grammarCheck(std::vector<std::string> lines)
return ans;
}

void MicrologicIDE::on_textEdit_textChanged()
{
void MicrologicIDE::on_textEdit_textChanged(){

}

void MicrologicIDE::updateDebug()
{
void MicrologicIDE::updateDebug(){
std::ifstream debug;
debug.open(exepath+"\\debug.log",std::ios::in);
if(!debug.good()){
Expand Down
Loading

0 comments on commit 46dedfd

Please sign in to comment.