hintbox: try to fix logic for enable/disable timeout bar.

Timeout bar could not be switched off, is now disabled for CHint
TODO: find a better solution to vizualize timeout for CHint.
      It looks not so good on the top of the hintbox, especially
      with round corners or frameless window.
This commit is contained in:
2021-10-04 16:52:57 +02:00
parent aa81278cfb
commit c9efac0665
4 changed files with 38 additions and 28 deletions

View File

@@ -202,13 +202,12 @@ void CHintBox::init( const std::string& Text,
CHintBox::~CHintBox()
{
enable_timeout_bar = false;
disableTimeOutBar();
clearTimeOutBar();
}
void CHintBox::enableTimeOutBar(bool enable)
void CHintBox::initTimeOutBar(bool do_init)
{
if (!enable_timeout_bar || !enable)
if (!do_init)
{
if(timeout_pb_timer){
delete timeout_pb_timer; timeout_pb_timer = NULL;
@@ -220,10 +219,8 @@ void CHintBox::enableTimeOutBar(bool enable)
timeout_pb->kill();
delete timeout_pb; timeout_pb = NULL;
}
return;
}
if (enable_timeout_bar && enable)
else
{
if(timeout_pb){
timeout_pb->setValues(timeout_pb->getValue()+1, 10*timeout);
@@ -259,7 +256,7 @@ int CHintBox::exec()
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(timeout);
enableTimeOutBar(timeout > 0);
initTimeOutBar(enable_timeout_bar && timeout > 0);
while ( ! ( res & ( messages_return::cancel_info | messages_return::cancel_all ) ) )
{
@@ -304,7 +301,7 @@ int CHintBox::exec()
}
}
disableTimeOutBar();
clearTimeOutBar();
return res;
}
@@ -459,7 +456,7 @@ int ShowHint(const char * const Caption, const char * const Text, const int Widt
int res = messages_return::none;
CHintBox hintBox(Caption, Text, Width, Icon, Picon, header_buttons);
hintBox.setTimeOut(timeout);
hintBox.setTimeOut(timeout, true);
hintBox.paint();
res = hintBox.exec();
hintBox.hide();
@@ -498,7 +495,7 @@ int ShowHintS(const char * const Text, int timeout, bool show_background)
{
int res = messages_return::none;
CHint hint(Text, show_background);
hint.setTimeOut(timeout);
hint.setTimeOut(timeout, false);
hint.paint();
res = hint.exec();
hint.hide();
@@ -523,7 +520,7 @@ int ShowHintS(const char * const Text, const sigc::slot<void> &Slot, int timeout
sigc::signal<void> OnCall;
OnCall.connect(Slot);
CHint hint(Text, show_background);
hint.setTimeOut(timeout);
hint.setTimeOut(timeout, false);
hint.paint();
OnCall();
res = hint.exec();

View File

@@ -91,7 +91,7 @@ class CHintBox : public CComponentsWindow
const int& frame_width);
virtual void ReSize();
void showTimeOutBar(){enableTimeOutBar();}
void showTimeOutBar(){initTimeOutBar();}
int getMaxWidth(const std::string& Text, const std::string& Title, Font *font, const int& minWidth);
public:
@@ -209,23 +209,36 @@ class CHintBox : public CComponentsWindow
* Timeout is enabled with parameter1 = DEFAULT_TIMEOUT (-1) or any other value > 0
* To disable timeout use NO_TIMEOUT (0)
* @param[in] Timeout as int as seconds
* @param[in] enable_Timeout_Bar as bool, default = true
* @param[in] enable_Timeout_Bar as bool
*/
virtual void setTimeOut(const int& Timeout, const bool& enable_Timeout_Bar = true){timeout = Timeout; enable_timeout_bar = enable_Timeout_Bar;}
virtual void setTimeOut(const int& Timeout, const bool& enable_Timeout_Bar){timeout = Timeout; enable_timeout_bar = enable_Timeout_Bar;}
/**
* enable/disable visualized timeout as progressbar under titlebar
* @param[in] enable
* @li optional: expects type bool, default = true
*/
void enableTimeOutBar(bool enable = true);
* enable/disable visualized timeout as progressbar under titlebar
* @param[in] enable
* @li expects type bool, default = true
*/
void enableTimeOutBar(bool enable = true){enable_timeout_bar = enable;}
/**
* disable visualized timeout as progressbar
* @see enableTimeOutBar
*/
* disable visualized timeout as progressbar under titlebar
* @see enableTimeOutBar()
*/
void disableTimeOutBar(){enableTimeOutBar(false);}
/**
* init or unload visualized timeout as progressbar under titlebar
* @param[in] do_init
* @li type bool, default = true
*/
void initTimeOutBar(bool do_init = true);
/**
* unload visualized timeout as progressbar
* @see initTimeOutBar
*/
void clearTimeOutBar(){initTimeOutBar(false);}
/**
* scroll handler for text objects: NOTE: exec() must be called !
* @param[in] hint_id
@@ -377,7 +390,7 @@ class CHint : public CHintBox
{
if (delay)
{
setTimeOut(delay);
setTimeOut(delay, false);
exec();
}
};

View File

@@ -73,7 +73,7 @@ int CKeyChooserItem::exec(CMenuTarget* parent, const std::string &)
int timeout = 10;
CHintBox hintbox(name, LOCALE_KEYCHOOSER_TEXT, HINTBOX_MIN_WIDTH, NEUTRINO_ICON_SETTINGS, NEUTRINO_ICON_HINT_KEYS);
hintbox.setTimeOut(timeout);
hintbox.setTimeOut(timeout, true);
hintbox.paint();
CFrameBuffer::getInstance()->blit();
@@ -84,7 +84,7 @@ int CKeyChooserItem::exec(CMenuTarget* parent, const std::string &)
timeoutEnd = CRCInput::calcTimeoutEnd(timeout);
get_Message:
hintbox.enableTimeOutBar();
hintbox.initTimeOutBar();
g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd );
if (msg != CRCInput::RC_timeout)

View File

@@ -278,7 +278,7 @@ int CMsgBox::exec()
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(timeout);
if (timeout > 0)
enableTimeOutBar();
initTimeOutBar();
bool loop = true;
while (loop)
@@ -364,7 +364,7 @@ int CMsgBox::exec()
}
}
disableTimeOutBar();
clearTimeOutBar();
return res;
}