summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ldmicro/CMakeLists.txt6
-rw-r--r--ldmicro/coildialog.cpp5
-rw-r--r--ldmicro/commentdialog.cpp108
-rw-r--r--ldmicro/contactsdialog.cpp242
-rw-r--r--ldmicro/lib/linuxUI/linuxUI.h1
-rw-r--r--ldmicro/resetdialog.cpp165
-rw-r--r--ldmicro/schematic.cpp8
7 files changed, 215 insertions, 320 deletions
diff --git a/ldmicro/CMakeLists.txt b/ldmicro/CMakeLists.txt
index ff67a60..ec4c2d3 100644
--- a/ldmicro/CMakeLists.txt
+++ b/ldmicro/CMakeLists.txt
@@ -143,11 +143,11 @@ endif()
iolist.cpp
#confdialog.cpp
#lutdialog.cpp
- #resetdialog.cpp
+ resetdialog.cpp
# simpledialog.cpp
coildialog.cpp
- #contactsdialog.cpp
- #commentdialog.cpp
+ contactsdialog.cpp
+ commentdialog.cpp
simulate.cpp
loadsave.cpp
undoredo.cpp
diff --git a/ldmicro/coildialog.cpp b/ldmicro/coildialog.cpp
index e917bb4..758e308 100644
--- a/ldmicro/coildialog.cpp
+++ b/ldmicro/coildialog.cpp
@@ -36,8 +36,6 @@ static QRadioButton* NormalRadio;
static QRadioButton* SetOnlyRadio;
static QRadioButton* ResetOnlyRadio;
static QLineEdit* NameTextbox;
-static QPushButton* OkButton;
-static QPushButton* CancelButton;
static LONG_PTR PrevNameProc;
@@ -100,9 +98,8 @@ inline void DestroyWindow()
delete SetOnlyRadio;
delete ResetOnlyRadio;
delete NameTextbox;
- delete OkButton;
- delete CancelButton;
delete CoilGrid;
+ ProgramChanged();
}
void ShowCoilDialog(BOOL *negated, BOOL *setOnly, BOOL *resetOnly, char *name)
diff --git a/ldmicro/commentdialog.cpp b/ldmicro/commentdialog.cpp
index 4ceb107..d9c6d9f 100644
--- a/ldmicro/commentdialog.cpp
+++ b/ldmicro/commentdialog.cpp
@@ -27,90 +27,52 @@
#include "ldmicro.h"
-static HWID CommentDialog;
+static QDialog* CommentDialog;
-static HWID CommentTextbox;
+static QLineEdit* CommentTextbox;
-static HWID CommentGrid;
-static HWID CommentPackingBox;
-static HWID OkButton;
-static HWID CancelButton;
+static QGridLayout* CommentGrid;
static void MakeControls(void)
{
- CommentTextbox = gtk_entry_new();
- gtk_entry_set_max_length (GTK_ENTRY (CommentTextbox), 0);
- gtk_widget_set_hexpand (CommentTextbox, TRUE);
- gtk_widget_set_vexpand (CommentTextbox, TRUE);
-
- OkButton = gtk_button_new_with_label ("OK");
- CancelButton = gtk_button_new_with_label ("Cancel");
-
- gtk_grid_attach (GTK_GRID (CommentGrid), CommentTextbox, 1, 2, 1, 1);
- gtk_grid_attach (GTK_GRID (CommentGrid), OkButton, 5, 2, 1, 1);
- gtk_grid_attach (GTK_GRID (CommentGrid), CancelButton, 5, 3, 1, 1);
-
- gtk_grid_set_column_spacing (GTK_GRID (CommentGrid), 1);
- gtk_box_pack_start(GTK_BOX(CommentPackingBox), CommentGrid, TRUE, TRUE, 0);
+ NiceFont(CommentDialog);
+ QDialogButtonBox *ButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok
+ | QDialogButtonBox::Cancel, Qt::Vertical,
+ CommentDialog);
+ CommentTextbox = new QLineEdit();
+ CommentGrid->addWidget(CommentTextbox, 0, 0);
+ CommentGrid->addWidget(ButtonBox, 0, 1);
+ QObject::connect(ButtonBox, SIGNAL(accepted()), CommentDialog, SLOT(accept()));
+ QObject::connect(ButtonBox, SIGNAL(rejected()), CommentDialog, SLOT(reject()));
+ FixedFont(CommentTextbox);
}
-void CommentDialogGetData (char* comment){
- strncpy (comment, gtk_entry_get_text (GTK_ENTRY (CommentTextbox)),
- MAX_COMMENT_LEN-1);
- gtk_widget_set_sensitive (MainWindow, TRUE);
- DestroyWindow (CommentDialog);
+inline void DestroyWindow(){
+ delete CommentDialog;
+ delete CommentTextbox;
+ delete CommentGrid;
ProgramChanged();
}
-// Mouse click callback
-void CommentDialogMouseClick (HWID widget, gpointer data){
- CommentDialogGetData((char*)data);
-}
-
-// Checks for the required key press
-gboolean CommentDialogKeyPress (HWID widget, GdkEventKey* event, gpointer data){
- if (event -> keyval == GDK_KEY_Return){
- CommentDialogGetData((char*)data);
- }
- else if (event -> keyval == GDK_KEY_Escape){
- DestroyWindow (CommentDialog);
- gtk_widget_set_sensitive (MainWindow, TRUE);
- ProgramChanged();
- }
- return FALSE;
-}
-
-void CommentCallDestroyWindow (HWID widget, gpointer data){
- DestroyWindow (CommentDialog);
- ProgramChanged();
- gtk_widget_set_sensitive (MainWindow, TRUE);
-}
-
void ShowCommentDialog(char *comment)
{
- CommentGrid = gtk_grid_new();
- CommentPackingBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
-
- CommentDialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(CommentDialog), "Comment");
- gtk_window_set_default_size(GTK_WINDOW(CommentDialog), 700, 50);
- gtk_window_set_resizable (GTK_WINDOW (CommentDialog), FALSE);
- gtk_widget_add_events (CommentDialog, GDK_KEY_PRESS_MASK);
- gtk_widget_add_events (CommentDialog, GDK_BUTTON_PRESS_MASK);
-
+ CommentDialog = CreateWindowClient(_("Comment"),
+ 100, 100, 359, 115, MainWindow);
+ CommentGrid = new QGridLayout(CommentDialog);
MakeControls();
- gtk_entry_set_text (GTK_ENTRY (CommentTextbox), comment);
- gtk_container_add(GTK_CONTAINER(CommentDialog), CommentPackingBox);
- gtk_widget_set_sensitive (MainWindow, FALSE);
- gtk_widget_show_all (CommentDialog);
- gtk_widget_grab_focus (CommentTextbox);
-
- g_signal_connect (G_OBJECT (CommentDialog), "key-press-event",
- G_CALLBACK(CommentDialogKeyPress), (gpointer)comment);
- g_signal_connect (G_OBJECT (OkButton), "clicked",
- G_CALLBACK(CommentDialogMouseClick), (gpointer)comment);
- g_signal_connect (G_OBJECT (CancelButton), "clicked",
- G_CALLBACK(CommentCallDestroyWindow), NULL);
-
- return;
+ CommentTextbox->setText(comment);
+ int ret = CommentDialog->exec();
+ switch(ret)
+ {
+ case QDialog::Accepted:
+ {
+ strncpy(comment, CommentTextbox->text().toStdString().c_str(),
+ MAX_COMMENT_LEN -1);
+
+ }
+ break;
+ case QDialog::Rejected:
+ break;
+ }
+ DestroyWindow();
}
diff --git a/ldmicro/contactsdialog.cpp b/ldmicro/contactsdialog.cpp
index 38750c8..01c55fb 100644
--- a/ldmicro/contactsdialog.cpp
+++ b/ldmicro/contactsdialog.cpp
@@ -27,177 +27,117 @@
#include "ldmicro.h"
-static HWID ContactsDialog;
+static QDialog* ContactsDialog;
-static HWID NegatedCheckbox;
-static HWID SourceInternalRelayRadio;
-static HWID SourceInputPinRadio;
-static HWID SourceOutputPinRadio;
-static HWID NameTextbox;
-static HWID OkButton;
-static HWID CancelButton;
+static QCheckBox* NegatedCheckbox;
+static QRadioButton* SourceInternalRelayRadio;
+static QRadioButton* SourceInputPinRadio;
+static QRadioButton* SourceOutputPinRadio;
+static QLineEdit* NameTextbox;
static LONG_PTR PrevNameProc;
-static HWID ContactsGrid;
-static HWID ContactsPackingBox;
+static QGridLayout* ContactsGrid;
char* tmpname;
BOOL* tmpnegated;
-//-----------------------------------------------------------------------------
-// Don't allow any characters other than A-Za-z0-9_ in the name.
-//-----------------------------------------------------------------------------
-// static LRESULT CALLBACK MyNameProc(HWND hwnd, UINT msg, WPARAM wParam,
-// LPARAM lParam)
-// {
-// if(msg == WM_CHAR) {
-// if(!(isalpha(wParam) || isdigit(wParam) || wParam == '_' ||
-// wParam == '\b'))
-// {
-// return 0;
-// }
-// }
-
-// return CallWindowProc((WNDPROC)PrevNameProc, hwnd, msg, wParam, lParam);
-// }
-
-void ContactsDialogMyNameProc (GtkEditable *editable, gchar *NewText, gint length,
- gint *position, gpointer data){
- // gtk_widget_set_sensitive (MainWindow, TRUE);
- for (int i = 0; i < length; i++){
- if (!(isalpha (NewText[i]) || NewText[i] == '_' || isdigit (NewText[i])
- || NewText[i] == '\b' )){
- g_signal_stop_emission_by_name (G_OBJECT (editable), "insert-text");
- return;
- }
- }
-}
static void MakeControls(void)
{
- SourceInternalRelayRadio = gtk_radio_button_new_with_label (NULL, "Internal Relay");
-
- SourceInputPinRadio = gtk_radio_button_new_with_label_from_widget
- (GTK_RADIO_BUTTON (SourceInternalRelayRadio), "Input pin");
-
- SourceOutputPinRadio = gtk_radio_button_new_with_label_from_widget
- (GTK_RADIO_BUTTON (SourceInternalRelayRadio), "Output pin");
-
- HWID textLabel = gtk_label_new ("Name:");
-
- NameTextbox = gtk_entry_new();
- gtk_entry_set_max_length (GTK_ENTRY (NameTextbox), 0);
-
- NegatedCheckbox = gtk_check_button_new_with_label ("|/| Negated");
-
- OkButton = gtk_button_new_with_label ("OK");
- CancelButton = gtk_button_new_with_label ("Cancel");
-
- gtk_grid_attach (GTK_GRID (ContactsGrid), SourceInternalRelayRadio, 1, 2, 1, 1);
- gtk_grid_attach (GTK_GRID (ContactsGrid), SourceInputPinRadio, 1, 3, 1, 1);
- gtk_grid_attach (GTK_GRID (ContactsGrid), SourceOutputPinRadio, 1, 4, 1, 1);
- gtk_grid_attach (GTK_GRID (ContactsGrid), textLabel, 2, 2, 1, 1);
- gtk_grid_attach (GTK_GRID (ContactsGrid), NegatedCheckbox, 2, 3, 1, 1);
- gtk_grid_attach (GTK_GRID (ContactsGrid), NameTextbox, 3, 2, 1, 1);
- gtk_grid_attach (GTK_GRID (ContactsGrid), OkButton, 4, 2, 1, 1);
- gtk_grid_attach (GTK_GRID (ContactsGrid), CancelButton, 4, 3, 1, 1);
-
- gtk_grid_set_column_spacing (GTK_GRID (ContactsGrid), 1);
- gtk_box_pack_start(GTK_BOX(ContactsPackingBox), ContactsGrid, TRUE, TRUE, 0);
-
-// PrevNameProc = SetWindowLongPtr(NameTextbox, GWLP_WNDPROC,
-// (LONG_PTR)MyNameProc);
+ QGroupBox* grouper = new QGroupBox(_("Source"));
+ QGridLayout *SourceGrid = new QGridLayout();
+ QGridLayout *NameGrid = new QGridLayout();
+ QDialogButtonBox *ButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok
+ | QDialogButtonBox::Cancel, Qt::Vertical,
+ ContactsDialog);
+ NiceFont(ContactsDialog);
+
+ ContactsGrid->setSpacing(3);
+ SourceGrid->setSpacing(3);
+
+ SourceInternalRelayRadio = new QRadioButton(_("Internal Relay"), ContactsDialog);
+ SourceInputPinRadio = new QRadioButton(_("Input pin"), ContactsDialog);
+ SourceOutputPinRadio = new QRadioButton(_("Output pin"), ContactsDialog);
+ SourceGrid->addWidget(SourceInternalRelayRadio,0,0);
+ SourceGrid->addWidget(SourceInputPinRadio,1,0);
+ SourceGrid->addWidget(SourceOutputPinRadio,2,0);
+ /*SourceGrid->addItem(
+ new QSpacerItem(SetOnlyRadio->width(),
+ SetOnlyRadio->height()), 2, 0);*/
+ QLabel* textLabel = new QLabel(_("Name:"));
+ NameTextbox = new QLineEdit();
+ NegatedCheckbox = new QCheckBox(_("|/| Negated"), ContactsDialog);
+ FixedFont(NameTextbox);
+ NameTextbox->setFixedWidth(155);
+ NameGrid->addWidget(textLabel,0,0);
+ NameGrid->addWidget(NameTextbox,0,1);
+ NameGrid->addWidget(NegatedCheckbox, 1,0);
+ grouper->setLayout(SourceGrid);
+ ContactsGrid->addWidget(grouper,0,0);
+ ContactsGrid->addLayout(NameGrid,0,1);
+ ContactsGrid->addWidget(ButtonBox,0,2);
+ QObject::connect(ButtonBox, SIGNAL(accepted()), ContactsDialog, SLOT(accept()));
+ QObject::connect(ButtonBox, SIGNAL(rejected()), ContactsDialog, SLOT(reject()));
}
-void ContactsDialogGetData (BOOL* negated, char* name){
- if(gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (NegatedCheckbox))) {
- *negated = TRUE;
- }
- else {
- *negated = FALSE;
- }
- if(gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
- (SourceInternalRelayRadio))) {
- name[0] = 'R';
- }
- else if(gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
- (SourceInputPinRadio))) {
- name[0] = 'X';
- }
- else {
- name[0] = 'Y';
- }
- strcpy (name+1, gtk_entry_get_text (GTK_ENTRY (NameTextbox)));
-
- DestroyWindow (ContactsDialog);
+inline void DestroyWindow (){
+ delete NegatedCheckbox;
+ delete SourceInternalRelayRadio;
+ delete SourceInputPinRadio;
+ delete SourceOutputPinRadio;
+ delete NameTextbox;
+ delete ContactsDialog;
ProgramChanged();
- gtk_widget_set_sensitive (MainWindow, TRUE);
-}
-
-// Mouse click callback
-void ContactsDialogMouseClick(HWID widget, gpointer data){
- ContactsDialogGetData(tmpnegated, tmpname);
-}
-
-// Checks for the required key press
-gboolean ContactsDialogKeyPress (HWID widget, GdkEventKey* event, gpointer data){
- if (event -> keyval == GDK_KEY_Return){
- ContactsDialogGetData(tmpnegated, tmpname);
- }
- else if (event -> keyval == GDK_KEY_Escape){
- DestroyWindow (ContactsDialog);
- ProgramChanged();
- gtk_widget_set_sensitive (MainWindow, TRUE);
- }
- return FALSE;
-}
-
-void ContactsCallDestroyWindow (HWID widget, gpointer data){
- DestroyWindow (ContactsDialog);
- ProgramChanged();
- gtk_widget_set_sensitive (MainWindow, TRUE);
}
void ShowContactsDialog(BOOL *negated, char *name)
{
- ContactsGrid = gtk_grid_new();
- ContactsPackingBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
-
- ContactsDialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(ContactsDialog), "Contacts");
- gtk_window_set_default_size(GTK_WINDOW(ContactsDialog), 100, 50);
- gtk_window_set_resizable (GTK_WINDOW (ContactsDialog), FALSE);
- gtk_container_add(GTK_CONTAINER(ContactsDialog), ContactsPackingBox);
- gtk_widget_add_events (ContactsDialog, GDK_KEY_PRESS_MASK);
- gtk_widget_add_events (ContactsDialog, GDK_BUTTON_PRESS_MASK);
-
+ ContactsDialog = CreateWindowClient(_("Contacts"),
+ 100, 100, 359, 115, MainWindow);
+ ContactsGrid = new QGridLayout(ContactsDialog);
+ ContactsDialog->setWindowTitle("Contacts");
+ // CoilDialog->setFixedSize(359,115);
MakeControls();
-
+ NameTextbox->setValidator(
+ new QRegExpValidator(QRegExp("[a-zA-Z0-9_]+")));
+
if(name[0] == 'R') {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (SourceInternalRelayRadio), TRUE);
- }
- else if(name[0] == 'Y') {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (SourceOutputPinRadio), TRUE);
+ SourceInternalRelayRadio->setChecked(TRUE);
+ } else if (name[0] == 'Y'){
+ SourceOutputPinRadio->setChecked(TRUE);
}
- else {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (SourceInputPinRadio), TRUE);
+ else
+ {
+ SourceInputPinRadio->setChecked(TRUE);
}
+ NameTextbox->setText(name + 1);
if(*negated) {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (NegatedCheckbox), TRUE);
+ NegatedCheckbox->setChecked(TRUE);
+ } else{
+ NegatedCheckbox->setChecked(FALSE);
}
- gtk_entry_set_text (GTK_ENTRY (NameTextbox), name + 1);
-
- gtk_widget_set_sensitive (MainWindow, FALSE);
- gtk_widget_show_all (ContactsDialog);
- gtk_widget_grab_focus (NameTextbox);
- tmpname = name;
- tmpnegated = negated;
-
- g_signal_connect (G_OBJECT(NameTextbox), "insert-text",
- G_CALLBACK(ContactsDialogMyNameProc), NULL);
- g_signal_connect (G_OBJECT (ContactsDialog), "key-press-event",
- G_CALLBACK(ContactsDialogKeyPress), NULL);
- g_signal_connect (G_OBJECT (OkButton), "clicked",
- G_CALLBACK(ContactsDialogMouseClick), NULL);
- g_signal_connect (G_OBJECT (CancelButton), "clicked",
- G_CALLBACK(ContactsCallDestroyWindow), NULL);
+ int ret = ContactsDialog->exec();
+ switch(ret)
+ {
+ case QDialog::Accepted:
+ {
+ if(SourceInternalRelayRadio->isChecked())
+ {
+ name[0] = 'R';
+ }else if(SourceInputPinRadio->isChecked()){
+ name[0] = 'X';
+ } else {
+ name[0] = 'Y';
+ }
+ strncpy(name +1, NameTextbox->text().toStdString().c_str(),16);
+ if(NegatedCheckbox->isChecked()) {
+ *negated = TRUE;
+ } else {
+ *negated = FALSE;
+ }
+ }
+ break;
+ case QDialog::Rejected:
+ break;
+ }
+ DestroyWindow();
}
diff --git a/ldmicro/lib/linuxUI/linuxUI.h b/ldmicro/lib/linuxUI/linuxUI.h
index 507bd57..09f0c8b 100644
--- a/ldmicro/lib/linuxUI/linuxUI.h
+++ b/ldmicro/lib/linuxUI/linuxUI.h
@@ -25,6 +25,7 @@
#include <QPushButton>
#include <QDialogButtonBox>
#include <QRegExpValidator>
+#include <QCheckBox>
// #include <QtGui>
// #include <QSize>
// #include "freezeLD.h"
diff --git a/ldmicro/resetdialog.cpp b/ldmicro/resetdialog.cpp
index ff250df..e398098 100644
--- a/ldmicro/resetdialog.cpp
+++ b/ldmicro/resetdialog.cpp
@@ -29,103 +29,98 @@
using namespace std;
-static HWID ResetDialog;
+static QDialog* ResetDialog;
-static HWID TypeTimerRadio;
-static HWID TypeCounterRadio;
-static HWID NameTextbox;
-static HWID OkButton;
-static HWID CancelButton;
+static QRadioButton* TypeTimerRadio;
+static QRadioButton* TypeCounterRadio;
+static QLineEdit* NameTextbox;
+static QDialogButtonBox* ButtonBox;
-static LONG_PTR PrevNameProc;
-static HWID ResetGrid;
-static HWID ResetPackingBox;
-
-//-----------------------------------------------------------------------------
-// Don't allow any characters other than A-Za-z0-9_ in the name.
-//-----------------------------------------------------------------------------
-
-void ResetDialogMyNameProc (GtkEditable *editable, gchar *NewText, gint length,
- gint *position, gpointer data){
- // gtk_widget_set_sensitive (MainWindow, TRUE);
- for (int i = 0; i < length; i++){
- if (!(isalpha (NewText[i]) || NewText[i] == '_' || isdigit (NewText[i])
- || NewText[i] == '\b' )){
- g_signal_stop_emission_by_name (G_OBJECT (editable), "insert-text");
- return;
- }
- }
-}
+// static LONG_PTR PrevNameProc;
+static QGridLayout* ResetGrid;
+// static HWID ResetPackingBox;
static void MakeControls(void)
{
- TypeTimerRadio = gtk_radio_button_new_with_label (NULL, "Timer");
-
- TypeCounterRadio = gtk_radio_button_new_with_label_from_widget
- (GTK_RADIO_BUTTON (TypeTimerRadio), "Counter");
-
- HWID textLabel = gtk_label_new ("Name");
-
- NameTextbox = gtk_entry_new();
- gtk_entry_set_max_length (GTK_ENTRY (NameTextbox), 0);
-
- OkButton = gtk_button_new_with_label ("OK");
- CancelButton = gtk_button_new_with_label ("Cancel");
-
- gtk_grid_attach (GTK_GRID (ResetGrid), TypeTimerRadio, 1, 2, 1, 1);
- gtk_grid_attach (GTK_GRID (ResetGrid), TypeCounterRadio, 1, 3, 1, 1);
- gtk_grid_attach (GTK_GRID (ResetGrid), textLabel, 2, 2, 1, 1);
- gtk_grid_attach (GTK_GRID (ResetGrid), NameTextbox, 3, 2, 1, 1);
- gtk_grid_attach (GTK_GRID (ResetGrid), OkButton, 4, 2, 1, 1);
- gtk_grid_attach (GTK_GRID (ResetGrid), CancelButton, 4, 3, 1, 1);
-
- gtk_grid_set_column_spacing (GTK_GRID (ResetGrid), 1);
- gtk_box_pack_start(GTK_BOX(ResetPackingBox), ResetGrid, TRUE, TRUE, 0);
-
- g_signal_connect (G_OBJECT(NameTextbox), "insert-text",
- G_CALLBACK(ResetDialogMyNameProc), NULL);
+ QGroupBox* grouper = new QGroupBox(_("Type"));
+ QGridLayout *TypeGrid = new QGridLayout();
+ QGridLayout *NameGrid = new QGridLayout();
+ ButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok
+ | QDialogButtonBox::Cancel, Qt::Vertical,
+ ResetDialog);
+ NiceFont(ResetDialog);
+
+ ResetGrid->setSpacing(3);
+ TypeGrid->setSpacing(3);
+
+ TypeTimerRadio = new QRadioButton(_("Timer"), ResetDialog);
+ TypeCounterRadio = new QRadioButton(_("Counter"), ResetDialog);
+ TypeGrid->addWidget(TypeTimerRadio,0,0);
+ TypeGrid->addWidget(TypeCounterRadio,1,0);
+ /*SourceGrid->addItem(
+ new QSpacerItem(SetOnlyRadio->width(),
+ SetOnlyRadio->height()), 2, 0);*/
+ QLabel* textLabel = new QLabel(_("Name:"));
+ NameTextbox = new QLineEdit();
+ FixedFont(NameTextbox);
+ NameTextbox->setFixedWidth(155);
+ NameGrid->addWidget(textLabel,0,0);
+ NameGrid->addWidget(NameTextbox,0,1);
+ grouper->setLayout(TypeGrid);
+ ResetGrid->addWidget(grouper,0,0);
+ ResetGrid->addLayout(NameGrid,0,1);
+ ResetGrid->addWidget(ButtonBox,0,2);
+ QObject::connect(ButtonBox, SIGNAL(accepted()), ResetDialog, SLOT(accept()));
+ QObject::connect(ButtonBox, SIGNAL(rejected()), ResetDialog, SLOT(reject()));
}
-void ResetDialogGetData (char* name){
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (TypeTimerRadio))){
- name[0] = 'T';
- }
- else {
- name[0] = 'C';
- }
- strcpy (name+1, gtk_entry_get_text (GTK_ENTRY (NameTextbox)));
- gtk_widget_set_sensitive (MainWindow, TRUE);
- DestroyWindow (ResetDialog);
+inline void DestroyWindow (){
+ delete TypeTimerRadio;
+ delete TypeCounterRadio;
+ delete NameTextbox;
+ delete ButtonBox;
+ delete ResetGrid;
+ delete ResetDialog;
ProgramChanged();
}
-// Mouse click callback
-void ResetDialogMouseClick (HWID widget, gpointer data){
- ResetDialogGetData((char*)data);
-}
+void ShowResetDialog(char *name)
+{
+ ResetDialog = CreateWindowClient(_("Reset"),
+ 100, 100, 359, 115, MainWindow);
+ ResetGrid = new QGridLayout(ResetDialog);
+ ResetDialog->setWindowTitle("Reset");
+ // CoilDialog->setFixedSize(359,115);
+ MakeControls();
+ NameTextbox->setValidator(
+ new QRegExpValidator(QRegExp("[a-zA-Z0-9_]+")));
-// Checks for the required key press
-gboolean ResetDialogKeyPress (HWID widget, GdkEventKey* event, gpointer data){
- if (event -> keyval == GDK_KEY_Return){
- ResetDialogGetData((char*)data);
+ if(name[0] == 'T') {
+ TypeTimerRadio->setChecked(TRUE);
+ } else{
+ TypeCounterRadio->setChecked(TRUE);
}
- else if (event -> keyval == GDK_KEY_Escape){
- DestroyWindow (ResetDialog);
- ProgramChanged();
- gtk_widget_set_sensitive (MainWindow, TRUE);
+ NameTextbox->setText(name + 1);
+
+ int ret = ResetDialog->exec();
+ switch(ret)
+ {
+ case QDialog::Accepted:
+ {
+ if(TypeTimerRadio->isChecked())
+ {
+ name[0] = 'T';
+ }else {
+ name[0] = 'C';
+ }
+ strncpy(name +1, NameTextbox->text().toStdString().c_str(),16);
+ }
+ break;
+ case QDialog::Rejected:
+ break;
}
- return FALSE;
-}
-
-void ResetCallDestroyWindow (HWID widget, gpointer data){
- DestroyWindow (ResetDialog);
- ProgramChanged();
- gtk_widget_set_sensitive (MainWindow, TRUE);
-}
-
-void ShowResetDialog(char *name)
-{
- ResetGrid = gtk_grid_new();
+ DestroyWindow();
+ /*ResetGrid = gtk_grid_new();
ResetPackingBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
ResetDialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
@@ -155,5 +150,5 @@ void ShowResetDialog(char *name)
g_signal_connect (G_OBJECT (OkButton), "clicked",
G_CALLBACK(ResetDialogMouseClick), (gpointer)name);
g_signal_connect (G_OBJECT (CancelButton), "clicked",
- G_CALLBACK(ResetCallDestroyWindow), NULL);
+ G_CALLBACK(ResetCallDestroyWindow), NULL);*/
}
diff --git a/ldmicro/schematic.cpp b/ldmicro/schematic.cpp
index 1670475..840d095 100644
--- a/ldmicro/schematic.cpp
+++ b/ldmicro/schematic.cpp
@@ -403,14 +403,14 @@ void EditSelectedElement(void)
if(!Selected || Selected->selectedState == SELECTED_NONE) return;
switch(SelectedWhich) {
- /*case ELEM_COMMENT:
+ case ELEM_COMMENT:
ShowCommentDialog(Selected->d.comment.str);
break;
case ELEM_CONTACTS:
ShowContactsDialog(&(Selected->d.contacts.negated),
Selected->d.contacts.name);
- break;*/
+ break;
case ELEM_COIL:
ShowCoilDialog(&(Selected->d.coil.negated),
@@ -449,11 +449,11 @@ void EditSelectedElement(void)
ShowMathDialog(SelectedWhich, Selected->d.math.dest,
Selected->d.math.op1, Selected->d.math.op2);
break;
-
+*/
case ELEM_RES:
ShowResetDialog(Selected->d.reset.name);
break;
-
+/*
case ELEM_MOVE:
ShowMoveDialog(Selected->d.move.dest, Selected->d.move.src);
break;