Adds DisplayErrorDialog to show the error message of the failure of mirroring to the users.
This CL depends on http://codereview.chromium.org/10989084/. BUG=149061 Review URL: https://chromiumcodereview.appspot.com/10986087 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160521 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@ -74,6 +74,8 @@
|
||||
'desktop_background/desktop_background_widget_controller.h',
|
||||
'display/display_controller.cc',
|
||||
'display/display_controller.h',
|
||||
'display/display_error_dialog.cc',
|
||||
'display/display_error_dialog.h',
|
||||
'display/mouse_cursor_event_filter.cc',
|
||||
'display/mouse_cursor_event_filter.h',
|
||||
'display/multi_display_manager.cc',
|
||||
|
@ -473,6 +473,9 @@ Press Search or Shift to cancel.
|
||||
<message name="IDS_ASH_MINIMIZE_WINDOW" desc="A help text to show that when the button gets clicked the window gets minimized.">
|
||||
Minimize
|
||||
</message>
|
||||
<message name="IDS_ASH_DISPLAY_FAILURE_ON_MIRRORING" desc="An error message to show that the system failed to enter the mirroring mode.">
|
||||
Can't duplicate image on attached monitors. No matching resolution found.
|
||||
</message>
|
||||
</messages>
|
||||
</release>
|
||||
</grit>
|
||||
|
101
ash/display/display_error_dialog.cc
Normal file
101
ash/display/display_error_dialog.cc
Normal file
@ -0,0 +1,101 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "ash/display/display_error_dialog.h"
|
||||
|
||||
#include "ash/screen_ash.h"
|
||||
#include "ash/shell.h"
|
||||
#include "grit/ash_strings.h"
|
||||
#include "ui/aura/window.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/base/ui_base_types.h"
|
||||
#include "ui/gfx/display.h"
|
||||
#include "ui/gfx/screen.h"
|
||||
#include "ui/views/border.h"
|
||||
#include "ui/views/controls/label.h"
|
||||
#include "ui/views/widget/widget.h"
|
||||
|
||||
namespace ash {
|
||||
namespace internal {
|
||||
namespace {
|
||||
|
||||
// The width of the area to show the error message.
|
||||
const int kDialogMessageWidthPixel = 300;
|
||||
|
||||
// The margin width from the error message to the edge of the dialog.
|
||||
const int kDialogMessageMarginWidthPixel = 5;
|
||||
|
||||
DisplayErrorDialog* g_instance = NULL;
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
void DisplayErrorDialog::ShowDialog() {
|
||||
if (g_instance) {
|
||||
DCHECK(g_instance->GetWidget());
|
||||
g_instance->GetWidget()->StackAtTop();
|
||||
g_instance->GetWidget()->Activate();
|
||||
return;
|
||||
}
|
||||
|
||||
const gfx::Display& secondary_display = ash::ScreenAsh::GetSecondaryDisplay();
|
||||
|
||||
g_instance = new DisplayErrorDialog();
|
||||
views::Widget* widget = new views::Widget;
|
||||
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
|
||||
params.delegate = g_instance;
|
||||
// Makes |widget| belong to the secondary display. Size and location are
|
||||
// fixed by CenterWindow() below.
|
||||
params.bounds = secondary_display.bounds();
|
||||
params.keep_on_top = true;
|
||||
widget->Init(params);
|
||||
|
||||
widget->GetNativeView()->SetName("DisplayErrorDialog");
|
||||
widget->CenterWindow(widget->GetRootView()->GetPreferredSize());
|
||||
widget->Show();
|
||||
}
|
||||
|
||||
DisplayErrorDialog::DisplayErrorDialog() {
|
||||
Shell::GetInstance()->display_controller()->AddObserver(this);
|
||||
label_ = new views::Label(
|
||||
l10n_util::GetStringUTF16(IDS_ASH_DISPLAY_FAILURE_ON_MIRRORING));
|
||||
AddChildView(label_);
|
||||
|
||||
label_->SetMultiLine(true);
|
||||
label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
|
||||
label_->set_border(views::Border::CreateEmptyBorder(
|
||||
kDialogMessageMarginWidthPixel,
|
||||
kDialogMessageMarginWidthPixel,
|
||||
kDialogMessageMarginWidthPixel,
|
||||
kDialogMessageMarginWidthPixel));
|
||||
label_->SizeToFit(kDialogMessageWidthPixel);
|
||||
}
|
||||
|
||||
DisplayErrorDialog::~DisplayErrorDialog() {
|
||||
Shell::GetInstance()->display_controller()->RemoveObserver(this);
|
||||
g_instance = NULL;
|
||||
}
|
||||
|
||||
int DisplayErrorDialog::GetDialogButtons() const {
|
||||
return ui::DIALOG_BUTTON_OK;
|
||||
}
|
||||
|
||||
ui::ModalType DisplayErrorDialog::GetModalType() const {
|
||||
return ui::MODAL_TYPE_NONE;
|
||||
}
|
||||
|
||||
views::View* DisplayErrorDialog::GetContentsView() {
|
||||
return this;
|
||||
}
|
||||
|
||||
gfx::Size DisplayErrorDialog::GetPreferredSize() {
|
||||
return label_->GetPreferredSize();
|
||||
}
|
||||
|
||||
void DisplayErrorDialog::OnDisplayConfigurationChanging() {
|
||||
GetWidget()->Close();
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ash
|
61
ash/display/display_error_dialog.h
Normal file
61
ash/display/display_error_dialog.h
Normal file
@ -0,0 +1,61 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ASH_DISPLAY_DISPLAY_ERROR_DIALOG_H_
|
||||
#define ASH_DISPLAY_DISPLAY_ERROR_DIALOG_H_
|
||||
|
||||
#include "ash/display/display_controller.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "ui/views/window/dialog_delegate.h"
|
||||
|
||||
namespace aura {
|
||||
class RootWindow;
|
||||
} // namespace aura
|
||||
|
||||
namespace gfx {
|
||||
class Display;
|
||||
class Size;
|
||||
} // namespace gfx
|
||||
|
||||
namespace views {
|
||||
class Label;
|
||||
} // namespace views
|
||||
|
||||
namespace ash {
|
||||
namespace internal {
|
||||
|
||||
// Dialog used to show an error messages when unable to change the display
|
||||
// configuration to mirroring.
|
||||
class DisplayErrorDialog : public views::DialogDelegateView,
|
||||
public ash::DisplayController::Observer {
|
||||
public:
|
||||
// Shows the error dialog.
|
||||
static void ShowDialog();
|
||||
|
||||
private:
|
||||
DisplayErrorDialog();
|
||||
virtual ~DisplayErrorDialog();
|
||||
|
||||
// views::DialogDelegate overrides:
|
||||
virtual int GetDialogButtons() const OVERRIDE;
|
||||
|
||||
// views::WidgetDelegate overrides::
|
||||
virtual ui::ModalType GetModalType() const OVERRIDE;
|
||||
virtual views::View* GetContentsView() OVERRIDE;
|
||||
|
||||
// views::View overrides:
|
||||
virtual gfx::Size GetPreferredSize() OVERRIDE;
|
||||
|
||||
// ash::DisplayController::Observer overrides:
|
||||
virtual void OnDisplayConfigurationChanging() OVERRIDE;
|
||||
|
||||
views::Label* label_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(DisplayErrorDialog);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ash
|
||||
|
||||
#endif // ASH_DISPLAY_DISPLAY_ERROR_DIALOG_H_
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "ash/display/output_configurator_animation.h"
|
||||
|
||||
#include "ash/display/display_error_dialog.h"
|
||||
#include "ash/shell.h"
|
||||
#include "ash/shell_window_ids.h"
|
||||
#include "base/bind.h"
|
||||
@ -209,6 +210,7 @@ void OutputConfiguratorAnimation::OnDisplayModeChanged() {
|
||||
void OutputConfiguratorAnimation::OnDisplayModeChangeFailed() {
|
||||
if (!hiding_layers_.empty())
|
||||
StartFadeInAnimation();
|
||||
DisplayErrorDialog::ShowDialog();
|
||||
}
|
||||
|
||||
void OutputConfiguratorAnimation::ClearHidingLayers() {
|
||||
|
Reference in New Issue
Block a user