-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd37e0a
commit d61f01f
Showing
6 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package kryptonbutterfly.totp.ui.qrexport; | ||
|
||
import java.awt.event.ActionEvent; | ||
import java.awt.event.KeyEvent; | ||
import java.awt.event.KeyListener; | ||
|
||
import kryptonbutterfly.totp.TinyTotp; | ||
import kryptonbutterfly.totp.ui.misc.KeyTypedAdapter; | ||
import kryptonbutterfly.util.swing.Logic; | ||
|
||
final class BL extends Logic<QrExportGui, Void> | ||
{ | ||
final KeyListener escapeListener = new KeyTypedAdapter(c -> ok(null), KeyEvent.VK_ESCAPE); | ||
|
||
BL(QrExportGui gui) | ||
{ | ||
super(gui); | ||
} | ||
|
||
void ok(ActionEvent ae) | ||
{ | ||
gui.if_(QrExportGui::dispose); | ||
} | ||
|
||
@Override | ||
protected void disposeAction() | ||
{ | ||
gui.if_(TinyTotp.windowStates.qrExport::persistBounds); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package kryptonbutterfly.totp.ui.qrexport; | ||
|
||
import java.awt.BorderLayout; | ||
import java.awt.FlowLayout; | ||
import java.awt.Window; | ||
import java.awt.image.BufferedImage; | ||
import java.util.function.Consumer; | ||
|
||
import javax.swing.ImageIcon; | ||
import javax.swing.JButton; | ||
import javax.swing.JLabel; | ||
import javax.swing.JPanel; | ||
|
||
import kryptonbutterfly.totp.TinyTotp; | ||
import kryptonbutterfly.totp.misc.Assets; | ||
import kryptonbutterfly.util.swing.ObservableDialog; | ||
import kryptonbutterfly.util.swing.events.GuiCloseEvent; | ||
|
||
@SuppressWarnings("serial") | ||
public class QrExportGui extends ObservableDialog<BL, Void, Void> | ||
{ | ||
private final JButton btnOk = new JButton("ok"); | ||
|
||
public QrExportGui( | ||
Window owner, | ||
ModalityType modality, | ||
Consumer<GuiCloseEvent<Void>> closeListener, | ||
BufferedImage qr) | ||
{ | ||
super(owner, modality, closeListener); | ||
TinyTotp.windowStates.qrExport.setBounds(this); | ||
setTitle("Export Secret"); | ||
setIconImage(Assets.getQr16ByBackground(getBackground()).getImage()); | ||
|
||
add(new JLabel(new ImageIcon(qr)), BorderLayout.CENTER); | ||
|
||
final var footerPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); | ||
add(footerPanel, BorderLayout.SOUTH); | ||
footerPanel.add(btnOk); | ||
|
||
businessLogic.if_(this::init); | ||
|
||
setVisible(true); | ||
} | ||
|
||
@Override | ||
protected BL createBusinessLogic(Void args) | ||
{ | ||
return new BL(this); | ||
} | ||
|
||
private void init(BL bl) | ||
{ | ||
btnOk.addActionListener(bl::ok); | ||
btnOk.addKeyListener(bl.escapeListener); | ||
} | ||
} |