refresh d48565f66ff8acede3634684d8b27f49805b70aa
[tagua/yd.git] / src / mainwindow.cpp
blobbb6d536744749eb74a80c2edfaecf5b7c7d6ef86
1 /*
2 Copyright (c) 2006-2007 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2006-2007 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #include "mainwindow.h"
12 #include <boost/scoped_ptr.hpp>
14 #include <QKeySequence>
15 #include <QStackedWidget>
16 #include <QDockWidget>
17 #include <QCloseEvent>
18 #include <QTextStream>
19 #include <QTextCodec>
21 #include <KAction>
22 #include <KStandardAction>
23 #include <KActionCollection>
24 #include <KIcon>
25 #include <KLocale>
26 #include <KFileDialog>
27 #include <kio/netaccess.h>
28 #include <KMessageBox>
29 #include <KMenuBar>
30 #include <KTemporaryFile>
32 #include <core/behaviour.h>
33 #include <core/color.h>
34 #include <core/state.h>
35 #include "variant.h"
37 #include "actioncollection.h"
38 #include "chesstable.h"
39 #include "console.h"
40 #include "clock.h"
41 #include "newgame.h"
42 #include "variants.h"
43 #include "gameinfo.h"
44 #include "controllers/editgame.h"
45 #include "controllers/editposition.h"
46 #include "engineinfo.h"
47 #include "movelist_table.h"
48 #include "icsconnection.h"
49 #include "qconnect.h"
50 #include "mastersettings.h"
51 #include "flash.h"
52 #include "foreach.h"
53 #include "pgnparser.h"
54 #include "pref_highlight.h"
55 #include "pref_preferences.h"
56 #include "tabwidget.h"
58 using namespace Qt;
59 using namespace boost;
61 MainWindow::~MainWindow() {
62 delete console;
63 qApp->quit();
66 MainWindow::MainWindow(const QString& variant)
67 : KXmlGuiWindow(0)
68 , m_ui(actionCollection()) {
69 setObjectName("tagua_main");
70 m_main = new TabWidget(this);
71 m_main->setTabBarHidden(true);
72 setCentralWidget(m_main);
74 m_movelist_stack = new QStackedWidget;
76 connect(m_main, SIGNAL(currentChanged(int)),
77 this, SLOT(changeTab(int)));
78 connect(m_main, SIGNAL(closeTab()),
79 this, SLOT(closeTab()));
81 movelist_dock = new QDockWidget(this);
82 movelist_dock->setWidget(m_movelist_stack);
83 movelist_dock->setWindowTitle(i18n("Move list"));
84 movelist_dock->setObjectName("move_list");
85 addDockWidget(Qt::LeftDockWidgetArea, movelist_dock, Qt::Vertical);
86 movelist_dock->show();
88 Variant* v = Variants::self().create(variant);
89 if (v == NULL) {
90 std::cerr << "Cannot instantiate variant \"" << variant << "\", aborting" << std::endl;
91 exit(1);
93 ChessTable* board = new ChessTable(v);
95 board->setFocus();
97 console_dock = new QDockWidget(this);
98 console = new Console(0, i18n("FICS Connection"));
99 console_dock->setWidget(console);
100 console_dock->setFocusProxy(console);
101 console_dock->setWindowTitle(i18n("Console"));
102 console_dock->setObjectName("console");
103 addDockWidget(Qt::BottomDockWidgetArea, console_dock, Qt::Horizontal);
104 console_dock->setWindowFlags(console_dock->windowFlags() & ~Qt::WindowStaysOnTopHint);
105 console_dock->show();
107 settings().onChange(this, "settingsChanged");
109 connect(board, SIGNAL(error(ErrorCode)), this, SLOT(displayErrorMessage(ErrorCode)));
111 setupActions();
112 setupGUI();
113 setupEngineMenu();
115 // start in edit game mode
116 newGame(v->name(), StatePtr(), true);
117 updateVariantActions();
120 ChessTable* MainWindow::table() {
121 return qobject_cast<ChessTable*>(m_main->currentWidget());
124 KAction* MainWindow::installRegularAction(const QString& name, const KIcon& icon, const QString& text, QObject* obj, const char* slot) {
125 KAction* temp = new KAction(icon, text, this);
126 actionCollection()->addAction(name, temp);
127 connect(temp, SIGNAL(triggered(bool)), obj, slot);
128 return temp;
131 void MainWindow::setupEngineMenu() {
132 QMenu* engine_menu = 0;
133 SettingArray engine_settings = settings().group("engines").array("engine");
134 foreach (Settings s, engine_settings) {
135 if (!engine_menu) {
136 // this way the menu is created only if there is at least one engine
137 engine_menu = menuBar()->addMenu(i18n("E&ngines"));
140 QString name;
141 EngineDetails engine_details;
142 engine_details.load(s);
144 EngineInfo* engine = new EngineInfo(engine_details, ui());
146 m_engines.push_back(engine);
148 QMenu* menu = engine_menu->addMenu(engine_details.name);
151 KAction* play_white = new KAction(i18n("Play as &white"), this);
152 play_white->setCheckable(true);
153 connect(play_white, SIGNAL(triggered()), engine, SLOT(playAsWhite()));
154 menu->addAction(play_white);
157 KAction* play_black = new KAction(i18n("Play as &black"), this);
158 play_black->setCheckable(true);
159 connect(play_black, SIGNAL(triggered()), engine, SLOT(playAsBlack()));
160 menu->addAction(play_black);
162 #if 0 // disable analysis for the moment
164 KAction* analyze = new KAction(i18n("&Analyze"), this);
165 analyze->setCheckable(true);
166 connect(analyze, SIGNAL(triggered()), engine, SLOT(analyze()));
167 menu->addAction(analyze);
169 #endif
173 void MainWindow::setupActions() {
174 KAction* tmp;
176 KStandardAction::openNew(this, SLOT(newGame()), actionCollection());
177 KStandardAction::open(this, SLOT(loadGame()), actionCollection());
178 KStandardAction::save(this, SLOT(saveGame()), actionCollection());
179 KStandardAction::saveAs(this, SLOT(saveGameAs()), actionCollection());
180 KStandardAction::quit(this, SLOT(quit()), actionCollection());
181 KStandardAction::preferences(this, SLOT(preferences()), actionCollection());
183 installRegularAction("back", KIcon("go-previous"), i18n("&Back"), &ui(), SLOT(back()));
184 installRegularAction("forward", KIcon("go-next"), i18n("&Forward"), &ui(), SLOT(forward()));
185 installRegularAction("begin", KIcon("go-first"), i18n("Be&gin"), &ui(), SLOT(gotoFirst()));
186 installRegularAction("end", KIcon("go-last"), i18n("&End"), &ui(), SLOT(gotoLast()));
187 installRegularAction("connect", KIcon("connection-established"), i18n("&Connect"), this, SLOT(icsConnect()));
188 installRegularAction("disconnect", KIcon("connect-no"), i18n("&Disconnect"), this, SLOT(icsDisconnect()));
190 KStandardAction::undo(&ui(), SLOT(undo()), actionCollection());
191 KStandardAction::redo(&ui(), SLOT(redo()), actionCollection());
193 // installRegularAction("pgnCopy", KIcon("edit-copy"), i18n("Copy PGN"), this, SLOT(pgnCopy()));
194 // installRegularAction("pgnPaste", KIcon("edit-paste"), i18n("Paste PGN"), this, SLOT(pgnPaste()));
195 installRegularAction("editPosition", KIcon("edit"), i18n("&Edit position"), this, SLOT(editPosition()));
196 installRegularAction("clearBoard", KIcon("edit-delete"), i18n("&Clear board"), &ui(), SLOT(clearBoard()));
197 installRegularAction("setStartingPosition", KIcon("contents"), i18n("&Set starting position"),
198 &ui(), SLOT(setStartingPosition()));
199 // installRegularAction("copyPosition", KIcon(), i18n("&Copy position"), &ui(), SLOT(copyPosition()));
200 // installRegularAction("pastePosition", KIcon(), i18n("&Paste position"), &ui(), SLOT(pastePosition()));
201 tmp = installRegularAction("flip", KIcon("rotate"), i18n("&Flip view"), this, SLOT(flipView()));
202 tmp->setShortcut(Qt::CTRL + Qt::Key_F);
203 installRegularAction("toggleConsole", KIcon("openterm"), i18n("Toggle &console"), this, SLOT(toggleConsole()));
204 installRegularAction("toggleMoveList", KIcon("view_text"), i18n("Toggle &move list"), this, SLOT(toggleMoveList()));
207 void MainWindow::updateVariantActions() {
208 ActionCollection* variant_actions = m_ui.variantActions();
209 unplugActionList("variantActions");
210 if (variant_actions) {
211 plugActionList("variantActions", variant_actions->actions());
213 else {
214 WARNING("No variant actions");
218 void MainWindow::readSettings() { }
219 void MainWindow::writeSettings() { }
221 void MainWindow::closeEvent(QCloseEvent* e) {
222 e->accept();
223 writeSettings();
224 delete this;
228 void MainWindow::keyPressEvent(QKeyEvent* event) {
229 if (event->key() == Qt::Key_F5) {
230 ui().createCtrlAction();
234 void MainWindow::keyReleaseEvent(QKeyEvent* event) {
235 if (event->key() == Qt::Key_F5) {
236 ui().destroyCtrlAction();
240 void MainWindow::changeTab(int index) {
241 m_ui.setCurrentTab(m_main->currentWidget());
242 m_movelist_stack->setCurrentIndex(index);
243 updateVariantActions();
246 void MainWindow::closeTab() {
247 if (m_main->count() > 1) {
248 int old_index = m_main->currentIndex();
249 ChessTable* old_board = table();
251 int new_index = old_index - 1;
252 if (new_index < 0)
253 new_index = old_index + 1;
254 m_main->setCurrentIndex(new_index);
256 m_main->removeTab(old_index);
257 m_movelist_stack->removeWidget(m_movelist_stack->widget(old_index));
258 m_ui.removeController(old_board);
260 if (m_main->count() <= 1) {
261 m_main->setTabBarHidden(true);
264 #if 0 // this doesn't work... why?
265 ChessTable* old_board = table();
266 m_ui.removeController(old_board);
267 m_movelist_stack->removeWidget(
268 m_movelist_stack->widget(m_main->currentIndex()));
269 m_main->removeTab(m_main->currentIndex());
271 delete old_board;
273 if (m_main->count() <= 1) {
274 m_main->hideTabBar();
277 // update ui controller (just in case...)
278 m_ui.setCurrentTab(m_main->currentWidget());
279 #endif
283 void MainWindow::createTab(ChessTable* board, const shared_ptr<Controller>& controller,
284 const QString& caption, int index) {
285 if (index == -1)
286 index = m_main->addTab(board, caption);
287 else
288 m_main->insertTab(index, board, caption);
290 m_ui.addController(board, controller);
291 // m_ui.setCurrentTab(board);
292 m_movelist_stack->addWidget(board->moveListTable());
294 m_main->setCurrentIndex(index);
295 m_movelist_stack->setCurrentIndex(index);
297 if (m_main->count() > 1) m_main->setTabBarHidden(false);
301 void MainWindow::cleanupGame(const QString& what, const QString& result) {
302 Q_UNUSED(what);
303 Q_UNUSED(result);
305 cleanupGame();
308 void MainWindow::cleanupGame() {
309 ui().detach();
310 ui().end();
313 bool MainWindow::newGame(const QString& variantName,
314 const StatePtr& startingPos,
315 bool newTab) {
316 Variant* variant = Variants::self().create(variantName);
317 if (!variant) {
318 WARNING("no variant " << variantName << " found");
319 variant = Variants::self().create("chess");
322 if (variant) {
323 ChessTable* board = newTab ? new ChessTable(variant) : table();
324 QString text = QString("Editing %1 game").arg(variant->name().toLower());
326 shared_ptr<Controller> controller(
327 new EditGameController(board, startingPos));
328 if (newTab) {
329 createTab(board, controller, text);
331 else {
332 unplugActionList("variantActions");
333 ui().setController(controller);
334 table()->setPlayers(Player(), Player());
335 m_main->setTabText(m_main->currentIndex(), text);
337 return true;
339 else {
340 ERROR("Could not find the chess variant");
341 exit(1);
342 return false;
347 void MainWindow::editPosition() {
348 //BROKEN
349 #if 0
350 shared_ptr<Controller> controller(new EditPositionController(table(), ChessVariant::info()));
351 m_main->setTabText(m_main->currentIndex(), "Editing chess position");
352 ui().setController(controller);
353 #endif
356 void MainWindow::setupGame(const GameInfo* gameInfo, const PositionInfo& style12) {
357 QString variantCode = gameInfo->variant();
358 Variant* variant = Variants::self().create(variantCode);
359 shared_ptr<EditGameController> controller(
360 new EditGameController(table()));
361 Q_ASSERT(style12.relation == PositionInfo::NotMyMove ||
362 style12.relation == PositionInfo::MyMove);
364 // set opponent side
365 const IColor* turn = style12.position->turn();
366 const IBehaviour* behaviour = style12.position->behaviour();
367 if (!behaviour) return;
368 const IColor* side = style12.relation == PositionInfo::MyMove ?
369 behaviour->opponent(turn) : turn;
371 if (controller->addICSPlayer(side, style12.gameNumber, m_connection)) {
372 ui().setController(controller);
373 table()->setPlayers(gameInfo->white(), gameInfo->black());
374 m_main->setTabText(m_main->currentIndex(),
375 QString("FICS Game - %1 vs %2").arg(style12.whitePlayer)
376 .arg(style12.blackPlayer));
380 void MainWindow::setupExaminedGame(const GameInfo* gameInfo, const PositionInfo& style12) {
381 table()->setVariant(
382 Variants::self().create(gameInfo->variant()));
383 shared_ptr<EditGameController> controller(
384 new EditGameController(table()));
385 if (controller->setExaminationMode(style12.gameNumber, m_connection)) {
386 table()->setPlayers(Player(style12.whitePlayer, -1),
387 Player(style12.blackPlayer, -1));
388 ui().setController(controller);
389 m_main->setTabText(m_main->currentIndex(),
390 QString("Examining - %1 vs %2").arg(style12.whitePlayer)
391 .arg(style12.blackPlayer));
396 void MainWindow::setupObservedGame(const GameInfo* g, const PositionInfo& style12) {
397 Variant* variant = Variants::self().create(g->variant());
398 std::auto_ptr<ChessTable> board(new ChessTable(variant));
400 shared_ptr<EditGameController> controller(
401 new EditGameController(board.get()));
402 if (controller->setObserveMode(style12.gameNumber, m_connection)) {
403 board->setPlayers(Player(style12.whitePlayer, -1),
404 Player(style12.blackPlayer, -1));
405 // ui().setController(controller);
406 //std::cout << "adding tab" << std::endl;
407 createTab(board.get(), controller,
408 QString("Observing - %1 vs %2").arg(style12.whitePlayer)
409 .arg(style12.blackPlayer));
410 board.release();
414 void MainWindow::setupPGN(const QString& s) {
415 PGN pgn(s);
417 std::map<QString, QString>::const_iterator var = pgn.m_tags.find("Variant");
418 Variant* variant;
420 if (var == pgn.m_tags.end()) {
421 variant = Variants::self().create("chess");
423 else if (!(variant = Variants::self().create(var->second))) {
424 std::cout << " --> MainWindow::setupPGN: Error, no such variant " << var->second << std::endl;
425 return;
428 shared_ptr<EditGameController> controller(
429 new EditGameController(table()));
430 ui().setController(controller);
431 controller->loadPGN(pgn);
433 // table()->setPlayers(gameInfo->white(), gameInfo->black());
434 // m_main->setTabText(m_main->currentIndex(),
435 // QString("FICS Game - %1 vs %2").arg(style12.whitePlayer)
436 // .arg(style12.blackPlayer));
439 bool MainWindow::openFile(const QString& filename) {
440 QFileInfo info(filename);
442 if(info.isDir()) {
443 KMessageBox::sorry(this, i18n("You have specified a folder"), i18n("Error"));
444 return false;
447 if(!info.exists() || !info.isFile()) {
448 KMessageBox::sorry(this, i18n("The specified file does not exist"), i18n("Error"));
449 return false;
452 QFile file(filename);
454 if(!file.open(QIODevice::ReadOnly)) {
455 KMessageBox::sorry(this, i18n("You do not have read permission to this file."), i18n("Error"));
456 return false;
459 QTextStream stream(&file);
460 QTextCodec *codec;
461 codec = QTextCodec::codecForLocale();
462 stream.setCodec(codec);
464 setupPGN(stream.readAll());
465 //ui().pgnPaste(stream.readAll());
466 return true;
469 void MainWindow::loadGame() {
470 KUrl url = KFileDialog::getOpenUrl(KUrl(), "*.pgn", this, i18n("Open PGN file"));
472 if(url.isEmpty())
473 return;
475 QString tmp_file;
476 if (KIO::NetAccess::download(url, tmp_file, this)) {
477 openFile(tmp_file);
478 KIO::NetAccess::removeTempFile(tmp_file);
480 else
481 KMessageBox::error(this, KIO::NetAccess::lastErrorString());
484 void MainWindow::saveGame() {
485 if (m_url.isEmpty())
486 saveGameAs();
487 else
488 m_url = saveGame(m_url);
491 void MainWindow::saveGameAs() {
492 m_url = saveGame(KFileDialog::getSaveUrl(KUrl(), "*.pgn", this, i18n("Save PGN file")));
495 KUrl MainWindow::saveGame(const KUrl& url) {
496 if (url.isEmpty())
497 return KUrl();
499 if (!url.isLocalFile()) {
500 // save in a temporary file
501 KTemporaryFile tmp_file;
502 tmp_file.open();
503 saveFile(tmp_file);
504 if (!KIO::NetAccess::upload(tmp_file.fileName(), url, this))
505 return KUrl();
507 else {
508 QFile file(url.path());
509 if (!file.open(QIODevice::WriteOnly))
510 return KUrl();
511 saveFile(file);
514 return url;
517 void MainWindow::saveFile(QFile& file) {
518 QTextStream stream(&file);
519 QTextCodec *codec;
520 codec = QTextCodec::codecForLocale();
521 stream.setCodec(codec);
522 stream << ui().currentPGN() << "\n";
525 void MainWindow::createConnection(const QString& username, const QString& password,
526 const QString& host, quint16 port,
527 const QString& timeseal, const QString& timeseal_cmd) {
528 m_connection = shared_ptr<ICSConnection>(new ICSConnection);
530 connect(m_connection.get(), SIGNAL(established()), this, SLOT(onEstablishConnection()));
531 connect(m_connection.get(), SIGNAL(hostLookup()), this, SLOT(onHostLookup()));
532 connect(m_connection.get(), SIGNAL(hostFound()), this, SLOT(onHostFound()));
534 connect(m_connection.get(), SIGNAL(receivedLine(QString, int)), console, SLOT(displayText(QString, int)));
535 connect(m_connection.get(), SIGNAL(receivedText(QString, int)), console, SLOT(displayText(QString, int)));
537 connect(console, SIGNAL(receivedInput(const QString&)), m_connection.get(), SLOT(sendText(const QString&)));
538 connect(console, SIGNAL(notify()), this, SLOT(flash()));
540 connect(m_connection.get(), SIGNAL(loginPrompt()), this, SLOT(sendLogin()));
541 connect(m_connection.get(), SIGNAL(registeredNickname()), this, SLOT(sendBlankPassword()));
542 connect(m_connection.get(), SIGNAL(prompt()), this, SLOT(prompt()));
545 connect(m_connection.get(), SIGNAL(creatingExaminedGame(const GameInfo*, const PositionInfo&)),
546 this, SLOT(setupExaminedGame(const GameInfo*, const PositionInfo&)));
547 connect(m_connection.get(), SIGNAL(endingExaminedGame(int)), this, SLOT(cleanupGame()));
549 connect(m_connection.get(), SIGNAL(creatingObservedGame(const GameInfo*, const PositionInfo&)),
550 this, SLOT(setupObservedGame(const GameInfo*, const PositionInfo&)));
551 connect(m_connection.get(), SIGNAL(endingObservedGame(int)), this, SLOT(cleanupGame()));
554 connect(m_connection.get(), SIGNAL(creatingGame(const GameInfo*, const PositionInfo&)),
555 this, SLOT(setupGame(const GameInfo*, const PositionInfo&)));
556 connect(m_connection.get(), SIGNAL(endingGame(const QString&, const QString&)),
557 this, SLOT(cleanupGame(const QString&, const QString&)));
558 connect(m_connection.get(), SIGNAL(notification()), this, SLOT(flash()));
560 m_connection->establish(host.toAscii().constData(), port, timeseal, timeseal_cmd);
561 console->show();
563 // send username / password combination
564 if (!username.isEmpty()) {
565 m_connection->sendText(username);
566 m_connection->sendText(password);
569 quickConnectDialog.reset();
572 void MainWindow::icsConnect() {
573 quickConnectDialog = shared_ptr<QConnect>(new QConnect(this));
574 connect(quickConnectDialog.get(),
575 SIGNAL(acceptConnection(const QString&,
576 const QString&,
577 const QString&,
578 quint16,
579 const QString&,
580 const QString&)),
581 this,
582 SLOT(createConnection(const QString&,
583 const QString&,
584 const QString&,
585 quint16,
586 const QString&,
587 const QString&)));
588 quickConnectDialog->show();
591 void MainWindow::destroyConnection() {
592 m_connection.reset();
595 void MainWindow::icsDisconnect() {
596 destroyConnection();
597 console->hide();
598 console->clear();
601 void MainWindow::testConnect() {
602 Settings s_ics = settings().group("ics");
603 if (s_ics["username"]) {
604 QString username = s_ics["username"].value<QString>();
605 QString password = (s_ics["password"] | "");
606 QString host = (s_ics["icsHost"] | "freechess.org");
607 quint16 port = (s_ics["icsPort"] | 5000);
608 createConnection(username, password, host, port, QString(), QString() );
610 else icsConnect();
614 void MainWindow::onEstablishConnection() {
615 // std::cout << "connection established" << std::endl;
618 void MainWindow::onConnectionError(int ) {
619 // std::cout << "connection error (" << code << ")" << std::endl;
622 void MainWindow::onHostLookup() {
623 // std::cout << "hostLookup..." << std::flush;
626 void MainWindow::onHostFound() {
627 // std::cout << "found" << std::endl;
631 void MainWindow::sendLogin() {
632 // std::cout << "sending username" << std::endl;
633 // connection->sendText(connection->username());
636 void MainWindow::sendBlankPassword() {
637 m_connection->sendText("");
640 void MainWindow::prompt() {
641 if (!m_connection->initialized()) {
642 m_connection->startup();
643 m_connection->setInitialized();
647 void MainWindow::newGame() {
648 StatePtr pos = ui().position();
649 scoped_ptr<NewGame> dialog(new NewGame(this));
650 if (dialog->exec() == QDialog::Accepted) {
651 if (!newGame(dialog->variant(), StatePtr(), dialog->newTab()))
652 QMessageBox::information(this, i18n("Error"), i18n("Error creating game"));
656 void MainWindow::quit() {
657 delete this;
660 void MainWindow::flipView() {
661 table()->flip();
664 void MainWindow::toggleConsole() {
665 if (console_dock->isVisible())
666 console_dock->hide();
667 else {
668 console_dock->show();
669 console_dock->setFocus(Qt::MouseFocusReason
670 /*Qt::ActiveWindowFocusReason*/ /*Qt::OtherFocusReason*/);
674 void MainWindow::toggleMoveList() {
675 if (movelist_dock->isVisible())
676 movelist_dock->hide();
677 else {
678 movelist_dock->show();
679 movelist_dock->setFocus(Qt::OtherFocusReason);
684 void MainWindow::displayMessage(const QString& msg) {
685 Q_UNUSED(msg); // TODO
686 // statusBar()->message(msg, 2000);
689 void MainWindow::displayErrorMessage(ErrorCode code) {
690 switch(code) {
691 case InvalidMove:
692 displayMessage(i18n("Illegal move"));
693 break;
697 void MainWindow::flash() {
698 if( !isAncestorOf(QApplication::focusWidget()) )
699 Flash::flash(this);
702 #if 0
703 void MainWindow::prefHighlight() {
704 PrefHighlight dialog;
705 int result = dialog.exec();
706 if (result == QDialog::Accepted) {
707 dialog.apply();
710 #endif
712 void MainWindow::preferences() {
713 Preferences dialog(ui().currentVariant());
714 int result = dialog.exec();
715 if (result == QDialog::Accepted)
716 dialog.apply();
719 void MainWindow::settingsChanged() {
720 ui().reloadSettings();