mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-22 12:09:41 +02:00
Create sections for built-in action links if necessary
Previously, the built-in actions would only be added if their respective sections already existed. This also works around the fact that Menu::paint() crashes if there are no sections present.
This commit is contained in:
parent
08ecd7d8d9
commit
fad68bfb6e
@ -377,41 +377,38 @@ void GMenu2X::initFont() {
|
|||||||
void GMenu2X::initMenu() {
|
void GMenu2X::initMenu() {
|
||||||
//Menu structure handler
|
//Menu structure handler
|
||||||
menu.reset(new Menu(*this, ts));
|
menu.reset(new Menu(*this, ts));
|
||||||
for (uint i=0; i<menu->getSections().size(); i++) {
|
|
||||||
//Add virtual links in the applications section
|
// Add action links in the applications section.
|
||||||
if (menu->getSections()[i]=="applications") {
|
auto appIdx = menu->sectionNamed("applications");
|
||||||
menu->addActionLink(i, "Explorer",
|
menu->addActionLink(appIdx, "Explorer",
|
||||||
bind(&GMenu2X::explorer, this),
|
bind(&GMenu2X::explorer, this),
|
||||||
tr["Launch an application"],
|
tr["Launch an application"],
|
||||||
"skin:icons/explorer.png");
|
"skin:icons/explorer.png");
|
||||||
}
|
|
||||||
|
|
||||||
//Add virtual links in the setting section
|
// Add action links in the settings section.
|
||||||
else if (menu->getSections()[i]=="settings") {
|
auto settingIdx = menu->sectionNamed("settings");
|
||||||
menu->addActionLink(i, "GMenu2X",
|
menu->addActionLink(settingIdx, "GMenu2X",
|
||||||
bind(&GMenu2X::showSettings, this),
|
bind(&GMenu2X::showSettings, this),
|
||||||
tr["Configure GMenu2X's options"],
|
tr["Configure GMenu2X's options"],
|
||||||
"skin:icons/configure.png");
|
"skin:icons/configure.png");
|
||||||
menu->addActionLink(i, tr["Skin"],
|
menu->addActionLink(settingIdx, tr["Skin"],
|
||||||
bind(&GMenu2X::skinMenu, this),
|
bind(&GMenu2X::skinMenu, this),
|
||||||
tr["Configure skin"],
|
tr["Configure skin"],
|
||||||
"skin:icons/skin.png");
|
"skin:icons/skin.png");
|
||||||
menu->addActionLink(i, tr["Wallpaper"],
|
menu->addActionLink(settingIdx, tr["Wallpaper"],
|
||||||
bind(&GMenu2X::changeWallpaper, this),
|
bind(&GMenu2X::changeWallpaper, this),
|
||||||
tr["Change GMenu2X wallpaper"],
|
tr["Change GMenu2X wallpaper"],
|
||||||
"skin:icons/wallpaper.png");
|
"skin:icons/wallpaper.png");
|
||||||
if (fileExists(LOG_FILE)) {
|
if (fileExists(LOG_FILE)) {
|
||||||
menu->addActionLink(i, tr["Log Viewer"],
|
menu->addActionLink(settingIdx, tr["Log Viewer"],
|
||||||
bind(&GMenu2X::viewLog, this),
|
bind(&GMenu2X::viewLog, this),
|
||||||
tr["Displays last launched program's output"],
|
tr["Displays last launched program's output"],
|
||||||
"skin:icons/ebook.png");
|
"skin:icons/ebook.png");
|
||||||
}
|
}
|
||||||
menu->addActionLink(i, tr["About"],
|
menu->addActionLink(settingIdx, tr["About"],
|
||||||
bind(&GMenu2X::about, this),
|
bind(&GMenu2X::about, this),
|
||||||
tr["Info about GMenu2X"],
|
tr["Info about GMenu2X"],
|
||||||
"skin:icons/about.png");
|
"skin:icons/about.png");
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
menu->skinUpdated();
|
menu->skinUpdated();
|
||||||
menu->orderLinks();
|
menu->orderLinks();
|
||||||
|
Loading…
Reference in New Issue
Block a user