Typica is a free program for professional coffee roasters. https://typica.us
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <window id="editreminder">
  2. <layout type="vertical">
  3. <layout type="horizontal">
  4. <label>Name:</label>
  5. <line id="name" />
  6. </layout>
  7. <label>Description:</label>
  8. <textarea id="description" />
  9. <layout type="horizontal">
  10. <label>Since:</label>
  11. <calendar time="true" id="since" />
  12. <button name="Now" id="now" type="push" />
  13. </layout>
  14. <layout type="horizontal">
  15. <label>Condition:</label>
  16. <sqldrop id="condition" />
  17. </layout>
  18. <layout type="stack" id="conditionvars">
  19. <page>
  20. <layout type="horizontal">
  21. <line id="productionweight" validator="numeric" />
  22. <sqldrop id="productionunit" />
  23. </layout>
  24. </page>
  25. <page>
  26. <layout type="horizontal">
  27. <line id="days" validator="numeric" />
  28. </layout>
  29. </page>
  30. <page>
  31. <layout type="horizontal">
  32. <line id="batches" validator="numeric" />
  33. </layout>
  34. </page>
  35. <page>
  36. <layout type="horizontal">
  37. <line id="roastingtime" validator="numeric" />
  38. </layout>
  39. </page>
  40. </layout>
  41. <layout type="horizontal">
  42. <button name="Delete" id="delete" type="push" />
  43. <button name="Save" id="save" type="push" />
  44. </layout>
  45. </layout>
  46. <program>
  47. <![CDATA[
  48. var window = this;
  49. window.setRefreshFunction = function(callback) {
  50. window.refreshCallback = callback;
  51. }
  52. window.currentReminder = new Object();
  53. this.windowTitle = TTR("editreminder", "Typica - Edit Reminder");
  54. var unitBox = findChildObject(this, 'productionunit');
  55. unitBox.addItem(TTR("editreminder", "Kg"));
  56. unitBox.addItem(TTR("editreminder", "Lb"));
  57. unitBox.currentIndex = QSettings.value("script/report_unit", 1);
  58. var condition = findChildObject(this, 'condition');
  59. condition.addItem(TTR("editreminder", "Roasted Coffee Production"));
  60. condition.addItem(TTR("editreminder", "Days"));
  61. condition.addItem(TTR("editreminder", "Batches Roasted"));
  62. condition.addItem(TTR("editreminder", "Hours of Roasting Time"));
  63. var conditionpage = findChildObject(this, 'conditionvars');
  64. condition['currentIndexChanged(int)'].connect(function(c) {
  65. conditionpage.setCurrentIndex(c);
  66. });
  67. var namefield = findChildObject(this, 'name');
  68. var descfield = findChildObject(this, 'description');
  69. var sincefield = findChildObject(this, 'since');
  70. var prodweight = findChildObject(this, 'productionweight');
  71. var daysfield = findChildObject(this, 'days');
  72. var batchesfield = findChildObject(this, 'batches');
  73. var hoursfield = findChildObject(this, 'roastingtime');
  74. var time = new QTime();
  75. var nowButton = findChildObject(this, 'now');
  76. nowButton.clicked.connect(function() {
  77. sincefield.setToCurrentTime();
  78. });
  79. var deleteButton = findChildObject(this, 'delete');
  80. deleteButton.enabled = false;
  81. deleteButton.clicked.connect(function() {
  82. var query = new QSqlQuery;
  83. query.prepare("DELETE FROM reminders WHERE id = :id");
  84. query.bind("id", window.currentReminder.dbid);
  85. query.exec();
  86. query = query.invalidate();
  87. window.refreshCallback();
  88. window.close();
  89. });
  90. var saveButton = findChildObject(this, 'save');
  91. saveButton.clicked.connect(function() {
  92. r = new Object();
  93. r.title = namefield.text;
  94. r.description = descfield.plainText;
  95. r.start_year = sincefield.year();
  96. r.start_month = sincefield.month();
  97. r.start_day = sincefield.day();
  98. r.start_time = sincefield.time.toString("hh:mm:ss");
  99. switch(condition.currentIndex)
  100. {
  101. case 0:
  102. r.condition = "PRODUCTIONWEIGHT";
  103. r.value = Number(prodweight.text);
  104. if(unitBox.currentIndex == 0)
  105. {
  106. r.unit = "KG";
  107. }
  108. else
  109. {
  110. r.unit = "LB";
  111. }
  112. break;
  113. case 1:
  114. r.condition = "DAYS";
  115. r.value = daysfield.text;
  116. break;
  117. case 2:
  118. r.condition = "PRODUCTIONBATCHES";
  119. r.value = batchesfield.text;
  120. break;
  121. case 3:
  122. r.condition = "PRODUCTIONHOURS";
  123. r.value = hoursfield.text;
  124. break;
  125. }
  126. var query = new QSqlQuery;
  127. if(window.currentReminder.hasOwnProperty("dbid"))
  128. {
  129. query.prepare("UPDATE reminders SET reminder = :reminder WHERE id = :id");
  130. query.bind("reminder", JSON.stringify(r));
  131. query.bind("id", window.currentReminder.dbid);
  132. }
  133. else
  134. {
  135. query.prepare("INSERT INTO reminders (id, reminder) VALUES(default, :reminder)");
  136. query.bind("reminder", JSON.stringify(r));
  137. }
  138. query.exec();
  139. query = query.invalidate();
  140. window.refreshCallback();
  141. window.close();
  142. });
  143. window.loadData = function(reminder) {
  144. window.currentReminder = reminder;
  145. deleteButton.enabled = reminder.hasOwnProperty("dbid");
  146. if(reminder.hasOwnProperty("title"))
  147. {
  148. namefield.text = reminder.title;
  149. }
  150. if(reminder.hasOwnProperty("description"))
  151. {
  152. descfield.plainText = reminder.description;
  153. }
  154. if(reminder.hasOwnProperty("start_year") &&
  155. reminder.hasOwnProperty("start_month") &&
  156. reminder.hasOwnProperty("start_day"))
  157. {
  158. sincefield.setDate(reminder.start_year, reminder.start_month, reminder.start_day);
  159. }
  160. if(reminder.hasOwnProperty("start_time"))
  161. {
  162. sincefield.time = time.fromString(reminder.start_time, "hh:mm:ss");
  163. }
  164. if(reminder.hasOwnProperty("condition"))
  165. {
  166. if(reminder.condition == "PRODUCTIONWEIGHT")
  167. {
  168. condition.setCurrentIndex(0);
  169. if(reminder.hasOwnProperty("value"))
  170. {
  171. prodweight.text = reminder.value;
  172. }
  173. if(reminder.unit == "KG")
  174. {
  175. unitBox.setCurrentIndex(0);
  176. }
  177. else
  178. {
  179. unitBox.setCurrentIndex(1);
  180. }
  181. }
  182. else if(reminder.condition == "DAYS")
  183. {
  184. condition.setCurrentIndex(1);
  185. if(reminder.hasOwnProperty("value"))
  186. {
  187. daysfield.text = reminder.value;
  188. }
  189. }
  190. else if(reminder.condition == "PRODUCTIONBATCHES")
  191. {
  192. condition.setCurrentIndex(2);
  193. if(reminder.hasOwnProperty("value"))
  194. {
  195. batchesfield.text = reminder.value;
  196. }
  197. }
  198. else if(reminder.condition == "PRODUCTIONHOURS")
  199. {
  200. condition.setCurrentIndex(3);
  201. if(reminder.hasOwnProperty("value"))
  202. {
  203. hoursfield.text = reminder.value;
  204. }
  205. }
  206. }
  207. }
  208. ]]>
  209. </program>
  210. </window>