Added repository directory in file explorer button
This commit is contained in:
parent
234e04192b
commit
d3c1664f45
@ -19,6 +19,7 @@ import androidx.compose.ui.unit.sp
|
|||||||
import app.theme.primaryTextColor
|
import app.theme.primaryTextColor
|
||||||
import app.viewmodels.MenuViewModel
|
import app.viewmodels.MenuViewModel
|
||||||
|
|
||||||
|
// TODO Add tooltips to all the buttons
|
||||||
@Composable
|
@Composable
|
||||||
fun Menu(
|
fun Menu(
|
||||||
menuViewModel: MenuViewModel,
|
menuViewModel: MenuViewModel,
|
||||||
@ -79,6 +80,12 @@ fun Menu(
|
|||||||
)
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
|
|
||||||
|
IconMenuButton(
|
||||||
|
modifier = Modifier.padding(end = 8.dp),
|
||||||
|
icon = painterResource("source.svg"),
|
||||||
|
onClick = { menuViewModel.openFolderInFileExplorer() },
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,3 +131,39 @@ fun MenuButton(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun IconMenuButton(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
enabled: Boolean = true,
|
||||||
|
icon: Painter,
|
||||||
|
onClick: () -> Unit
|
||||||
|
) {
|
||||||
|
val iconColor = if (enabled) {
|
||||||
|
MaterialTheme.colors.primary
|
||||||
|
} else {
|
||||||
|
MaterialTheme.colors.secondaryVariant
|
||||||
|
}
|
||||||
|
|
||||||
|
OutlinedButton(
|
||||||
|
modifier = modifier
|
||||||
|
.padding(horizontal = 2.dp),
|
||||||
|
enabled = enabled,
|
||||||
|
onClick = onClick,
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
horizontalArrangement = Arrangement.Center,
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
) {
|
||||||
|
Image(
|
||||||
|
painter = icon,
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(horizontal = 4.dp)
|
||||||
|
.size(24.dp),
|
||||||
|
colorFilter = ColorFilter.tint(iconColor),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ import app.git.RefreshType
|
|||||||
import app.git.RemoteOperationsManager
|
import app.git.RemoteOperationsManager
|
||||||
import app.git.StashManager
|
import app.git.StashManager
|
||||||
import app.git.TabState
|
import app.git.TabState
|
||||||
|
import java.awt.Desktop
|
||||||
|
import java.io.File
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class MenuViewModel @Inject constructor(
|
class MenuViewModel @Inject constructor(
|
||||||
@ -38,4 +40,10 @@ class MenuViewModel @Inject constructor(
|
|||||||
|
|
||||||
return@safeProcessing RefreshType.UNCOMMITED_CHANGES
|
return@safeProcessing RefreshType.UNCOMMITED_CHANGES
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun openFolderInFileExplorer() = tabState.runOperation { git ->
|
||||||
|
Desktop.getDesktop().open(git.repository.directory.parentFile)
|
||||||
|
|
||||||
|
return@runOperation RefreshType.NONE
|
||||||
|
}
|
||||||
}
|
}
|
1
src/main/resources/source.svg
Normal file
1
src/main/resources/source.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24"/><path d="M20,6h-8l-2-2H4C2.9,4,2.01,4.9,2.01,6L2,18c0,1.1,0.9,2,2,2h16c1.1,0,2-0.9,2-2V8C22,6.9,21.1,6,20,6z M14,16H6v-2h8V16z M18,12H6v-2h12V12z"/></g></svg>
|
After Width: | Height: | Size: 339 B |
Loading…
Reference in New Issue
Block a user