Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  * Copyright (C) 2015 Boris Barbulovski <bbarbulovski@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7) #include <QAction>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8) #include <QApplication>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9) #include <QCloseEvent>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10) #include <QDebug>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11) #include <QDesktopWidget>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12) #include <QFileDialog>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13) #include <QLabel>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14) #include <QLayout>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15) #include <QList>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16) #include <QMenu>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17) #include <QMenuBar>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18) #include <QMessageBox>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19) #include <QToolBar>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) #include <stdlib.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) #include "lkc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) #include "qconf.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) #include "images.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) static QApplication *configApp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) static ConfigSettings *configSettings;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) QAction *ConfigMainWindow::saveAction;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) ConfigSettings::ConfigSettings()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) 	: QSettings("kernel.org", "qconf")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40)  * Reads a list of integer values from the application settings.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) QList<int> ConfigSettings::readSizes(const QString& key, bool *ok)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) 	QList<int> result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) 	if (contains(key))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) 		QStringList entryList = value(key).toStringList();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) 		QStringList::Iterator it;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) 		for (it = entryList.begin(); it != entryList.end(); ++it)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) 			result.push_back((*it).toInt());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) 		*ok = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) 		*ok = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63)  * Writes a list of integer values to the application settings.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) bool ConfigSettings::writeSizes(const QString& key, const QList<int>& value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) 	QStringList stringList;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) 	QList<int>::ConstIterator it;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) 	for (it = value.begin(); it != value.end(); ++it)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) 		stringList.push_back(QString::number(*it));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) 	setValue(key, stringList);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) 	return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) QIcon ConfigItem::symbolYesIcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) QIcon ConfigItem::symbolModIcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) QIcon ConfigItem::symbolNoIcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) QIcon ConfigItem::choiceYesIcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) QIcon ConfigItem::choiceNoIcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) QIcon ConfigItem::menuIcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) QIcon ConfigItem::menubackIcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86)  * update the displayed of a menu entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) void ConfigItem::updateMenu(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) 	ConfigList* list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) 	struct symbol* sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) 	struct property *prop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) 	QString prompt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) 	int type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) 	tristate expr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) 	list = listView();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) 	if (goParent) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) 		setIcon(promptColIdx, menubackIcon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) 		prompt = "..";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) 		goto set_prompt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) 	sym = menu->sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) 	prop = menu->prompt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) 	prompt = menu_get_prompt(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) 	if (prop) switch (prop->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) 	case P_MENU:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) 		if (list->mode == singleMode || list->mode == symbolMode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) 			/* a menuconfig entry is displayed differently
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) 			 * depending whether it's at the view root or a child.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) 			if (sym && list->rootEntry == menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) 			setIcon(promptColIdx, menuIcon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) 			if (sym)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) 			setIcon(promptColIdx, QIcon());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) 		goto set_prompt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) 	case P_COMMENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) 		setIcon(promptColIdx, QIcon());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) 		goto set_prompt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) 		;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) 	if (!sym)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) 		goto set_prompt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) 	setText(nameColIdx, sym->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) 	type = sym_get_type(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) 	switch (type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) 	case S_BOOLEAN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) 	case S_TRISTATE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) 		char ch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) 		if (!sym_is_changeable(sym) && list->optMode == normalOpt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) 			setIcon(promptColIdx, QIcon());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) 		expr = sym_get_tristate_value(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) 		switch (expr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) 		case yes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) 			if (sym_is_choice_value(sym) && type == S_BOOLEAN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) 				setIcon(promptColIdx, choiceYesIcon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) 				setIcon(promptColIdx, symbolYesIcon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) 			ch = 'Y';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) 		case mod:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) 			setIcon(promptColIdx, symbolModIcon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 			ch = 'M';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) 			if (sym_is_choice_value(sym) && type == S_BOOLEAN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 				setIcon(promptColIdx, choiceNoIcon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) 				setIcon(promptColIdx, symbolNoIcon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) 			ch = 'N';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) 		setText(dataColIdx, QChar(ch));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) 	case S_INT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) 	case S_HEX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) 	case S_STRING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) 		setText(dataColIdx, sym_get_string_value(sym));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) 	if (!sym_has_value(sym) && visible)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) 		prompt += " (NEW)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) set_prompt:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) 	setText(promptColIdx, prompt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) void ConfigItem::testUpdateMenu(bool v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) 	ConfigItem* i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) 	visible = v;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) 	if (!menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) 	sym_calc_value(menu->sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) 	if (menu->flags & MENU_CHANGED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) 		/* the menu entry changed, so update all list items */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 		menu->flags &= ~MENU_CHANGED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 		for (i = (ConfigItem*)menu->data; i; i = i->nextItem)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) 			i->updateMenu();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) 	} else if (listView()->updateAll)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) 		updateMenu();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200)  * construct a menu entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) void ConfigItem::init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) 	if (menu) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) 		ConfigList* list = listView();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 		nextItem = (ConfigItem*)menu->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) 		menu->data = this;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) 		if (list->mode != fullMode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) 			setExpanded(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) 		sym_calc_value(menu->sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) 		if (menu->sym) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 			enum symbol_type type = menu->sym->type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) 			// Allow to edit "int", "hex", and "string" in-place in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) 			// the data column. Unfortunately, you cannot specify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) 			// the flags per column. Set ItemIsEditable for all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) 			// columns here, and check the column in createEditor().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) 			if (type == S_INT || type == S_HEX || type == S_STRING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) 				setFlags(flags() | Qt::ItemIsEditable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) 	updateMenu();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228)  * destruct a menu entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) ConfigItem::~ConfigItem(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 	if (menu) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) 		ConfigItem** ip = (ConfigItem**)&menu->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 		for (; *ip; ip = &(*ip)->nextItem) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) 			if (*ip == this) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 				*ip = nextItem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) QWidget *ConfigItemDelegate::createEditor(QWidget *parent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) 					  const QStyleOptionViewItem &option,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 					  const QModelIndex &index) const
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 	ConfigItem *item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 	// Only the data column is editable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 	if (index.column() != dataColIdx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 		return nullptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 	// You cannot edit invisible menus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 	item = static_cast<ConfigItem *>(index.internalPointer());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 	if (!item || !item->menu || !menu_is_visible(item->menu))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) 		return nullptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) 	return QStyledItemDelegate::createEditor(parent, option, index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) void ConfigItemDelegate::setModelData(QWidget *editor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) 				      QAbstractItemModel *model,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) 				      const QModelIndex &index) const
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) 	QLineEdit *lineEdit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) 	ConfigItem *item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 	struct symbol *sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) 	bool success;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) 	lineEdit = qobject_cast<QLineEdit *>(editor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) 	// If this is not a QLineEdit, use the parent's default.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) 	// (does this happen?)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) 	if (!lineEdit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) 		goto parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) 	item = static_cast<ConfigItem *>(index.internalPointer());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) 	if (!item || !item->menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) 		goto parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) 	sym = item->menu->sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) 	if (!sym)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) 		goto parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) 	success = sym_set_string_value(sym, lineEdit->text().toUtf8().data());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) 	if (success) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) 		ConfigList::updateListForAll();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 		QMessageBox::information(editor, "qconf",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) 			"Cannot set the data (maybe due to out of range).\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) 			"Setting the old value.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 		lineEdit->setText(sym_get_string_value(sym));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) parent:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 	QStyledItemDelegate::setModelData(editor, model, index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) ConfigList::ConfigList(QWidget *parent, const char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 	: QTreeWidget(parent),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) 	  updateAll(false),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 	  showName(false), mode(singleMode), optMode(normalOpt),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) 	  rootEntry(0), headerPopup(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) 	setObjectName(name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) 	setSortingEnabled(false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 	setRootIsDecorated(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) 	setVerticalScrollMode(ScrollPerPixel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 	setHorizontalScrollMode(ScrollPerPixel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 	setHeaderLabels(QStringList() << "Option" << "Name" << "Value");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 	connect(this, SIGNAL(itemSelectionChanged(void)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 		SLOT(updateSelection(void)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 	if (name) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) 		configSettings->beginGroup(name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 		showName = configSettings->value("/showName", false).toBool();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) 		optMode = (enum optionMode)configSettings->value("/optionMode", 0).toInt();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 		configSettings->endGroup();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) 		connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) 	showColumn(promptColIdx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 	setItemDelegate(new ConfigItemDelegate(this));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 	allLists.append(this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 	reinit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) ConfigList::~ConfigList()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 	allLists.removeOne(this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) bool ConfigList::menuSkip(struct menu *menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 	if (optMode == normalOpt && menu_is_visible(menu))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 	if (optMode == promptOpt && menu_has_prompt(menu))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 	if (optMode == allOpt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 	return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) void ConfigList::reinit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 	hideColumn(nameColIdx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 	if (showName)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 		showColumn(nameColIdx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 	updateListAll();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) void ConfigList::setOptionMode(QAction *action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 	if (action == showNormalAction)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 		optMode = normalOpt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) 	else if (action == showAllAction)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) 		optMode = allOpt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) 		optMode = promptOpt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 	updateListAll();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) void ConfigList::saveSettings(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) 	if (!objectName().isEmpty()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 		configSettings->beginGroup(objectName());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 		configSettings->setValue("/showName", showName);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 		configSettings->setValue("/optionMode", (int)optMode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 		configSettings->endGroup();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) ConfigItem* ConfigList::findConfigItem(struct menu *menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) 	ConfigItem* item = (ConfigItem*)menu->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 	for (; item; item = item->nextItem) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 		if (this == item->listView())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) 	return item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) void ConfigList::updateSelection(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 	struct menu *menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) 	enum prop_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) 	if (selectedItems().count() == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) 	ConfigItem* item = (ConfigItem*)selectedItems().first();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) 	if (!item)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) 	menu = item->menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 	emit menuChanged(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) 	if (!menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) 	type = menu->prompt ? menu->prompt->type : P_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 	if (mode == menuMode && type == P_MENU)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 		emit menuSelected(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) void ConfigList::updateList()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 	ConfigItem* last = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 	ConfigItem *item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) 	if (!rootEntry) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) 		if (mode != listMode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 			goto update;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) 		QTreeWidgetItemIterator it(this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 		while (*it) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 			item = (ConfigItem*)(*it);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 			if (!item->menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 			item->testUpdateMenu(menu_is_visible(item->menu));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) 			++it;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 	if (rootEntry != &rootmenu && (mode == singleMode ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 	    (mode == symbolMode && rootEntry->parent != &rootmenu))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) 		item = (ConfigItem *)topLevelItem(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) 		if (!item)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) 			item = new ConfigItem(this, 0, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) 		last = item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) 	if ((mode == singleMode || (mode == symbolMode && !(rootEntry->flags & MENU_ROOT))) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 	    rootEntry->sym && rootEntry->prompt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 		item = last ? last->nextSibling() : nullptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) 		if (!item)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) 			item = new ConfigItem(this, last, rootEntry, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 			item->testUpdateMenu(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) 		updateMenuList(item, rootEntry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) 		update();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) 		resizeColumnToContents(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) update:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) 	updateMenuList(rootEntry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) 	update();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 	resizeColumnToContents(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) void ConfigList::updateListForAll()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 	QListIterator<ConfigList *> it(allLists);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 	while (it.hasNext()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) 		ConfigList *list = it.next();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) 		list->updateList();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) void ConfigList::updateListAllForAll()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 	QListIterator<ConfigList *> it(allLists);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 	while (it.hasNext()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 		ConfigList *list = it.next();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) 		list->updateList();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) void ConfigList::setValue(ConfigItem* item, tristate val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 	struct symbol* sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) 	int type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 	tristate oldval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 	sym = item->menu ? item->menu->sym : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 	if (!sym)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 	type = sym_get_type(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 	switch (type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 	case S_BOOLEAN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 	case S_TRISTATE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 		oldval = sym_get_tristate_value(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 		if (!sym_set_tristate_value(sym, val))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 		if (oldval == no && item->menu->list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 			item->setExpanded(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 		ConfigList::updateListForAll();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) void ConfigList::changeValue(ConfigItem* item)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 	struct symbol* sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 	struct menu* menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 	int type, oldexpr, newexpr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 	menu = item->menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 	if (!menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 	sym = menu->sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 	if (!sym) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 		if (item->menu->list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 			item->setExpanded(!item->isExpanded());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 	type = sym_get_type(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 	switch (type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) 	case S_BOOLEAN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 	case S_TRISTATE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) 		oldexpr = sym_get_tristate_value(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) 		newexpr = sym_toggle_tristate_value(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) 		if (item->menu->list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) 			if (oldexpr == newexpr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 				item->setExpanded(!item->isExpanded());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) 			else if (oldexpr == no)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 				item->setExpanded(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) 		if (oldexpr != newexpr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 			ConfigList::updateListForAll();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) void ConfigList::setRootMenu(struct menu *menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 	enum prop_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) 	if (rootEntry == menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 	type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) 	if (type != P_MENU)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) 	updateMenuList(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) 	rootEntry = menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) 	updateListAll();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) 	if (currentItem()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) 		setSelected(currentItem(), hasFocus());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) 		scrollToItem(currentItem());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) void ConfigList::setParentMenu(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 	ConfigItem* item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 	struct menu *oldroot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 	oldroot = rootEntry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 	if (rootEntry == &rootmenu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 	setRootMenu(menu_get_parent_menu(rootEntry->parent));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 	QTreeWidgetItemIterator it(this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 	while (*it) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 		item = (ConfigItem *)(*it);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 		if (item->menu == oldroot) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 			setCurrentItem(item);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 			scrollToItem(item);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 		++it;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586)  * update all the children of a menu entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587)  *   removes/adds the entries from the parent widget as necessary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589)  * parent: either the menu list widget or a menu entry widget
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590)  * menu: entry to be updated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) void ConfigList::updateMenuList(ConfigItem *parent, struct menu* menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) 	struct menu* child;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) 	ConfigItem* item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 	ConfigItem* last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 	bool visible;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 	enum prop_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 	if (!menu) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 		while (parent->childCount() > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 			delete parent->takeChild(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 	last = parent->firstChild();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 	if (last && !last->goParent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 		last = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 	for (child = menu->list; child; child = child->next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 		item = last ? last->nextSibling() : parent->firstChild();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 		type = child->prompt ? child->prompt->type : P_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 		switch (mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) 		case menuMode:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) 			if (!(child->flags & MENU_ROOT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 				goto hide;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 		case symbolMode:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 			if (child->flags & MENU_ROOT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 				goto hide;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 		visible = menu_is_visible(child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 		if (!menuSkip(child)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) 			if (!child->sym && !child->list && !child->prompt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 			if (!item || item->menu != child)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) 				item = new ConfigItem(parent, last, child, visible);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 				item->testUpdateMenu(visible);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) 			if (mode == fullMode || mode == menuMode || type != P_MENU)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) 				updateMenuList(item, child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) 				updateMenuList(item, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) 			last = item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) hide:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 		if (item && item->menu == child) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 			last = parent->firstChild();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) 			if (last == item)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 				last = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) 			else while (last->nextSibling() != item)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) 				last = last->nextSibling();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 			delete item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) void ConfigList::updateMenuList(struct menu *menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) 	struct menu* child;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) 	ConfigItem* item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) 	ConfigItem* last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) 	bool visible;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) 	enum prop_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 	if (!menu) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 		while (topLevelItemCount() > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 			delete takeTopLevelItem(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) 	last = (ConfigItem *)topLevelItem(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 	if (last && !last->goParent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 		last = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) 	for (child = menu->list; child; child = child->next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 		item = last ? last->nextSibling() : (ConfigItem *)topLevelItem(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) 		type = child->prompt ? child->prompt->type : P_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) 		switch (mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) 		case menuMode:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 			if (!(child->flags & MENU_ROOT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 				goto hide;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 		case symbolMode:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 			if (child->flags & MENU_ROOT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 				goto hide;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 		visible = menu_is_visible(child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 		if (!menuSkip(child)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 			if (!child->sym && !child->list && !child->prompt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 			if (!item || item->menu != child)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 				item = new ConfigItem(this, last, child, visible);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 				item->testUpdateMenu(visible);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) 			if (mode == fullMode || mode == menuMode || type != P_MENU)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 				updateMenuList(item, child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 				updateMenuList(item, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 			last = item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) hide:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 		if (item && item->menu == child) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) 			last = (ConfigItem *)topLevelItem(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) 			if (last == item)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) 				last = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) 			else while (last->nextSibling() != item)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) 				last = last->nextSibling();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 			delete item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) void ConfigList::keyPressEvent(QKeyEvent* ev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 	QTreeWidgetItem* i = currentItem();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 	ConfigItem* item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 	struct menu *menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 	enum prop_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) 	if (ev->key() == Qt::Key_Escape && mode != fullMode && mode != listMode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) 		emit parentSelected();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 		ev->accept();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) 	if (!i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 		Parent::keyPressEvent(ev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 	item = (ConfigItem*)i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 	switch (ev->key()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 	case Qt::Key_Return:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 	case Qt::Key_Enter:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 		if (item->goParent) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 			emit parentSelected();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 		menu = item->menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 		if (!menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) 		type = menu->prompt ? menu->prompt->type : P_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 		if (type == P_MENU && rootEntry != menu &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) 		    mode != fullMode && mode != menuMode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) 			if (mode == menuMode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 				emit menuSelected(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 				emit itemSelected(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 	case Qt::Key_Space:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) 		changeValue(item);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) 	case Qt::Key_N:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) 		setValue(item, no);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 	case Qt::Key_M:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 		setValue(item, mod);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) 	case Qt::Key_Y:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 		setValue(item, yes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 		Parent::keyPressEvent(ev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 	ev->accept();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) void ConfigList::mousePressEvent(QMouseEvent* e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 	//QPoint p(contentsToViewport(e->pos()));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 	//printf("contentsMousePressEvent: %d,%d\n", p.x(), p.y());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) 	Parent::mousePressEvent(e);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) void ConfigList::mouseReleaseEvent(QMouseEvent* e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 	QPoint p = e->pos();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) 	ConfigItem* item = (ConfigItem*)itemAt(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) 	struct menu *menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) 	enum prop_type ptype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) 	QIcon icon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) 	int idx, x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) 	if (!item)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) 		goto skip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) 	menu = item->menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) 	x = header()->offset() + p.x();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) 	idx = header()->logicalIndexAt(x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 	switch (idx) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) 	case promptColIdx:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 		icon = item->icon(promptColIdx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) 		if (!icon.isNull()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 			int off = header()->sectionPosition(0) + visualRect(indexAt(p)).x() + 4; // 4 is Hardcoded image offset. There might be a way to do it properly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 			if (x >= off && x < off + icon.availableSizes().first().width()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 				if (item->goParent) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 					emit parentSelected();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 					break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 				} else if (!menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 					break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 				ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 				if (ptype == P_MENU && rootEntry != menu &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 				    mode != fullMode && mode != menuMode &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815)                                     mode != listMode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 					emit menuSelected(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) 				else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 					changeValue(item);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 	case dataColIdx:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) 		changeValue(item);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) skip:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 	//printf("contentsMouseReleaseEvent: %d,%d\n", p.x(), p.y());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 	Parent::mouseReleaseEvent(e);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) void ConfigList::mouseMoveEvent(QMouseEvent* e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 	//QPoint p(contentsToViewport(e->pos()));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 	//printf("contentsMouseMoveEvent: %d,%d\n", p.x(), p.y());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 	Parent::mouseMoveEvent(e);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) void ConfigList::mouseDoubleClickEvent(QMouseEvent* e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 	QPoint p = e->pos();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 	ConfigItem* item = (ConfigItem*)itemAt(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 	struct menu *menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 	enum prop_type ptype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 	if (!item)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 		goto skip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 	if (item->goParent) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 		emit parentSelected();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 		goto skip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 	menu = item->menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) 	if (!menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) 		goto skip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) 	ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) 	if (ptype == P_MENU && mode != listMode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) 		if (mode == singleMode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) 			emit itemSelected(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) 		else if (mode == symbolMode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) 			emit menuSelected(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 	} else if (menu->sym)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 		changeValue(item);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) skip:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 	//printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) 	Parent::mouseDoubleClickEvent(e);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) void ConfigList::focusInEvent(QFocusEvent *e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 	struct menu *menu = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 	Parent::focusInEvent(e);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 	ConfigItem* item = (ConfigItem *)currentItem();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) 	if (item) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 		setSelected(item, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 		menu = item->menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) 	emit gotFocus(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) void ConfigList::contextMenuEvent(QContextMenuEvent *e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 	if (!headerPopup) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) 		QAction *action;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) 		headerPopup = new QMenu(this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 		action = new QAction("Show Name", this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 		action->setCheckable(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) 		connect(action, SIGNAL(toggled(bool)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 			SLOT(setShowName(bool)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) 		connect(this, SIGNAL(showNameChanged(bool)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 			action, SLOT(setChecked(bool)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) 		action->setChecked(showName);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) 		headerPopup->addAction(action);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) 	headerPopup->exec(e->globalPos());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) 	e->accept();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) void ConfigList::setShowName(bool on)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) 	if (showName == on)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) 	showName = on;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) 	reinit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) 	emit showNameChanged(on);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) QList<ConfigList *> ConfigList::allLists;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) QAction *ConfigList::showNormalAction;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) QAction *ConfigList::showAllAction;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) QAction *ConfigList::showPromptAction;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) void ConfigList::setAllOpen(bool open)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) 	QTreeWidgetItemIterator it(this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 	while (*it) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) 		(*it)->setExpanded(open);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) 		++it;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 	: Parent(parent), sym(0), _menu(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) 	setObjectName(name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 	setOpenLinks(false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) 	if (!objectName().isEmpty()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) 		configSettings->beginGroup(objectName());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 		setShowDebug(configSettings->value("/showDebug", false).toBool());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 		configSettings->endGroup();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 		connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) 	contextMenu = createStandardContextMenu();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 	QAction *action = new QAction("Show Debug Info", contextMenu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) 	action->setCheckable(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 	connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 	connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setChecked(bool)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) 	action->setChecked(showDebug());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 	contextMenu->addSeparator();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) 	contextMenu->addAction(action);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) void ConfigInfoView::saveSettings(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 	if (!objectName().isEmpty()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 		configSettings->beginGroup(objectName());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 		configSettings->setValue("/showDebug", showDebug());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) 		configSettings->endGroup();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) void ConfigInfoView::setShowDebug(bool b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 	if (_showDebug != b) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) 		_showDebug = b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) 		if (_menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) 			menuInfo();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 		else if (sym)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) 			symbolInfo();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 		emit showDebugChanged(b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) void ConfigInfoView::setInfo(struct menu *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 	if (_menu == m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 	_menu = m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) 	sym = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 	if (!_menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) 		clear();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 		menuInfo();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) void ConfigInfoView::symbolInfo(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 	QString str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) 	str += "<big>Symbol: <b>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 	str += print_filter(sym->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) 	str += "</b></big><br><br>value: ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) 	str += print_filter(sym_get_string_value(sym));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) 	str += "<br>visibility: ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) 	str += sym->visible == yes ? "y" : sym->visible == mod ? "m" : "n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) 	str += "<br>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) 	str += debug_info(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) 	setText(str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) void ConfigInfoView::menuInfo(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) 	struct symbol* sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) 	QString info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) 	QTextStream stream(&info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 	sym = _menu->sym;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 	if (sym) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) 		if (_menu->prompt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 			stream << "<big><b>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 			stream << print_filter(_menu->prompt->text);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) 			stream << "</b></big>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 			if (sym->name) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) 				stream << " (";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) 				if (showDebug())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) 					stream << "<a href=\"s" << sym->name << "\">";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) 				stream << print_filter(sym->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 				if (showDebug())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) 					stream << "</a>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) 				stream << ")";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) 		} else if (sym->name) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) 			stream << "<big><b>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) 			if (showDebug())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) 				stream << "<a href=\"s" << sym->name << "\">";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) 			stream << print_filter(sym->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 			if (showDebug())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 				stream << "</a>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 			stream << "</b></big>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 		stream << "<br><br>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) 		if (showDebug())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 			stream << debug_info(sym);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 		struct gstr help_gstr = str_new();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) 		menu_get_ext_help(_menu, &help_gstr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) 		stream << print_filter(str_get(&help_gstr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) 		str_free(&help_gstr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) 	} else if (_menu->prompt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) 		stream << "<big><b>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) 		stream << print_filter(_menu->prompt->text);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) 		stream << "</b></big><br><br>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) 		if (showDebug()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) 			if (_menu->prompt->visible.expr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) 				stream << "&nbsp;&nbsp;dep: ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) 				expr_print(_menu->prompt->visible.expr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) 					   expr_print_help, &stream, E_NONE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) 				stream << "<br><br>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) 			stream << "defined at " << _menu->file->name << ":"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) 			       << _menu->lineno << "<br><br>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) 	setText(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) QString ConfigInfoView::debug_info(struct symbol *sym)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) 	QString debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) 	QTextStream stream(&debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) 	stream << "type: ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) 	stream << print_filter(sym_type_name(sym->type));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) 	if (sym_is_choice(sym))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) 		stream << " (choice)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) 	debug += "<br>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) 	if (sym->rev_dep.expr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) 		stream << "reverse dep: ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) 		expr_print(sym->rev_dep.expr, expr_print_help, &stream, E_NONE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) 		stream << "<br>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) 	for (struct property *prop = sym->prop; prop; prop = prop->next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) 		switch (prop->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) 		case P_PROMPT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) 		case P_MENU:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) 			stream << "prompt: <a href=\"m" << sym->name << "\">";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) 			stream << print_filter(prop->text);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) 			stream << "</a><br>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) 		case P_DEFAULT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) 		case P_SELECT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) 		case P_RANGE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) 		case P_COMMENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) 		case P_IMPLY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) 		case P_SYMBOL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) 			stream << prop_get_type_name(prop->type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) 			stream << ": ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) 			expr_print(prop->expr, expr_print_help,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) 				   &stream, E_NONE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) 			stream << "<br>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) 		case P_CHOICE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) 			if (sym_is_choice(sym)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) 				stream << "choice: ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) 				expr_print(prop->expr, expr_print_help,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) 					   &stream, E_NONE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) 				stream << "<br>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) 			stream << "unknown property: ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) 			stream << prop_get_type_name(prop->type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) 			stream << "<br>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) 		if (prop->visible.expr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) 			stream << "&nbsp;&nbsp;&nbsp;&nbsp;dep: ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) 			expr_print(prop->visible.expr, expr_print_help,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) 				   &stream, E_NONE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) 			stream << "<br>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) 	stream << "<br>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) 	return debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) QString ConfigInfoView::print_filter(const QString &str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) 	QRegExp re("[<>&\"\\n]");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) 	QString res = str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) 	for (int i = 0; (i = res.indexOf(re, i)) >= 0;) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) 		switch (res[i].toLatin1()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) 		case '<':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) 			res.replace(i, 1, "&lt;");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) 			i += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) 		case '>':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) 			res.replace(i, 1, "&gt;");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) 			i += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) 		case '&':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) 			res.replace(i, 1, "&amp;");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) 			i += 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) 		case '"':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) 			res.replace(i, 1, "&quot;");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) 			i += 6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) 		case '\n':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) 			res.replace(i, 1, "<br>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) 			i += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) 	return res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) 	QTextStream *stream = reinterpret_cast<QTextStream *>(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) 	if (sym && sym->name && !(sym->flags & SYMBOL_CONST)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) 		*stream << "<a href=\"s" << sym->name << "\">";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) 		*stream << print_filter(str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) 		*stream << "</a>";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) 		*stream << print_filter(str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) void ConfigInfoView::clicked(const QUrl &url)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) 	QByteArray str = url.toEncoded();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) 	const std::size_t count = str.size();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) 	char *data = new char[count + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) 	struct symbol **result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) 	struct menu *m = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) 	if (count < 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) 		delete[] data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) 	memcpy(data, str.constData(), count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) 	data[count] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) 	/* Seek for exact match */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) 	data[0] = '^';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) 	strcat(data, "$");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) 	result = sym_re_search(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) 	if (!result) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) 		delete[] data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) 	sym = *result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) 	/* Seek for the menu which holds the symbol */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) 	for (struct property *prop = sym->prop; prop; prop = prop->next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) 		    if (prop->type != P_PROMPT && prop->type != P_MENU)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) 			    continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) 		    m = prop->menu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) 		    break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) 	if (!m) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) 		/* Symbol is not visible as a menu */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) 		symbolInfo();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) 		emit showDebugChanged(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) 		emit menuSelected(m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) 	free(result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) 	delete[] data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) void ConfigInfoView::contextMenuEvent(QContextMenuEvent *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) 	contextMenu->popup(event->globalPos());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) 	event->accept();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow *parent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) 	: Parent(parent), result(NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) 	setObjectName("search");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) 	setWindowTitle("Search Config");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) 	QVBoxLayout* layout1 = new QVBoxLayout(this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) 	layout1->setContentsMargins(11, 11, 11, 11);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) 	layout1->setSpacing(6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) 	QHBoxLayout* layout2 = new QHBoxLayout();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) 	layout2->setContentsMargins(0, 0, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) 	layout2->setSpacing(6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) 	layout2->addWidget(new QLabel("Find:", this));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) 	editField = new QLineEdit(this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) 	connect(editField, SIGNAL(returnPressed()), SLOT(search()));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) 	layout2->addWidget(editField);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) 	searchButton = new QPushButton("Search", this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) 	searchButton->setAutoDefault(false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) 	connect(searchButton, SIGNAL(clicked()), SLOT(search()));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) 	layout2->addWidget(searchButton);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) 	layout1->addLayout(layout2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) 	split = new QSplitter(this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) 	split->setOrientation(Qt::Vertical);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) 	list = new ConfigList(split, "search");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) 	list->mode = listMode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) 	info = new ConfigInfoView(split, "search");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) 	connect(list, SIGNAL(menuChanged(struct menu *)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) 		info, SLOT(setInfo(struct menu *)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) 	connect(list, SIGNAL(menuChanged(struct menu *)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) 		parent, SLOT(setMenuLink(struct menu *)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) 	layout1->addWidget(split);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) 	QVariant x, y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) 	int width, height;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) 	bool ok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) 	configSettings->beginGroup("search");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) 	width = configSettings->value("/window width", parent->width() / 2).toInt();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) 	height = configSettings->value("/window height", parent->height() / 2).toInt();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) 	resize(width, height);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) 	x = configSettings->value("/window x");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) 	y = configSettings->value("/window y");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) 	if (x.isValid() && y.isValid())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) 		move(x.toInt(), y.toInt());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) 	QList<int> sizes = configSettings->readSizes("/split", &ok);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) 	if (ok)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) 		split->setSizes(sizes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) 	configSettings->endGroup();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) 	connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) void ConfigSearchWindow::saveSettings(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) 	if (!objectName().isEmpty()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) 		configSettings->beginGroup(objectName());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) 		configSettings->setValue("/window x", pos().x());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) 		configSettings->setValue("/window y", pos().y());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) 		configSettings->setValue("/window width", size().width());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) 		configSettings->setValue("/window height", size().height());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) 		configSettings->writeSizes("/split", split->sizes());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) 		configSettings->endGroup();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) void ConfigSearchWindow::search(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) 	struct symbol **p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) 	struct property *prop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) 	ConfigItem *lastItem = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) 	free(result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) 	list->clear();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) 	info->clear();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) 	result = sym_re_search(editField->text().toLatin1());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) 	if (!result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) 	for (p = result; *p; p++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) 		for_all_prompts((*p), prop)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) 			lastItem = new ConfigItem(list, lastItem, prop->menu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) 						  menu_is_visible(prop->menu));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307)  * Construct the complete config widget
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) ConfigMainWindow::ConfigMainWindow(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) 	: searchWindow(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) 	bool ok = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) 	QVariant x, y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) 	int width, height;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) 	char title[256];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) 	QDesktopWidget *d = configApp->desktop();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) 	snprintf(title, sizeof(title), "%s%s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) 		rootmenu.prompt->text,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) 		""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) 		);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) 	setWindowTitle(title);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) 	width = configSettings->value("/window width", d->width() - 64).toInt();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) 	height = configSettings->value("/window height", d->height() - 64).toInt();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) 	resize(width, height);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) 	x = configSettings->value("/window x");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) 	y = configSettings->value("/window y");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) 	if ((x.isValid())&&(y.isValid()))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) 		move(x.toInt(), y.toInt());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) 	// set up icons
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) 	ConfigItem::symbolYesIcon = QIcon(QPixmap(xpm_symbol_yes));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) 	ConfigItem::symbolModIcon = QIcon(QPixmap(xpm_symbol_mod));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) 	ConfigItem::symbolNoIcon = QIcon(QPixmap(xpm_symbol_no));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) 	ConfigItem::choiceYesIcon = QIcon(QPixmap(xpm_choice_yes));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) 	ConfigItem::choiceNoIcon = QIcon(QPixmap(xpm_choice_no));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) 	ConfigItem::menuIcon = QIcon(QPixmap(xpm_menu));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) 	ConfigItem::menubackIcon = QIcon(QPixmap(xpm_menuback));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) 	QWidget *widget = new QWidget(this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) 	QVBoxLayout *layout = new QVBoxLayout(widget);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) 	setCentralWidget(widget);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) 	split1 = new QSplitter(widget);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) 	split1->setOrientation(Qt::Horizontal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) 	split1->setChildrenCollapsible(false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) 	menuList = new ConfigList(widget, "menu");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) 	split2 = new QSplitter(widget);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) 	split2->setChildrenCollapsible(false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) 	split2->setOrientation(Qt::Vertical);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) 	// create config tree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) 	configList = new ConfigList(widget, "config");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) 	helpText = new ConfigInfoView(widget, "help");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) 	layout->addWidget(split2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) 	split2->addWidget(split1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) 	split1->addWidget(configList);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) 	split1->addWidget(menuList);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) 	split2->addWidget(helpText);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) 	setTabOrder(configList, helpText);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) 	configList->setFocus();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) 	backAction = new QAction(QPixmap(xpm_back), "Back", this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) 	connect(backAction, SIGNAL(triggered(bool)), SLOT(goBack()));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) 	QAction *quitAction = new QAction("&Quit", this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) 	quitAction->setShortcut(Qt::CTRL + Qt::Key_Q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) 	connect(quitAction, SIGNAL(triggered(bool)), SLOT(close()));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) 	QAction *loadAction = new QAction(QPixmap(xpm_load), "&Load", this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) 	loadAction->setShortcut(Qt::CTRL + Qt::Key_L);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) 	connect(loadAction, SIGNAL(triggered(bool)), SLOT(loadConfig()));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) 	saveAction = new QAction(QPixmap(xpm_save), "&Save", this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) 	saveAction->setShortcut(Qt::CTRL + Qt::Key_S);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) 	connect(saveAction, SIGNAL(triggered(bool)), SLOT(saveConfig()));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) 	conf_set_changed_callback(conf_changed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) 	// Set saveAction's initial state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) 	conf_changed();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) 	configname = xstrdup(conf_get_configname());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) 	QAction *saveAsAction = new QAction("Save &As...", this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) 	  connect(saveAsAction, SIGNAL(triggered(bool)), SLOT(saveConfigAs()));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) 	QAction *searchAction = new QAction("&Find", this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) 	searchAction->setShortcut(Qt::CTRL + Qt::Key_F);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) 	  connect(searchAction, SIGNAL(triggered(bool)), SLOT(searchConfig()));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) 	singleViewAction = new QAction(QPixmap(xpm_single_view), "Single View", this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) 	singleViewAction->setCheckable(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) 	  connect(singleViewAction, SIGNAL(triggered(bool)), SLOT(showSingleView()));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) 	splitViewAction = new QAction(QPixmap(xpm_split_view), "Split View", this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) 	splitViewAction->setCheckable(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) 	  connect(splitViewAction, SIGNAL(triggered(bool)), SLOT(showSplitView()));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) 	fullViewAction = new QAction(QPixmap(xpm_tree_view), "Full View", this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) 	fullViewAction->setCheckable(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) 	  connect(fullViewAction, SIGNAL(triggered(bool)), SLOT(showFullView()));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) 	QAction *showNameAction = new QAction("Show Name", this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) 	  showNameAction->setCheckable(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) 	connect(showNameAction, SIGNAL(toggled(bool)), configList, SLOT(setShowName(bool)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) 	showNameAction->setChecked(configList->showName);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) 	QActionGroup *optGroup = new QActionGroup(this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) 	optGroup->setExclusive(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) 	connect(optGroup, SIGNAL(triggered(QAction*)), configList,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) 		SLOT(setOptionMode(QAction *)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) 	connect(optGroup, SIGNAL(triggered(QAction *)), menuList,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) 		SLOT(setOptionMode(QAction *)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) 	ConfigList::showNormalAction = new QAction("Show Normal Options", optGroup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) 	ConfigList::showNormalAction->setCheckable(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) 	ConfigList::showAllAction = new QAction("Show All Options", optGroup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) 	ConfigList::showAllAction->setCheckable(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) 	ConfigList::showPromptAction = new QAction("Show Prompt Options", optGroup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) 	ConfigList::showPromptAction->setCheckable(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) 	QAction *showDebugAction = new QAction("Show Debug Info", this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) 	  showDebugAction->setCheckable(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) 	  connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) 	  showDebugAction->setChecked(helpText->showDebug());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) 	QAction *showIntroAction = new QAction("Introduction", this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) 	  connect(showIntroAction, SIGNAL(triggered(bool)), SLOT(showIntro()));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) 	QAction *showAboutAction = new QAction("About", this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) 	  connect(showAboutAction, SIGNAL(triggered(bool)), SLOT(showAbout()));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) 	// init tool bar
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) 	QToolBar *toolBar = addToolBar("Tools");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) 	toolBar->addAction(backAction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) 	toolBar->addSeparator();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) 	toolBar->addAction(loadAction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) 	toolBar->addAction(saveAction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) 	toolBar->addSeparator();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) 	toolBar->addAction(singleViewAction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) 	toolBar->addAction(splitViewAction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) 	toolBar->addAction(fullViewAction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) 	// create file menu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) 	QMenu *menu = menuBar()->addMenu("&File");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) 	menu->addAction(loadAction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) 	menu->addAction(saveAction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) 	menu->addAction(saveAsAction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) 	menu->addSeparator();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) 	menu->addAction(quitAction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) 	// create edit menu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) 	menu = menuBar()->addMenu("&Edit");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) 	menu->addAction(searchAction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) 	// create options menu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) 	menu = menuBar()->addMenu("&Option");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) 	menu->addAction(showNameAction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) 	menu->addSeparator();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) 	menu->addActions(optGroup->actions());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) 	menu->addSeparator();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) 	menu->addAction(showDebugAction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) 	// create help menu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) 	menu = menuBar()->addMenu("&Help");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) 	menu->addAction(showIntroAction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) 	menu->addAction(showAboutAction);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) 	connect (helpText, SIGNAL (anchorClicked (const QUrl &)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) 		 helpText, SLOT (clicked (const QUrl &)) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) 	connect(configList, SIGNAL(menuChanged(struct menu *)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) 		helpText, SLOT(setInfo(struct menu *)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) 	connect(configList, SIGNAL(menuSelected(struct menu *)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) 		SLOT(changeMenu(struct menu *)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) 	connect(configList, SIGNAL(itemSelected(struct menu *)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) 		SLOT(changeItens(struct menu *)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) 	connect(configList, SIGNAL(parentSelected()),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) 		SLOT(goBack()));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) 	connect(menuList, SIGNAL(menuChanged(struct menu *)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) 		helpText, SLOT(setInfo(struct menu *)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) 	connect(menuList, SIGNAL(menuSelected(struct menu *)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) 		SLOT(changeMenu(struct menu *)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) 	connect(configList, SIGNAL(gotFocus(struct menu *)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) 		helpText, SLOT(setInfo(struct menu *)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) 	connect(menuList, SIGNAL(gotFocus(struct menu *)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) 		helpText, SLOT(setInfo(struct menu *)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) 	connect(menuList, SIGNAL(gotFocus(struct menu *)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) 		SLOT(listFocusChanged(void)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) 	connect(helpText, SIGNAL(menuSelected(struct menu *)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) 		SLOT(setMenuLink(struct menu *)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) 	QString listMode = configSettings->value("/listMode", "symbol").toString();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) 	if (listMode == "single")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) 		showSingleView();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) 	else if (listMode == "full")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) 		showFullView();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) 	else /*if (listMode == "split")*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) 		showSplitView();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) 	// UI setup done, restore splitter positions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) 	QList<int> sizes = configSettings->readSizes("/split1", &ok);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) 	if (ok)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) 		split1->setSizes(sizes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) 	sizes = configSettings->readSizes("/split2", &ok);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) 	if (ok)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) 		split2->setSizes(sizes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) void ConfigMainWindow::loadConfig(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) 	QString str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) 	QByteArray ba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) 	const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) 	str = QFileDialog::getOpenFileName(this, "", configname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) 	if (str.isNull())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) 	ba = str.toLocal8Bit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) 	name = ba.data();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) 	if (conf_read(name))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) 		QMessageBox::information(this, "qconf", "Unable to load configuration!");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) 	free(configname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) 	configname = xstrdup(name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) 	ConfigList::updateListAllForAll();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) bool ConfigMainWindow::saveConfig(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) 	if (conf_write(configname)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) 		QMessageBox::information(this, "qconf", "Unable to save configuration!");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) 		return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) 	conf_write_autoconf(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) 	return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) void ConfigMainWindow::saveConfigAs(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) 	QString str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) 	QByteArray ba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) 	const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) 	str = QFileDialog::getSaveFileName(this, "", configname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) 	if (str.isNull())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) 	ba = str.toLocal8Bit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) 	name = ba.data();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) 	if (conf_write(name)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) 		QMessageBox::information(this, "qconf", "Unable to save configuration!");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) 	conf_write_autoconf(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) 	free(configname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) 	configname = xstrdup(name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) void ConfigMainWindow::searchConfig(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) 	if (!searchWindow)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) 		searchWindow = new ConfigSearchWindow(this);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) 	searchWindow->show();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) void ConfigMainWindow::changeItens(struct menu *menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) 	configList->setRootMenu(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) void ConfigMainWindow::changeMenu(struct menu *menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) 	menuList->setRootMenu(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) void ConfigMainWindow::setMenuLink(struct menu *menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) 	struct menu *parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) 	ConfigList* list = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) 	ConfigItem* item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) 	if (configList->menuSkip(menu))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) 	switch (configList->mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) 	case singleMode:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) 		list = configList;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) 		parent = menu_get_parent_menu(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) 		if (!parent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) 		list->setRootMenu(parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) 	case menuMode:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) 		if (menu->flags & MENU_ROOT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) 			menuList->setRootMenu(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) 			configList->clearSelection();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) 			list = configList;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) 			parent = menu_get_parent_menu(menu->parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) 			if (!parent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) 				return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) 			/* Select the config view */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) 			item = configList->findConfigItem(parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) 			if (item) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) 				configList->setSelected(item, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) 				configList->scrollToItem(item);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) 			menuList->setRootMenu(parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) 			menuList->clearSelection();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) 			list = menuList;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) 	case fullMode:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) 		list = configList;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) 	if (list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) 		item = list->findConfigItem(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) 		if (item) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) 			list->setSelected(item, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) 			list->scrollToItem(item);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) 			list->setFocus();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) 			helpText->setInfo(menu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) void ConfigMainWindow::listFocusChanged(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) 	if (menuList->mode == menuMode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) 		configList->clearSelection();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) void ConfigMainWindow::goBack(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) 	if (configList->rootEntry == &rootmenu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) 	configList->setParentMenu();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) void ConfigMainWindow::showSingleView(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) 	singleViewAction->setEnabled(false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) 	singleViewAction->setChecked(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) 	splitViewAction->setEnabled(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) 	splitViewAction->setChecked(false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662) 	fullViewAction->setEnabled(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) 	fullViewAction->setChecked(false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) 	backAction->setEnabled(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) 	menuList->hide();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) 	menuList->setRootMenu(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) 	configList->mode = singleMode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) 	if (configList->rootEntry == &rootmenu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) 		configList->updateListAll();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) 		configList->setRootMenu(&rootmenu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) 	configList->setFocus();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) void ConfigMainWindow::showSplitView(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) 	singleViewAction->setEnabled(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) 	singleViewAction->setChecked(false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) 	splitViewAction->setEnabled(false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) 	splitViewAction->setChecked(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) 	fullViewAction->setEnabled(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) 	fullViewAction->setChecked(false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) 	backAction->setEnabled(false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) 	configList->mode = menuMode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) 	if (configList->rootEntry == &rootmenu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) 		configList->updateListAll();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) 		configList->setRootMenu(&rootmenu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) 	configList->setAllOpen(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) 	configApp->processEvents();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) 	menuList->mode = symbolMode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) 	menuList->setRootMenu(&rootmenu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) 	menuList->setAllOpen(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) 	menuList->show();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) 	menuList->setFocus();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702) void ConfigMainWindow::showFullView(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) 	singleViewAction->setEnabled(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) 	singleViewAction->setChecked(false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) 	splitViewAction->setEnabled(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) 	splitViewAction->setChecked(false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) 	fullViewAction->setEnabled(false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) 	fullViewAction->setChecked(true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) 	backAction->setEnabled(false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) 	menuList->hide();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) 	menuList->setRootMenu(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) 	configList->mode = fullMode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) 	if (configList->rootEntry == &rootmenu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) 		configList->updateListAll();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) 		configList->setRootMenu(&rootmenu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) 	configList->setFocus();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724)  * ask for saving configuration before quitting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) void ConfigMainWindow::closeEvent(QCloseEvent* e)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728) 	if (!conf_get_changed()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) 		e->accept();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) 	QMessageBox mb("qconf", "Save configuration?", QMessageBox::Warning,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) 			QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) 	mb.setButtonText(QMessageBox::Yes, "&Save Changes");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) 	mb.setButtonText(QMessageBox::No, "&Discard Changes");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) 	mb.setButtonText(QMessageBox::Cancel, "Cancel Exit");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737) 	switch (mb.exec()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) 	case QMessageBox::Yes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739) 		if (saveConfig())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) 			e->accept();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) 			e->ignore();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) 	case QMessageBox::No:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) 		e->accept();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) 	case QMessageBox::Cancel:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) 		e->ignore();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) void ConfigMainWindow::showIntro(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) 	static const QString str =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) 		"Welcome to the qconf graphical configuration tool.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) 		"\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) 		"For bool and tristate options, a blank box indicates the "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) 		"feature is disabled, a check indicates it is enabled, and a "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) 		"dot indicates that it is to be compiled as a module. Clicking "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) 		"on the box will cycle through the three states. For int, hex, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) 		"and string options, double-clicking or pressing F2 on the "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) 		"Value cell will allow you to edit the value.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) 		"\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765) 		"If you do not see an option (e.g., a device driver) that you "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) 		"believe should be present, try turning on Show All Options "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) 		"under the Options menu. Enabling Show Debug Info will help you"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) 		"figure out what other options must be enabled to support the "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) 		"option you are interested in, and hyperlinks will navigate to "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) 		"them.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) 		"\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) 		"Toggling Show Debug Info under the Options menu will show the "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) 		"dependencies, which you can then match by examining other "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) 		"options.\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) 	QMessageBox::information(this, "qconf", str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) void ConfigMainWindow::showAbout(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781) 	static const QString str = "qconf is Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>.\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782) 		"Copyright (C) 2015 Boris Barbulovski <bbarbulovski@gmail.com>.\n\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) 		"Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785) 	QMessageBox::information(this, "qconf", str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) void ConfigMainWindow::saveSettings(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) 	configSettings->setValue("/window x", pos().x());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) 	configSettings->setValue("/window y", pos().y());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) 	configSettings->setValue("/window width", size().width());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) 	configSettings->setValue("/window height", size().height());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) 	QString entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) 	switch(configList->mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) 	case singleMode :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) 		entry = "single";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801) 	case symbolMode :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) 		entry = "split";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805) 	case fullMode :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) 		entry = "full";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812) 	configSettings->setValue("/listMode", entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) 	configSettings->writeSizes("/split1", split1->sizes());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) 	configSettings->writeSizes("/split2", split2->sizes());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) void ConfigMainWindow::conf_changed(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) 	if (saveAction)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821) 		saveAction->setEnabled(conf_get_changed());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) void fixup_rootmenu(struct menu *menu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) 	struct menu *child;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) 	static int menu_cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) 	menu->flags |= MENU_ROOT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) 	for (child = menu->list; child; child = child->next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) 		if (child->prompt && child->prompt->type == P_MENU) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) 			menu_cnt++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) 			fixup_rootmenu(child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) 			menu_cnt--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) 		} else if (!menu_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) 			fixup_rootmenu(child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) static const char *progname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) static void usage(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844) 	printf("%s [-s] <config>\n", progname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845) 	exit(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) int main(int ac, char** av)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) 	ConfigMainWindow* v;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) 	const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853) 	progname = av[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854) 	if (ac > 1 && av[1][0] == '-') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) 		switch (av[1][1]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856) 		case 's':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) 			conf_set_message_callback(NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859) 		case 'h':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860) 		case '?':
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861) 			usage();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) 		name = av[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865) 		name = av[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866) 	if (!name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867) 		usage();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) 	conf_parse(name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870) 	fixup_rootmenu(&rootmenu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871) 	conf_read(NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872) 	//zconfdump(stdout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) 	configApp = new QApplication(ac, av);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) 	configSettings = new ConfigSettings();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) 	configSettings->beginGroup("/kconfig/qconf");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878) 	v = new ConfigMainWindow();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880) 	//zconfdump(stdout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) 	configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit()));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) 	configApp->connect(configApp, SIGNAL(aboutToQuit()), v, SLOT(saveSettings()));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883) 	v->show();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) 	configApp->exec();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886) 	configSettings->endGroup();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) 	delete configSettings;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888) 	delete v;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889) 	delete configApp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892) }