Hide to tray bug fixed

This commit is contained in:
tonikelope 2016-09-29 23:45:09 +02:00
parent 29d201f051
commit 2c84f60782
8 changed files with 45 additions and 48 deletions

4
.gitignore vendored
View File

@ -6,11 +6,9 @@ dist/
nbdist/
nbactions.xml
nb-configuration.xml
megabasterd.db
*.class
*.jar
*.war
*.ear

View File

@ -97,6 +97,11 @@ public final class Download implements Transference, Runnable, SecureNotifiable
private long _last_chunk_id_dispatched;
public Download(MainPanel main_panel, String url, String download_path, String file_name, String file_key, Long file_size, String file_pass, String file_noexpire, boolean use_slots, int slots, boolean restart) {
_view = null; //Lazy init (getter!)
_speed_meter = null; //Lazy init (getter!)
_progress_meter = null; //Lazy init (getter!)
_paused_workers = 0;
_last_chunk_id_dispatched = 0L;
_status_error = false;
@ -126,10 +131,6 @@ public final class Download implements Transference, Runnable, SecureNotifiable
_partialProgressQueue = new ConcurrentLinkedQueue();
_rejectedChunkIds = new ConcurrentLinkedQueue();
_thread_pool = newCachedThreadPool();
_view = null; //Lazy init (getter!)
_speed_meter = null; //Lazy init (getter!)
_progress_meter = null; //Lazy init (getter!)
}

View File

