Skip to content

Commit

Permalink
Show an error message if there's no camera during QR code scan
Browse files Browse the repository at this point in the history
  • Loading branch information
zapek committed Aug 5, 2023
1 parent 162e691 commit f0c51a5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .run/XeresApplication.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="XeresApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true">
<option name="ACTIVE_PROFILES" value="dev"/>
<module name="io.xeres.Xeres.app.main"/>
<module name="Xeres.app.main"/>
<option name="PROGRAM_PARAMETERS" value="--fast-shutdown"/>
<option name="SPRING_BOOT_MAIN_CLASS" value="io.xeres.app.XeresApplication"/>
<option name="VM_PARAMETERS" value="-ea -Djava.net.preferIPv4Stack=true -Dfile.encoding=UTF-8"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import javafx.concurrent.Task;
import javafx.embed.swing.SwingFXUtils;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import net.rgielen.fxweaver.core.FxmlView;
Expand All @@ -53,6 +54,9 @@ public class CameraWindowController implements WindowController
@FXML
private ImageView capturedImage;

@FXML
private Label error;

private boolean stopCamera;
private AddRsIdWindowController parentController;
private final ObjectProperty<Image> imageProperty = new SimpleObjectProperty<>();
Expand All @@ -68,7 +72,11 @@ public void initialize() throws IOException
{
initializeCamera(camera);
}
// XXX: no camera found
else
{
error.setText("No camera has been detected");
error.setVisible(true);
}
}

@Override
Expand Down
2 changes: 2 additions & 0 deletions ui/src/main/resources/view/qrcode/camera.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
~ along with Xeres. If not, see <http://www.gnu.org/licenses/>.
-->

<?import javafx.scene.control.Label?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.VBox?>
<VBox alignment="CENTER" prefWidth="640" prefHeight="480" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.xeres.ui.controller.qrcode.CameraWindowController">
<ImageView fx:id="capturedImage" fitWidth="640" fitHeight="480" pickOnBounds="true" preserveRatio="true"/>
<Label fx:id="error" visible="false"/>
</VBox>

0 comments on commit f0c51a5

Please sign in to comment.