mirror of
https://abf.rosa.ru/djam/kcm-grub2.git
synced 2025-04-18 14:54:15 +00:00
LOG - fixed setting of default entry
This commit is contained in:
parent
9be2cc8c46
commit
9304b9f69b
2 changed files with 229 additions and 0 deletions
228
kcm-grub2-fixed-set-default.patch
Normal file
228
kcm-grub2-fixed-set-default.patch
Normal file
|
@ -0,0 +1,228 @@
|
|||
diff -Naur kcm-grub2-0.5.8/src/kcm_grub2.cpp kcm-grub2-new/src/kcm_grub2.cpp
|
||||
--- kcm-grub2-0.5.8/src/kcm_grub2.cpp 2013-03-05 16:35:06.055551307 +0400
|
||||
+++ kcm-grub2-new/src/kcm_grub2.cpp 2013-03-06 14:35:00.070840284 +0400
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <QDesktopWidget>
|
||||
#include <QtGlobal>
|
||||
#include <QtAlgorithms>
|
||||
+#include <QStandardItemModel>
|
||||
|
||||
//KDE
|
||||
#include <KAboutData>
|
||||
@@ -108,12 +109,18 @@
|
||||
}
|
||||
|
||||
bool ok;
|
||||
+ QString prev_id = "";
|
||||
ui.kcombobox_default->clear();
|
||||
if (m_entries.size() > 0) {
|
||||
- Q_FOREACH(const QString &entry, m_entries) {
|
||||
- ui.kcombobox_default->addItem(unquoteWord(entry), entry);
|
||||
+ Q_FOREACH(const QString &entry_id, m_entries) {
|
||||
+ ui.kcombobox_default->addItem(unquoteWord(m_names.value(entry_id)), entry_id);
|
||||
+ if ((prev_id.compare("") != 0) && (entry_id.startsWith(prev_id))) {
|
||||
+ int sub_id = ui.kcombobox_default->findData(prev_id);
|
||||
+ qobject_cast<QStandardItemModel *>(ui.kcombobox_default->model())->item(sub_id)->setEnabled(false);
|
||||
+ }
|
||||
+ prev_id = entry_id;
|
||||
}
|
||||
- int entryIndex = ui.kcombobox_default->findText(m_settings.value("GRUB_DEFAULT"));
|
||||
+ int entryIndex = ui.kcombobox_default->findData(m_settings.value("GRUB_DEFAULT"));
|
||||
if (entryIndex != -1) {
|
||||
ui.kcombobox_default->setCurrentIndex(entryIndex);
|
||||
} else {
|
||||
@@ -442,7 +449,10 @@
|
||||
saveAction.addArgument("configFileName", configPath);
|
||||
saveAction.addArgument("configFileContents", configFileContents);
|
||||
saveAction.addArgument("menuFileName", menuPath);
|
||||
- saveAction.addArgument("defaultEntry", m_entries.size() > 0 ? ui.kcombobox_default->currentText() : m_settings.value("GRUB_DEFAULT"));
|
||||
+ saveAction.addArgument("defaultEntry",
|
||||
+ m_entries.size() > 0
|
||||
+ ? ui.kcombobox_default->itemData(ui.kcombobox_default->currentIndex())
|
||||
+ : m_settings.value("GRUB_DEFAULT"));
|
||||
if (m_dirtyBits.testBit(memtestDirty)) {
|
||||
saveAction.addArgument("memtestFileName", memtestPath);
|
||||
saveAction.addArgument("memtest", ui.checkBox_memtest->isChecked());
|
||||
@@ -1258,10 +1268,64 @@
|
||||
return QString();
|
||||
}
|
||||
|
||||
+QString KCMGRUB2::parseNameOrId(QTextStream &stream)
|
||||
+{
|
||||
+ QChar ch;
|
||||
+ QString entry;
|
||||
+ entry.clear();
|
||||
+
|
||||
+ stream.skipWhiteSpace();
|
||||
+ if (stream.atEnd()) {
|
||||
+ return "";
|
||||
+ }
|
||||
+ stream >> ch;
|
||||
+ entry += ch;
|
||||
+ if (ch == '\'') {
|
||||
+ do {
|
||||
+ if (stream.atEnd()) {
|
||||
+ return "";
|
||||
+ }
|
||||
+ stream >> ch;
|
||||
+ entry += ch;
|
||||
+ } while (ch != '\'');
|
||||
+ } else if (ch == '"') {
|
||||
+ while (true) {
|
||||
+ if (stream.atEnd()) {
|
||||
+ return "";
|
||||
+ }
|
||||
+ stream >> ch;
|
||||
+ entry += ch;
|
||||
+ if (ch == '\\') {
|
||||
+ stream >> ch;
|
||||
+ entry += ch;
|
||||
+ } else if (ch == '"') {
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ while (true) {
|
||||
+ if (stream.atEnd()) {
|
||||
+ return "";
|
||||
+ }
|
||||
+ stream >> ch;
|
||||
+ if (ch.isSpace()) {
|
||||
+ break;
|
||||
+ }
|
||||
+ entry += ch;
|
||||
+ if (ch == '\\') {
|
||||
+ stream >> ch;
|
||||
+ entry += ch;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ return entry;
|
||||
+}
|
||||
+
|
||||
void KCMGRUB2::parseEntries(const QString &config)
|
||||
{
|
||||
QChar ch;
|
||||
- QString word, entry, entriesConfig = config;
|
||||
+ QString word, entriesConfig = config, group_id = "", entry_id, entry_name;
|
||||
+ QStringList tmp_return;
|
||||
QTextStream stream(&entriesConfig, QIODevice::ReadOnly | QIODevice::Text);
|
||||
while (!stream.atEnd()) {
|
||||
stream >> ch;
|
||||
@@ -1273,61 +1337,51 @@
|
||||
return;
|
||||
}
|
||||
stream >> word;
|
||||
- if (word.compare("menuentry") == 0) {
|
||||
- stream.skipWhiteSpace();
|
||||
+ if ((word.compare("menuentry") == 0) || (word.compare("submenu") == 0)) {
|
||||
+ entry_name.clear();
|
||||
+ entry_name = parseNameOrId(stream);
|
||||
+
|
||||
+ while (!stream.atEnd() and (word.compare("$menuentry_id_option") != 0)){
|
||||
+ stream.skipWhiteSpace();
|
||||
+ if (stream.atEnd()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ stream >> word;
|
||||
+ }
|
||||
if (stream.atEnd()) {
|
||||
return;
|
||||
}
|
||||
- entry.clear();
|
||||
- stream >> ch;
|
||||
- entry += ch;
|
||||
- if (ch == '\'') {
|
||||
- do {
|
||||
- if (stream.atEnd()) {
|
||||
- return;
|
||||
- }
|
||||
- stream >> ch;
|
||||
- entry += ch;
|
||||
- } while (ch != '\'');
|
||||
- } else if (ch == '"') {
|
||||
- while (true) {
|
||||
- if (stream.atEnd()) {
|
||||
- return;
|
||||
- }
|
||||
- stream >> ch;
|
||||
- entry += ch;
|
||||
- if (ch == '\\') {
|
||||
- stream >> ch;
|
||||
- entry += ch;
|
||||
- } else if (ch == '"') {
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
- } else {
|
||||
- while (true) {
|
||||
- if (stream.atEnd()) {
|
||||
- return;
|
||||
- }
|
||||
- stream >> ch;
|
||||
- if (ch.isSpace()) {
|
||||
- break;
|
||||
- }
|
||||
- entry += ch;
|
||||
- if (ch == '\\') {
|
||||
- stream >> ch;
|
||||
- entry += ch;
|
||||
- }
|
||||
- }
|
||||
+ entry_id.clear();
|
||||
+ entry_id = parseNameOrId(stream);
|
||||
+ entry_id = unquoteWord(entry_id);
|
||||
+ if (!group_id.isEmpty()) {
|
||||
+ entry_id = group_id + '>' + entry_id;
|
||||
+ }
|
||||
+
|
||||
+ if (entry_name.isEmpty() || entry_id.isEmpty()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ m_names[entry_id] = entry_name;
|
||||
+ m_entries.append(entry_id);
|
||||
+ tmp_return.append(group_id);
|
||||
+ group_id = entry_id;
|
||||
+ } else if ((word.compare("}") == 0)) { //return to save sub-level
|
||||
+ if (group_id.isEmpty()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (tmp_return.isEmpty()) {
|
||||
+ return;
|
||||
}
|
||||
- m_entries.append(entry);
|
||||
- } else if (word.compare("linux") == 0 && !entry.isEmpty()) {
|
||||
+ group_id.clear();
|
||||
+ group_id = tmp_return.takeLast();
|
||||
+ } else if (word.compare("linux") == 0 && !group_id.isEmpty()) {
|
||||
stream.skipWhiteSpace();
|
||||
if (stream.atEnd()) {
|
||||
return;
|
||||
}
|
||||
stream >> word;
|
||||
- m_kernels[unquoteWord(entry)] = word;
|
||||
- entry.clear();
|
||||
+ m_kernels[group_id] = word;
|
||||
}
|
||||
}
|
||||
}
|
||||
diff -Naur kcm-grub2-0.5.8/src/kcm_grub2.h kcm-grub2-new/src/kcm_grub2.h
|
||||
--- kcm-grub2-0.5.8/src/kcm_grub2.h 2013-03-05 16:35:06.056551450 +0400
|
||||
+++ kcm-grub2-new/src/kcm_grub2.h 2013-03-05 17:54:02.750014381 +0400
|
||||
@@ -94,6 +94,7 @@
|
||||
QString quoteWord(const QString &word);
|
||||
QString unquoteWord(const QString &word);
|
||||
|
||||
+ QString parseNameOrId(QTextStream &stream);
|
||||
void parseEntries(const QString &config);
|
||||
void parseSettings(const QString &config);
|
||||
void parseEnv(const QString &config);
|
||||
@@ -139,6 +140,7 @@
|
||||
QString resultLanguage;
|
||||
|
||||
QStringList m_entries;
|
||||
+ QHash<QString, QString> m_names;
|
||||
QHash<QString, QString> m_kernels;
|
||||
QHash<QString, QString> m_settings;
|
||||
QHash<QString, QString> m_env;
|
|
@ -25,6 +25,7 @@ Source3: kcm-grub2-languages
|
|||
|
||||
Patch0: kcm-grub2-read-mode-from-file.patch
|
||||
Patch1: kcm-grub2-language.patch
|
||||
Patch2: kcm-grub2-fixed-set-default.patch
|
||||
#%kde4_runtime_requires
|
||||
|
||||
%description
|
||||
|
|
Loading…
Add table
Reference in a new issue