mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
SystemMenu: Rename PowerDialog => ShutdownDialog
This commit is contained in:
parent
e5ea243842
commit
efb3a34e43
Notes:
sideshowbarker
2024-07-19 06:23:45 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/efb3a34e43c
4 changed files with 17 additions and 18 deletions
|
@ -1,6 +1,6 @@
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
main.cpp
|
main.cpp
|
||||||
PowerDialog.cpp
|
ShutdownDialog.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
serenity_bin(SystemMenu)
|
serenity_bin(SystemMenu)
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "ShutdownDialog.h"
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <LibGUI/BoxLayout.h>
|
#include <LibGUI/BoxLayout.h>
|
||||||
|
@ -34,33 +35,31 @@
|
||||||
#include <LibGUI/Widget.h>
|
#include <LibGUI/Widget.h>
|
||||||
#include <LibGfx/Font.h>
|
#include <LibGfx/Font.h>
|
||||||
|
|
||||||
#include "PowerDialog.h"
|
struct Option {
|
||||||
|
|
||||||
struct PowerOption {
|
|
||||||
String title;
|
String title;
|
||||||
Vector<char const*> cmd;
|
Vector<char const*> cmd;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
bool default_action;
|
bool default_action;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const Vector<PowerOption> options = {
|
static const Vector<Option> options = {
|
||||||
{ "Shut down", { "/bin/shutdown", "--now", nullptr }, true, true },
|
{ "Shut down", { "/bin/shutdown", "--now", nullptr }, true, true },
|
||||||
{ "Restart", { "/bin/reboot", nullptr }, true, false },
|
{ "Restart", { "/bin/reboot", nullptr }, true, false },
|
||||||
{ "Log out", {}, false, false },
|
{ "Log out", {}, false, false },
|
||||||
{ "Sleep", {}, false, false },
|
{ "Sleep", {}, false, false },
|
||||||
};
|
};
|
||||||
|
|
||||||
Vector<char const*> PowerDialog::show()
|
Vector<char const*> ShutdownDialog::show()
|
||||||
{
|
{
|
||||||
auto rc = PowerDialog::construct()->exec();
|
auto rc = ShutdownDialog::construct()->exec();
|
||||||
if(rc == ExecResult::ExecOK)
|
if (rc == ExecResult::ExecOK)
|
||||||
return options[rc].cmd;
|
return options[rc].cmd;
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
PowerDialog::PowerDialog()
|
ShutdownDialog::ShutdownDialog()
|
||||||
: GUI::Dialog(nullptr)
|
: Dialog(nullptr)
|
||||||
{
|
{
|
||||||
Gfx::Rect rect({ 0, 0, 180, 180 + ((static_cast<int>(options.size()) - 3) * 16) });
|
Gfx::Rect rect({ 0, 0, 180, 180 + ((static_cast<int>(options.size()) - 3) * 16) });
|
||||||
rect.center_within(GUI::Desktop::the().rect());
|
rect.center_within(GUI::Desktop::the().rect());
|
||||||
|
@ -114,6 +113,6 @@ PowerDialog::PowerDialog()
|
||||||
cancel_button.set_text("Cancel");
|
cancel_button.set_text("Cancel");
|
||||||
}
|
}
|
||||||
|
|
||||||
PowerDialog::~PowerDialog()
|
ShutdownDialog::~ShutdownDialog()
|
||||||
{
|
{
|
||||||
}
|
}
|
|
@ -25,17 +25,17 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <LibCore/Object.h>
|
|
||||||
#include <LibGUI/Dialog.h>
|
#include <LibGUI/Dialog.h>
|
||||||
|
|
||||||
class PowerDialog : public GUI::Dialog {
|
class ShutdownDialog : public GUI::Dialog {
|
||||||
C_OBJECT(PowerDialog)
|
C_OBJECT(ShutdownDialog);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Vector<char const*> show();
|
static Vector<char const*> show();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PowerDialog();
|
ShutdownDialog();
|
||||||
~PowerDialog();
|
virtual ~ShutdownDialog() override;
|
||||||
|
|
||||||
int m_selected_option { -1 };
|
int m_selected_option { -1 };
|
||||||
};
|
};
|
|
@ -24,7 +24,7 @@
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "PowerDialog.h"
|
#include "ShutdownDialog.h"
|
||||||
#include <AK/FileSystemPath.h>
|
#include <AK/FileSystemPath.h>
|
||||||
#include <AK/QuickSort.h>
|
#include <AK/QuickSort.h>
|
||||||
#include <LibCore/ConfigFile.h>
|
#include <LibCore/ConfigFile.h>
|
||||||
|
@ -203,7 +203,7 @@ NonnullRefPtr<GUI::Menu> build_system_menu()
|
||||||
}));
|
}));
|
||||||
system_menu->add_separator();
|
system_menu->add_separator();
|
||||||
system_menu->add_action(GUI::Action::create("Exit...", [](auto&) {
|
system_menu->add_action(GUI::Action::create("Exit...", [](auto&) {
|
||||||
Vector<char const*> command = PowerDialog::show();
|
auto command = ShutdownDialog::show();
|
||||||
|
|
||||||
if (command.size() == 0)
|
if (command.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue