/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! The UI model, UI implementations, and functions using them. //! //! UIs must implement: //! * a `fn run_loop(&self, app: model::Application)` method which should display the UI and block while //! handling events until the application terminates, //! * a `fn invoke(&self, f: model::InvokeFn)` method which invokes the given function //! asynchronously (without blocking) on the UI loop thread.
usecrate::std::sync::Arc; usecrate::{
async_task::AsyncTask, config::Config, data, logic::ReportCrash, settings::Settings, std,
thread_bound::ThreadBound,
}; use model::{ui, Application}; use ui_impl::UI;
mod model;
#[cfg(all(not(test), any(target_os = "linux", target_os = "windows")))] mod icon { // Must be DWORD-aligned for Win32 CreateIconFromResource. #[repr(align(4))] struct Aligned<Bytes: ?Sized>(Bytes); static PNG_DATA_ALIGNMENT: &'static Aligned<[u8]> =
&Aligned(*include_bytes!("crashreporter.png")); pubstatic PNG_DATA: &'static [u8] = &PNG_DATA_ALIGNMENT.0;
}
#[cfg(test)] pubmod test { pubmod model { pubusecrate::ui::model::*;
}
}
/// Display an error dialog with the given message. #[cfg_attr(mock, allow(unused))] pubfn error_dialog<M: std::fmt::Debug>(config: Arc<Config>, message: M) { let close = data::Event::default(); // Config may not have localized strings let string_or = |name, fallback: &str| { if config.strings.is_none() {
fallback.into()
} else {
config.string(name)
}
};
let window = ui! {
Window title(string_or("crashreporter-branded-title", "Firefox Crash Reporter")) hsize(600) vsize(400)
close_when(&close) halign(Alignment::Fill) valign(Alignment::Fill) {
VBox margin(10) spacing(10) halign(Alignment::Fill) valign(Alignment::Fill) {
Label text(string_or( "crashreporter-error", "The application had a problem and crashed. \
Unfortunately, the crash reporter is unable to submit a report for the crash."
)),
Label text(string_or("crashreporter-error-details-header", "Details:")),
Scroll halign(Alignment::Fill) valign(Alignment::Fill) {
TextBox content(format!("{message:?}")) halign(Alignment::Fill) valign(Alignment::Fill)
},
HBox valign(Alignment::End) halign(Alignment::End) spacing(10) affirmative_order(true)
{
Button["restart"] hsize(160) visible(config.restart_command.is_some())
on_click(cc! { (config, close) move || {
config.restart_process();
close.fire(&());
}})
{
Label text(string_or("crashreporter-button-restart", "Restart"))
},
Button["quit"] hsize(160) on_click(move || close.fire(&()))
{
Label text(string_or("crashreporter-button-quit", "Quit"))
}
}
}
}
};
let progress_visible = submit_state.mapped(|s| s == &SubmitState::InProgress); let hardware_test_checkbox_visible = data::Synchronized::new(self.config.run_memtest);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.