Skip to content

A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.

Visible text selection in light inputs; BitLocker unlock prompt; sizes in px

gelenmedyabf8c647a5346
diff --git a/crates/rf-app/src/folder_view.rs b/crates/rf-app/src/folder_view.rs
index 4cc72f1a..724c82dd 100644
--- a/crates/rf-app/src/folder_view.rs
+++ b/crates/rf-app/src/folder_view.rs
@@ -1618,6 +1618,35 @@ impl FolderView {
}
}
+ /// A drive that could not be read because BitLocker keeps it locked: Windows' own unlock window opens, as from Explorer, and
+ /// the folder is read again once the drive is open (Discussion 711).
+ fn offer_bitlocker_unlock(&mut self, cx: &mut Context<Self>) {
+ let Some(letter) = self.location().path().and_then(|p| p.to_str()).and_then(|p| p.chars().next()).filter(|c| c.is_ascii_alphabetic())
+ else {
+ return;
+ };
+ cx.spawn(async move |this, cx| {
+ let locked = cx.background_spawn(async move { rf_win::volume::bitlocker_locked(letter) }).await;
+ if !locked {
+ return;
+ }
+ let _ = this.update(cx, |v, cx| {
+ v.error = Some(t!("Bu sürücü BitLocker ile kilitli. Kilidini açmak için Windows'un parola penceresi açıldı.").to_string());
+ cx.notify();
+ });
+ let open = cx
+ .background_spawn(async move {
+ let _ = rf_win::volume::bitlocker_unlock_prompt(letter);
+ !rf_win::volume::bitlocker_locked(letter)
+ })
+ .await;
+ if open {
+ let _ = this.update(cx, |v, cx| v.refresh(cx));
+ }
+ })
+ .detach();
+ }
+
pub fn refresh(&mut self, cx: &mut Context<Self>) {
// (a customised folder's icon may have changed without its time or attributes: ask for those again)
crate::image_cache::refresh_folder_icons();
@@ -2502,6 +2531,7 @@ impl FolderView {
cx.emit(FolderEvent::NeedPassword(archive, wrong));
} else if e != "İptal edildi" {
self.error = Some(e);
+ self.offer_bitlocker_unlock(cx);
}
}
}
@@ -7517,7 +7547,7 @@ const LIST_CELL_CHROME: f32 = 8. + 20. + 8. + 8. + 12.;
const LIST_MEASURE_MOST: usize = 4000;
/// Grid sizes (Ctrl+= / Ctrl+-): tile width, row height, thumbnail pixels. A row is high enough for the picture and two whole lines
/// of the name (see `tile_name_room`).
-const GRID_SIZES: [(f32, f32, u32); 5] = [(76., 102., 64), (92., 114., 80), (124., 150., 128), (172., 204., 192), (236., 276., 272)];
+pub(crate) const GRID_SIZES: [(f32, f32, u32); 5] = [(76., 102., 64), (92., 114., 80), (124., 150., 128), (172., 204., 192), (236., 276., 272)];
/// The height of one line of a tile's name. It is set on the label instead of left to the toolkit's default (1.618 of the text size,
/// 19.4 px): two such lines were higher than the room under the picture, and the second one was cut in half at the tile's edge
/// with "Compact items" on (a Discord report).
@@ -7567,7 +7597,7 @@ fn tile_name_room(size: usize, compact: bool) -> f32 {
}
const DEFAULT_GRID_SIZE: u8 = 2;
/// Details row heights for the "Size" slider (30 = the classic one; 22 = as tight as File Explorer's compact rows, asked for on Threads).
-const ROW_SIZES: [f32; 5] = [22., 30., 36., 44., 52.];
+pub(crate) const ROW_SIZES: [f32; 5] = [22., 30., 36., 44., 52.];
/// The same with "Compact items" on (Explorer's compact view: its rows are 22 px at the default size).
const COMPACT_ROW_SIZES: [f32; 5] = [20., 22., 28., 34., 42.];
/// What "Compact items" takes off a tile's height: the picture's 4 px frame, the 4 px gap under it and 4 of the cell's 8 px padding.
diff --git a/crates/rf-app/src/i18n_en.rs b/crates/rf-app/src/i18n_en.rs
index 5a5fccaf..64a70e26 100644
--- a/crates/rf-app/src/i18n_en.rs
+++ b/crates/rf-app/src/i18n_en.rs
@@ -2331,6 +2331,7 @@ pub const EN: &[(&str, &str)] = &[
("Gelen dosyaların klasörünü seçin", "Choose the folder for received files"),
("İndirme klasörü", "Download folder"),
("İndirmelerin klasörünü seçin", "Choose the folder for downloads"),
+ ("Bu sürücü BitLocker ile kilitli. Kilidini açmak için Windows'un parola penceresi açıldı.", "This drive is locked by BitLocker. Windows' password window opened to unlock it."),
("Git durumunu göster", "Show Git status"),
("Depoların içinde dosyaların Git durumu, adın yanındaki işaret ve commit sütunları; kapalıyken liste için Git hiç çalıştırılmaz", "Files' Git status inside repositories, the mark after a name and the commit columns; when off, Git is never run for the list"),
("Varsayılan satır boyutu", "Default row size"),
diff --git a/crates/rf-app/src/settings.rs b/crates/rf-app/src/settings.rs
index b8cb4b84..8694ea3f 100644
--- a/crates/rf-app/src/settings.rs
+++ b/crates/rf-app/src/settings.rs
@@ -1930,6 +1930,13 @@ pub fn apply_component_theme(cx: &mut App) {
// The component root paints the theme background under every window; keep it clear so
// the Mica backdrop shows through (our own surfaces bring their own fills).
Theme::update(cx, |t| t.background = gpui_kit::transparent_black());
+ // Selected text in the inputs (the address bar, rename, search) in the accent: the toolkit's own light selection was all but
+ // invisible on our light surfaces (issue 726).
+ Theme::update(cx, |t| {
+ let dark = t.mode.is_dark();
+ let p = if dark { crate::theme::Palette::dark() } else { crate::theme::Palette::light() };
+ t.selection = p.accent.opacity(if dark { 0.45 } else { 0.32 });
+ });
// the chosen font, else Windows 11's own typeface (optical sizes) when present
if let Some(f) = cx.global::<Settings>().font.clone() {
Theme::update(cx, |t| t.font_family = f.into());
diff --git a/crates/rf-app/src/settings_view.rs b/crates/rf-app/src/settings_view.rs
index 8cdde46c..1a84446d 100644
--- a/crates/rf-app/src/settings_view.rs
+++ b/crates/rf-app/src/settings_view.rs
@@ -297,9 +297,18 @@ pub(crate) fn sw(id: &'static str, p: &Palette, on: bool, set: fn(&mut Settings,
}
/// A button showing the current value; clicking opens the choices in our menu.
-/// The five size steps of the list's rows and of the grid's tiles, by name.
-fn size_steps() -> Vec<(u8, String)> {
- vec![(0, t!("Çok küçük").into()), (1, t!("Küçük").into()), (2, t!("Orta").into()), (3, t!("Büyük").into()), (4, t!("Çok büyük").into())]
+/// The five size steps of the list's rows or of the grid's tiles, by their height in pixels (names like "Medium" read as other
+/// things in some languages: "Orta" had become "Fair"); the default step is marked.
+fn size_steps(px: [f32; 5], default: u8) -> Vec<(u8, String)> {
+ (0..5u8)
+ .map(|i| {
+ let mut label = format!("{} px", px[i as usize] as u32);
+ if i == default {
+ label = format!("{label} ({})", t!("varsayılan"));
+ }
+ (i, label)
+ })
+ .collect()
}
pub(crate) fn dropdown<T: Copy + PartialEq + 'static>(id: &'static str, p: &Palette, current: T, options: Vec<(T, String)>, set: fn(&mut Settings, T)) -> AnyElement {
@@ -2560,14 +2569,14 @@ fn layout(p: &Palette, s: &Settings, cx: &mut App) -> Vec<AnyElement> {
L::Rows3,
t!("Varsayılan satır boyutu"),
Some(t!("Kendi düzeni olmayan klasörler Ayrıntılar ve Liste'de bu boyutta açılır")),
- dropdown("default-row-size", p, s.default_row_size, size_steps(), |s, v| s.default_row_size = v),
+ dropdown("default-row-size", p, s.default_row_size, size_steps(crate::folder_view::ROW_SIZES, 1), |s, v| s.default_row_size = v),
),
card(
p,
L::LayoutGrid,
t!("Varsayılan simge boyutu"),
Some(t!("Kendi düzeni olmayan klasörler ızgarada bu boyutta açılır")),
- dropdown("default-grid-size", p, s.default_grid_size, size_steps(), |s, v| s.default_grid_size = v),
+ dropdown("default-grid-size", p, s.default_grid_size, size_steps(crate::folder_view::GRID_SIZES.map(|g| g.0), 2), |s, v| s.default_grid_size = v),
),
section(p, t!("Sıralama ve gruplama")),
card(
diff --git a/crates/rf-win/src/volume.rs b/crates/rf-win/src/volume.rs
index fde716bc..e83a0713 100644
--- a/crates/rf-win/src/volume.rs
+++ b/crates/rf-win/src/volume.rs
@@ -103,6 +103,35 @@ pub fn set_label(root: &Path, label: &str) -> std::io::Result<()> {
unsafe { SetVolumeLabelW(windows::core::PCWSTR(wr.as_ptr()), label) }.map_err(|e| std::io::Error::from_raw_os_error(e.code().0 & 0xffff))
}
+/// BitLocker's state of a drive as the shell gives it (`System.Volume.BitLockerProtection`): 6 is "locked". Read without
+/// administrator rights, from the same property Explorer draws its lock from. `None` when the shell has no value.
+pub fn bitlocker_state(letter: char) -> Option<u32> {
+ use windows::Win32::System::Com::StructuredStorage::PropVariantToUInt32;
+ use windows::Win32::UI::Shell::PropertiesSystem::{GPS_DEFAULT, IPropertyStore, PSGetPropertyKeyFromName, SHGetPropertyStoreFromParsingName};
+ use windows::core::w;
+ ensure_com();
+ let root = wide(&format!("{letter}:\\"));
+ unsafe {
+ let store: IPropertyStore = SHGetPropertyStoreFromParsingName(PCWSTR(root.as_ptr()), None, GPS_DEFAULT).ok()?;
+ let mut key = Default::default();
+ PSGetPropertyKeyFromName(w!("System.Volume.BitLockerProtection"), &mut key).ok()?;
+ let v = store.GetValue(&key).ok()?;
+ PropVariantToUInt32(&v).ok()
+ }
+}
+
+/// Whether the drive is locked by BitLocker (its contents can't be read until it is unlocked).
+pub fn bitlocker_locked(letter: char) -> bool {
+ bitlocker_state(letter) == Some(6)
+}
+
+/// Windows' own "enter the password to unlock this drive" window (bdeunlock.exe, what Explorer opens for a locked drive); returns
+/// once it is closed, unlocked or not. Blocking: call it off the UI thread.
+pub fn bitlocker_unlock_prompt(letter: char) -> std::io::Result<()> {
+ let system = std::env::var_os("SystemRoot").map(PathBuf::from).unwrap_or_else(|| PathBuf::from(r"C:\Windows"));
+ std::process::Command::new(system.join("System32").join("bdeunlock.exe")).arg(format!("{letter}:")).status().map(|_| ())
+}
+
/// The removable drives that hold a volume now (a USB stick, a card in a reader): letter and label, in letter order. An empty card
/// reader is left out. Blocks briefly (one call for each drive letter in use, one more for each removable one): off the UI thread.
/// (A USB hard disk reports itself as a fixed drive and is not in this list yet.)