mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-26 23:13:13 +02:00
- buildinfo: formatting code using astyle; some manual code nicenings
Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
@@ -23,7 +23,6 @@
|
|||||||
Boston, MA 02110-1301, USA.
|
Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <global.h>
|
#include <global.h>
|
||||||
#include <neutrino.h>
|
#include <neutrino.h>
|
||||||
|
|
||||||
@@ -40,14 +39,14 @@ using namespace std;
|
|||||||
CBuildInfo::CBuildInfo(bool show) : CComponentsWindow(0, 0, CCW_PERCENT 85, CCW_PERCENT 85, LOCALE_BUILDINFO_MENU, NEUTRINO_ICON_INFO)
|
CBuildInfo::CBuildInfo(bool show) : CComponentsWindow(0, 0, CCW_PERCENT 85, CCW_PERCENT 85, LOCALE_BUILDINFO_MENU, NEUTRINO_ICON_INFO)
|
||||||
{
|
{
|
||||||
initVarBuildInfo();
|
initVarBuildInfo();
|
||||||
// setBodyBGImage(DATADIR "/neutrino/icons/start.jpg");
|
//setBodyBGImage(DATADIR "/neutrino/icons/start.jpg");
|
||||||
if (show)
|
if (show)
|
||||||
exec(NULL, "");
|
exec(NULL, "");
|
||||||
else
|
else
|
||||||
GetData();
|
GetData();
|
||||||
}
|
}
|
||||||
|
|
||||||
//init all var members
|
// init all var members
|
||||||
void CBuildInfo::initVarBuildInfo()
|
void CBuildInfo::initVarBuildInfo()
|
||||||
{
|
{
|
||||||
setCenterPos();
|
setCenterPos();
|
||||||
@@ -58,60 +57,63 @@ void CBuildInfo::initVarBuildInfo()
|
|||||||
shadow = CC_SHADOW_ON;
|
shadow = CC_SHADOW_ON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CBuildInfo::exec(CMenuTarget *parent, const string & /*actionKey*/)
|
||||||
int CBuildInfo::exec(CMenuTarget* parent, const string & /*actionKey*/)
|
|
||||||
{
|
{
|
||||||
int res = menu_return::RETURN_REPAINT;
|
int res = menu_return::RETURN_REPAINT;
|
||||||
|
|
||||||
if (parent)
|
if (parent)
|
||||||
parent->hide();
|
parent->hide();
|
||||||
|
|
||||||
//exit if no informations available
|
// exit if no informations available
|
||||||
if (!GetData()){
|
if (!GetData())
|
||||||
|
{
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
InitInfoItems();
|
InitInfoItems();
|
||||||
|
|
||||||
//paint window
|
// paint window
|
||||||
if (!is_painted)
|
if (!is_painted)
|
||||||
paint();
|
paint();
|
||||||
|
|
||||||
|
|
||||||
neutrino_msg_t msg;
|
neutrino_msg_t msg;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
neutrino_msg_data_t data;
|
neutrino_msg_data_t data;
|
||||||
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd_MS(100);
|
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd_MS(100);
|
||||||
g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );
|
g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd);
|
||||||
|
|
||||||
if(msg == CRCInput::RC_setup) {
|
if (msg == CRCInput::RC_setup)
|
||||||
|
{
|
||||||
res = menu_return::RETURN_EXIT_ALL;
|
res = menu_return::RETURN_EXIT_ALL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (CNeutrinoApp::getInstance()->listModeKey(msg)) {
|
else if (CNeutrinoApp::getInstance()->listModeKey(msg))
|
||||||
g_RCInput->postMsg (msg, 0);
|
{
|
||||||
|
g_RCInput->postMsg(msg, 0);
|
||||||
res = menu_return::RETURN_EXIT_ALL;
|
res = menu_return::RETURN_EXIT_ALL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if ((msg == CRCInput::RC_up) || (msg == CRCInput::RC_page_up)) {
|
else if ((msg == CRCInput::RC_up) || (msg == CRCInput::RC_page_up))
|
||||||
|
{
|
||||||
Scroll(false);
|
Scroll(false);
|
||||||
}
|
}
|
||||||
else if ((msg == CRCInput::RC_down) || (msg == CRCInput::RC_page_down)) {
|
else if ((msg == CRCInput::RC_down) || (msg == CRCInput::RC_page_down))
|
||||||
|
{
|
||||||
Scroll(true);
|
Scroll(true);
|
||||||
}
|
}
|
||||||
else if (msg <= CRCInput::RC_MaxRC){
|
else if (msg <= CRCInput::RC_MaxRC)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( msg > CRCInput::RC_MaxRC && msg != CRCInput::RC_timeout){
|
if (msg > CRCInput::RC_MaxRC && msg != CRCInput::RC_timeout)
|
||||||
CNeutrinoApp::getInstance()->handleMsg( msg, data );
|
{
|
||||||
|
CNeutrinoApp::getInstance()->handleMsg(msg, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//hide window
|
// hide window
|
||||||
hide();
|
hide();
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -119,9 +121,10 @@ int CBuildInfo::exec(CMenuTarget* parent, const string & /*actionKey*/)
|
|||||||
|
|
||||||
void CBuildInfo::Scroll(bool scrollDown)
|
void CBuildInfo::Scroll(bool scrollDown)
|
||||||
{
|
{
|
||||||
CTextBox* ctb = static_cast<CComponentsExtTextForm*>(ccw_body->getCCItem(3))->getTextObject()->getCTextBoxObject();
|
CTextBox *ctb = static_cast<CComponentsExtTextForm *>(ccw_body->getCCItem(3))->getTextObject()->getCTextBoxObject();
|
||||||
ctb->enableBackgroundPaint(true); //FIXME: behavior of CTextBox scroll is broken with disabled background paint
|
ctb->enableBackgroundPaint(true); // FIXME: behavior of CTextBox scroll is broken with disabled background paint
|
||||||
if (ctb) {
|
if (ctb)
|
||||||
|
{
|
||||||
if (scrollDown)
|
if (scrollDown)
|
||||||
ctb->scrollPageDown(1);
|
ctb->scrollPageDown(1);
|
||||||
else
|
else
|
||||||
@@ -129,7 +132,7 @@ void CBuildInfo::Scroll(bool scrollDown)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBuildInfo::setFontType(Font* font_text)
|
void CBuildInfo::setFontType(Font *font_text)
|
||||||
{
|
{
|
||||||
if (font_text == NULL)
|
if (font_text == NULL)
|
||||||
return;
|
return;
|
||||||
@@ -147,7 +150,7 @@ bool CBuildInfo::GetData()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USED_BUILD
|
#ifdef USED_BUILD
|
||||||
build_info_t build = {BI_TYPE_ID_USED_BUILD , LOCALE_BUILDINFO_COMPILED_ON, USED_BUILD};
|
build_info_t build = {BI_TYPE_ID_USED_BUILD, LOCALE_BUILDINFO_COMPILED_ON, USED_BUILD};
|
||||||
v_info.push_back(build);
|
v_info.push_back(build);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -160,7 +163,8 @@ bool CBuildInfo::GetData()
|
|||||||
cxxflags = trim(cxxflags);
|
cxxflags = trim(cxxflags);
|
||||||
// Remove double spaces
|
// Remove double spaces
|
||||||
size_t pos = cxxflags.find(" ");
|
size_t pos = cxxflags.find(" ");
|
||||||
while (pos != string::npos) {
|
while (pos != string::npos)
|
||||||
|
{
|
||||||
cxxflags.erase(pos, 1);
|
cxxflags.erase(pos, 1);
|
||||||
pos = cxxflags.find(" ", pos);
|
pos = cxxflags.find(" ", pos);
|
||||||
}
|
}
|
||||||
@@ -169,13 +173,14 @@ bool CBuildInfo::GetData()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
CConfigFile data ('\t');
|
CConfigFile data('\t');
|
||||||
data.loadConfig(IMAGE_VERSION_FILE);
|
data.loadConfig(IMAGE_VERSION_FILE);
|
||||||
build_info_t creator = {BI_TYPE_ID_CREATOR, LOCALE_BUILDINFO_CREATOR, data.getString("creator", "n/a")};
|
build_info_t creator = {BI_TYPE_ID_CREATOR, LOCALE_BUILDINFO_CREATOR, data.getString("creator", "n/a")};
|
||||||
v_info.push_back(creator);
|
v_info.push_back(creator);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (v_info.empty()){
|
if (v_info.empty())
|
||||||
|
{
|
||||||
DisplayInfoMessage("No Informations available. Please report!");
|
DisplayInfoMessage("No Informations available. Please report!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -185,28 +190,29 @@ bool CBuildInfo::GetData()
|
|||||||
|
|
||||||
void CBuildInfo::InitInfoItems()
|
void CBuildInfo::InitInfoItems()
|
||||||
{
|
{
|
||||||
//get and checkup required informations
|
// get and checkup required informations
|
||||||
if (!GetData())
|
if (!GetData())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//ensure a clean body
|
// ensure a clean body
|
||||||
ccw_body->clear();
|
ccw_body->clear();
|
||||||
|
|
||||||
//define size and position
|
// define size and position
|
||||||
int x_info = OFFSET_INNER_MID;
|
int x_info = OFFSET_INNER_MID;
|
||||||
int h_info = 0; //default height
|
int h_info = 0; //default height
|
||||||
int w_info = width-2*x_info;
|
int w_info = width - 2 * x_info;
|
||||||
int y_info = OFFSET_INNER_MID;
|
int y_info = OFFSET_INNER_MID;
|
||||||
|
|
||||||
//init info texts
|
// init info texts
|
||||||
for(size_t i=0; i<v_info.size(); i++){
|
for (size_t i = 0; i < v_info.size(); i++)
|
||||||
|
{
|
||||||
h_info = v_info[i].type_id != BI_TYPE_ID_USED_CXXFLAGS ? font->getHeight() * 2 + OFFSET_INNER_MID : ccw_body->getHeight() - y_info;
|
h_info = v_info[i].type_id != BI_TYPE_ID_USED_CXXFLAGS ? font->getHeight() * 2 + OFFSET_INNER_MID : ccw_body->getHeight() - y_info;
|
||||||
CComponentsExtTextForm *info = new CComponentsExtTextForm(OFFSET_INNER_MID, y_info, w_info, h_info, g_Locale->getText(v_info[i].caption), v_info[i].info_text, NULL, ccw_body);
|
CComponentsExtTextForm *info = new CComponentsExtTextForm(OFFSET_INNER_MID, y_info, w_info, h_info, g_Locale->getText(v_info[i].caption), v_info[i].info_text, NULL, ccw_body);
|
||||||
info->setLabelAndTextFont(font);
|
info->setLabelAndTextFont(font);
|
||||||
if (v_info[i].type_id == BI_TYPE_ID_USED_CXXFLAGS)
|
if (v_info[i].type_id == BI_TYPE_ID_USED_CXXFLAGS)
|
||||||
info->setTextModes(CTextBox::TOP , CTextBox::TOP | CTextBox::AUTO_WIDTH | CTextBox::SCROLL);
|
info->setTextModes(CTextBox::TOP, CTextBox::TOP | CTextBox::AUTO_WIDTH | CTextBox::SCROLL);
|
||||||
else
|
else
|
||||||
info->setTextModes(CTextBox::TOP , CTextBox::TOP | CTextBox::AUTO_LINEBREAK_NO_BREAKCHARS);
|
info->setTextModes(CTextBox::TOP, CTextBox::TOP | CTextBox::AUTO_LINEBREAK_NO_BREAKCHARS);
|
||||||
info->doPaintBg(false);
|
info->doPaintBg(false);
|
||||||
y_info += h_info;
|
y_info += h_info;
|
||||||
}
|
}
|
||||||
@@ -214,9 +220,10 @@ void CBuildInfo::InitInfoItems()
|
|||||||
|
|
||||||
// This allows to retrieve information about build infos.
|
// This allows to retrieve information about build infos.
|
||||||
// Use parameter 'type_info' to get specific information.
|
// Use parameter 'type_info' to get specific information.
|
||||||
build_info_t CBuildInfo::getInfo(const info_type_id_t& type_id)
|
build_info_t CBuildInfo::getInfo(const info_type_id_t &type_id)
|
||||||
{
|
{
|
||||||
for(size_t i=0; i<v_info.size(); i++){
|
for (size_t i = 0; i < v_info.size(); i++)
|
||||||
|
{
|
||||||
if (v_info[i].type_id == type_id)
|
if (v_info[i].type_id == type_id)
|
||||||
return v_info[i];
|
return v_info[i];
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,6 @@
|
|||||||
Boston, MA 02110-1301, USA.
|
Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __buildinfo__
|
#ifndef __buildinfo__
|
||||||
#define __buildinfo__
|
#define __buildinfo__
|
||||||
|
|
||||||
@@ -50,15 +49,15 @@ class CBuildInfo : public CMenuTarget, public CComponentsWindow
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::vector<build_info_t> v_info;
|
std::vector<build_info_t> v_info;
|
||||||
Font* font;
|
Font *font;
|
||||||
void initVarBuildInfo();
|
void initVarBuildInfo();
|
||||||
void InitInfoItems();
|
void InitInfoItems();
|
||||||
void Scroll(bool scrollDown);
|
void Scroll(bool scrollDown);
|
||||||
|
|
||||||
bool GetData();
|
bool GetData();
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//type_id's for infos
|
// type_id's for infos
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
BI_TYPE_ID_USED_COMPILER,
|
BI_TYPE_ID_USED_COMPILER,
|
||||||
@@ -74,11 +73,11 @@ class CBuildInfo : public CMenuTarget, public CComponentsWindow
|
|||||||
|
|
||||||
CBuildInfo(bool show = false);
|
CBuildInfo(bool show = false);
|
||||||
|
|
||||||
///assigns text Font type
|
// assigns text Font type
|
||||||
void setFontType(Font* font_text);
|
void setFontType(Font *font_text);
|
||||||
build_info_t getInfo(const info_type_id_t& type_id);
|
build_info_t getInfo(const info_type_id_t &type_id);
|
||||||
void hide();
|
void hide();
|
||||||
int exec(CMenuTarget* parent, const std::string & actionKey);
|
int exec(CMenuTarget *parent, const std::string &actionKey);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __buildinfo__
|
#endif // __buildinfo__
|
||||||
|
Reference in New Issue
Block a user