Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> |
| 3 | * Released under the terms of the GNU GPL v2.0. |
| 4 | */ |
| 5 | |
Alexander Stein | 133c5f7 | 2010-08-31 17:34:37 +0200 | [diff] [blame] | 6 | #include <qglobal.h> |
| 7 | |
Boris Barbulovski | b1f8a45 | 2015-09-22 11:36:02 -0700 | [diff] [blame] | 8 | #include <QMainWindow> |
Boris Barbulovski | 041fbdc | 2015-09-22 11:36:05 -0700 | [diff] [blame] | 9 | #include <QList> |
Boris Barbulovski | 924bbb5 | 2015-09-22 11:36:06 -0700 | [diff] [blame] | 10 | #include <qtextbrowser.h> |
Boris Barbulovski | 85eaf28 | 2015-09-22 11:36:03 -0700 | [diff] [blame] | 11 | #include <QAction> |
Boris Barbulovski | bea0077 | 2015-09-22 11:36:04 -0700 | [diff] [blame] | 12 | #include <QFileDialog> |
Boris Barbulovski | 76bede8 | 2015-09-22 11:36:07 -0700 | [diff] [blame] | 13 | #include <QMenu> |
Alexander Stein | 133c5f7 | 2010-08-31 17:34:37 +0200 | [diff] [blame] | 14 | |
| 15 | #include <qapplication.h> |
Markus Heidelberg | 8d90c97 | 2009-05-18 01:36:52 +0200 | [diff] [blame] | 16 | #include <qdesktopwidget.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <qtoolbar.h> |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 18 | #include <qlayout.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <qsplitter.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <qlineedit.h> |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 21 | #include <qlabel.h> |
| 22 | #include <qpushbutton.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include <qmenubar.h> |
| 24 | #include <qmessagebox.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #include <qregexp.h> |
Alexander Stein | 133c5f7 | 2010-08-31 17:34:37 +0200 | [diff] [blame] | 26 | #include <qevent.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | |
| 28 | #include <stdlib.h> |
| 29 | |
| 30 | #include "lkc.h" |
| 31 | #include "qconf.h" |
| 32 | |
| 33 | #include "qconf.moc" |
| 34 | #include "images.c" |
| 35 | |
Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 36 | #ifdef _ |
| 37 | # undef _ |
| 38 | # define _ qgettext |
| 39 | #endif |
| 40 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | static QApplication *configApp; |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 42 | static ConfigSettings *configSettings; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
Boris Barbulovski | 85eaf28 | 2015-09-22 11:36:03 -0700 | [diff] [blame] | 44 | QAction *ConfigMainWindow::saveAction; |
Karsten Wiese | 3b354c5 | 2006-12-13 00:34:08 -0800 | [diff] [blame] | 45 | |
Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 46 | static inline QString qgettext(const char* str) |
| 47 | { |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 48 | return QString::fromLocal8Bit(gettext(str)); |
Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | static inline QString qgettext(const QString& str) |
| 52 | { |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 53 | return QString::fromLocal8Bit(gettext(str.toLatin1())); |
Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 54 | } |
| 55 | |
Ben Hutchings | 00d4f8f | 2013-10-06 19:21:31 +0100 | [diff] [blame] | 56 | ConfigSettings::ConfigSettings() |
| 57 | : QSettings("kernel.org", "qconf") |
| 58 | { |
| 59 | } |
| 60 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | /** |
| 62 | * Reads a list of integer values from the application settings. |
| 63 | */ |
Boris Barbulovski | 041fbdc | 2015-09-22 11:36:05 -0700 | [diff] [blame] | 64 | QList<int> ConfigSettings::readSizes(const QString& key, bool *ok) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | { |
Boris Barbulovski | 041fbdc | 2015-09-22 11:36:05 -0700 | [diff] [blame] | 66 | QList<int> result; |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 67 | QStringList entryList = value(key).toStringList(); |
Li Zefan | c1f96f0 | 2010-05-07 13:58:04 +0800 | [diff] [blame] | 68 | QStringList::Iterator it; |
| 69 | |
| 70 | for (it = entryList.begin(); it != entryList.end(); ++it) |
| 71 | result.push_back((*it).toInt()); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
| 73 | return result; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Writes a list of integer values to the application settings. |
| 78 | */ |
Boris Barbulovski | 041fbdc | 2015-09-22 11:36:05 -0700 | [diff] [blame] | 79 | bool ConfigSettings::writeSizes(const QString& key, const QList<int>& value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | { |
| 81 | QStringList stringList; |
Boris Barbulovski | 041fbdc | 2015-09-22 11:36:05 -0700 | [diff] [blame] | 82 | QList<int>::ConstIterator it; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | |
| 84 | for (it = value.begin(); it != value.end(); ++it) |
| 85 | stringList.push_back(QString::number(*it)); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 86 | setValue(key, stringList); |
| 87 | return true; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 90 | ConfigLineEdit::ConfigLineEdit(ConfigView* parent) |
| 91 | : Parent(parent) |
| 92 | { |
| 93 | connect(this, SIGNAL(lostFocus()), SLOT(hide())); |
| 94 | } |
| 95 | |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 96 | void ConfigLineEdit::show(QTreeWidgetItem *i) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | { |
| 98 | item = i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | Parent::show(); |
| 100 | setFocus(); |
| 101 | } |
| 102 | |
| 103 | void ConfigLineEdit::keyPressEvent(QKeyEvent* e) |
| 104 | { |
| 105 | switch (e->key()) { |
Markus Heidelberg | fbb8637 | 2009-05-18 01:36:51 +0200 | [diff] [blame] | 106 | case Qt::Key_Escape: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | break; |
Markus Heidelberg | fbb8637 | 2009-05-18 01:36:51 +0200 | [diff] [blame] | 108 | case Qt::Key_Return: |
| 109 | case Qt::Key_Enter: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | parent()->updateList(item); |
| 111 | break; |
| 112 | default: |
| 113 | Parent::keyPressEvent(e); |
| 114 | return; |
| 115 | } |
| 116 | e->accept(); |
| 117 | parent()->list->setFocus(); |
| 118 | hide(); |
| 119 | } |
| 120 | |
Li Zefan | 39a4897 | 2010-05-10 16:33:41 +0800 | [diff] [blame] | 121 | ConfigView*ConfigView::viewList; |
| 122 | QAction *ConfigView::showNormalAction; |
| 123 | QAction *ConfigView::showAllAction; |
| 124 | QAction *ConfigView::showPromptAction; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 126 | ConfigView::ConfigView(QWidget* parent, const char *name) |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 127 | : Parent(parent) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | { |
Boris Barbulovski | 29a7016 | 2015-09-22 11:36:10 -0700 | [diff] [blame] | 129 | QVBoxLayout *verticalLayout = new QVBoxLayout(this); |
Boris Barbulovski | 92298b4 | 2015-09-22 11:36:11 -0700 | [diff] [blame] | 130 | verticalLayout->setContentsMargins(0, 0, 0, 0); |
Boris Barbulovski | 29a7016 | 2015-09-22 11:36:10 -0700 | [diff] [blame] | 131 | |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 132 | list = new QTreeWidget(this); |
Boris Barbulovski | 29a7016 | 2015-09-22 11:36:10 -0700 | [diff] [blame] | 133 | verticalLayout->addWidget(list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | lineEdit = new ConfigLineEdit(this); |
| 135 | lineEdit->hide(); |
Boris Barbulovski | 29a7016 | 2015-09-22 11:36:10 -0700 | [diff] [blame] | 136 | verticalLayout->addWidget(lineEdit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | |
| 138 | this->nextView = viewList; |
| 139 | viewList = this; |
| 140 | } |
| 141 | |
| 142 | ConfigView::~ConfigView(void) |
| 143 | { |
| 144 | ConfigView** vp; |
| 145 | |
| 146 | for (vp = &viewList; *vp; vp = &(*vp)->nextView) { |
| 147 | if (*vp == this) { |
| 148 | *vp = nextView; |
| 149 | break; |
| 150 | } |
| 151 | } |
| 152 | } |
| 153 | |
Li Zefan | 39a4897 | 2010-05-10 16:33:41 +0800 | [diff] [blame] | 154 | void ConfigView::setOptionMode(QAction *act) |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 155 | { |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | void ConfigView::setShowName(bool b) |
| 159 | { |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | void ConfigView::setShowRange(bool b) |
| 163 | { |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | void ConfigView::setShowData(bool b) |
| 167 | { |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 168 | } |
| 169 | |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 170 | void ConfigView::updateList(QTreeWidgetItem* item) |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 171 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | void ConfigView::updateListAll(void) |
| 175 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | } |
| 177 | |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 178 | ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name) |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 179 | : Parent(parent), sym(0), _menu(0) |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 180 | { |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 181 | if (name) { |
| 182 | configSettings->beginGroup(name); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 183 | _showDebug = configSettings->value("/showDebug", false).toBool(); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 184 | configSettings->endGroup(); |
| 185 | connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | void ConfigInfoView::saveSettings(void) |
| 190 | { |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 191 | /*if (name()) { |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 192 | configSettings->beginGroup(name()); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 193 | configSettings->setValue("/showDebug", showDebug()); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 194 | configSettings->endGroup(); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 195 | }*/ |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | void ConfigInfoView::setShowDebug(bool b) |
| 199 | { |
| 200 | if (_showDebug != b) { |
| 201 | _showDebug = b; |
Alexander Stein | 133c5f7 | 2010-08-31 17:34:37 +0200 | [diff] [blame] | 202 | if (_menu) |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 203 | menuInfo(); |
Roman Zippel | ab45d19 | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 204 | else if (sym) |
| 205 | symbolInfo(); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 206 | emit showDebugChanged(b); |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | void ConfigInfoView::setInfo(struct menu *m) |
| 211 | { |
Alexander Stein | 133c5f7 | 2010-08-31 17:34:37 +0200 | [diff] [blame] | 212 | if (_menu == m) |
Roman Zippel | b65a47e | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 213 | return; |
Alexander Stein | 133c5f7 | 2010-08-31 17:34:37 +0200 | [diff] [blame] | 214 | _menu = m; |
Roman Zippel | 6fa1da8 | 2007-01-10 23:15:31 -0800 | [diff] [blame] | 215 | sym = NULL; |
Alexander Stein | 133c5f7 | 2010-08-31 17:34:37 +0200 | [diff] [blame] | 216 | if (!_menu) |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 217 | clear(); |
Roman Zippel | 6fa1da8 | 2007-01-10 23:15:31 -0800 | [diff] [blame] | 218 | else |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 219 | menuInfo(); |
| 220 | } |
| 221 | |
Roman Zippel | ab45d19 | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 222 | void ConfigInfoView::symbolInfo(void) |
| 223 | { |
| 224 | QString str; |
| 225 | |
| 226 | str += "<big>Symbol: <b>"; |
| 227 | str += print_filter(sym->name); |
| 228 | str += "</b></big><br><br>value: "; |
| 229 | str += print_filter(sym_get_string_value(sym)); |
| 230 | str += "<br>visibility: "; |
| 231 | str += sym->visible == yes ? "y" : sym->visible == mod ? "m" : "n"; |
| 232 | str += "<br>"; |
| 233 | str += debug_info(sym); |
| 234 | |
| 235 | setText(str); |
| 236 | } |
| 237 | |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 238 | void ConfigInfoView::menuInfo(void) |
| 239 | { |
| 240 | struct symbol* sym; |
| 241 | QString head, debug, help; |
| 242 | |
Alexander Stein | 133c5f7 | 2010-08-31 17:34:37 +0200 | [diff] [blame] | 243 | sym = _menu->sym; |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 244 | if (sym) { |
Alexander Stein | 133c5f7 | 2010-08-31 17:34:37 +0200 | [diff] [blame] | 245 | if (_menu->prompt) { |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 246 | head += "<big><b>"; |
Alexander Stein | 133c5f7 | 2010-08-31 17:34:37 +0200 | [diff] [blame] | 247 | head += print_filter(_(_menu->prompt->text)); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 248 | head += "</b></big>"; |
| 249 | if (sym->name) { |
| 250 | head += " ("; |
Roman Zippel | ab45d19 | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 251 | if (showDebug()) |
| 252 | head += QString().sprintf("<a href=\"s%p\">", sym); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 253 | head += print_filter(sym->name); |
Roman Zippel | ab45d19 | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 254 | if (showDebug()) |
| 255 | head += "</a>"; |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 256 | head += ")"; |
| 257 | } |
| 258 | } else if (sym->name) { |
| 259 | head += "<big><b>"; |
Roman Zippel | ab45d19 | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 260 | if (showDebug()) |
| 261 | head += QString().sprintf("<a href=\"s%p\">", sym); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 262 | head += print_filter(sym->name); |
Roman Zippel | ab45d19 | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 263 | if (showDebug()) |
| 264 | head += "</a>"; |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 265 | head += "</b></big>"; |
| 266 | } |
| 267 | head += "<br><br>"; |
| 268 | |
| 269 | if (showDebug()) |
| 270 | debug = debug_info(sym); |
| 271 | |
Cheng Renquan | d74c15f | 2009-07-12 16:11:47 +0800 | [diff] [blame] | 272 | struct gstr help_gstr = str_new(); |
Alexander Stein | 133c5f7 | 2010-08-31 17:34:37 +0200 | [diff] [blame] | 273 | menu_get_ext_help(_menu, &help_gstr); |
Cheng Renquan | d74c15f | 2009-07-12 16:11:47 +0800 | [diff] [blame] | 274 | help = print_filter(str_get(&help_gstr)); |
| 275 | str_free(&help_gstr); |
Alexander Stein | 133c5f7 | 2010-08-31 17:34:37 +0200 | [diff] [blame] | 276 | } else if (_menu->prompt) { |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 277 | head += "<big><b>"; |
Alexander Stein | 133c5f7 | 2010-08-31 17:34:37 +0200 | [diff] [blame] | 278 | head += print_filter(_(_menu->prompt->text)); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 279 | head += "</b></big><br><br>"; |
| 280 | if (showDebug()) { |
Alexander Stein | 133c5f7 | 2010-08-31 17:34:37 +0200 | [diff] [blame] | 281 | if (_menu->prompt->visible.expr) { |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 282 | debug += " dep: "; |
Alexander Stein | 133c5f7 | 2010-08-31 17:34:37 +0200 | [diff] [blame] | 283 | expr_print(_menu->prompt->visible.expr, expr_print_help, &debug, E_NONE); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 284 | debug += "<br><br>"; |
| 285 | } |
| 286 | } |
| 287 | } |
| 288 | if (showDebug()) |
Alexander Stein | 133c5f7 | 2010-08-31 17:34:37 +0200 | [diff] [blame] | 289 | debug += QString().sprintf("defined at %s:%d<br><br>", _menu->file->name, _menu->lineno); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 290 | |
| 291 | setText(head + debug + help); |
| 292 | } |
| 293 | |
| 294 | QString ConfigInfoView::debug_info(struct symbol *sym) |
| 295 | { |
| 296 | QString debug; |
| 297 | |
| 298 | debug += "type: "; |
| 299 | debug += print_filter(sym_type_name(sym->type)); |
| 300 | if (sym_is_choice(sym)) |
| 301 | debug += " (choice)"; |
| 302 | debug += "<br>"; |
| 303 | if (sym->rev_dep.expr) { |
| 304 | debug += "reverse dep: "; |
| 305 | expr_print(sym->rev_dep.expr, expr_print_help, &debug, E_NONE); |
| 306 | debug += "<br>"; |
| 307 | } |
| 308 | for (struct property *prop = sym->prop; prop; prop = prop->next) { |
| 309 | switch (prop->type) { |
| 310 | case P_PROMPT: |
| 311 | case P_MENU: |
Roman Zippel | ab45d19 | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 312 | debug += QString().sprintf("prompt: <a href=\"m%p\">", prop->menu); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 313 | debug += print_filter(_(prop->text)); |
Roman Zippel | ab45d19 | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 314 | debug += "</a><br>"; |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 315 | break; |
| 316 | case P_DEFAULT: |
Roman Zippel | 9344908 | 2008-01-14 04:50:54 +0100 | [diff] [blame] | 317 | case P_SELECT: |
| 318 | case P_RANGE: |
| 319 | case P_ENV: |
| 320 | debug += prop_get_type_name(prop->type); |
| 321 | debug += ": "; |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 322 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); |
| 323 | debug += "<br>"; |
| 324 | break; |
| 325 | case P_CHOICE: |
| 326 | if (sym_is_choice(sym)) { |
| 327 | debug += "choice: "; |
| 328 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); |
| 329 | debug += "<br>"; |
| 330 | } |
| 331 | break; |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 332 | default: |
| 333 | debug += "unknown property: "; |
| 334 | debug += prop_get_type_name(prop->type); |
| 335 | debug += "<br>"; |
| 336 | } |
| 337 | if (prop->visible.expr) { |
| 338 | debug += " dep: "; |
| 339 | expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE); |
| 340 | debug += "<br>"; |
| 341 | } |
| 342 | } |
| 343 | debug += "<br>"; |
| 344 | |
| 345 | return debug; |
| 346 | } |
| 347 | |
| 348 | QString ConfigInfoView::print_filter(const QString &str) |
| 349 | { |
| 350 | QRegExp re("[<>&\"\\n]"); |
| 351 | QString res = str; |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 352 | for (int i = 0; (i = res.indexOf(re, i)) >= 0;) { |
| 353 | switch (res[i].toLatin1()) { |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 354 | case '<': |
| 355 | res.replace(i, 1, "<"); |
| 356 | i += 4; |
| 357 | break; |
| 358 | case '>': |
| 359 | res.replace(i, 1, ">"); |
| 360 | i += 4; |
| 361 | break; |
| 362 | case '&': |
| 363 | res.replace(i, 1, "&"); |
| 364 | i += 5; |
| 365 | break; |
| 366 | case '"': |
| 367 | res.replace(i, 1, """); |
| 368 | i += 6; |
| 369 | break; |
| 370 | case '\n': |
| 371 | res.replace(i, 1, "<br>"); |
| 372 | i += 4; |
| 373 | break; |
| 374 | } |
| 375 | } |
| 376 | return res; |
| 377 | } |
| 378 | |
Roman Zippel | ab45d19 | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 379 | void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char *str) |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 380 | { |
Roman Zippel | ab45d19 | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 381 | QString* text = reinterpret_cast<QString*>(data); |
| 382 | QString str2 = print_filter(str); |
| 383 | |
| 384 | if (sym && sym->name && !(sym->flags & SYMBOL_CONST)) { |
| 385 | *text += QString().sprintf("<a href=\"s%p\">", sym); |
| 386 | *text += str2; |
| 387 | *text += "</a>"; |
| 388 | } else |
| 389 | *text += str2; |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 390 | } |
| 391 | |
Boris Barbulovski | 924bbb5 | 2015-09-22 11:36:06 -0700 | [diff] [blame] | 392 | QMenu* ConfigInfoView::createStandardContextMenu(const QPoint & pos) |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 393 | { |
Boris Barbulovski | 924bbb5 | 2015-09-22 11:36:06 -0700 | [diff] [blame] | 394 | QMenu* popup = Parent::createStandardContextMenu(pos); |
Boris Barbulovski | 85eaf28 | 2015-09-22 11:36:03 -0700 | [diff] [blame] | 395 | QAction* action = new QAction(_("Show Debug Info"), popup); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 396 | action->setCheckable(true); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 397 | connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); |
| 398 | connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool))); |
Boris Barbulovski | 9c86235 | 2015-09-22 11:36:12 -0700 | [diff] [blame] | 399 | action->setChecked(showDebug()); |
Boris Barbulovski | 924bbb5 | 2015-09-22 11:36:06 -0700 | [diff] [blame] | 400 | popup->addSeparator(); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 401 | popup->addAction(action); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 402 | return popup; |
| 403 | } |
| 404 | |
Boris Barbulovski | 924bbb5 | 2015-09-22 11:36:06 -0700 | [diff] [blame] | 405 | void ConfigInfoView::contextMenuEvent(QContextMenuEvent *e) |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 406 | { |
Boris Barbulovski | 924bbb5 | 2015-09-22 11:36:06 -0700 | [diff] [blame] | 407 | Parent::contextMenuEvent(e); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 408 | } |
| 409 | |
Marco Costalba | 63431e7 | 2006-10-05 19:12:59 +0200 | [diff] [blame] | 410 | ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *name) |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 411 | : Parent(parent), result(NULL) |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 412 | { |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 413 | setWindowTitle("Search Config"); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 414 | |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 415 | QVBoxLayout* layout1 = new QVBoxLayout(this); |
| 416 | layout1->setContentsMargins(11, 11, 11, 11); |
| 417 | layout1->setSpacing(6); |
| 418 | QHBoxLayout* layout2 = new QHBoxLayout(0); |
| 419 | layout2->setContentsMargins(0, 0, 0, 0); |
| 420 | layout2->setSpacing(6); |
EGRY Gabor | c21a2d9 | 2008-01-11 23:52:07 +0100 | [diff] [blame] | 421 | layout2->addWidget(new QLabel(_("Find:"), this)); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 422 | editField = new QLineEdit(this); |
| 423 | connect(editField, SIGNAL(returnPressed()), SLOT(search())); |
| 424 | layout2->addWidget(editField); |
EGRY Gabor | c21a2d9 | 2008-01-11 23:52:07 +0100 | [diff] [blame] | 425 | searchButton = new QPushButton(_("Search"), this); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 426 | searchButton->setAutoDefault(false); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 427 | connect(searchButton, SIGNAL(clicked()), SLOT(search())); |
| 428 | layout2->addWidget(searchButton); |
| 429 | layout1->addLayout(layout2); |
| 430 | |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 431 | split = new QSplitter(this); |
Markus Heidelberg | 7298b93 | 2009-05-18 01:36:50 +0200 | [diff] [blame] | 432 | split->setOrientation(Qt::Vertical); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 433 | list = new ConfigView(split, name); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 434 | info = new ConfigInfoView(split, name); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 435 | connect(list->list, SIGNAL(menuChanged(struct menu *)), |
| 436 | info, SLOT(setInfo(struct menu *))); |
Marco Costalba | 63431e7 | 2006-10-05 19:12:59 +0200 | [diff] [blame] | 437 | connect(list->list, SIGNAL(menuChanged(struct menu *)), |
| 438 | parent, SLOT(setMenuLink(struct menu *))); |
| 439 | |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 440 | layout1->addWidget(split); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 441 | |
| 442 | if (name) { |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 443 | QVariant x, y; |
| 444 | int width, height; |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 445 | bool ok; |
| 446 | |
| 447 | configSettings->beginGroup(name); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 448 | width = configSettings->value("/window width", parent->width() / 2).toInt(); |
| 449 | height = configSettings->value("/window height", parent->height() / 2).toInt(); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 450 | resize(width, height); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 451 | x = configSettings->value("/window x"); |
| 452 | y = configSettings->value("/window y"); |
| 453 | if ((x.isValid())&&(y.isValid())) |
| 454 | move(x.toInt(), y.toInt()); |
Boris Barbulovski | 041fbdc | 2015-09-22 11:36:05 -0700 | [diff] [blame] | 455 | QList<int> sizes = configSettings->readSizes("/split", &ok); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 456 | if (ok) |
| 457 | split->setSizes(sizes); |
| 458 | configSettings->endGroup(); |
| 459 | connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | void ConfigSearchWindow::saveSettings(void) |
| 464 | { |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 465 | /*if (name()) { |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 466 | configSettings->beginGroup(name()); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 467 | configSettings->setValue("/window x", pos().x()); |
| 468 | configSettings->setValue("/window y", pos().y()); |
| 469 | configSettings->setValue("/window width", size().width()); |
| 470 | configSettings->setValue("/window height", size().height()); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 471 | configSettings->writeSizes("/split", split->sizes()); |
| 472 | configSettings->endGroup(); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 473 | }*/ |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 474 | } |
| 475 | |
| 476 | void ConfigSearchWindow::search(void) |
| 477 | { |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 478 | } |
| 479 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | /* |
| 481 | * Construct the complete config widget |
| 482 | */ |
| 483 | ConfigMainWindow::ConfigMainWindow(void) |
Roman Zippel | f12aa70 | 2006-11-25 11:09:31 -0800 | [diff] [blame] | 484 | : searchWindow(0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | { |
| 486 | QMenuBar* menu; |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 487 | bool ok; |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 488 | QVariant x, y; |
| 489 | int width, height; |
Randy Dunlap | a54bb70 | 2007-10-20 11:18:47 -0700 | [diff] [blame] | 490 | char title[256]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | |
Markus Heidelberg | 8d90c97 | 2009-05-18 01:36:52 +0200 | [diff] [blame] | 492 | QDesktopWidget *d = configApp->desktop(); |
Arnaud Lacombe | 0954828 | 2010-08-18 01:57:13 -0400 | [diff] [blame] | 493 | snprintf(title, sizeof(title), "%s%s", |
| 494 | rootmenu.prompt->text, |
Michal Marek | 76a136c | 2010-09-01 17:39:27 +0200 | [diff] [blame] | 495 | "" |
Michal Marek | 76a136c | 2010-09-01 17:39:27 +0200 | [diff] [blame] | 496 | ); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 497 | setWindowTitle(title); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 499 | width = configSettings->value("/window width", d->width() - 64).toInt(); |
| 500 | height = configSettings->value("/window height", d->height() - 64).toInt(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | resize(width, height); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 502 | x = configSettings->value("/window x"); |
| 503 | y = configSettings->value("/window y"); |
| 504 | if ((x.isValid())&&(y.isValid())) |
| 505 | move(x.toInt(), y.toInt()); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | |
| 507 | split1 = new QSplitter(this); |
Markus Heidelberg | 7298b93 | 2009-05-18 01:36:50 +0200 | [diff] [blame] | 508 | split1->setOrientation(Qt::Horizontal); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | setCentralWidget(split1); |
| 510 | |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 511 | menuView = new ConfigView(split1, "menu"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | menuList = menuView->list; |
| 513 | |
| 514 | split2 = new QSplitter(split1); |
Markus Heidelberg | 7298b93 | 2009-05-18 01:36:50 +0200 | [diff] [blame] | 515 | split2->setOrientation(Qt::Vertical); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | |
| 517 | // create config tree |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 518 | configView = new ConfigView(split2, "config"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | configList = configView->list; |
| 520 | |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 521 | helpText = new ConfigInfoView(split2, "help"); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 522 | //helpText->setTextFormat(Qt::RichText); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | |
| 524 | setTabOrder(configList, helpText); |
| 525 | configList->setFocus(); |
| 526 | |
| 527 | menu = menuBar(); |
Boris Barbulovski | b1f8a45 | 2015-09-22 11:36:02 -0700 | [diff] [blame] | 528 | toolBar = new QToolBar("Tools", this); |
Boris Barbulovski | 29a7016 | 2015-09-22 11:36:10 -0700 | [diff] [blame] | 529 | addToolBar(toolBar); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 530 | |
Boris Barbulovski | 85eaf28 | 2015-09-22 11:36:03 -0700 | [diff] [blame] | 531 | backAction = new QAction(QPixmap(xpm_back), _("Back"), this); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 532 | connect(backAction, SIGNAL(activated()), SLOT(goBack())); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 533 | backAction->setEnabled(false); |
Boris Barbulovski | 85eaf28 | 2015-09-22 11:36:03 -0700 | [diff] [blame] | 534 | QAction *quitAction = new QAction(_("&Quit"), this); |
| 535 | quitAction->setShortcut(Qt::CTRL + Qt::Key_Q); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | connect(quitAction, SIGNAL(activated()), SLOT(close())); |
Boris Barbulovski | 85eaf28 | 2015-09-22 11:36:03 -0700 | [diff] [blame] | 537 | QAction *loadAction = new QAction(QPixmap(xpm_load), _("&Load"), this); |
| 538 | loadAction->setShortcut(Qt::CTRL + Qt::Key_L); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | connect(loadAction, SIGNAL(activated()), SLOT(loadConfig())); |
Boris Barbulovski | 85eaf28 | 2015-09-22 11:36:03 -0700 | [diff] [blame] | 540 | saveAction = new QAction(QPixmap(xpm_save), _("&Save"), this); |
| 541 | saveAction->setShortcut(Qt::CTRL + Qt::Key_S); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | connect(saveAction, SIGNAL(activated()), SLOT(saveConfig())); |
Karsten Wiese | 3b354c5 | 2006-12-13 00:34:08 -0800 | [diff] [blame] | 543 | conf_set_changed_callback(conf_changed); |
| 544 | // Set saveAction's initial state |
| 545 | conf_changed(); |
Boris Barbulovski | 85eaf28 | 2015-09-22 11:36:03 -0700 | [diff] [blame] | 546 | QAction *saveAsAction = new QAction(_("Save &As..."), this); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs())); |
Boris Barbulovski | 85eaf28 | 2015-09-22 11:36:03 -0700 | [diff] [blame] | 548 | QAction *searchAction = new QAction(_("&Find"), this); |
| 549 | searchAction->setShortcut(Qt::CTRL + Qt::Key_F); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 550 | connect(searchAction, SIGNAL(activated()), SLOT(searchConfig())); |
Boris Barbulovski | 780505e | 2015-09-22 11:36:13 -0700 | [diff] [blame] | 551 | singleViewAction = new QAction(QPixmap(xpm_single_view), _("Single View"), this); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 552 | singleViewAction->setCheckable(true); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView())); |
Boris Barbulovski | 780505e | 2015-09-22 11:36:13 -0700 | [diff] [blame] | 554 | splitViewAction = new QAction(QPixmap(xpm_split_view), _("Split View"), this); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 555 | splitViewAction->setCheckable(true); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView())); |
Boris Barbulovski | 780505e | 2015-09-22 11:36:13 -0700 | [diff] [blame] | 557 | fullViewAction = new QAction(QPixmap(xpm_tree_view), _("Full View"), this); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 558 | fullViewAction->setCheckable(true); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView())); |
| 560 | |
Boris Barbulovski | 85eaf28 | 2015-09-22 11:36:03 -0700 | [diff] [blame] | 561 | QAction *showNameAction = new QAction(_("Show Name"), this); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 562 | showNameAction->setCheckable(true); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 563 | connect(showNameAction, SIGNAL(toggled(bool)), configView, SLOT(setShowName(bool))); |
| 564 | connect(configView, SIGNAL(showNameChanged(bool)), showNameAction, SLOT(setOn(bool))); |
Boris Barbulovski | 9c86235 | 2015-09-22 11:36:12 -0700 | [diff] [blame] | 565 | showNameAction->setChecked(configView->showName()); |
Boris Barbulovski | 85eaf28 | 2015-09-22 11:36:03 -0700 | [diff] [blame] | 566 | QAction *showRangeAction = new QAction(_("Show Range"), this); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 567 | showRangeAction->setCheckable(true); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 568 | connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool))); |
| 569 | connect(configView, SIGNAL(showRangeChanged(bool)), showRangeAction, SLOT(setOn(bool))); |
Boris Barbulovski | 85eaf28 | 2015-09-22 11:36:03 -0700 | [diff] [blame] | 570 | QAction *showDataAction = new QAction(_("Show Data"), this); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 571 | showDataAction->setCheckable(true); |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 572 | connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool))); |
| 573 | connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool))); |
Li Zefan | 39a4897 | 2010-05-10 16:33:41 +0800 | [diff] [blame] | 574 | |
| 575 | QActionGroup *optGroup = new QActionGroup(this); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 576 | optGroup->setExclusive(true); |
Li Zefan | 39a4897 | 2010-05-10 16:33:41 +0800 | [diff] [blame] | 577 | connect(optGroup, SIGNAL(selected(QAction *)), configView, |
| 578 | SLOT(setOptionMode(QAction *))); |
| 579 | connect(optGroup, SIGNAL(selected(QAction *)), menuView, |
| 580 | SLOT(setOptionMode(QAction *))); |
| 581 | |
Alexander Stein | 133c5f7 | 2010-08-31 17:34:37 +0200 | [diff] [blame] | 582 | configView->showNormalAction = new QAction(_("Show Normal Options"), optGroup); |
| 583 | configView->showAllAction = new QAction(_("Show All Options"), optGroup); |
| 584 | configView->showPromptAction = new QAction(_("Show Prompt Options"), optGroup); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 585 | configView->showNormalAction->setCheckable(true); |
| 586 | configView->showAllAction->setCheckable(true); |
| 587 | configView->showPromptAction->setCheckable(true); |
Li Zefan | 39a4897 | 2010-05-10 16:33:41 +0800 | [diff] [blame] | 588 | |
Boris Barbulovski | 85eaf28 | 2015-09-22 11:36:03 -0700 | [diff] [blame] | 589 | QAction *showDebugAction = new QAction( _("Show Debug Info"), this); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 590 | showDebugAction->setCheckable(true); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 591 | connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool))); |
| 592 | connect(helpText, SIGNAL(showDebugChanged(bool)), showDebugAction, SLOT(setOn(bool))); |
Boris Barbulovski | 9c86235 | 2015-09-22 11:36:12 -0700 | [diff] [blame] | 593 | showDebugAction->setChecked(helpText->showDebug()); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | |
Boris Barbulovski | 85eaf28 | 2015-09-22 11:36:03 -0700 | [diff] [blame] | 595 | QAction *showIntroAction = new QAction( _("Introduction"), this); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro())); |
Boris Barbulovski | 85eaf28 | 2015-09-22 11:36:03 -0700 | [diff] [blame] | 597 | QAction *showAboutAction = new QAction( _("About"), this); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout())); |
| 599 | |
| 600 | // init tool bar |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 601 | toolBar->addAction(backAction); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | toolBar->addSeparator(); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 603 | toolBar->addAction(loadAction); |
| 604 | toolBar->addAction(saveAction); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | toolBar->addSeparator(); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 606 | toolBar->addAction(singleViewAction); |
| 607 | toolBar->addAction(splitViewAction); |
| 608 | toolBar->addAction(fullViewAction); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | |
| 610 | // create config menu |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 611 | QMenu* config = menu->addMenu(_("&File")); |
| 612 | config->addAction(loadAction); |
| 613 | config->addAction(saveAction); |
| 614 | config->addAction(saveAsAction); |
Boris Barbulovski | 76bede8 | 2015-09-22 11:36:07 -0700 | [diff] [blame] | 615 | config->addSeparator(); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 616 | config->addAction(quitAction); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | |
Shlomi Fish | 66e7c72 | 2007-02-14 00:32:58 -0800 | [diff] [blame] | 618 | // create edit menu |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 619 | QMenu* editMenu = menu->addMenu(_("&Edit")); |
| 620 | editMenu->addAction(searchAction); |
Shlomi Fish | 66e7c72 | 2007-02-14 00:32:58 -0800 | [diff] [blame] | 621 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | // create options menu |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 623 | QMenu* optionMenu = menu->addMenu(_("&Option")); |
| 624 | optionMenu->addAction(showNameAction); |
| 625 | optionMenu->addAction(showRangeAction); |
| 626 | optionMenu->addAction(showDataAction); |
Boris Barbulovski | 76bede8 | 2015-09-22 11:36:07 -0700 | [diff] [blame] | 627 | optionMenu->addSeparator(); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 628 | optionMenu->addActions(optGroup->actions()); |
Boris Barbulovski | 76bede8 | 2015-09-22 11:36:07 -0700 | [diff] [blame] | 629 | optionMenu->addSeparator(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | |
| 631 | // create help menu |
Boris Barbulovski | 76bede8 | 2015-09-22 11:36:07 -0700 | [diff] [blame] | 632 | menu->addSeparator(); |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 633 | QMenu* helpMenu = menu->addMenu(_("&Help")); |
| 634 | helpMenu->addAction(showIntroAction); |
| 635 | helpMenu->addAction(showAboutAction); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 637 | connect(configList, SIGNAL(menuChanged(struct menu *)), |
| 638 | helpText, SLOT(setInfo(struct menu *))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | connect(configList, SIGNAL(menuSelected(struct menu *)), |
| 640 | SLOT(changeMenu(struct menu *))); |
| 641 | connect(configList, SIGNAL(parentSelected()), |
| 642 | SLOT(goBack())); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 643 | connect(menuList, SIGNAL(menuChanged(struct menu *)), |
| 644 | helpText, SLOT(setInfo(struct menu *))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | connect(menuList, SIGNAL(menuSelected(struct menu *)), |
| 646 | SLOT(changeMenu(struct menu *))); |
| 647 | |
Roman Zippel | b65a47e | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 648 | connect(configList, SIGNAL(gotFocus(struct menu *)), |
| 649 | helpText, SLOT(setInfo(struct menu *))); |
| 650 | connect(menuList, SIGNAL(gotFocus(struct menu *)), |
| 651 | helpText, SLOT(setInfo(struct menu *))); |
| 652 | connect(menuList, SIGNAL(gotFocus(struct menu *)), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | SLOT(listFocusChanged(void))); |
Roman Zippel | b65a47e | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 654 | connect(helpText, SIGNAL(menuSelected(struct menu *)), |
| 655 | SLOT(setMenuLink(struct menu *))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 657 | QString listMode = configSettings->value("/listMode", "symbol").toString(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | if (listMode == "single") |
| 659 | showSingleView(); |
| 660 | else if (listMode == "full") |
| 661 | showFullView(); |
| 662 | else /*if (listMode == "split")*/ |
| 663 | showSplitView(); |
| 664 | |
| 665 | // UI setup done, restore splitter positions |
Boris Barbulovski | 041fbdc | 2015-09-22 11:36:05 -0700 | [diff] [blame] | 666 | QList<int> sizes = configSettings->readSizes("/split1", &ok); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 | if (ok) |
| 668 | split1->setSizes(sizes); |
| 669 | |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 670 | sizes = configSettings->readSizes("/split2", &ok); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | if (ok) |
| 672 | split2->setSizes(sizes); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | } |
| 674 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | void ConfigMainWindow::loadConfig(void) |
| 676 | { |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 677 | QString s = QFileDialog::getOpenFileName(this, "", conf_get_configname()); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | if (s.isNull()) |
| 679 | return; |
Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 680 | if (conf_read(QFile::encodeName(s))) |
EGRY Gabor | c21a2d9 | 2008-01-11 23:52:07 +0100 | [diff] [blame] | 681 | QMessageBox::information(this, "qconf", _("Unable to load configuration!")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | ConfigView::updateListAll(); |
| 683 | } |
| 684 | |
Michal Marek | bac6aa8 | 2011-05-25 15:10:25 +0200 | [diff] [blame] | 685 | bool ConfigMainWindow::saveConfig(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | { |
Michal Marek | bac6aa8 | 2011-05-25 15:10:25 +0200 | [diff] [blame] | 687 | if (conf_write(NULL)) { |
EGRY Gabor | c21a2d9 | 2008-01-11 23:52:07 +0100 | [diff] [blame] | 688 | QMessageBox::information(this, "qconf", _("Unable to save configuration!")); |
Michal Marek | bac6aa8 | 2011-05-25 15:10:25 +0200 | [diff] [blame] | 689 | return false; |
| 690 | } |
| 691 | return true; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 692 | } |
| 693 | |
| 694 | void ConfigMainWindow::saveConfigAs(void) |
| 695 | { |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 696 | QString s = QFileDialog::getSaveFileName(this, "", conf_get_configname()); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | if (s.isNull()) |
| 698 | return; |
Arnaud Lacombe | d49e468 | 2011-05-24 14:16:18 -0400 | [diff] [blame] | 699 | saveConfig(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | } |
| 701 | |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 702 | void ConfigMainWindow::searchConfig(void) |
| 703 | { |
| 704 | if (!searchWindow) |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 705 | searchWindow = new ConfigSearchWindow(this, "search"); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 706 | searchWindow->show(); |
| 707 | } |
| 708 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | void ConfigMainWindow::changeMenu(struct menu *menu) |
| 710 | { |
Boris Barbulovski | 7653866 | 2015-09-22 11:36:14 -0700 | [diff] [blame] | 711 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | } |
| 713 | |
Roman Zippel | b65a47e | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 714 | void ConfigMainWindow::setMenuLink(struct menu *menu) |
| 715 | { |
Roman Zippel | b65a47e | 2006-06-08 22:12:47 -0700 | [diff] [blame] | 716 | } |
| 717 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 718 | void ConfigMainWindow::listFocusChanged(void) |
| 719 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 720 | } |
| 721 | |
| 722 | void ConfigMainWindow::goBack(void) |
| 723 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 724 | } |
| 725 | |
| 726 | void ConfigMainWindow::showSingleView(void) |
| 727 | { |
Boris Barbulovski | 780505e | 2015-09-22 11:36:13 -0700 | [diff] [blame] | 728 | singleViewAction->setEnabled(false); |
| 729 | singleViewAction->setChecked(true); |
| 730 | splitViewAction->setEnabled(true); |
| 731 | splitViewAction->setChecked(false); |
| 732 | fullViewAction->setEnabled(true); |
| 733 | fullViewAction->setChecked(false); |
| 734 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 735 | menuView->hide(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 736 | configList->setFocus(); |
| 737 | } |
| 738 | |
| 739 | void ConfigMainWindow::showSplitView(void) |
| 740 | { |
Boris Barbulovski | 780505e | 2015-09-22 11:36:13 -0700 | [diff] [blame] | 741 | singleViewAction->setEnabled(true); |
| 742 | singleViewAction->setChecked(false); |
| 743 | splitViewAction->setEnabled(false); |
| 744 | splitViewAction->setChecked(true); |
| 745 | fullViewAction->setEnabled(true); |
| 746 | fullViewAction->setChecked(false); |
| 747 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 748 | menuView->show(); |
| 749 | menuList->setFocus(); |
| 750 | } |
| 751 | |
| 752 | void ConfigMainWindow::showFullView(void) |
| 753 | { |
Boris Barbulovski | 780505e | 2015-09-22 11:36:13 -0700 | [diff] [blame] | 754 | singleViewAction->setEnabled(true); |
| 755 | singleViewAction->setChecked(false); |
| 756 | splitViewAction->setEnabled(true); |
| 757 | splitViewAction->setChecked(false); |
| 758 | fullViewAction->setEnabled(false); |
| 759 | fullViewAction->setChecked(true); |
| 760 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | menuView->hide(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 762 | configList->setFocus(); |
| 763 | } |
| 764 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 765 | /* |
| 766 | * ask for saving configuration before quitting |
| 767 | * TODO ask only when something changed |
| 768 | */ |
| 769 | void ConfigMainWindow::closeEvent(QCloseEvent* e) |
| 770 | { |
Karsten Wiese | b321429 | 2006-12-13 00:34:06 -0800 | [diff] [blame] | 771 | if (!conf_get_changed()) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 772 | e->accept(); |
| 773 | return; |
| 774 | } |
EGRY Gabor | c21a2d9 | 2008-01-11 23:52:07 +0100 | [diff] [blame] | 775 | QMessageBox mb("qconf", _("Save configuration?"), QMessageBox::Warning, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 776 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape); |
EGRY Gabor | c21a2d9 | 2008-01-11 23:52:07 +0100 | [diff] [blame] | 777 | mb.setButtonText(QMessageBox::Yes, _("&Save Changes")); |
| 778 | mb.setButtonText(QMessageBox::No, _("&Discard Changes")); |
| 779 | mb.setButtonText(QMessageBox::Cancel, _("Cancel Exit")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 780 | switch (mb.exec()) { |
| 781 | case QMessageBox::Yes: |
Michal Marek | bac6aa8 | 2011-05-25 15:10:25 +0200 | [diff] [blame] | 782 | if (saveConfig()) |
| 783 | e->accept(); |
| 784 | else |
| 785 | e->ignore(); |
| 786 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 787 | case QMessageBox::No: |
| 788 | e->accept(); |
| 789 | break; |
| 790 | case QMessageBox::Cancel: |
| 791 | e->ignore(); |
| 792 | break; |
| 793 | } |
| 794 | } |
| 795 | |
| 796 | void ConfigMainWindow::showIntro(void) |
| 797 | { |
Arnaud Lacombe | 652cf98 | 2010-08-14 23:51:40 -0400 | [diff] [blame] | 798 | static const QString str = _("Welcome to the qconf graphical configuration tool.\n\n" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 799 | "For each option, a blank box indicates the feature is disabled, a check\n" |
| 800 | "indicates it is enabled, and a dot indicates that it is to be compiled\n" |
| 801 | "as a module. Clicking on the box will cycle through the three states.\n\n" |
| 802 | "If you do not see an option (e.g., a device driver) that you believe\n" |
| 803 | "should be present, try turning on Show All Options under the Options menu.\n" |
| 804 | "Although there is no cross reference yet to help you figure out what other\n" |
| 805 | "options must be enabled to support the option you are interested in, you can\n" |
| 806 | "still view the help of a grayed-out option.\n\n" |
| 807 | "Toggling Show Debug Info under the Options menu will show the dependencies,\n" |
EGRY Gabor | c21a2d9 | 2008-01-11 23:52:07 +0100 | [diff] [blame] | 808 | "which you can then match by examining other options.\n\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 809 | |
| 810 | QMessageBox::information(this, "qconf", str); |
| 811 | } |
| 812 | |
| 813 | void ConfigMainWindow::showAbout(void) |
| 814 | { |
EGRY Gabor | c21a2d9 | 2008-01-11 23:52:07 +0100 | [diff] [blame] | 815 | static const QString str = _("qconf is Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>.\n\n" |
| 816 | "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 817 | |
| 818 | QMessageBox::information(this, "qconf", str); |
| 819 | } |
| 820 | |
| 821 | void ConfigMainWindow::saveSettings(void) |
| 822 | { |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 823 | configSettings->setValue("/window x", pos().x()); |
| 824 | configSettings->setValue("/window y", pos().y()); |
| 825 | configSettings->setValue("/window width", size().width()); |
| 826 | configSettings->setValue("/window height", size().height()); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 827 | |
| 828 | QString entry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 829 | |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 830 | configSettings->setValue("/listMode", entry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 831 | |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 832 | configSettings->writeSizes("/split1", split1->sizes()); |
| 833 | configSettings->writeSizes("/split2", split2->sizes()); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 834 | } |
| 835 | |
Karsten Wiese | 3b354c5 | 2006-12-13 00:34:08 -0800 | [diff] [blame] | 836 | void ConfigMainWindow::conf_changed(void) |
| 837 | { |
| 838 | if (saveAction) |
| 839 | saveAction->setEnabled(conf_get_changed()); |
| 840 | } |
| 841 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 842 | void fixup_rootmenu(struct menu *menu) |
| 843 | { |
| 844 | struct menu *child; |
| 845 | static int menu_cnt = 0; |
| 846 | |
| 847 | menu->flags |= MENU_ROOT; |
| 848 | for (child = menu->list; child; child = child->next) { |
| 849 | if (child->prompt && child->prompt->type == P_MENU) { |
| 850 | menu_cnt++; |
| 851 | fixup_rootmenu(child); |
| 852 | menu_cnt--; |
| 853 | } else if (!menu_cnt) |
| 854 | fixup_rootmenu(child); |
| 855 | } |
| 856 | } |
| 857 | |
| 858 | static const char *progname; |
| 859 | |
| 860 | static void usage(void) |
| 861 | { |
Boris Barbulovski | 68ccb7e | 2015-09-22 11:36:15 -0700 | [diff] [blame^] | 862 | printf(_("%s [-s] <config>\n").toLatin1().constData(), progname); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 863 | exit(0); |
| 864 | } |
| 865 | |
| 866 | int main(int ac, char** av) |
| 867 | { |
| 868 | ConfigMainWindow* v; |
| 869 | const char *name; |
| 870 | |
Arnaldo Carvalho de Melo | 3b9fa09 | 2005-05-05 15:09:46 -0700 | [diff] [blame] | 871 | bindtextdomain(PACKAGE, LOCALEDIR); |
| 872 | textdomain(PACKAGE); |
| 873 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 874 | progname = av[0]; |
| 875 | configApp = new QApplication(ac, av); |
| 876 | if (ac > 1 && av[1][0] == '-') { |
| 877 | switch (av[1][1]) { |
Michal Marek | 0a1f00a | 2015-04-08 13:30:42 +0200 | [diff] [blame] | 878 | case 's': |
| 879 | conf_set_message_callback(NULL); |
| 880 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 881 | case 'h': |
| 882 | case '?': |
| 883 | usage(); |
| 884 | } |
| 885 | name = av[2]; |
| 886 | } else |
| 887 | name = av[1]; |
| 888 | if (!name) |
| 889 | usage(); |
| 890 | |
| 891 | conf_parse(name); |
| 892 | fixup_rootmenu(&rootmenu); |
| 893 | conf_read(NULL); |
| 894 | //zconfdump(stdout); |
| 895 | |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 896 | configSettings = new ConfigSettings(); |
| 897 | configSettings->beginGroup("/kconfig/qconf"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 898 | v = new ConfigMainWindow(); |
| 899 | |
| 900 | //zconfdump(stdout); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 901 | configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit())); |
| 902 | configApp->connect(configApp, SIGNAL(aboutToQuit()), v, SLOT(saveSettings())); |
Roman Zippel | 43bf612 | 2006-06-08 22:12:45 -0700 | [diff] [blame] | 903 | v->show(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 904 | configApp->exec(); |
| 905 | |
Roman Zippel | 7fc925f | 2006-06-08 22:12:46 -0700 | [diff] [blame] | 906 | configSettings->endGroup(); |
| 907 | delete configSettings; |
| 908 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 909 | return 0; |
| 910 | } |