Skip to content

Commit

Permalink
Upload part of the auto save function code
Browse files Browse the repository at this point in the history
  • Loading branch information
mrQzs committed May 25, 2021
1 parent f71ece4 commit a64b27c
Show file tree
Hide file tree
Showing 7 changed files with 317 additions and 63 deletions.
4 changes: 2 additions & 2 deletions LVGLBuilder.pro
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ SOURCES += \
core/LVGLCommands.cpp \
core/LVGLCore.cpp \
core/LVGLDialog.cpp \
core/LVGLExportThread.cpp \
core/LVGLFontData.cpp \
core/LVGLFontDialog.cpp \
core/LVGLHelper.cpp \
Expand All @@ -112,6 +111,7 @@ SOURCES += \
core/LVGLStyle.cpp \
core/LVGLStyleModel.cpp \
core/LVGLTabWidget.cpp \
core/LVGLThreads.cpp \
core/LVGLWidgetListView.cpp \
core/LVGLWidgetModel.cpp \
core/LVGLWidgetModelDisplay.cpp \
Expand Down Expand Up @@ -200,7 +200,6 @@ HEADERS += \
core/LVGLCommands.h \
core/LVGLCore.h \
core/LVGLDialog.h \
core/LVGLExportThread.h \
core/LVGLFontData.h \
core/LVGLFontDialog.h \
core/LVGLHelper.h \
Expand All @@ -218,6 +217,7 @@ HEADERS += \
core/LVGLStyle.h \
core/LVGLStyleModel.h \
core/LVGLTabWidget.h \
core/LVGLThreads.h \
core/LVGLWidgetListView.h \
core/LVGLWidgetModel.h \
core/LVGLWidgetModelDisplay.h \
Expand Down
78 changes: 76 additions & 2 deletions MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <QUndoGroup>

