diff --git a/src/gmenu2x.cpp b/src/gmenu2x.cpp index 51222fa..0446cdd 100644 --- a/src/gmenu2x.cpp +++ b/src/gmenu2x.cpp @@ -578,7 +578,7 @@ void GMenu2X::writeTmp(int selelem, const string &selectordir) { inf << "link=" << menu->selLinkIndex() << endl; if (selelem>-1) inf << "selectorelem=" << selelem << endl; - if (selectordir!="") + if (!selectordir.empty()) inf << "selectordir=" << selectordir << endl; inf.close(); sync(); diff --git a/src/inputdialog.cpp b/src/inputdialog.cpp index 6d54ecc..595569a 100644 --- a/src/inputdialog.cpp +++ b/src/inputdialog.cpp @@ -47,7 +47,7 @@ InputDialog::InputDialog(GMenu2X *gmenu2x, InputManager &inputMgr_, , inputMgr(inputMgr_) , ts(ts_) { - if (title == "") { + if (title.empty()) { this->title = text; this->text = ""; } else { @@ -55,7 +55,7 @@ InputDialog::InputDialog(GMenu2X *gmenu2x, InputManager &inputMgr_, this->text = text; } this->icon = ""; - if (icon != "" && gmenu2x->sc[icon] != NULL) { + if (!icon.empty() && gmenu2x->sc[icon] != NULL) { this->icon = icon; } diff --git a/src/linkapp.cpp b/src/linkapp.cpp index 76eccab..f1676cc 100644 --- a/src/linkapp.cpp +++ b/src/linkapp.cpp @@ -202,7 +202,7 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_, ifstream infile (file.c_str(), ios_base::in); while (getline(infile, line, '\n')) { line = trim(line); - if (line=="") continue; + if (line.empty()) continue; if (line[0]=='#') continue; string::size_type position = line.find("="); @@ -320,22 +320,22 @@ bool LinkApp::save() { ofstream f(file.c_str()); if (f.is_open()) { if (!isOpk()) { - if (title!="" ) f << "title=" << title << endl; - if (description!="" ) f << "description=" << description << endl; - if (icon!="" ) f << "icon=" << icon << endl; - if (exec!="" ) f << "exec=" << exec << endl; - if (params!="" ) f << "params=" << params << endl; - if (manual!="" ) f << "manual=" << manual << endl; + if (!title.empty() ) f << "title=" << title << endl; + if (!description.empty() ) f << "description=" << description << endl; + if (!icon.empty() ) f << "icon=" << icon << endl; + if (!exec.empty() ) f << "exec=" << exec << endl; + if (!params.empty() ) f << "params=" << params << endl; + if (!manual.empty() ) f << "manual=" << manual << endl; #if defined(PLATFORM_A320) || defined(PLATFORM_GCW0) - if (consoleApp ) f << "consoleapp=true" << endl; + if (consoleApp ) f << "consoleapp=true" << endl; #endif - if (selectorfilter!="*" ) f << "selectorfilter=" << selectorfilter << endl; + if (selectorfilter != "*") f << "selectorfilter=" << selectorfilter << endl; } - if (iclock!=0 ) f << "clock=" << iclock << endl; - if (selectordir!="" ) f << "selectordir=" << selectordir << endl; - if (!selectorbrowser ) f << "selectorbrowser=false" << endl; - if (selectorscreens!="") f << "selectorscreens=" << selectorscreens << endl; - if (aliasfile!="" ) f << "selectoraliases=" << aliasfile << endl; + if (iclock != 0 ) f << "clock=" << iclock << endl; + if (!selectordir.empty() ) f << "selectordir=" << selectordir << endl; + if (!selectorbrowser ) f << "selectorbrowser=false" << endl; + if (!selectorscreens.empty() ) f << "selectorscreens=" << selectorscreens << endl; + if (!aliasfile.empty() ) f << "selectoraliases=" << aliasfile << endl; f.close(); sync(); return true; @@ -359,7 +359,7 @@ void LinkApp::drawRun() { gmenu2x->s->rectangle(gmenu2x->halfX-halfBoxW, gmenu2x->halfY-21, boxW, 42, gmenu2x->skinConfColors[COLOR_MESSAGE_BOX_BORDER]); int x = gmenu2x->halfX+10-halfBoxW; - /*if (getIcon()!="") + /*if (!getIcon().empty()) gmenu2x->sc[getIcon()]->blit(gmenu2x->s,x,104); else gmenu2x->sc["icons/generic.png"]->blit(gmenu2x->s,x,104);*/ @@ -369,7 +369,7 @@ void LinkApp::drawRun() { } void LinkApp::start() { - if (selectordir!="") + if (!selectordir.empty()) selector(); else launch(); @@ -550,7 +550,7 @@ void LinkApp::selector(int startSelection, const string &selectorDir) { void LinkApp::launch(const string &selectedFile, const string &selectedDir) { drawRun(); - if (selectedDir == "") + if (selectedDir.empty()) selectordir = getSelectorDir(); else selectordir = selectedDir; @@ -591,10 +591,10 @@ void LinkApp::launch(const string &selectedFile, const string &selectedDir) { } } - if (selectedFile != "") { + if (!selectedFile.empty()) { string path = cmdclean(selectordir + selectedFile); - if (params == "") { + if (params.empty()) { params = path; } else { unsigned int i; @@ -623,7 +623,7 @@ void LinkApp::launch(const string &selectedFile, const string &selectedDir) { chmod( command.c_str(), newstat.st_mode ); } // else, well.. we are no worse off :) - if (params!="") command += " " + params; + if (!params.empty()) command += " " + params; #if defined(PLATFORM_A320) || defined(PLATFORM_GCW0) if (gmenu2x->confInt["outputLogs"] && !consoleApp) command += " &> " + cmdclean(gmenu2x->getHome()) + "/log.txt"; @@ -638,7 +638,7 @@ void LinkApp::launch(const string &selectedFile, const string &selectedDir) { gmenu2x->saveSelection(); - if (selectedFile == "") { + if (selectedFile.empty()) { gmenu2x->writeTmp(); } #ifdef ENABLE_CPUFREQ @@ -729,7 +729,9 @@ const string &LinkApp::getSelectorDir() { void LinkApp::setSelectorDir(const string &selectordir) { this->selectordir = selectordir; - if (this->selectordir!="" && this->selectordir[this->selectordir.length()-1]!='/') this->selectordir += "/"; + if (!selectordir.empty() && selectordir[selectordir.length() - 1] != '/') { + this->selectordir += "/"; + } edited = true; } diff --git a/src/menu.cpp b/src/menu.cpp index 8feadc9..3711bdc 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -411,9 +411,9 @@ bool Menu::addActionLink(uint section, const string &title, function_t action, c } bool Menu::addLink(string path, string file, string section) { - if (section=="") + if (section.empty()) { section = selSection(); - else if (find(sections.begin(),sections.end(),section)==sections.end()) { + } else if (find(sections.begin(),sections.end(),section)==sections.end()) { //section directory doesn't exists if (!addSection(section)) return false; diff --git a/src/messagebox.cpp b/src/messagebox.cpp index 3dd6314..c821603 100644 --- a/src/messagebox.cpp +++ b/src/messagebox.cpp @@ -82,7 +82,7 @@ int MessageBox::exec() { int btnX = gmenu2x->halfX+box.w/2-6; for (uint i = 0; i < BUTTON_TYPE_SIZE; i++) { - if (buttons[i] != "") { + if (!buttons[i].empty()) { buttonPositions[i].y = box.y+box.h-4; buttonPositions[i].w = btnX; @@ -101,8 +101,8 @@ int MessageBox::exec() { while (result < 0) { InputManager::ButtonEvent event; if (gmenu2x->input.pollEvent(&event) - && (event.state == InputManager::PRESSED) - && (buttons[event.button] != "")) { + && event.state == InputManager::PRESSED + && !buttons[event.button].empty()) { result = event.button; } diff --git a/src/selector.cpp b/src/selector.cpp index 3ea3295..ff03e4e 100644 --- a/src/selector.cpp +++ b/src/selector.cpp @@ -48,7 +48,7 @@ Selector::Selector(GMenu2X *gmenu2x, LinkApp *link, const string &selectorDir) : this->link = link; loadAliases(); selRow = 0; - if (selectorDir=="") + if (selectorDir.empty()) dir = link->getSelectorDir(); else dir = selectorDir; @@ -103,7 +103,8 @@ int Selector::exec(int startSelection) { gmenu2x->s->box(1, iY, 309, 14, gmenu2x->skinConfColors[COLOR_SELECTION_BG]); //Screenshot - if (selected-fl.dirCount() 200) { gmenu2x->sc[screens[selected-fl.dirCount()]]->blitRight( @@ -262,7 +263,9 @@ void Selector::prepare(FileLister *fl, vector *screens, vector * titles->resize(fl->getFiles().size()); string screendir = link->getSelectorScreens(); - if (screendir != "" && screendir[screendir.length()-1]!='/') screendir += "/"; + if (!screendir.empty() && screendir[screendir.length() - 1] != '/') { + screendir += "/"; + } string noext; string::size_type pos; @@ -272,7 +275,7 @@ void Selector::prepare(FileLister *fl, vector *screens, vector * if (pos!=string::npos && pos>0) noext = noext.substr(0, pos); titles->at(i) = getAlias(noext); - if (titles->at(i)=="") + if (titles->at(i).empty()) titles->at(i) = noext; DEBUG("Searching for screen '%s%s.png'\n", screendir.c_str(), noext.c_str()); @@ -286,7 +289,7 @@ void Selector::prepare(FileLister *fl, vector *screens, vector * void Selector::freeScreenshots(vector *screens) { for (uint i=0; isize(); i++) { - if (screens->at(i) != "") + if (!screens->at(i).empty()) gmenu2x->sc.del(screens->at(i)); } } diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 28759c9..654ded3 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -36,7 +36,7 @@ SettingsDialog::SettingsDialog( , ts(ts_) , text(text_) { - if (icon != "" && gmenu2x->sc[icon] != NULL) { + if (!icon.empty() && gmenu2x->sc[icon] != NULL) { this->icon = icon; } else { this->icon = "icons/generic.png"; diff --git a/src/textmanualdialog.cpp b/src/textmanualdialog.cpp index b662e4b..fc1d8c7 100644 --- a/src/textmanualdialog.cpp +++ b/src/textmanualdialog.cpp @@ -58,10 +58,10 @@ TextManualDialog::TextManualDialog(GMenu2X *gmenu2x, const string &title, const for (uint page=0; page 0) { //first lines - while (trim(pages[page].text[0])=="") + while (trim(pages[page].text[0]).empty()) pages[page].text.erase(pages[page].text.begin()); //last lines - while (trim(pages[page].text[pages[page].text.size()-1])=="") + while (trim(pages[page].text[pages[page].text.size()-1]).empty()) pages[page].text.erase(pages[page].text.end()); } } diff --git a/src/translator.cpp b/src/translator.cpp index fec6135..a83ccd2 100644 --- a/src/translator.cpp +++ b/src/translator.cpp @@ -54,7 +54,7 @@ void Translator::setLang(const string &lang) { if (infile.is_open()) { while (getline(infile, line, '\n')) { line = trim(line); - if (line=="") continue; + if (line.empty()) continue; if (line[0]=='#') continue; string::size_type position = line.find("=");