https://github.com/tonikelope/megabasterd/issues/437 (EXPERIMENTAL FOR IMAGES AND VIDEOS)

Thumbnails optional in Settings>Uploads (default=true)
This commit is contained in:
tonikelope 2023-01-06 13:54:02 +01:00
parent a849975141
commit 6dfe097b22
4 changed files with 72 additions and 23 deletions

View File

@ -971,6 +971,7 @@ public class LabelTranslatorSingleton {
_addTranslation("Use multi slot download mode", "Utilizar descarga multi slot");
_addTranslation("Selecting file...", "Seleccionando archivo...");
_addTranslation("Copy folder link", "Copiar enlace de carpeta");
_addTranslation("Open folder in browser", "Abrir carpeta en navegador");
_addTranslation("Limit download speed", "Limitar velocidad de descarga");
_addTranslation("REMOVE THIS", "QUITAR ESTO");
_addTranslation("Copy file link", "Copiar enlace de archivo");

View File

@ -9,6 +9,7 @@
*/
package com.tonikelope.megabasterd;
import static com.tonikelope.megabasterd.MainPanel.THREAD_POOL;
import static com.tonikelope.megabasterd.MainPanel.VERSION;
import java.awt.Component;
import java.awt.Container;
@ -1200,24 +1201,25 @@ public class MiscTools {
}
public static void openBrowserURL(final String url) {
THREAD_POOL.execute(() -> {
try {
Logger.getLogger(MiscTools.class.getName()).log(Level.INFO, "Trying to open URL in external browser: {0}", url);
try {
Logger.getLogger(MiscTools.class.getName()).log(Level.INFO, "Trying to open URL in external browser: {0}", url);
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
Desktop.getDesktop().browse(new URI(url));
return;
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
Desktop.getDesktop().browse(new URI(url));
return;
}
if (System.getProperty("os.name").toLowerCase().contains("nux")) {
Process p = Runtime.getRuntime().exec(new String[]{"xdg-open", url});
p.waitFor();
p.destroy();
return;
}
Logger.getLogger(MiscTools.class.getName()).log(Level.WARNING, "Unable to open URL: Unsupported platform.", url);
} catch (Exception ex) {
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, ex.getMessage());
}
if (System.getProperty("os.name").toLowerCase().contains("nux")) {
Process p = Runtime.getRuntime().exec(new String[]{"xdg-open", url});
p.waitFor();
p.destroy();
return;
}
Logger.getLogger(MiscTools.class.getName()).log(Level.WARNING, "Unable to open URL: Unsupported platform.", url);
} catch (Exception ex) {
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, ex.getMessage());
}
});
}
public static byte[] recReverseArray(byte[] arr, int start, int end) {

View File

@ -31,9 +31,11 @@
<Component id="progress_pbar" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="file_size_label" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="open_browser_button" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="folder_link_button" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="file_link_button" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
@ -108,10 +110,11 @@
<Component id="folder_link_button" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="file_link_button" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="file_size_label" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="open_browser_button" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="progress_pbar" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="speed_label" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="pause_button" alignment="3" min="-2" max="-2" attributes="0"/>
@ -375,5 +378,23 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="queue_bottom_buttonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="open_browser_button">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="16" style="1"/>
</Property>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/images/icons8-export-30.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Open folder in browser"/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Cursor de Mano"/>
</Property>
<Property name="doubleBuffered" type="boolean" value="true"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="open_browser_buttonActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@ -97,6 +97,10 @@ public class UploadView extends javax.swing.JPanel implements TransferenceView {
return folder_link_button;
}
public JButton getOpen_browser_button() {
return open_browser_button;
}
public JLabel getStatus_label() {
return status_label;
}
@ -168,6 +172,7 @@ public class UploadView extends javax.swing.JPanel implements TransferenceView {
cbc_label = new javax.swing.JLabel();
queue_top_button = new javax.swing.JButton();
queue_bottom_button = new javax.swing.JButton();
open_browser_button = new javax.swing.JButton();
setBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 204, 255), 3, true));
@ -311,6 +316,17 @@ public class UploadView extends javax.swing.JPanel implements TransferenceView {
}
});
open_browser_button.setFont(new java.awt.Font("Dialog", 1, 16)); // NOI18N
open_browser_button.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons8-export-30.png"))); // NOI18N
open_browser_button.setText("Open folder in browser");
open_browser_button.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
open_browser_button.setDoubleBuffered(true);
open_browser_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
open_browser_buttonActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@ -321,9 +337,11 @@ public class UploadView extends javax.swing.JPanel implements TransferenceView {
.addComponent(progress_pbar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(file_size_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(6, 6, 6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(open_browser_button)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(folder_link_button)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(file_link_button))
.addGroup(layout.createSequentialGroup()
.addComponent(file_name_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
@ -383,10 +401,11 @@ public class UploadView extends javax.swing.JPanel implements TransferenceView {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(folder_link_button)
.addComponent(file_link_button)
.addComponent(file_size_label))
.addComponent(file_size_label)
.addComponent(open_browser_button, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(progress_pbar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(speed_label)
.addComponent(pause_button))
@ -522,6 +541,11 @@ public class UploadView extends javax.swing.JPanel implements TransferenceView {
});
}//GEN-LAST:event_queue_bottom_buttonActionPerformed
private void open_browser_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_open_browser_buttonActionPerformed
// TODO add your handling code here:
MiscTools.openBrowserURL(_upload.getFolder_link());
}//GEN-LAST:event_open_browser_buttonActionPerformed
public void updateCBC(String status) {
MiscTools.GUIRunAndWait(() -> {
@ -674,6 +698,7 @@ public class UploadView extends javax.swing.JPanel implements TransferenceView {
private javax.swing.JLabel file_name_label;
private javax.swing.JLabel file_size_label;
private javax.swing.JButton folder_link_button;
private javax.swing.JButton open_browser_button;
private javax.swing.JButton pause_button;
private javax.swing.JProgressBar progress_pbar;
private javax.swing.JButton queue_bottom_button;