Neal Wilson 9 년 전
부모
커밋
83b27e8635
2개의 변경된 파일29개의 추가작업 그리고 1개의 파일을 삭제
  1. 19
    1
      config/Windows/newbatch.xml
  2. 10
    0
      src/typica.w

+ 19
- 1
config/Windows/newbatch.xml 파일 보기

@@ -495,6 +495,20 @@
495 495
             var approval = findChildObject(this, 'approval');
496 496
             approval.checked = true;
497 497
             var target = findChildObject(this, 'target');
498
+            var checkSubmitEnable = function () {
499
+                if(roasted.currentIndex > 0) {
500
+                    if(timefield.text.length > 0) {
501
+                        if(duration.text.length > 0) {
502
+                            if(batch.tempData.length > 0) {
503
+                                if(green.text.length > 0) {
504
+                                    return true;
505
+                                }
506
+                            }
507
+                        }
508
+                    }
509
+                }
510
+                return false;
511
+            }
498 512
             submitbutton.clicked.connect(function() {
499 513
                 var proceed = false;
500 514
                 if(validateCapacity()) {
@@ -503,7 +517,11 @@
503 517
                     proceed = displayWarning("Suspicious Input", "Entered green coffee weight exceeds maximum batch size. Continue?");
504 518
                 }
505 519
                 if(proceed) {
506
-                    doSubmit();
520
+                    if(checkSubmitEnable()) {
521
+                        doSubmit();
522
+                    } else {
523
+                        displayError("Incomplete Input", "Some required information is not available. Please check inputs and try again.");
524
+                    }
507 525
                 }
508 526
             });
509 527
             var doSubmit = function() {

+ 10
- 0
src/typica.w 파일 보기

@@ -937,12 +937,15 @@ message and return the selected action.
937 937
 
938 938
 @<Function prototypes for scripting@>=
939 939
 QScriptValue displayWarning(QScriptContext *context, QScriptEngine *engine);
940
+QScriptValue displayError(QScriptContext *context, QScriptEngine *engine);
940 941
 
941 942
 @ This function is exposed to the host environment.
942 943
 
943 944
 @<Set up the scripting engine@>=
944 945
 constructor = engine->newFunction(displayWarning);
945 946
 engine->globalObject().setProperty("displayWarning", constructor);
947
+constructor = engine->newFunction(displayError);
948
+engine->globalObject().setProperty("displayError", constructor);
946 949
 
947 950
 @ The function takes some arguments.
948 951
 
@@ -959,6 +962,13 @@ QScriptValue displayWarning(QScriptContext *context, QScriptEngine *)
959 962
     return QScriptValue(false);
960 963
 }
961 964
 
965
+QScriptValue displayError(QScriptContext *context, QScriptEngine *)
966
+{
967
+    QMessageBox::critical(NULL, argument<QString>(0, context),
968
+                          argument<QString>(1, context));
969
+    return QScriptValue();
970
+}
971
+
962 972
 @* Scripting QMainWindow.
963 973
 
964 974
 \noindent Rather than directly exposing |QMainWindow| to the scripting engine,

Loading…
취소
저장