#include "core/LVGLDialog.h"
#include "core/LVGLExportThread.h"
#include "core/LVGLFontData.h"
#include "core/LVGLFontDialog.h"
#include "core/LVGLHelper.h"
Expand All @@ -24,6 +23,7 @@
#include "core/LVGLSimulator.h"
#include "core/LVGLStyleModel.h"
#include "core/LVGLTabWidget.h"
#include "core/LVGLThreads.h"
#include "core/LVGLWidgetListView.h"
#include "core/LVGLWidgetModel.h"
#include "core/LVGLWidgetModelDisplay.h"
Expand Down Expand Up @@ -56,7 +56,8 @@ MainWindow::MainWindow(QWidget *parent)
m_lastindex(-1),
m_pcBar(new LVGLProcessBar(this)),
m_exportThread(new LVGLExportThread),
m_etThread(new QThread(this)) {
m_etThread(new QThread(this)),
m_autosaveState(0) {
m_ui->setupUi(this);
lvgl.init(320, 480);
m_ui->style_tree->setStyleSheet(
Expand Down Expand Up @@ -166,6 +167,8 @@ MainWindow::MainWindow(QWidget *parent)
// m_pcBar->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
// m_pcBar->setAttribute(Qt::WA_TranslucentBackground);

m_ui->actionOFF->setChecked(true);

LVGLLog::log_trace("Main started", __FILE__, __LINE__, __func__);
}

Expand Down Expand Up @@ -450,6 +453,55 @@ void MainWindow::setAllModelNull() {
m_styleModel->setLvglObj(nullptr);
}

void MainWindow::setAutoSaveChecked(int state) {
m_ui->actionOFF->setChecked(false);
m_ui->action1_Min->setChecked(false);
m_ui->action2_Min->setChecked(false);
m_ui->action3_Min->setChecked(false);
m_ui->action4_Min->setChecked(false);
m_ui->action5_Min->setChecked(false);
m_ui->action6_Min->setChecked(false);
m_ui->action7_Min->setChecked(false);
m_ui->action8_Min->setChecked(false);
m_ui->action9_Min->setChecked(false);
m_ui->action10_Min->setChecked(false);
switch (state) {
case 0:
m_ui->actionOFF->setChecked(true);
break;
case 1:
m_ui->action1_Min->setChecked(true);
break;
case 2:
m_ui->action2_Min->setChecked(true);
break;
case 3:
m_ui->action3_Min->setChecked(true);
break;
case 4:
m_ui->action4_Min->setChecked(true);
break;
case 5:
m_ui->action5_Min->setChecked(true);
break;
case 6:
m_ui->action6_Min->setChecked(true);
break;
case 7:
m_ui->action7_Min->setChecked(true);
break;
case 8:
m_ui->action8_Min->setChecked(true);
break;
case 9:
m_ui->action8_Min->setChecked(true);
break;
case 10:
m_ui->action10_Min->setChecked(true);
break;
}
}

void MainWindow::on_action_load_triggered() {
QString path;
if (m_project != nullptr) path = m_project->fileName();
Expand Down Expand Up @@ -1041,3 +1093,25 @@ void MainWindow::ontabclose(int index) {
void MainWindow::on_eaction_export_triggered() {
on_action_export_c_triggered();
}

void MainWindow::on_actionOFF_triggered() { setAutoSaveChecked(0); }

void MainWindow::on_action1_Min_triggered() { setAutoSaveChecked(1); }

void MainWindow::on_action2_Min_triggered() { setAutoSaveChecked(2); }

void MainWindow::on_action3_Min_triggered() { setAutoSaveChecked(3); }

void MainWindow::on_action4_Min_triggered() { setAutoSaveChecked(4); }

void MainWindow::on_action5_Min_triggered() { setAutoSaveChecked(5); }

void MainWindow::on_action6_Min_triggered() { setAutoSaveChecked(6); }

void MainWindow::on_action7_Min_triggered() { setAutoSaveChecked(7); }

void MainWindow::on_action8_Min_triggered() { setAutoSaveChecked(8); }

void MainWindow::on_action9_Min_triggered() { setAutoSaveChecked(9); }

void MainWindow::on_action10_Min_triggered() { setAutoSaveChecked(10); }
16 changes: 13 additions & 3 deletions MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,22 @@ class MainWindow : public QMainWindow {
void on_list_fonts_currentItemChanged(QListWidgetItem *current,
QListWidgetItem *previous);
void on_action_run_toggled(bool run);

void on_combo_state_currentIndexChanged(int index);

void tabChanged(int index);
void onObjPressed(LVGLObject *obj);
void ontabclose(int index);

void on_eaction_export_triggered();
void on_actionOFF_triggered();
void on_action1_Min_triggered();
void on_action2_Min_triggered();
void on_action3_Min_triggered();
void on_action4_Min_triggered();
void on_action5_Min_triggered();
void on_action6_Min_triggered();
void on_action7_Min_triggered();
void on_action8_Min_triggered();
void on_action9_Min_triggered();
void on_action10_Min_triggered();

protected:
void showEvent(QShowEvent *event) override;
Expand Down Expand Up @@ -109,6 +117,7 @@ class MainWindow : public QMainWindow {
void updateItemDelegate();
void setUndoStack();
void setAllModelNull();
void setAutoSaveChecked(int state);

private:
Ui::MainWindow *m_ui;
Expand Down Expand Up @@ -148,5 +157,6 @@ class MainWindow : public QMainWindow {
LVGLProcessBar *m_pcBar;
LVGLExportThread *m_exportThread;
QThread *m_etThread;
int m_autosaveState;
};
#endif // MAINWINDOW_H
142 changes: 114 additions & 28 deletions MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -86,32 +86,30 @@
<addaction name="separator"/>
<addaction name="menu_resent_filess"/>
</widget>
<widget class="QMenu" name="menuEdit">
<widget class="QMenu" name="menuAutoSave">
<property name="title">
<string>Edit</string>
</property>
</widget>
<widget class="QMenu" name="menuView">
<property name="title">
<string>View</string>
</property>
<addaction name="separator"/>
</widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
<string>Tools</string>
</property>
</widget>
<widget class="QMenu" name="menuHelp_2">
<property name="title">
<string>Help</string>
<string>AutoSave</string>
</property>
<widget class="QMenu" name="menuOn">
<property name="title">
<string>On</string>
</property>
<addaction name="action1_Min"/>
<addaction name="action2_Min"/>
<addaction name="action3_Min"/>
<addaction name="action4_Min"/>
<addaction name="action5_Min"/>
<addaction name="action6_Min"/>
<addaction name="action7_Min"/>
<addaction name="action8_Min"/>
<addaction name="action9_Min"/>
<addaction name="action10_Min"/>
</widget>
<addaction name="menuOn"/>
<addaction name="actionOFF"/>
</widget>
<addaction name="menuLittlevGL_Builder"/>
<addaction name="menuEdit"/>
<addaction name="menuView"/>
<addaction name="menuHelp"/>
<addaction name="menuHelp_2"/>
<addaction name="menuAutoSave"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="toolBar">
Expand Down Expand Up @@ -141,8 +139,8 @@
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
<width>70</width>
<height>89</height>
</size>
</property>
<property name="baseSize">
Expand Down Expand Up @@ -508,8 +506,8 @@
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
<width>72</width>
<height>133</height>
</size>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -647,8 +645,8 @@
<widget class="QDockWidget" name="UndoEditor">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
<width>118</width>
<height>122</height>
</size>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -802,6 +800,94 @@
<string>Ctrl+E</string>
</property>
</action>
<action name="actionOFF">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>OFF</string>
</property>
</action>
<action name="action1_Min">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>1 Min</string>
</property>
</action>
<action name="action2_Min">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>2 Min</string>
</property>
</action>
<action name="action3_Min">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>3 Min</string>
</property>
</action>
<action name="action4_Min">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>4 Min</string>
</property>
</action>
<action name="action5_Min">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>5 Min</string>
</property>
</action>
<action name="action6_Min">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>6 Min</string>
</property>
</action>
<action name="action7_Min">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>7 Min</string>
</property>
</action>
<action name="action8_Min">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>8 Min</string>
</property>
</action>
<action name="action9_Min">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>9 Min</string>
</property>
</action>
<action name="action10_Min">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>10 Min</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
Expand Down
28 changes: 0 additions & 28 deletions core/LVGLExportThread.cpp

This file was deleted.

Loading

0 comments on commit a64b27c

Please sign in to comment.