@ -14,7 +14,7 @@ public final class DownloadManager extends TransferenceManager {
public DownloadManager(MainPanel main_panel) {
super(main_panel, main_panel.getView().jPanel_scroll_down);
super(main_panel, main_panel.getView().getjPanel_scroll_down());
}
public void remove(Download download) {

View File

@ -4,7 +4,6 @@ import java.awt.AWTException;
import static java.awt.EventQueue.invokeLater;
import java.awt.Font;
import static java.awt.Font.BOLD;
import static java.awt.Frame.NORMAL;
import java.awt.Image;
import java.awt.MenuItem;
import java.awt.PopupMenu;
@ -17,7 +16,6 @@ import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import static java.awt.event.WindowEvent.WINDOW_CLOSING;
import java.io.File;
import java.io.IOException;
import static java.lang.Integer.parseInt;
@ -57,13 +55,14 @@ import static megabasterd.Transference.MAX_TRANSFERENCE_SPEED_DEFAULT;
*/
public final class MainPanel {
public static final String VERSION="1.0";
public static final String VERSION="1.1";
public static final String LOCK_FILE="megabasterd.lock";
public static final String USER_AGENT="Mozilla/5.0 (X11; Linux x86_64; rv:48.0) Gecko/20100101 Firefox/48.0";
public static final int CONNECTION_TIMEOUT = 30000;
public static final int THROTTLE_SLICE_SIZE=16*1024;
public static final ExecutorService THREAD_POOL = newCachedThreadPool();
public static final Font FONT_DEFAULT = createAndRegisterFont("Gochi.ttf");
public static void main(String args[]) {
setNimbusLookAndFeel();
@ -73,7 +72,6 @@ public final class MainPanel {
invokeLater(new Runnable() {
@Override
public void run() {
main_panel.getView().setVisible(true);
}
});
@ -92,8 +90,11 @@ public final class MainPanel {
private TrayIcon _trayicon;
private final ClipboardSpy _clipboardspy;
private KissVideoStreamServer _streamserver;
public MainPanel() {
_view = null; //Lazy init (getter!)
checkAppIsRunning();
try {
@ -112,8 +113,6 @@ public final class MainPanel {
getLogger(MainPanel.class.getName()).log(SEVERE, null, ex);
}
_view = null; //Lazy init (getter!)
loadUserSettings();
_mega_active_accounts = new HashMap<>();
@ -144,6 +143,7 @@ public final class MainPanel {
}
public MainPanelView getView() {
return _view == null?(_view = new MainPanelView(this)):_view;
}
@ -479,7 +479,7 @@ public final class MainPanel {
menu.setFont(FONT_DEFAULT.deriveFont(BOLD, 18));
final javax.swing.JFrame myframe = getView();
final MainPanelView myframe = getView();
MenuItem messageItem = new MenuItem("Restore window");
@ -488,9 +488,10 @@ public final class MainPanel {
@Override
public void actionPerformed(ActionEvent e) {
swingReflectionInvokeAndWait("setExtendedState", myframe, NORMAL);
swingReflectionInvokeAndWait("setExtendedState", myframe, javax.swing.JFrame.NORMAL);
swingReflectionInvokeAndWait("setVisible", myframe, true);
swingReflectionInvoke("setVisible", myframe, true);
}
});
@ -517,13 +518,13 @@ public final class MainPanel {
if(!(boolean)swingReflectionInvokeAndWaitForReturn("isVisible", myframe))
{
swingReflectionInvokeAndWait("setExtendedState", myframe, NORMAL);
swingReflectionInvokeAndWait("setExtendedState", myframe, javax.swing.JFrame.NORMAL);
swingReflectionInvoke("setVisible", myframe, true);
swingReflectionInvokeAndWait("setVisible", myframe, true);
}
else
{
swingReflectionInvoke("dispatchEvent", myframe, new WindowEvent(myframe, WINDOW_CLOSING));
swingReflectionInvoke("dispatchEvent", myframe, new WindowEvent(myframe, WindowEvent.WINDOW_CLOSING));
}

View File

@ -211,9 +211,6 @@
</Property>
<Property name="doubleBuffered" type="boolean" value="true"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="kiss_server_status">
<Properties>
@ -314,9 +311,6 @@
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel_scroll_down">
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
<Property name="axis" type="int" value="1"/>
@ -424,9 +418,6 @@
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel_scroll_up">
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
<Property name="axis" type="int" value="1"/>

View File

@ -62,7 +62,7 @@ public final class MainPanelView extends javax.swing.JFrame {
return close_all_finished_down_button;
}
public JButton getClose_all_finished_up() {
public JButton getClose_all_finished_up_button() {
return close_all_finished_up_button;
}
@ -118,6 +118,8 @@ public final class MainPanelView extends javax.swing.JFrame {
public MainPanelView(MainPanel main_panel) {
System.out.println("Main panel view constructor!! ");
initComponents();
_main_panel = main_panel;
@ -154,7 +156,9 @@ public final class MainPanelView extends javax.swing.JFrame {
swingReflectionInvoke("setForeground", global_speed_down_label, getMain_panel().isLimit_download_speed()?new Color(255,0,0):new Color(0,128,255));
swingReflectionInvoke("setForeground", global_speed_up_label, getMain_panel().isLimit_upload_speed()?new Color(255,0,0):new Color(0,128,255));
swingReflectionInvoke("setVisible", close_all_finished_down_button, false);
swingReflectionInvoke("setVisible", close_all_finished_up_button, false);
swingReflectionInvoke("setVisible", pause_all_down_button, false);
swingReflectionInvoke("setVisible", pause_all_up_button, false);
swingReflectionInvoke("setEnabled", clean_all_down_menu, false);
swingReflectionInvoke("setEnabled", clean_all_up_menu, false);
@ -647,14 +651,12 @@ public final class MainPanelView extends javax.swing.JFrame {
}//GEN-LAST:event_settings_menuActionPerformed
private void hide_tray_menuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hide_tray_menuActionPerformed
dispatchEvent(new WindowEvent(this, WINDOW_CLOSING));
}//GEN-LAST:event_hide_tray_menuActionPerformed
private void about_menuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_about_menuActionPerformed
AboutDialog dialog = new AboutDialog(this, true);
swingReflectionInvokeAndWait("setLocationRelativeTo", dialog, this);
@ -883,8 +885,8 @@ public final class MainPanelView extends javax.swing.JFrame {
private javax.swing.JLabel global_speed_up_label;
private javax.swing.JMenu help_menu;
private javax.swing.JMenuItem hide_tray_menu;
protected javax.swing.JPanel jPanel_scroll_down;
protected javax.swing.JPanel jPanel_scroll_up;
private javax.swing.JPanel jPanel_scroll_down;
private javax.swing.JPanel jPanel_scroll_up;
private javax.swing.JScrollPane jScrollPane_down;
private javax.swing.JScrollPane jScrollPane_up;
private javax.swing.JPopupMenu.Separator jSeparator1;
@ -895,7 +897,7 @@ public final class MainPanelView extends javax.swing.JFrame {
private javax.swing.JPopupMenu.Separator jSeparator6;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JLabel kiss_server_status;
protected javax.swing.JLabel logo_label;
private javax.swing.JLabel logo_label;
private javax.swing.JMenuBar main_menubar;
private javax.swing.JMenuItem new_download_menu;
private javax.swing.JMenuItem new_stream_menu;

View File

@ -80,7 +80,13 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
private final String _folder_link;
private final boolean _use_slots;
private final boolean _restart;
public Upload(MainPanel main_panel, MegaAPI ma, String filename, String parent_node, int[] ul_key, String ul_url, String root_node, byte[] share_key, String folder_link, boolean use_slots, int slots, boolean restart) {
_view = null; //Lazy init (getter!)
_speed_meter = null; //Lazy init (getter!)
_progress_meter = null; //Lazy init (getter!)
_saved_file_mac = new int[]{0, 0, 0, 0};
_notified = false;
_provision_ok = true;
@ -101,9 +107,7 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
_partialProgressQueue = new ConcurrentLinkedQueue();
_rejectedChunkIds = new ConcurrentLinkedQueue();
_thread_pool = Executors.newCachedThreadPool();
_view = null; //Lazy init (getter!)
_speed_meter = null; //Lazy init (getter!)
_progress_meter = null; //Lazy init (getter!)
}
public String getDir_name() {
@ -473,7 +477,7 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
getView().pause();
}
_main_panel.getUpload_manager().secureNotify();
getMain_panel().getUpload_manager().secureNotify();
}
@Override
@ -491,9 +495,9 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
@Override
public void close() {
_main_panel.getUpload_manager().getTransference_remove_queue().add(this);
getMain_panel().getUpload_manager().getTransference_remove_queue().add(this);
_main_panel.getUpload_manager().secureNotify();
getMain_panel().getUpload_manager().secureNotify();
}
@Override
@ -842,9 +846,9 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
getMain_panel().getUpload_manager().getTransference_finished_queue().add(this);
getMain_panel().getView().jPanel_scroll_up.remove(getView());
getMain_panel().getUpload_manager().getScroll_panel().remove(getView());
getMain_panel().getView().jPanel_scroll_up.add(getView());
getMain_panel().getUpload_manager().getScroll_panel().add(getView());
getMain_panel().getUpload_manager().secureNotify();
}
@ -930,9 +934,9 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
getMain_panel().getUpload_manager().getTransference_finished_queue().add(this);
_main_panel.getView().jPanel_scroll_up.remove(getView());
getMain_panel().getUpload_manager().getScroll_panel().remove(getView());
_main_panel.getView().jPanel_scroll_up.add(getView());
getMain_panel().getUpload_manager().getScroll_panel().add(getView());
getMain_panel().getUpload_manager().secureNotify();

View File

@ -19,7 +19,7 @@ public final class UploadManager extends TransferenceManager {
public UploadManager(MainPanel main_panel) {
super(main_panel, main_panel.getView().jPanel_scroll_up);
super(main_panel, main_panel.getView().getjPanel_scroll_up());
}
public void provision(Upload upload)
@ -157,7 +157,7 @@ public final class UploadManager extends TransferenceManager {
}
}
checkButtonsAndMenus(getMain_panel().getView().getClose_all_finished_up(), getMain_panel().getView().getPause_all_up(), getMain_panel().getView().getNew_upload_menu(), getMain_panel().getView().getClean_all_up_menu());
checkButtonsAndMenus(getMain_panel().getView().getClose_all_finished_up_button(), getMain_panel().getView().getPause_all_up(), getMain_panel().getView().getNew_upload_menu(), getMain_panel().getView().getClean_all_up_menu());
secureWait();
}