diff options
author | akshay-c | 2019-12-16 11:09:46 +0530 |
---|---|---|
committer | akshay-c | 2019-12-16 11:09:46 +0530 |
commit | 89ac0ff09bcf77bb0d6d3158746d97b916d1935c (patch) | |
tree | 3097c9f0f56917d39a1d5e4c1aa3c8522c104f3d | |
parent | 8794ca93788a8aa75911fe799748dc043510047d (diff) | |
download | LDmicroQt-89ac0ff09bcf77bb0d6d3158746d97b916d1935c.tar.gz LDmicroQt-89ac0ff09bcf77bb0d6d3158746d97b916d1935c.tar.bz2 LDmicroQt-89ac0ff09bcf77bb0d6d3158746d97b916d1935c.zip |
Comment dialog Bugfix;Toolbar disable during simulation;Code cleanup;
-rw-r--r-- | ldmicro/commentdialog.cpp | 3 | ||||
-rw-r--r-- | ldmicro/draw_outputdev.cpp | 5 | ||||
-rw-r--r-- | ldmicro/includes/ldmicro.h | 4 | ||||
-rw-r--r-- | ldmicro/ldmicro.cpp | 3 | ||||
-rw-r--r-- | ldmicro/lutdialog.cpp | 20 | ||||
-rw-r--r-- | ldmicro/maincontrols.cpp | 21 | ||||
-rw-r--r-- | ldmicro/simulate.cpp | 4 | ||||
-rw-r--r-- | ldmicro/toolbar.cpp | 16 |
8 files changed, 39 insertions, 37 deletions
diff --git a/ldmicro/commentdialog.cpp b/ldmicro/commentdialog.cpp index 8e29528..28cd521 100644 --- a/ldmicro/commentdialog.cpp +++ b/ldmicro/commentdialog.cpp @@ -54,9 +54,9 @@ static void MakeControls(void) } static inline void DestroyWindow(){ - delete CommentDialog; delete CommentTextbox; delete CommentGrid; + delete CommentDialog; ProgramChanged(); } @@ -76,7 +76,6 @@ void ShowCommentDialog(char *comment) strncpy(comment, CommentTextbox->text().toStdString().c_str(), MAX_COMMENT_LEN -1); - } break; case QDialog::Rejected: diff --git a/ldmicro/draw_outputdev.cpp b/ldmicro/draw_outputdev.cpp index d38f3a8..28b8f78 100644 --- a/ldmicro/draw_outputdev.cpp +++ b/ldmicro/draw_outputdev.cpp @@ -110,8 +110,10 @@ BOOL BlinkCursor(BOOL kill = FALSE) if (PREV_x != c.left() || PREV_y != c.top() || PREV_w != c.width() || PREV_h != c.height()) { + scrollbar->setFrameRect(c); CursorObject->setGeometry(c); CursorObject->setVisible(TRUE); + scrollbar->ensureWidgetVisible(CursorObject); PREV_x = c.left(); PREV_y = c.top(); PREV_w = c.width(); @@ -319,7 +321,6 @@ void PaintWidget::paintEvent(QPaintEvent *event) cy += thisHeight; cy += POS_HEIGHT; } - // printf("Endrung:%d\n", cy); QSize DWSize = this->size(); int newHeight = ((cy + (POS_HEIGHT/2)) * FONT_HEIGHT + Y_PADDING + 50); if(DWSize.height() + POS_HEIGHT < newHeight) @@ -394,7 +395,7 @@ static void SetSyntaxHighlightingColours(void) RGB(0, 0, 0), // simBg RGB(130, 130, 130), // simRungNum - RGB(100, 130, 130), // simOff + RGB(170, 200, 200), // simOff RGB(255, 150, 150), // simOn RGB(255, 150, 150), // simBusLeft diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h index 34b9520..d6ca469 100644 --- a/ldmicro/includes/ldmicro.h +++ b/ldmicro/includes/ldmicro.h @@ -37,8 +37,8 @@ typedef signed long SDWORD; // #define FREEZE_SUBKEY "LDMicro" // Size of the font that we will use to draw the ladder diagrams, in pixels -#define FONT_WIDTH 7 -#define FONT_HEIGHT 14 +#define FONT_WIDTH 8 +#define FONT_HEIGHT 16 //----------------------------------------------- // Constants for the GUI. We have drop-down menus, a listview for the I/Os, diff --git a/ldmicro/ldmicro.cpp b/ldmicro/ldmicro.cpp index 8e5d758..fa5ea5a 100644 --- a/ldmicro/ldmicro.cpp +++ b/ldmicro/ldmicro.cpp @@ -294,9 +294,12 @@ void ProgramChanged(void) } #define CHANGING_PROGRAM(x) { \ + if(!InSimulationMode) \ + { \ UndoRemember(); \ x; \ ProgramChanged();\ + } \ } //----------------------------------------------------------------------------- diff --git a/ldmicro/lutdialog.cpp b/ldmicro/lutdialog.cpp index bd13fc8..feef56f 100644 --- a/ldmicro/lutdialog.cpp +++ b/ldmicro/lutdialog.cpp @@ -85,10 +85,12 @@ static inline void DestroyWindow (){ delete DestTextbox; delete IndexTextbox; delete CountTextbox; - delete AsStringCheckbox; + if(WasAsString) + delete AsStringCheckbox; delete FixedControlGrid; delete LutGrid; delete ButtonBox; + delete LutDialog; ProgramChanged(); } @@ -107,11 +109,8 @@ static void MakeFixedControls(BOOL forPwl) Labels[2] = new QLabel(forPwl ? _("Points:") : _("Count:")); DestTextbox = new QLineEdit(); - // gtk_entry_set_max_length (GTK_ENTRY (DestTextbox), 0); IndexTextbox = new QLineEdit(); - // gtk_entry_set_max_length (GTK_ENTRY (IndexTextbox), 0); CountTextbox = new QLineEdit(); - // gtk_entry_set_max_length (GTK_ENTRY (CountTextbox), 0); DestTextbox->setValidator( new QRegExpValidator( QRegExp("[a-zA-Z0-9_]+"))); @@ -144,8 +143,11 @@ static void MakeFixedControls(BOOL forPwl) LutGrid->addWidget(ButtonBox,0,1); QObject::connect(ButtonBox, SIGNAL(accepted()), LutDialog, SLOT(accept())); QObject::connect(ButtonBox, SIGNAL(rejected()), LutDialog, SLOT(reject())); - QObject::connect(AsStringCheckbox, - &QCheckBox::stateChanged, CheckBoxFunction); + if (!forPwl) + { + QObject::connect(AsStringCheckbox, + &QCheckBox::stateChanged, CheckBoxFunction); + } QObject::connect(CountTextbox, &QLineEdit::textChanged,CountFunction); } @@ -420,17 +422,11 @@ void CountFunction(QString text) // ShowLookUpTableDialog function to improve performance in Qt void StringFunction(QString text) { - // printf("StringFunction called \n"); char* scratch = (char*)text.toStdString().c_str(); - // SendMessage(StringTextbox, WM_GETTEXT, (WPARAM)sizeof(scratch), - // (LPARAM)scratch); if(strcmp(scratch, PrevTableAsString)!=0) { if(StringToValuesCache(scratch, &ControlCount)) { strcpy(PrevTableAsString, scratch); } else { - // Too long; put back the old one - // SendMessage(StringTextbox, WM_SETTEXT, 0, - // (LPARAM)PrevTableAsString); StringTextbox->setText(PrevTableAsString); } } diff --git a/ldmicro/maincontrols.cpp b/ldmicro/maincontrols.cpp index b0e1db1..7d78f6a 100644 --- a/ldmicro/maincontrols.cpp +++ b/ldmicro/maincontrols.cpp @@ -662,6 +662,8 @@ void SetMenusEnabled(BOOL canNegate, BOOL canNormal, BOOL canResetOnly, EnableMenuItem(InstructionMenu, InsertFmtdStrMenu, t); //Disable respective tool items + EnableMenuItem(NULL, ContactBtn, t); + EnableMenuItem(NULL, NegContactBtn, t); EnableMenuItem(NULL, TonBtn, t); EnableMenuItem(NULL, TofBtn, t); EnableMenuItem(NULL, CtuBtn, t); @@ -702,6 +704,22 @@ void ToggleSimulationMode(void) CheckMenuItem(SimulateMenu, SimulationModeMenu, MF_CHECKED); + // Disable our easy-access toolbox + EnableMenuItem(NULL, ContactBtn, MF_GRAYED); + EnableMenuItem(NULL, NegContactBtn, MF_GRAYED); + EnableMenuItem(NULL, CoilBtn, MF_GRAYED); + EnableMenuItem(NULL, NegCoilBtn, MF_GRAYED); + EnableMenuItem(NULL, SetCoilBtn, MF_GRAYED); + EnableMenuItem(NULL, ResetCoilBtn, MF_GRAYED); + EnableMenuItem(NULL, AddBtn, MF_GRAYED); + EnableMenuItem(NULL, SubBtn, MF_GRAYED); + EnableMenuItem(NULL, MulBtn, MF_GRAYED); + EnableMenuItem(NULL, DivBtn, MF_GRAYED); + EnableMenuItem(NULL, TonBtn, MF_GRAYED); + EnableMenuItem(NULL, TofBtn, MF_GRAYED); + EnableMenuItem(NULL, CtuBtn, MF_GRAYED); + EnableMenuItem(NULL, CtdBtn, MF_GRAYED); + ClearSimulationData(); // simulation.cpp, ldmicro.h // Recheck InSimulationMode, because there could have been a Compile // error, which would have kicked us out of simulation mode. @@ -728,6 +746,9 @@ void ToggleSimulationMode(void) EnableMenuItem(TopMenu, InstructionMenu, MF_ENABLED); EnableMenuItem(TopMenu, Compile, MF_ENABLED); + //Enable our Easy-access Toolbar + WhatCanWeDoFromCursorAndTopology(); + CheckMenuItem(SimulateMenu, SimulationModeMenu, MF_UNCHECKED); if(UartFunctionUsed()) { diff --git a/ldmicro/simulate.cpp b/ldmicro/simulate.cpp index 7211e96..392a9af 100644 --- a/ldmicro/simulate.cpp +++ b/ldmicro/simulate.cpp @@ -722,8 +722,6 @@ void SimulateOneCycle(BOOL forceRefresh) if(NeedRedraw || SimulateRedrawAfterNextCycle || forceRefresh) { InvalidateRect(DrawWindow, NULL, FALSE); RefreshControlsToSettings(); - // gtk_widget_queue_draw(DrawWindow); - // ListView_RedrawItems(IoList, 0, Prog.io.count - 1); } SimulateRedrawAfterNextCycle = FALSE; @@ -854,8 +852,6 @@ void ShowUartSimulationWindow(void) UartSimulationWindow = CreateWindowClient("UART Simulation (Terminal)", TerminalX, TerminalY, TerminalW, TerminalH, MainWindow); - // UartSimulationWindow->setWindowTitle("UART Simulation (Terminal)"); - /// remove close button UartSimulationWindow->setWindowFlags(Qt::Window | Qt::WindowMinimizeButtonHint | Qt::WindowStaysOnTopHint); diff --git a/ldmicro/toolbar.cpp b/ldmicro/toolbar.cpp index 99bba4b..f37ec43 100644 --- a/ldmicro/toolbar.cpp +++ b/ldmicro/toolbar.cpp @@ -53,21 +53,7 @@ void CreateToolBar() DivIco = new QIcon(DIV_ICON); CtuIco = new QIcon(CTU_ICON); CtdIco = new QIcon(CTD_ICON); - /*ContactBtn = new QAction(*ContactIco, "C-NO"); - NegContactBtn = new QAction(*NegContactIco, "C-NC"); - CoilBtn = new QAction(*CoilIco, "L-NO"); - NegCoilBtn = new QAction(*NegCoilIco, "L-NC"); - SetCoilBtn = new QAction(*SetCoilIco, "L-SO"); - ResetCoilBtn = new QAction(*ResetCoilIco, "L-RO"); - TonBtn = new QAction(*TonIco, "TON"); - TofBtn = new QAction(*TofIco, "TOF"); - RtoBtn = new QAction(*RtoIco, "RTO"); - AddBtn = new QAction(*AddIco, "Add"); - SubBtn = new QAction(*SubIco, "Sub"); - MulBtn = new QAction(*MulIco, "Mul"); - DivBtn = new QAction(*DivIco, "Div"); - CtuBtn = new QAction(*CtuIco, "CTU"); - CtdBtn = new QAction(*CtdIco, "CTD");*/ + EasyAccessTool = new QToolBar(); EasyAccessTool->addSeparator(); ContactBtn = EasyAccessTool->addAction(*ContactIco, "Normal Contact"); |