mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +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
|
||||
main.cpp
|
||||
PowerDialog.cpp
|
||||
ShutdownDialog.cpp
|
||||
)
|
||||
|
||||
serenity_bin(SystemMenu)
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "ShutdownDialog.h"
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
|
@ -34,33 +35,31 @@
|
|||
#include <LibGUI/Widget.h>
|
||||
#include <LibGfx/Font.h>
|
||||
|
||||
#include "PowerDialog.h"
|
||||
|
||||
struct PowerOption {
|
||||
struct Option {
|
||||
String title;
|
||||
Vector<char const*> cmd;
|
||||
bool enabled;
|
||||
bool default_action;
|
||||
};
|
||||
|
||||
static const Vector<PowerOption> options = {
|
||||
static const Vector<Option> options = {
|
||||
{ "Shut down", { "/bin/shutdown", "--now", nullptr }, true, true },
|
||||
{ "Restart", { "/bin/reboot", nullptr }, true, false },
|
||||
{ "Log out", {}, false, false },
|
||||
{ "Sleep", {}, false, false },
|
||||
};
|
||||
|
||||
Vector<char const*> PowerDialog::show()
|
||||
Vector<char const*> ShutdownDialog::show()
|
||||
{
|
||||
auto rc = PowerDialog::construct()->exec();
|
||||
if(rc == ExecResult::ExecOK)
|
||||
auto rc = ShutdownDialog::construct()->exec();
|
||||
if (rc == ExecResult::ExecOK)
|
||||
return options[rc].cmd;
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
PowerDialog::PowerDialog()
|
||||
: GUI::Dialog(nullptr)
|
||||
ShutdownDialog::ShutdownDialog()
|
||||
: Dialog(nullptr)
|
||||
{
|
||||
Gfx::Rect rect({ 0, 0, 180, 180 + ((static_cast<int>(options.size()) - 3) * 16) });
|
||||
rect.center_within(GUI::Desktop::the().rect());
|
||||
|
@ -114,6 +113,6 @@ PowerDialog::PowerDialog()
|
|||
cancel_button.set_text("Cancel");
|
||||
}
|
||||
|
||||
PowerDialog::~PowerDialog()
|
||||
ShutdownDialog::~ShutdownDialog()
|
||||
{
|
||||
}
|
|
@ -25,17 +25,17 @@
|
|||
*/
|
||||
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibGUI/Dialog.h>
|
||||
|
||||
class PowerDialog : public GUI::Dialog {
|
||||
C_OBJECT(PowerDialog)
|
||||
class ShutdownDialog : public GUI::Dialog {
|
||||
C_OBJECT(ShutdownDialog);
|
||||
|
||||
public:
|
||||
static Vector<char const*> show();
|
||||
|
||||
private:
|
||||
PowerDialog();
|
||||
~PowerDialog();
|
||||
ShutdownDialog();
|
||||
virtual ~ShutdownDialog() override;
|
||||
|
||||
int m_selected_option { -1 };
|
||||
};
|
|
@ -24,7 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "PowerDialog.h"
|
||||
#include "ShutdownDialog.h"
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/QuickSort.h>
|
||||
#include <LibCore/ConfigFile.h>
|
||||
|
@ -203,7 +203,7 @@ NonnullRefPtr<GUI::Menu> build_system_menu()
|
|||
}));
|
||||
system_menu->add_separator();
|
||||
system_menu->add_action(GUI::Action::create("Exit...", [](auto&) {
|
||||
Vector<char const*> command = PowerDialog::show();
|
||||
auto command = ShutdownDialog::show();
|
||||
|
||||
if (command.size() == 0)
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue