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

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: rebase, single quotes in browsertest js 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
« no previous file with comments | « ash/system/date/date_view.h ('k') | ash/system/date/tray_date.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 if (action_ == TrayDate::NONE)
173 return false; 173 return false;
174 174 if (action_ == TrayDate::SHOW_DATE_SETTINGS)
175 ash::Shell::GetInstance()->system_tray_delegate()->ShowDateSettings(); 175 ash::Shell::GetInstance()->system_tray_delegate()->ShowDateSettings();
176 else if (action_ == TrayDate::SET_SYSTEM_TIME)
177 ash::Shell::GetInstance()->system_tray_delegate()->ShowSetTimeDialog();
176 return true; 178 return true;
177 } 179 }
178 180
179 void DateView::OnMouseEntered(const ui::MouseEvent& event) { 181 void DateView::OnMouseEntered(const ui::MouseEvent& event) {
180 if (!actionable_) 182 if (action_ == TrayDate::NONE)
181 return; 183 return;
182 date_label_->SetEnabledColor(kHeaderTextColorHover); 184 date_label_->SetEnabledColor(kHeaderTextColorHover);
183 SchedulePaint(); 185 SchedulePaint();
184 } 186 }
185 187
186 void DateView::OnMouseExited(const ui::MouseEvent& event) { 188 void DateView::OnMouseExited(const ui::MouseEvent& event) {
187 if (!actionable_) 189 if (action_ == TrayDate::NONE)
188 return; 190 return;
189 date_label_->SetEnabledColor(kHeaderTextColorNormal); 191 date_label_->SetEnabledColor(kHeaderTextColorNormal);
190 SchedulePaint(); 192 SchedulePaint();
191 } 193 }
192 194
193 /////////////////////////////////////////////////////////////////////////////// 195 ///////////////////////////////////////////////////////////////////////////////
194 196
195 TimeView::TimeView(TrayDate::ClockLayout clock_layout) 197 TimeView::TimeView(TrayDate::ClockLayout clock_layout)
196 : hour_type_(ash::Shell::GetInstance()->system_tray_delegate()-> 198 : hour_type_(ash::Shell::GetInstance()->system_tray_delegate()->
197 GetHourClockType()) { 199 GetHourClockType()) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 308
307 void TimeView::SetupLabel(views::Label* label) { 309 void TimeView::SetupLabel(views::Label* label) {
308 label->set_owned_by_client(); 310 label->set_owned_by_client();
309 SetupLabelForTray(label); 311 SetupLabelForTray(label);
310 label->SetFontList(label->font_list().DeriveWithStyle( 312 label->SetFontList(label->font_list().DeriveWithStyle(
311 label->font_list().GetFontStyle() & ~gfx::Font::BOLD)); 313 label->font_list().GetFontStyle() & ~gfx::Font::BOLD));
312 } 314 }
313 315
314 } // namespace tray 316 } // namespace tray
315 } // namespace ash 317 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/date/date_view.h ('k') | ash/system/date/tray_date.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698