From patchwork Mon Mar 7 16:47:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 548884 Delivered-To: patch@linaro.org Received: by 2002:adf:80eb:0:0:0:0:0 with SMTP id 98csp1098429wrl; Mon, 7 Mar 2022 08:59:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJwHx7n882u2cgEwcOTmYNu9r9YECxJk5LVogktYWC+BW4a6z9vJLUmnfREvLh1Lq/XZZUJo X-Received: by 2002:a25:bd41:0:b0:628:71a0:88af with SMTP id p1-20020a25bd41000000b0062871a088afmr8470598ybm.397.1646672398989; Mon, 07 Mar 2022 08:59:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646672398; cv=none; d=google.com; s=arc-20160816; b=PAu+JVuzlS2Fk/qGS1XZAnrM1Yn7efFjtL/YQTPuUbaaiuJTuYVwEf3xFOq3SSTjd5 Zew9eug8+oYv8zHW8477zc6PxKlKBWewvwMisufiLFNNeRAPTQOSPFzU/5eOw5gvNL1R PgMwHGx/YlfM9yzpxPqSM5wNVYnSfL+/li42zA6ZCrpXHc70ZUOMRYFJEF3MI1Te6D7j eP7fcK0ZE7PovLNxUSHwuy1MfczTct2+GNAFa1pt+w5RjuUdZg7AkCCtGP1XaW1oYy7d +vzKXBbBSZXaeE9GdpGwj/PINYnfPR/a5pkOiyItSP8ZyF7zvXySml/DYSBw7OmIAWL4 TD+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=U2DXG281yG+T8TcjY7hKoPvKUj4soEUbCsJuYEFv69Y=; b=nrPwNa4WUsz7acgFWzeDaCc/sC4H9i3PXuWVIjMD9zMOXZDYq9Ydlp+6j1ANWs6tsv RlGq1e9XFVOZVPeElckLKs0ayIX+J3h5O+sRJNoVD0w0p6RXRIlzIHnMVhMQFL+E4lV7 3xVPAdInE63cenevVJWW6Ldfptv7IHkWDV9vxCYpAaO4ozXHKOe40Jat6fLLqsEGiVMG fTsPJ1j7vEXikK6+C7RxOIJvMsVRRZpvuaTbV7Hx2pJUc/4UpEzpplAKLKhegn69Lthg BeBhO3HswsXqboYE087lVP30ptg9aTAUbPqf4A3nivieIKUrRn4ZTMqMW3Nhi5XSCkVx TV4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DXRtA6IK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m130-20020a812688000000b002dbf43ed806si8981919ywm.408.2022.03.07.08.59.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Mar 2022 08:59:58 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DXRtA6IK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRGiE-0001to-Aw for patch@linaro.org; Mon, 07 Mar 2022 11:59:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34224) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRGW8-000208-Pk for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:28 -0500 Received: from [2a00:1450:4864:20::430] (port=45966 helo=mail-wr1-x430.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nRGW6-0007mO-Rq for qemu-devel@nongnu.org; Mon, 07 Mar 2022 11:47:28 -0500 Received: by mail-wr1-x430.google.com with SMTP id p9so24271579wra.12 for ; Mon, 07 Mar 2022 08:47:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=U2DXG281yG+T8TcjY7hKoPvKUj4soEUbCsJuYEFv69Y=; b=DXRtA6IKLXX0B5QfLDpI41/XiSIvhTtaCneWcPBiJTHzBZNP2xKUUzQ6Hkic3NFKj6 fHTiC7VUfIJJ+yVntqxA+7+2ybrRDbiB0rcjX0kjMcAmSm5j1DsVdX0GjCdC9WJVjXIQ bT+DOjsduf4U0njNYtIYmeVO5jIMpAHdwA+Eb7mskW0Py5hH5yMuyuo1inNVNbGDtgGc vG+NvG/QeOQVrtTztD/0ho7wIL295xGzzt0kXDrqR8E482CXocZUKMYLi5eZNexm3RAV UWbjXGEm826IgZYvrMo5kijPCOC2lCGYvw+kka5osGA1xg6gR6n+mvcWSumGtYkZ8GKc oP5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=U2DXG281yG+T8TcjY7hKoPvKUj4soEUbCsJuYEFv69Y=; b=mWE0/kjIbe532qspzzGwRygccEqvRiDelBrzmPkzW9DGMpMzx1qf5cu+t1qvr6tT09 ik2/b+dieIyVg+TY96uYJREhrbzLFoyDEv5r66FaptIAEjoMkVyc+Rmpt/fLq67JdRlF x7IVP9SW9qVSprVCSUTpfvwh2axClGGJrSPQMuLmAQu+CXzreUUZoyrWwQ3WGVBqBG4Y /E2zgtkWAKsCyuR4yl1ZBb/UZMEA5LNVvQpvUBJW9tUuKythYhMdvvuxTPtescJ8G8Rr BiBTpGfb8ye8rpzFG7Am+B4PZMxiF7wWIA2JoIq7LuQupzBC4KubBS7ddtmGuKB4soqZ m5BQ== X-Gm-Message-State: AOAM532qetXPw60EnNCRhFb7UxlCjhil+WN5jmKx/dayhjyCHxkjFPL7 dslKCWKRI1PbTeAD9oAot18/b++oR1Ejew== X-Received: by 2002:a5d:534a:0:b0:1f0:5c4b:cec8 with SMTP id t10-20020a5d534a000000b001f05c4bcec8mr9360646wrv.115.1646671645509; Mon, 07 Mar 2022 08:47:25 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v188-20020a1cacc5000000b00384b71a50d5sm13806652wme.24.2022.03.07.08.47.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 08:47:25 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 16/18] ui/cocoa: Use the standard about panel Date: Mon, 7 Mar 2022 16:47:07 +0000 Message-Id: <20220307164709.2503250-17-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220307164709.2503250-1-peter.maydell@linaro.org> References: <20220307164709.2503250-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::430 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x430.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Akihiko Odaki This provides standard look and feel for the about panel and reduces code. Signed-off-by: Akihiko Odaki Message-id: 20220227042241.1543-1-akihiko.odaki@gmail.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- ui/cocoa.m | 112 +++++++++++------------------------------------------ 1 file changed, 23 insertions(+), 89 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 8ab9ab5e84d..c88149852b0 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -83,7 +83,7 @@ static void cocoa_switch(DisplayChangeListener *dcl, static void cocoa_refresh(DisplayChangeListener *dcl); -static NSWindow *normalWindow, *about_window; +static NSWindow *normalWindow; static const DisplayChangeListenerOps dcl_ops = { .dpy_name = "cocoa", .dpy_gfx_update = cocoa_update, @@ -1140,7 +1140,6 @@ QemuCocoaView *cocoaView; - (BOOL)verifyQuit; - (void)openDocumentation:(NSString *)filename; - (IBAction) do_about_menu_item: (id) sender; -- (void)make_about_window; - (void)adjustSpeed:(id)sender; @end @@ -1186,8 +1185,6 @@ QemuCocoaView *cocoaView; [pauseLabel setFont: [NSFont fontWithName: @"Helvetica" size: 90]]; [pauseLabel setTextColor: [NSColor blackColor]]; [pauseLabel sizeToFit]; - - [self make_about_window]; } return self; } @@ -1471,92 +1468,29 @@ QemuCocoaView *cocoaView; /* The action method for the About menu item */ - (IBAction) do_about_menu_item: (id) sender { - [about_window makeKeyAndOrderFront: nil]; -} - -/* Create and display the about dialog */ -- (void)make_about_window -{ - /* Make the window */ - int x = 0, y = 0, about_width = 400, about_height = 200; - NSRect window_rect = NSMakeRect(x, y, about_width, about_height); - about_window = [[NSWindow alloc] initWithContentRect:window_rect - styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | - NSWindowStyleMaskMiniaturizable - backing:NSBackingStoreBuffered - defer:NO]; - [about_window setTitle: @"About"]; - [about_window setReleasedWhenClosed: NO]; - [about_window center]; - NSView *superView = [about_window contentView]; - - /* Create the dimensions of the picture */ - int picture_width = 80, picture_height = 80; - x = (about_width - picture_width)/2; - y = about_height - picture_height - 10; - NSRect picture_rect = NSMakeRect(x, y, picture_width, picture_height); - - /* Make the picture of QEMU */ - NSImageView *picture_view = [[NSImageView alloc] initWithFrame: - picture_rect]; - char *qemu_image_path_c = get_relocated_path(CONFIG_QEMU_ICONDIR "/hicolor/512x512/apps/qemu.png"); - NSString *qemu_image_path = [NSString stringWithUTF8String:qemu_image_path_c]; - g_free(qemu_image_path_c); - NSImage *qemu_image = [[NSImage alloc] initWithContentsOfFile:qemu_image_path]; - [picture_view setImage: qemu_image]; - [picture_view setImageScaling: NSImageScaleProportionallyUpOrDown]; - [superView addSubview: picture_view]; - - /* Make the name label */ - NSBundle *bundle = [NSBundle mainBundle]; - if (bundle) { - x = 0; - y = y - 25; - int name_width = about_width, name_height = 20; - NSRect name_rect = NSMakeRect(x, y, name_width, name_height); - NSTextField *name_label = [[NSTextField alloc] initWithFrame: name_rect]; - [name_label setEditable: NO]; - [name_label setBezeled: NO]; - [name_label setDrawsBackground: NO]; - [name_label setAlignment: NSTextAlignmentCenter]; - NSString *qemu_name = [[bundle executablePath] lastPathComponent]; - [name_label setStringValue: qemu_name]; - [superView addSubview: name_label]; + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + char *icon_path_c = get_relocated_path(CONFIG_QEMU_ICONDIR "/hicolor/512x512/apps/qemu.png"); + NSString *icon_path = [NSString stringWithUTF8String:icon_path_c]; + g_free(icon_path_c); + NSImage *icon = [[NSImage alloc] initWithContentsOfFile:icon_path]; + NSString *version = @"QEMU emulator version " QEMU_FULL_VERSION; + NSString *copyright = @QEMU_COPYRIGHT; + NSDictionary *options; + if (icon) { + options = @{ + NSAboutPanelOptionApplicationIcon : icon, + NSAboutPanelOptionApplicationVersion : version, + @"Copyright" : copyright, + }; + [icon release]; + } else { + options = @{ + NSAboutPanelOptionApplicationVersion : version, + @"Copyright" : copyright, + }; } - - /* Set the version label's attributes */ - x = 0; - y = 50; - int version_width = about_width, version_height = 20; - NSRect version_rect = NSMakeRect(x, y, version_width, version_height); - NSTextField *version_label = [[NSTextField alloc] initWithFrame: - version_rect]; - [version_label setEditable: NO]; - [version_label setBezeled: NO]; - [version_label setAlignment: NSTextAlignmentCenter]; - [version_label setDrawsBackground: NO]; - - /* Create the version string*/ - NSString *version_string; - version_string = [[NSString alloc] initWithFormat: - @"QEMU emulator version %s", QEMU_FULL_VERSION]; - [version_label setStringValue: version_string]; - [superView addSubview: version_label]; - - /* Make copyright label */ - x = 0; - y = 35; - int copyright_width = about_width, copyright_height = 20; - NSRect copyright_rect = NSMakeRect(x, y, copyright_width, copyright_height); - NSTextField *copyright_label = [[NSTextField alloc] initWithFrame: - copyright_rect]; - [copyright_label setEditable: NO]; - [copyright_label setBezeled: NO]; - [copyright_label setDrawsBackground: NO]; - [copyright_label setAlignment: NSTextAlignmentCenter]; - [copyright_label setStringValue: [NSString stringWithFormat: @"%s", - QEMU_COPYRIGHT]]; - [superView addSubview: copyright_label]; + [NSApp orderFrontStandardAboutPanelWithOptions:options]; + [pool release]; } /* Used by the Speed menu items */