8 |
9 | #include "ui_Lua4RSWidget.h"
10 | #include "Lua4RSWidget.h"
11 | #include "Lua/LuaCore.h"
12 | #include "Lua/LuaList.h"
13 | #include "interface/L4RInterface.h"
14 |
15 | #define ALL_SCRIPTS_COLUMN_ENABLE 4
16 |
17 | Lua4RSWidget::Lua4RSWidget(QWidget *parent) :
18 | MainPage(parent),
19 | ui(new Ui::Lua4RSWidget),
20 | _activeContainer(NULL),
21 | _disableOutput(false)
22 | {
23 | ui->setupUi(this);
24 |
25 | _lua = L4R::L4RConfig->getCore();
26 |
27 | setLuaCodes(_lua->codeList());
28 |
29 | clearUi();
30 |
31 | luaContainerToUi(_activeContainer);
32 |
33 | // Fill Hints TreeWidget with main items
34 | _lua->setupRsFunctionsAndTw(ui->tw_hints);
35 |
36 | // f*c: Set header resize mode of tw_allscripts to content dependant
37 | #if QT_VERSION < 0x050000
38 | ui->tw_allscripts->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
39 | #else
40 | ui->tw_allscripts->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
41 | #endif
42 |
43 | // Help Button
44 | QString help_str = tr(
45 | "
Lua4RS
\
46 | With Lua4RS you get three things with one Plugin:
\
47 | \
48 | - You can write, save, load and run Lua programs within RetroShare.
\
49 | - You can use Lua programs like macros (think of macros in LibreOffice) \
50 | to control and automate many features of RetroShare.
\
51 | - You can execute your Lua programs either by timer control (think of \
52 | cron or at) or by certain RetroShare events (e.g. a friend comes \
53 | online or a chat message is received and many more).
\
54 |
\
55 | ");
56 |
57 | registerHelpButton(ui->helpButton, help_str);
58 |
59 | QShortcut *shortcut = new QShortcut(QKeySequence("Ctrl+S"), ui->pte_luacode);
60 | QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(on_pb_save_clicked()));
61 | }
62 |
63 | Lua4RSWidget::~Lua4RSWidget()
64 | {
65 | delete ui;
66 | }
67 |
68 | void Lua4RSWidget::disableOutput()
69 | {
70 | _disableOutput = true;
71 | }
72 |
73 | void Lua4RSWidget::setLuaCodes(LuaList* list)
74 | {
75 | ui->tw_allscripts->setRowCount(0);
76 |
77 | // disable sorting (better performance)
78 | ui->tw_allscripts->setSortingEnabled(false);
79 | LuaContainerList::const_iterator it;
80 | for(it = list->begin(); it != list->end(); ++it)
81 | allScriptsAddRow(*it);
82 |
83 | ui->tw_allscripts->setSortingEnabled(true);
84 | }
85 |
86 | void Lua4RSWidget::clearOutput()
87 | {
88 | if(!_disableOutput)
89 | ui->tb_output->clear();
90 | }
91 |
92 | void Lua4RSWidget::appendOutput(const std::string& s)
93 | {
94 | appendOutput(QString::fromStdString(s));
95 | }
96 |
97 | void Lua4RSWidget::appendOutput(const QString& s)
98 | {
99 | if(!_disableOutput)
100 | ui->tb_output->appendPlainText(s);
101 | }
102 |
103 | void Lua4RSWidget::appendLog(const std::string& s)
104 | {
105 | appendLog(QString::fromUtf8(s.c_str()));
106 | }
107 |
108 | void Lua4RSWidget::appendLog(const QString& s)
109 | {
110 | if(!_disableOutput)
111 | ui->tb_log->appendPlainText(QDateTime::currentDateTime().toString("dd.MM.yy hh:mm:ss") + QString(" > ") + s);
112 | }
113 |
114 | /* #############################################################
115 | * # helper
116 | * #############################################################
117 | */
118 |
119 | LuaContainer* Lua4RSWidget::allScriptsGetLuaContainerFromSelectedRow()
120 | {
121 | // get corresponding LuaContainer
122 | QModelIndexList rows = ui->tw_allscripts->selectionModel()->selectedRows();
123 | if(rows.count() != 1)
124 | return NULL;
125 |
126 | return allScriptsGetLuaContainerFromRow(rows[0].row());
127 | }
128 |
129 | LuaContainer* Lua4RSWidget::allScriptsGetLuaContainerFromRow(const int row)
130 | {
131 | if(row < 0)
132 | return NULL;
133 |
134 | // get script name
135 | QTableWidgetItem* name = ui->tw_allscripts->item(row, 0);
136 |
137 | std::cout << "[Lua] Lua4RSWidget::allScriptsGetLuaContainerFromRow : trying to load LuaContaienr for " << name->text().toStdString() << " ...";
138 |
139 | // get container by name
140 | LuaContainer* container;
141 | if(_lua->codeList()->itemByName(name->text(), container))
142 | {
143 | std::cout << " got it!" << std::endl;
144 | return container;
145 | }
146 | // else
147 | std::cout << " failed!" << std::endl;
148 | return NULL;
149 | }
150 |
151 | void Lua4RSWidget::allScriptsAddRow(LuaContainer* container)
152 | {
153 | int rows = ui->tw_allscripts->rowCount();
154 | ui->tw_allscripts->setRowCount(rows + 1);
155 |
156 | QTableWidgetItem* name = new QTableWidgetItem();
157 | QTableWidgetItem* desc = new QTableWidgetItem();
158 | QTableWidgetItem* lastRun = new QTableWidgetItem();
159 | QTableWidgetItem* trigger = new QTableWidgetItem();
160 | QTableWidgetItem* enabled = new QTableWidgetItem();
161 |
162 | name->setText(container->getName());
163 | desc->setText(container->getDesc());
164 | lastRun->setText(container->getLastTriggered().toString());
165 | trigger->setText("TODO");
166 | enabled->setCheckState(container->getEnabled() ? Qt::Checked : Qt::Unchecked);
167 |
168 | ui->tw_allscripts->setItem(rows, 0, name);
169 | ui->tw_allscripts->setItem(rows, 1, desc);
170 | ui->tw_allscripts->setItem(rows, 2, lastRun);
171 | ui->tw_allscripts->setItem(rows, 3, trigger);
172 | ui->tw_allscripts->setItem(rows, 4, enabled);
173 | }
174 |
175 | // init the gui at startup and after a container switch before the ini is loaded
176 | void Lua4RSWidget::clearUi()
177 | {
178 | ui->cbx_enable->setChecked(false);
179 | ui->cbx_timeconstraint->setChecked(false);
180 | ui->tied_timefrom->setTime(QTime(0,0,0));
181 | ui->tied_timeto->setTime(QTime(0,0,0));
182 |
183 | ui->le_scriptname->clear();
184 | ui->le_scriptdesc->clear();
185 | ui->pte_luacode->clear();
186 |
187 | ui->cb_every->setChecked(false);
188 | ui->cb_once->setChecked(false);
189 | ui->cb_startup->setChecked(false);
190 | ui->cb_shutdown->setChecked(false);
191 |
192 | ui->rb_runonevent->setChecked(false);
193 | ui->dd_events->setCurrentIndex(0);
194 |
195 | ui->spb_everycount->setValue(5);
196 | ui->dd_everyunits->setCurrentIndex(1);
197 |
198 | ui->dte_runonce->setDateTime(QDateTime::currentDateTime());
199 |
200 | ui->cb_chatmessage->setChecked(false);
201 | }
202 |
203 | void Lua4RSWidget::luaContainerToUi(LuaContainer* container)
204 | {
205 | // clear ui and set needed fields/boxes
206 | clearUi();
207 |
208 | // for settings things to default / resetting
209 | if(container == NULL)
210 | {
211 | ///TODO there might be better ways that this - good enough for the moment
212 | ui->pte_luacode->setEnabled(false);
213 | } else
214 | {
215 | // name, desc, code
216 | ui->le_scriptname->setText(container->getName());
217 | ui->le_scriptdesc->setText(container->getDesc());
218 | ui->pte_luacode->setPlainText(container->getCode());
219 |
220 | ui->cbx_enable->setChecked(container->getEnabled());
221 | ui->cbx_timeconstraint->setChecked(container->getConstraintEnabled());
222 |
223 | QTime from, to;
224 | container->getConstraintFromTo(from, to);
225 | ui->tied_timefrom->setTime(from);
226 | ui->tied_timeto->setTime(to);
227 |
228 | // trigger
229 | uint amount, unit;
230 | if(container->getRunEveryChecked(amount, unit))
231 | {
232 | ui->cb_every->setChecked(true);
233 | ui->spb_everycount->setValue(amount);
234 | ui->dd_everyunits->setCurrentIndex(unit);
235 | }
236 | QDateTime dt;
237 | if(container->getRunOnceChecked(dt))
238 | {
239 | ui->cb_once->setChecked(true);
240 | ui->dte_runonce->setDateTime(dt);
241 | }
242 | if(container->getRunShutdownChecked())
243 | ui->cb_shutdown->setChecked(true);
244 | if(container->getRunStartupChecked())
245 | ui->cb_startup->setChecked(true);
246 |
247 | // event trigger
248 | if(container->getEventTriggerChecked(L4R_LOBBY_MESSAGERECEIVED))
249 | ui->cb_chatmessage->setChecked(true);
250 |
251 |
252 | ///TODO rest
253 |
254 | ui->pte_luacode->setEnabled(true);
255 | }
256 | }
257 |
258 | bool Lua4RSWidget::uiToLuaContainer(LuaContainer* container)
259 | {
260 | if(!saneValues())
261 | {
262 | std::cerr << "[Lua] Lua4RSWidget::uiToLuaContainer : wrong values detected - aborting" << std::endl;
263 | return false;
264 | }
265 |
266 | // name, desc, code
267 | container->setName(ui->le_scriptname->text());
268 | container->setDesc(ui->le_scriptdesc->text());
269 | container->setCode(ui->pte_luacode->toPlainText());
270 |
271 | // enable, constraint
272 | container->setEnabled(ui->cbx_enable->isChecked());
273 | container->setConstraintEnabled(ui->cbx_timeconstraint->isChecked());
274 |
275 | QTime from, to;
276 | from = ui->tied_timefrom->time();
277 | to = ui->tied_timeto->time();
278 | container->setConstraintFromTo(from, to);
279 |
280 | // trigger
281 | container->removeAllTrigger();
282 |
283 | // add trigger
284 | if(ui->cb_every->isChecked())
285 | container->addRunEveryTrigger((uint)ui->spb_everycount->value(), (uint)ui->dd_everyunits->currentIndex());
286 | if(ui->cb_once->isChecked())
287 | container->addRunOnceTrigger(ui->dte_runonce->dateTime());
288 | if(ui->cb_shutdown->isChecked())
289 | container->addRunShutdownTrigger();
290 | if(ui->cb_startup->isChecked())
291 | container->addRunStratupTrigger();
292 |
293 | // add event trigger (need to make this nice someday)
294 | if(ui->cb_chatmessage->isChecked())
295 | container->addEventTrigger(L4R_LOBBY_MESSAGERECEIVED);
296 |
297 | ///TODO rest
298 |
299 | return true;
300 | }
301 |
302 | void Lua4RSWidget::switchContainer(LuaContainer* container)
303 | {
304 | // remember conatiner
305 | _activeContainer = container;
306 |
307 | // update UI
308 | // clearUi(); // no need for this since luaContainerToUi() calls clearUi()
309 | luaContainerToUi(_activeContainer);
310 |
311 | if(_activeContainer != NULL)
312 | std::cout << "[Lua] Lua4RSWidget::switchContainer : switched to " << _activeContainer->getName().toStdString() << std::endl;
313 | else
314 | std::cout << "[Lua] Lua4RSWidget::switchContainer : switched to NULL "<< std::endl;
315 | }
316 |
317 | void saneValuesHelper(const QString& msg, QString& allMsgs)
318 | {
319 | std::cerr << "[Lua] Lua4RSWidget::saneValues : " << msg.toStdString() << std::endl;
320 | allMsgs += "- " + msg + '\n';
321 | }
322 |
323 | bool Lua4RSWidget::saneValues()
324 | {
325 | QString msg = tr("The following problem(s) was/were found:\n");
326 | bool ret = true;
327 | if(ui->le_scriptname->text().isEmpty())
328 | {
329 | saneValuesHelper(tr("script name is empty"), msg);
330 | ret = false;
331 | }
332 |
333 | if(ui->cb_once->isChecked() && ui->dte_runonce->dateTime() < QDateTime::currentDateTime())
334 | {
335 | saneValuesHelper(tr("runOnce value lies in the past"), msg);
336 | ret = false;
337 | }
338 |
339 | if(ui->cbx_timeconstraint->isChecked() && ui->cb_once->isChecked() && (( // contraint enabled + run once
340 | ui->tied_timefrom->time() < ui->tied_timeto->time() && // from < to e.g. from 09:00 to 15:00
341 | (ui->dte_runonce->time() < ui->tied_timefrom->time() || ui->dte_runonce->time() > ui->tied_timeto->time()) // run once is outside of time window
342 | ) || (
343 | ui->tied_timefrom->time() > ui->tied_timeto->time() && // from > to e.g. from 23:00 to 06:00
344 | (ui->dte_runonce->time() <= ui->tied_timefrom->time() && ui->dte_runonce->time() >= ui->tied_timeto->time()) // run once is outside of time window
345 | // !(ui->dte_runonce->time() > ui->tied_timefrom->time() || ui->dte_runonce->time() < ui->tied_timeto->time()) equivalent - maybe easier to understand
346 | )))
347 | {
348 | saneValuesHelper(tr("runOnce value lies outside of constraint"), msg);
349 | ret = false;
350 | }
351 |
352 | if(ui->spb_everycount->value() < 0)
353 | {
354 | saneValuesHelper(tr("run every value is below 0"), msg);
355 | ret = false;
356 | }
357 |
358 | ///TODO check rest
359 |
360 | if(!ret)
361 | {
362 | // show errors to user
363 | QMessageBox mbox;
364 | mbox.setIcon(QMessageBox::Warning);
365 | mbox.setText(tr("Error(s) while checking"));
366 | mbox.setInformativeText(msg);
367 | mbox.setStandardButtons(QMessageBox::Ok);
368 | mbox.exec();
369 | }
370 |
371 | return ret;
372 | }
373 |
374 | void Lua4RSWidget::newScript()
375 | {
376 | _activeContainer = _lua->codeList()->createItem();
377 | // add new container to list
378 | _lua->codeList()->addItem(_activeContainer);
379 |
380 | // update all scripts
381 | setLuaCodes(_lua->codeList());
382 |
383 | // update ui
384 | luaContainerToUi(_activeContainer);
385 | }
386 |
387 | bool Lua4RSWidget::saveScript(bool showErrorMsg)
388 | {
389 | if(_activeContainer == NULL)
390 | return true;
391 |
392 | // check for rename
393 | {
394 | QString oldName = _activeContainer->getName();
395 | // get values from ui
396 | if(!uiToLuaContainer(_activeContainer))
397 | return false;
398 |
399 | if(_activeContainer->getName() != oldName)
400 | {
401 | std::cout << "[Lua] Lua4RSWidget::on_pb_save_clicked() : renaming " << oldName.toStdString() << " to " << _activeContainer->getName().toStdString() << std::endl;
402 | _lua->codeList()->rename(oldName, _activeContainer->getName());
403 | }
404 | }
405 |
406 | bool rc = _lua->codeList()->saveAll();
407 | if(!rc && showErrorMsg)
408 | {
409 | QMessageBox mbox;
410 | mbox.setIcon(QMessageBox::Warning);
411 | mbox.setText(tr("Error"));
412 | mbox.setInformativeText(tr("an error occured while saving"));
413 | mbox.setStandardButtons( QMessageBox::Ok );
414 | mbox.exec();
415 | }
416 | return rc;
417 | }
418 |
419 | /* #############################################################
420 | * # slots
421 | * #############################################################
422 | */
423 |
424 | // "Run" clicked : execute the script in the editor control
425 | void Lua4RSWidget::on_pb_run_clicked()
426 | {
427 | appendLog(QString("running: ") + ui->le_scriptname->text());
428 |
429 | QString code = ui->pte_luacode->toPlainText();
430 |
431 | _lua->runLuaByString(code);
432 |
433 | }
434 |
435 | // "New" clicked : create a new empty script
436 | void Lua4RSWidget::on_pb_newscript_clicked()
437 | {
438 | newScript();
439 | }
440 |
441 | // "Edit" clicked : edit the script selected in AllMyScripts
442 | void Lua4RSWidget::on_pb_editscript_clicked()
443 | {
444 | // get corresponding LuaContainer
445 | LuaContainer* container = allScriptsGetLuaContainerFromSelectedRow();
446 |
447 | if(container == NULL)
448 | {
449 | std::cerr << "[Lua] Lua4RSWidget::on_pb_editscript_clicked : got NULL" << std::endl;
450 | return;
451 | }
452 | switchContainer(container);
453 | }
454 |
455 | // "Delete" clicked : delete the script selected in AllMyScripts
456 | void Lua4RSWidget::on_pb_deletescript_clicked()
457 | {
458 | LuaContainer* container = allScriptsGetLuaContainerFromSelectedRow();
459 | if(container == NULL)
460 | return;
461 |
462 | // update UI when necessary
463 | if(_activeContainer == container)
464 | {
465 | _activeContainer = NULL;
466 | luaContainerToUi(_activeContainer);
467 | }
468 |
469 | _lua->codeList()->removeItemAndDelete(container);
470 | // container is deleted now
471 | container = NULL;
472 |
473 | // update all scripts
474 | setLuaCodes(_lua->codeList());
475 | }
476 |
477 | // "Load" clicked : load a scriptfile from disk into the editor control
478 | void Lua4RSWidget::on_pb_load_clicked()
479 | {
480 | QString name = "";
481 | if(_activeContainer != NULL)
482 | {
483 | // a file was opened -> save its name
484 | name = _activeContainer->getName();
485 |
486 | // ask for confirmation
487 | QMessageBox mbox;
488 | mbox.setIcon(QMessageBox::Information);
489 | mbox.setText(tr("Continue?"));
490 | mbox.setInformativeText(tr("You have a Lua script opened. Save it before closing it?"));
491 | mbox.setStandardButtons( QMessageBox::Save | QMessageBox::Discard | QMessageBox::Abort);
492 |
493 | int ret = mbox.exec();
494 | if(ret == QMessageBox::Abort)
495 | return;
496 |
497 | if(ret == QMessageBox::Save)
498 | saveScript();
499 | }
500 |
501 | LuaList* list = _lua->codeList();
502 |
503 | list->loadAll();
504 | // _activeContainer is invalid from now on!
505 | _activeContainer = NULL;
506 |
507 | setLuaCodes(list);
508 |
509 | if(name == "")
510 | // no file was opened - were are done
511 | return;
512 |
513 | LuaContainer* lc;
514 | if(list->itemByName(name, lc))
515 | switchContainer(lc);
516 | else
517 | // couldn't find the file one was working one ...
518 | switchContainer(NULL);
519 | }
520 |
521 | // "Save" clicked : save the contents of the editor control to a file on disk
522 | void Lua4RSWidget::on_pb_save_clicked()
523 | {
524 | saveScript();
525 | }
526 |
527 | // "Enabled Script" clicked :
528 | void Lua4RSWidget::on_cbx_enable_clicked(bool checked)
529 | {
530 | if(_activeContainer == NULL)
531 | return;
532 |
533 | _activeContainer->setEnabled(checked);
534 |
535 | // update all scripts
536 | LuaContainer* lc;
537 | for(int i = 0; i < ui->tw_allscripts->rowCount(); ++i)
538 | {
539 | lc = allScriptsGetLuaContainerFromRow(i);
540 | if(lc == _activeContainer)
541 | {
542 | QTableWidgetItem* enabled = ui->tw_allscripts->item(i, ALL_SCRIPTS_COLUMN_ENABLE);
543 | enabled->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
544 | break;
545 | }
546 | }
547 | }
548 |
549 |
550 | //------------------------------------------------------------------------------
551 | // Execution Constraint
552 | //------------------------------------------------------------------------------
553 |
554 | // "...between" clicked : Constraint enabled/disabled has changed
555 | // note: think about disabling constraint from and to timeedits if unchecked
556 | void Lua4RSWidget::on_cbx_timeconstraint_clicked(bool checked)
557 | {
558 | if(_activeContainer == NULL)
559 | {
560 | std::cerr << "[Lua] Lua4RSWidget::on_cbx_timeconstraint_toggled : got no activeContainer" << std::endl;
561 | return;
562 | }
563 | _activeContainer->setConstraintEnabled(checked);
564 | }
565 |
566 | // from : Constraint "from"-time has changed
567 | // note: dont forget to check if from < to!
568 | void Lua4RSWidget::on_tied_timefrom_editingFinished()
569 | {
570 | }
571 |
572 | // to : Constraint "to"-time has changed
573 | // note: dont forget to check if from < to!
574 | void Lua4RSWidget::on_tied_timeto_editingFinished()
575 | {
576 | }
577 |
578 | //------------------------------------------------------------------------------
579 | // All Scripts
580 | //------------------------------------------------------------------------------
581 |
582 | void Lua4RSWidget::on_tw_allscripts_cellClicked(int row, int column)
583 | {
584 | if(column == ALL_SCRIPTS_COLUMN_ENABLE) // 4 = enabled
585 | {
586 | LuaContainer* container = allScriptsGetLuaContainerFromRow(row);
587 | QTableWidgetItem* cell = ui->tw_allscripts->item(row, column);
588 |
589 | container->setEnabled(cell->checkState() == Qt::Checked ? true : false);
590 |
591 | if(container == _activeContainer)
592 | // update ui->cbx_enable
593 | ui->cbx_enable->setChecked(_activeContainer->getEnabled());
594 | }
595 | }
596 |
597 | void Lua4RSWidget::on_tw_allscripts_cellDoubleClicked(int row, int /*column*/)
598 | {
599 | if(row < 0)
600 | return;
601 |
602 | // save then load
603 | saveScript();
604 |
605 | // get container
606 | LuaContainer* container = allScriptsGetLuaContainerFromRow(row);
607 | if(container == NULL)
608 | {
609 | std::cerr << "[Lua] Lua4RSWidget::on_tw_allscripts_doubleClicked : got NULL" << std::endl;
610 | return;
611 | }
612 | switchContainer(container);
613 | }
614 |
615 | //------------------------------------------------------------------------------
616 | // Tabpage "By Timer"
617 | //------------------------------------------------------------------------------
618 | void Lua4RSWidget::on_spb_everycount_editingFinished()
619 | {
620 | return;
621 | }
622 |
623 |
624 | // "Run Every" : amount of timer units has changed
625 | // note: if changed, rb_runevery should be selected
626 | void Lua4RSWidget::on_dd_everyunits_currentIndexChanged(int index)
627 | {
628 | uint TIME_UNITS[5] = {1, 60, 3600, 86400, 604800};
629 | uint unit,amount,interval;
630 |
631 | amount = ui->spb_everycount->value();
632 | unit = TIME_UNITS[index];
633 | interval = amount * unit;
634 |
635 | ui->l_runeveryhelper->setText( QString::number(interval) + " secs" ); // just to see
636 | }
637 |
638 | // "RunEvery" : unit of timer units has changed
639 | // note: if changed, rb_runevery should be selected
640 | void Lua4RSWidget::on_spb_everycount_valueChanged(int arg1)
641 | {
642 | uint TIME_UNITS[5] = {1, 60, 3600, 86400, 604800};
643 | uint unit,amount,interval;
644 |
645 | amount = arg1;
646 | unit = TIME_UNITS[ui->dd_everyunits->currentIndex()];
647 | interval = amount * unit;
648 |
649 | ui->l_runeveryhelper->setText( QString::number(interval) + " secs" );
650 | }
651 |
652 | // hack for color
653 | #define ACTIVE_COLOR "background:lightgreen;"
654 |
655 | // Run Every was selected
656 | void Lua4RSWidget::on_cb_every_toggled(bool checked)
657 | {
658 | ui->cb_every->setStyleSheet(checked ? ACTIVE_COLOR : "background:transparent;");
659 | }
660 |
661 | // Run Once was selected
662 | void Lua4RSWidget::on_cb_once_toggled(bool checked)
663 | {
664 | ui->cb_once->setStyleSheet(checked ? ACTIVE_COLOR : "background:transparent;");
665 | }
666 |
667 | // Run at startup was selected
668 | void Lua4RSWidget::on_cb_startup_toggled(bool checked)
669 | {
670 | ui->cb_startup->setStyleSheet(checked ? ACTIVE_COLOR : "background:transparent;");
671 | }
672 |
673 | // Run at shutdown was selected
674 | void Lua4RSWidget::on_cb_shutdown_toggled(bool checked)
675 | {
676 | ui->cb_shutdown->setStyleSheet(checked ? ACTIVE_COLOR : "background:transparent;");
677 | }
678 | #undef ACTIVE_COLOR
679 |
680 | //------------------------------------------------------------------------------
681 | // Tabpage "By Event"
682 | //------------------------------------------------------------------------------
683 | void Lua4RSWidget::on_rb_runonevent_toggled(bool /*checked*/)
684 | {
685 | }
686 |
687 | void Lua4RSWidget::on_dd_events_currentIndexChanged(int /*index*/)
688 | {
689 | }
690 |
691 |
692 | //------------------------------------------------------------------------------
693 | // hints
694 | //------------------------------------------------------------------------------
695 | void Lua4RSWidget::on_pb_pastehint_released()
696 | {
697 | QList items = ui->tw_hints->selectedItems();
698 | if(items.empty() || items.size() != 1 || !ui->pte_luacode->isEnabled())
699 | return;
700 |
701 | ui->pte_luacode->insertPlainText(items.at(0)->text(1));
702 | }
703 |
704 | void Lua4RSWidget::on_tw_hints_itemDoubleClicked(QTreeWidgetItem *item, int /*column*/)
705 | {
706 | QString hint = item->text(1);
707 |
708 | // when you want to expant a namespace, you double click it --> don't append hint on a double click on a namespace
709 | if(hint.endsWith('.') || !ui->pte_luacode->isEnabled())
710 | return;
711 |
712 | ui->pte_luacode->insertPlainText(hint);
713 | }
714 |
--------------------------------------------------------------------------------
/lang/Lua4RS_de.ts:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Lua4RSConfig
6 |
7 |
8 | Form
9 |
10 |
11 |
12 |
13 | tick options
14 | Tickoptionen
15 |
16 |
17 |
18 | This lets you choose after how many seconds the startup event is triggered
19 |
20 |
21 |
22 |
23 | tick interval
24 | Tickintervall
25 |
26 |
27 |
28 |
29 | s
30 | Sekunde
31 | s
32 |
33 |
34 |
35 | this lets you choose after how many seconds a tick event is triggered
36 |
37 |
38 |
39 |
40 | startup event
41 | Startup Event
42 |
43 |
44 |
45 | NOBODY WILL HELP YOU :O
46 |
47 |
48 |
49 |
50 | Lua4RSWidget
51 |
52 |
53 | Form
54 |
55 |
56 |
57 |
58 | Lua4RS
59 | Lua4RS
60 |
61 |
62 |
63 | All My Scripts
64 | Meine Scripte
65 |
66 |
67 |
68 | by sehraf & far*call
69 | von sehraf & far*call
70 |
71 |
72 |
73 |
74 | Scriptname
75 | Scriptname
76 |
77 |
78 |
79 |
80 | Description
81 | Beschreibung
82 |
83 |
84 |
85 | Last Run
86 | Letzte Ausführung
87 |
88 |
89 |
90 | Trigger
91 | Auslöser
92 |
93 |
94 |
95 | Enabled
96 | Aktiv
97 |
98 |
99 |
100 | Edit the selected script in the Lua Code Editor
101 |
102 |
103 |
104 |
105 | Edit
106 | Bearbeiten
107 |
108 |
109 |
110 | Create a new empty script
111 |
112 |
113 |
114 |
115 | New
116 | Neu
117 |
118 |
119 |
120 | Delete the selected script
121 |
122 |
123 |
124 |
125 | Delete
126 | Löschen
127 |
128 |
129 |
130 | Load a Lua script from disk into the Lua Code Editor
131 |
132 |
133 |
134 |
135 | Load from disk
136 | Laden
137 |
138 |
139 |
140 | Activation
141 | Aktivierung
142 |
143 |
144 |
145 | Check/Uncheck to enable/disable the execution of the current script
146 |
147 |
148 |
149 |
150 | Enable script
151 | Script aktvieren
152 |
153 |
154 |
155 | Check/Uncheck to constrain script execution to certain hours of the day
156 |
157 |
158 |
159 |
160 | ... from
161 | ... von
162 |
163 |
164 |
165 | Start of execution interval
166 |
167 |
168 |
169 |
170 |
171 | HH:mm:ss 'h
172 |
173 |
174 |
175 |
176 | to
177 | bis
178 |
179 |
180 |
181 | End of execution interval
182 |
183 |
184 |
185 |
186 | The filename of this script in your script folder
187 |
188 |
189 |
190 |
191 | Enter a description of this script to remember what it is doing
192 |
193 |
194 |
195 |
196 | Code
197 | Code
198 |
199 |
200 |
201 | Run current Lua script. View script output in the Output Tab
202 |
203 |
204 |
205 |
206 | Run
207 | Ausführen
208 |
209 |
210 |
211 | Save current Lua script
212 |
213 |
214 |
215 |
216 | Save
217 | Speichern
218 |
219 |
220 |
221 | Undock the editor to a separate resizable window
222 |
223 |
224 |
225 |
226 | Undock
227 |
228 |
229 |
230 |
231 | RS Properties
232 | RS Funktionen
233 |
234 |
235 |
236 | Doubleclick on item to paste it into the Lua Code Editor
237 |
238 |
239 |
240 |
241 | Paste selected Item into the Lua editor at the current cursor position
242 |
243 |
244 |
245 |
246 | Paste
247 | Einfügen
248 |
249 |
250 |
251 | Output
252 | Ausgabe
253 |
254 |
255 |
256 | By Timer
257 | nach Zeit
258 |
259 |
260 |
261 | Control script execution by timer
262 |
263 |
264 |
265 |
266 | Run the current script on an interval basis
267 |
268 |
269 |
270 |
271 | Run every
272 | Ausführung alle
273 |
274 |
275 |
276 | Seconds
277 | Sekunden
278 |
279 |
280 |
281 | Minutes
282 | Minuten
283 |
284 |
285 |
286 | Hours
287 | Stunden
288 |
289 |
290 |
291 | Days
292 | Tage
293 |
294 |
295 |
296 | Weeks
297 | Wochen
298 |
299 |
300 |
301 | (300 secs)
302 |
303 |
304 |
305 |
306 | Run the current script once at the specified time
307 |
308 |
309 |
310 |
311 | Run once at
312 | Einmalig um
313 |
314 |
315 |
316 | d MMM yyyy, HH:mm:ss t
317 |
318 |
319 |
320 |
321 | Run the current script only once when RS starts
322 |
323 |
324 |
325 |
326 | Run at Startup
327 | Ausfurung beim Start
328 |
329 |
330 |
331 | Run at Shutdown
332 | Ausführung beim Beenden
333 |
334 |
335 |
336 | By Event
337 | nach Event
338 |
339 |
340 |
341 | Control script execution by events
342 |
343 |
344 |
345 |
346 | Run on Event
347 |
348 |
349 |
350 |
351 | Friend Comes Online (Friend, When)
352 |
353 |
354 |
355 |
356 | Friend Goes Offline (Friend, When)
357 |
358 |
359 |
360 |
361 | Download Started (Filename, Hash, Size, When)
362 |
363 |
364 |
365 |
366 | Download Finished (Filename, Hash, Size, When)
367 |
368 |
369 |
370 |
371 | Chat Message Received (Lobby, MsgText, Author, When)
372 |
373 |
374 |
375 |
376 | Chat Message Sent (Lobby, MsgText, When)
377 |
378 |
379 |
380 |
381 | Mail Received (From, Subject, Body, When)
382 |
383 |
384 |
385 |
386 | Mail Sent (To, Subject, Body, When)
387 |
388 |
389 |
390 |
391 | RetroShare Shutdown (When)
392 |
393 |
394 |
395 |
396 | User Entered Lobby (User, Lobby, List of Users, When)
397 |
398 |
399 |
400 |
401 | User Left Lobby (User, Lobby, List of Users, When)
402 |
403 |
404 |
405 |
406 | Log
407 | Log
408 |
409 |
410 |
411 | <h1><img width="32" src=":/images/64px_help.png"> Lua4RS</h1> <p>With Lua4RS you get three things with one Plugin: </p> <ul> <li>You can write, save, load and run Lua programs within RetroShare.</li> <li>You can use Lua programs like macros (think of macros in LibreOffice) to control and automate many features of RetroShare. </li> <li>You can execute your Lua programs either by timer control (think of cron or at) or by certain RetroShare events (e.g. <i>a friend comes online</i> or <i>a chat message is received</i> and many more).</li> </ul>
412 |
413 |
414 |
415 |
416 | The following problem(s) was/were found:
417 |
418 | Die folgenden Probleme wurden gefunden:
419 |
420 |
421 |
422 |
423 | script name is empty
424 | der Scriptname ist leer
425 |
426 |
427 |
428 | runOnce value lies in the past
429 | die einmalige Ausführung liegt in der Vergangenheit
430 |
431 |
432 |
433 | runOnce value lies outside of constraint
434 | die einmalige Ausführung liegt nicht innerhalb des Zeitfensters
435 |
436 |
437 |
438 | run every value is below 0
439 | der "Ausführung alle"-Wert ist kleiner 0
440 |
441 |
442 |
443 | Error(s) while checking
444 | Fehler beim Überprüfen
445 |
446 |
447 |
448 | Error
449 | Fehler
450 |
451 |
452 |
453 | an error occured while saving
454 | Ein Fehler trat beim Speichern auf
455 |
456 |
457 |
458 | Continue?
459 | Fortfahren?
460 |
461 |
462 |
463 | You have a Lua script opened. Save it before closing it?
464 | Ein Lua Script ist geöffnet. Soll es vor dem Schließen gespeichert werden?
465 |
466 |
467 |
468 | QObject
469 |
470 |
471 | clears the output
472 | Löscht die Ausgabe
473 |
474 |
475 |
476 | prints to output
477 | schreibt etwas in die Ausgabe
478 |
479 |
480 |
481 | returns own SSL id
482 |
483 |
484 |
485 |
486 | returns list of online friends (SSL id)
487 |
488 |
489 |
490 |
491 | returns list of all friends (SSL id)
492 |
493 |
494 |
495 |
496 | returns number of all friends and online friends
497 |
498 |
499 |
500 |
501 | returns if a peer is a friend
502 |
503 |
504 |
505 |
506 | returns is a PGP key is accepted
507 |
508 |
509 |
510 |
511 | returns if a peer is online
512 |
513 |
514 |
515 |
516 | returns the PGP name for a given PGP id
517 |
518 |
519 |
520 |
521 | returns the name for a given SSL/PGP id
522 |
523 |
524 |
525 |
526 | returns peer details as a table for a given SSL id
527 |
528 |
529 |
530 |
531 | returns own PGP id
532 |
533 |
534 |
535 |
536 |
537 | returns the PGP id for a given SSL/PGP id
538 |
539 |
540 |
541 |
542 | creates a new group
543 |
544 |
545 |
546 |
547 | edits an existing group
548 |
549 |
550 |
551 |
552 | removes the group with the given groupd id
553 |
554 |
555 |
556 |
557 | returns group info for a given group id
558 |
559 |
560 |
561 |
562 | returns an array with all groups and their group infos
563 |
564 |
565 |
566 |
567 | returns the current operation mode as int and string
568 |
569 |
570 |
571 |
572 | sets the openration mode (takes int or string)
573 |
574 |
575 |
576 |
577 | sets max down-/upload bandwidth in kB
578 |
579 |
580 |
581 |
582 | gets max down-/upload bandwidth in kB
583 |
584 |
585 |
586 |
587 | gets current down-/upload bandwidth in kB
588 |
589 |
590 |
591 |
592 | triggered script:
593 |
594 |
595 |
596 |
597 | This plugin let you script RS with Lua.
598 |
599 |
600 |
601 |
602 |
--------------------------------------------------------------------------------