mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:17:35 +00:00
CatDog: Help the user debug their programs
This adds helpful speech bubbles to CatDog. CatDog just wants to help, that's all.
This commit is contained in:
parent
da5923bc54
commit
e0fe38ea25
6 changed files with 132 additions and 0 deletions
|
@ -5,6 +5,8 @@
|
|||
*/
|
||||
|
||||
#include "CatDog.h"
|
||||
#include "SpeechBubble.h"
|
||||
#include <LibCore/Timer.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
|
@ -63,5 +65,43 @@ int main(int argc, char** argv)
|
|||
catdog_widget.start_timer(250, Core::TimerShouldFireWhenNotVisible::Yes);
|
||||
catdog_widget.start_the_timer(); // timer for "mouse sleep detection"
|
||||
|
||||
auto advice_window = GUI::Window::construct();
|
||||
advice_window->set_title("CatDog Advice");
|
||||
advice_window->resize(225, 50);
|
||||
advice_window->set_frameless(true);
|
||||
advice_window->set_resizable(false);
|
||||
advice_window->set_has_alpha_channel(true);
|
||||
advice_window->set_alpha_hit_threshold(1.0f);
|
||||
|
||||
auto& advice_widget = advice_window->set_main_widget<SpeechBubble>();
|
||||
advice_widget.set_layout<GUI::VerticalBoxLayout>();
|
||||
advice_widget.layout()->set_spacing(0);
|
||||
|
||||
auto advice_timer = Core::Timer::construct();
|
||||
advice_timer->set_interval(15000);
|
||||
advice_timer->set_single_shot(true);
|
||||
advice_timer->on_timeout = [&] {
|
||||
window->move_to_front();
|
||||
advice_window->move_to_front();
|
||||
catdog_widget.set_roaming(false);
|
||||
advice_window->move_to(window->x() - advice_window->width() / 2, window->y() - advice_window->height());
|
||||
advice_window->show();
|
||||
};
|
||||
advice_timer->start();
|
||||
|
||||
advice_widget.on_dismiss = [&] {
|
||||
catdog_widget.set_roaming(true);
|
||||
advice_window->hide();
|
||||
advice_timer->start();
|
||||
};
|
||||
|
||||
// Let users toggle the advice functionality by clicking on catdog.
|
||||
catdog_widget.on_click = [&] {
|
||||
if (advice_timer->is_active())
|
||||
advice_timer->stop();
|
||||
else
|
||||
advice_timer->start();
|
||||
};
|
||||
|
||||
return app->exec();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue