Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(616)

Side by Side Diff: ash/system/date/date_view.cc

Issue 247663003: Date and Time dialog for when the clock isn't synced. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/system/date/date_view.h" 5 #include "ash/system/date/date_view.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/tray/system_tray_delegate.h" 8 #include "ash/system/tray/system_tray_delegate.h"
9 #include "ash/system/tray/tray_constants.h" 9 #include "ash/system/tray/tray_constants.h"
10 #include "ash/system/tray/tray_utils.h" 10 #include "ash/system/tray/tray_utils.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 PreferredSizeChanged(); 121 PreferredSizeChanged();
122 } 122 }
123 123
124 void BaseDateTimeView::OnLocaleChanged() { 124 void BaseDateTimeView::OnLocaleChanged() {
125 UpdateText(); 125 UpdateText();
126 } 126 }
127 127
128 DateView::DateView() 128 DateView::DateView()
129 : hour_type_(ash::Shell::GetInstance()->system_tray_delegate()-> 129 : hour_type_(ash::Shell::GetInstance()->system_tray_delegate()->
130 GetHourClockType()), 130 GetHourClockType()),
131 actionable_(false) { 131 action_(TrayDate::NONE) {
132 SetLayoutManager( 132 SetLayoutManager(
133 new views::BoxLayout( 133 new views::BoxLayout(
134 views::BoxLayout::kVertical, 0, 0, 0)); 134 views::BoxLayout::kVertical, 0, 0, 0));
135 date_label_ = CreateLabel(); 135 date_label_ = CreateLabel();
136 date_label_->SetEnabledColor(kHeaderTextColorNormal); 136 date_label_->SetEnabledColor(kHeaderTextColorNormal);
137 UpdateTextInternal(base::Time::Now()); 137 UpdateTextInternal(base::Time::Now());
138 AddChildView(date_label_); 138 AddChildView(date_label_);
139 SetFocusable(actionable_); 139 SetFocusable(false);
140 } 140 }
141 141
142 DateView::~DateView() { 142 DateView::~DateView() {
143 } 143 }
144 144
145 void DateView::SetActionable(bool actionable) { 145 void DateView::SetAction(TrayDate::DateAction action) {
146 actionable_ = actionable; 146 action_ = action;
147 SetFocusable(actionable_); 147 SetFocusable(action_ != TrayDate::NONE);
148 } 148 }
149 149
150 void DateView::UpdateTimeFormat() { 150 void DateView::UpdateTimeFormat() {
151 hour_type_ = 151 hour_type_ =
152 ash::Shell::GetInstance()->system_tray_delegate()->GetHourClockType(); 152 ash::Shell::GetInstance()->system_tray_delegate()->GetHourClockType();
153 UpdateText(); 153 UpdateText();
154 } 154 }
155 155
156 base::HourClockType DateView::GetHourTypeForTesting() const { 156 base::HourClockType DateView::GetHourTypeForTesting() const {
157 return hour_type_; 157 return hour_type_;
158 } 158 }
159 159
160 void DateView::UpdateTextInternal(const base::Time& now) { 160 void DateView::UpdateTextInternal(const base::Time& now) {
161 SetAccessibleName( 161 SetAccessibleName(
162 base::TimeFormatFriendlyDate(now) + 162 base::TimeFormatFriendlyDate(now) +
163 base::ASCIIToUTF16(", ") + 163 base::ASCIIToUTF16(", ") +
164 base::TimeFormatTimeOfDayWithHourClockType( 164 base::TimeFormatTimeOfDayWithHourClockType(
165 now, hour_type_, base::kKeepAmPm)); 165 now, hour_type_, base::kKeepAmPm));
166 date_label_->SetText( 166 date_label_->SetText(
167 l10n_util::GetStringFUTF16( 167 l10n_util::GetStringFUTF16(
168 IDS_ASH_STATUS_TRAY_DATE, FormatDayOfWeek(now), FormatDate(now))); 168 IDS_ASH_STATUS_TRAY_DATE, FormatDayOfWeek(now), FormatDate(now)));
169 } 169 }
170 170
171 bool DateView::PerformAction(const ui::Event& event) { 171 bool DateView::PerformAction(const ui::Event& event) {
172 if (!actionable_) 172 switch (action_) {
173 return false; 173 case TrayDate::SHOW_DATE_SETTINGS:
174 174 ash::Shell::GetInstance()->system_tray_delegate()->ShowDateSettings();
175 ash::Shell::GetInstance()->system_tray_delegate()->ShowDateSettings(); 175 return true;
176 return true; 176 case TrayDate::SET_SYSTEM_TIME:
177 ash::Shell::GetInstance()->system_tray_delegate()->ShowSetTimeDialog();
178 return true;
179 case TrayDate::NONE:
180 return false;
181 }
177 } 182 }
178 183
179 void DateView::OnMouseEntered(const ui::MouseEvent& event) { 184 void DateView::OnMouseEntered(const ui::MouseEvent& event) {
180 if (!actionable_) 185 if (action_ == TrayDate::NONE)
181 return; 186 return;
182 date_label_->SetEnabledColor(kHeaderTextColorHover); 187 date_label_->SetEnabledColor(kHeaderTextColorHover);
183 SchedulePaint(); 188 SchedulePaint();
184 } 189 }
185 190
186 void DateView::OnMouseExited(const ui::MouseEvent& event) { 191 void DateView::OnMouseExited(const ui::MouseEvent& event) {
187 if (!actionable_) 192 if (action_ == TrayDate::NONE)
188 return; 193 return;
189 date_label_->SetEnabledColor(kHeaderTextColorNormal); 194 date_label_->SetEnabledColor(kHeaderTextColorNormal);
190 SchedulePaint(); 195 SchedulePaint();
191 } 196 }
192 197
193 /////////////////////////////////////////////////////////////////////////////// 198 ///////////////////////////////////////////////////////////////////////////////
194 199
195 TimeView::TimeView(TrayDate::ClockLayout clock_layout) 200 TimeView::TimeView(TrayDate::ClockLayout clock_layout)
196 : hour_type_(ash::Shell::GetInstance()->system_tray_delegate()-> 201 : hour_type_(ash::Shell::GetInstance()->system_tray_delegate()->
197 GetHourClockType()) { 202 GetHourClockType()) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 311
307 void TimeView::SetupLabel(views::Label* label) { 312 void TimeView::SetupLabel(views::Label* label) {
308 label->set_owned_by_client(); 313 label->set_owned_by_client();
309 SetupLabelForTray(label); 314 SetupLabelForTray(label);
310 label->SetFontList(label->font_list().DeriveWithStyle( 315 label->SetFontList(label->font_list().DeriveWithStyle(
311 label->font_list().GetFontStyle() & ~gfx::Font::BOLD)); 316 label->font_list().GetFontStyle() & ~gfx::Font::BOLD));
312 } 317 }
313 318
314 } // namespace tray 319 } // namespace tray
315 } // namespace ash 320 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698