Skip to content

Commit

Permalink
added hotkey to whisper helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Exslims committed Oct 24, 2017
1 parent 8fd6d33 commit 382ee03
Show file tree
Hide file tree
Showing 26 changed files with 48 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.mercury.platform.shared.config.MercuryConfigurationSource;
import com.mercury.platform.shared.hotkey.HotKeysInterceptor;
import com.mercury.platform.shared.store.MercuryStoreCore;
import com.mercury.platform.shared.wh.WhisperHelperHandler;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
Expand All @@ -29,6 +30,7 @@ public void startApplication() {
new SoundNotifier();
new ChatHelper();
new HotKeysInterceptor();
new WhisperHelperHandler();

Executor executor = Executors.newSingleThreadExecutor();
UpdateClientStarter updateClientStarter = new UpdateClientStarter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.mercury.platform.shared.config.descriptor.adr.AdrVisibleState;
import com.mercury.platform.shared.hotkey.HotKeysInterceptor;
import com.mercury.platform.shared.store.MercuryStoreCore;
import com.mercury.platform.shared.wh.WhisperHelperHandler;
import com.sun.jna.Native;
import com.sun.jna.platform.win32.User32;
import com.sun.jna.platform.win32.WinDef;
Expand All @@ -36,6 +37,7 @@ public void startApplication() {
new SoundNotifier();
new ChatHelper();
new HotKeysInterceptor();
new WhisperHelperHandler();

Executor executor = Executors.newSingleThreadExecutor();
UpdateClientStarter updateClientStarter = new UpdateClientStarter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public class NotificationSettingsDescriptor implements Serializable {
private boolean incNotificationEnable = true;
private boolean outNotificationEnable = true;
private boolean scannerNotificationEnable = true;
private boolean whisperHelperEnable = false;
private HotKeyDescriptor whisperHelperHotKey = new HotKeyDescriptor("Ctrl", 29, false, false, true);
private int limitCount = 3;
private int unfoldCount = 2;
private FlowDirections flowDirections = FlowDirections.DOWNWARDS;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package com.mercury.platform.shared.hotkey;


import com.mercury.platform.shared.config.descriptor.HotKeyDescriptor;
import com.mercury.platform.shared.store.MercuryStoreCore;
import org.jnativehook.keyboard.NativeKeyEvent;
import org.jnativehook.keyboard.NativeKeyListener;

import javax.swing.*;

public class MercuryNativeKeyListener implements NativeKeyListener {
private boolean menuPressed;
private boolean shiftPressed;
Expand Down Expand Up @@ -59,13 +56,7 @@ public void nativeKeyReleased(NativeKeyEvent nativeKeyEvent) {
}
}
if (!this.block) {
if (nativeKeyEvent.getKeyCode() == 29) {
Timer timer = new Timer(500, action -> {
MercuryStoreCore.tradeWhisperSubject.onNext(true);
});
timer.setRepeats(false);
timer.start();
}
MercuryStoreCore.hotKeyReleaseSubject.onNext(this.getDescriptor(nativeKeyEvent));
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.mercury.platform.shared.wh;

import com.mercury.platform.shared.config.Configuration;
import com.mercury.platform.shared.config.descriptor.NotificationSettingsDescriptor;
import com.mercury.platform.shared.store.MercuryStoreCore;

import javax.swing.*;

public class WhisperHelperHandler {
public WhisperHelperHandler() {
MercuryStoreCore.hotKeyReleaseSubject.subscribe(hotKeyDescriptor -> {
NotificationSettingsDescriptor config = Configuration.get().notificationConfiguration().get();
if (config.isWhisperHelperEnable() && config.getWhisperHelperHotKey().equals(hotKeyDescriptor)) {
Timer timer = new Timer(500, action -> {
MercuryStoreCore.tradeWhisperSubject.onNext(true);
});
timer.setRepeats(false);
timer.start();
}
});
}
}
3 changes: 0 additions & 3 deletions app-shared/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
<artifactId>app-shared</artifactId>
<version>1.0.0.5</version>
<packaging>jar</packaging>
<dependencies>

</dependencies>
<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,25 @@ public void focusLost(FocusEvent e) {

private JPanel getWhisperHelperPanel() {
JPanel root = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.ADR_BG);
root.add(this.componentsFactory.getTextLabel("When you release CTRL key clipboard content will be transferred to chat.", FontStyle.REGULAR, 16), BorderLayout.PAGE_START);

JPanel parametersPanel = this.componentsFactory.getJPanel(new GridLayout(2, 2), AppThemeColor.ADR_BG);
JCheckBox enableCheckbox = this.componentsFactory.getCheckBox(this.generalSnapshot.isWhisperHelperEnable());
enableCheckbox.addActionListener(action -> {
this.generalSnapshot.setWhisperHelperEnable(enableCheckbox.isSelected());
});
parametersPanel.add(this.componentsFactory.getTextLabel("Enabled:", FontStyle.REGULAR, 16));
parametersPanel.add(enableCheckbox);
parametersPanel.add(this.componentsFactory.getTextLabel("Hotkey:", FontStyle.REGULAR, 16));
parametersPanel.add(new HotKeyPanel(this.generalSnapshot.getWhisperHelperHotKey()));

JPanel showcasePanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.ADR_BG);
showcasePanel.add(this.componentsFactory.getTextLabel("When you release hotkey button clipboard content will be transferred to chat.", FontStyle.REGULAR, 16), BorderLayout.PAGE_START);
JLabel img = new JLabel();
img.setIcon(this.componentsFactory.getImage("app/whisper-helper.png"));
root.add(this.componentsFactory.wrapToSlide(img, AppThemeColor.ADR_BG, 4, 4, 4, 4), BorderLayout.CENTER);
root.add(this.componentsFactory.getTextLabel("Example: press CTRL => click on 'Whisper' button => release CTRL.", FontStyle.REGULAR, 16), BorderLayout.PAGE_END);
showcasePanel.add(this.componentsFactory.wrapToSlide(img, AppThemeColor.ADR_BG, 4, 4, 4, 4), BorderLayout.CENTER);
showcasePanel.add(this.componentsFactory.getTextLabel("Example: press hotkey button => click on 'Whisper' button => release hotkey button.", FontStyle.REGULAR, 16), BorderLayout.PAGE_END);
root.add(parametersPanel, BorderLayout.PAGE_START);
root.add(showcasePanel, BorderLayout.CENTER);
root.setVisible(false);
return root;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ private JPanel getOperationsButtons() {
JButton openTests = this.getOperationButton("Open tests", "app/open-tests.png");
openTests.addActionListener(action -> {
FramesManager.INSTANCE.hideFrame(SettingsFrame.class);
// FramesManager.INSTANCE.showFrame(TestCasesFrame.class);
FramesManager.INSTANCE.preShowFrame(TestCasesFrame.class);
FramesManager.INSTANCE.showFrame(TestCasesFrame.class);
// FramesManager.INSTANCE.preShowFrame(TestCasesFrame.class);
});
root.add(this.componentsFactory.wrapToSlide(openTutorial));
root.add(this.componentsFactory.wrapToSlide(checkUpdates));
Expand Down
Binary file added app-ui/src/main/resources/app/incoming_arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app-ui/src/main/resources/app/outgoing_arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app-ui/src/main/resources/app/pin_arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added app-ui/src/main/resources/app/whisper-helper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 382ee03

Please sign in to comment.