Skip to content

Commit

Permalink
Add options menu to chat overview sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
parg committed Jan 23, 2025
1 parent de4055e commit 36f3797
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 36 deletions.
16 changes: 12 additions & 4 deletions core/src/com/biglybt/plugin/net/buddy/BuddyPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,16 @@

private static final int FEED_UPDATE_MIN_MILLIS = 6*60*60*1000;

private static final String VIEW_ID = "azbuddy";
public static final String VIEW_ID = "azbuddy";

private static final boolean BETA_ENABLE_DEFAULT = true;

public static boolean
isBetaChatEnabled()
{
return( COConfigurationManager.getBooleanParameter( "Plugin.azbuddy.azbuddy.dchat.decentralized.enabled", BETA_ENABLE_DEFAULT ));
}

public static void
load(
PluginInterface plugin_interface )
Expand Down Expand Up @@ -451,9 +459,9 @@

// decentralised stuff


beta_enabled_param = config.addBooleanParameter2( "azbuddy.dchat.decentralized.enabled", "azbuddy.dchat.decentralized.enabled", true );

// this parameter is explicitly accessed above

beta_enabled_param = config.addBooleanParameter2( "azbuddy.dchat.decentralized.enabled", "azbuddy.dchat.decentralized.enabled", BETA_ENABLE_DEFAULT );

config.createGroup(
"azbuddy.dchat.decentralized",
Expand Down
7 changes: 7 additions & 0 deletions core/src/com/biglybt/plugin/net/buddy/BuddyPluginUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.biglybt.core.peer.util.PeerUtils;
import com.biglybt.core.torrent.TOTorrent;
import com.biglybt.core.util.*;
import com.biglybt.pif.Plugin;
import com.biglybt.pif.PluginInterface;
import com.biglybt.pif.download.Download;
import com.biglybt.pif.peers.Peer;
Expand Down Expand Up @@ -288,6 +289,12 @@
return( null );
}

public static boolean
isBetaChatEnabled()
{
return( BuddyPlugin.isBetaChatEnabled());
}

public static boolean
isBetaChatAvailable()
{
Expand Down
1 change: 1 addition & 0 deletions uis/src/com/biglybt/ui/swt/mdi/BaseMDI.java
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,7 @@ public boolean loadEntryByID(String id, boolean activate,
builder = vi.getBuilder(getDataSourceType(), id);
}
if (builder != null) {
builder.setInitialDatasource(datasource);
mdiEntry = createEntry(builder, true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
package com.biglybt.ui.swt.plugin.net.buddy.swt;

import java.net.InetSocketAddress;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.*;

Expand Down Expand Up @@ -72,7 +71,6 @@
import com.biglybt.ui.swt.imageloader.ImageLoader;
import com.biglybt.ui.swt.mainwindow.ClipboardCopy;
import com.biglybt.ui.swt.mainwindow.Colors;
import com.biglybt.ui.swt.plugin.net.buddy.*;
import com.biglybt.ui.swt.shells.MessageBoxShell;
import com.biglybt.ui.swt.utils.TagUIUtilsV3;

Expand Down Expand Up @@ -109,6 +107,7 @@
private CTabFolder tab_folder;

private CTabItem classic_item;
private CTabItem chat_item;

private boolean classic_enabled;
private boolean beta_enabled;
Expand Down Expand Up @@ -149,9 +148,9 @@
GridData grid_data = new GridData(GridData.FILL_BOTH);
tab_folder.setLayoutData(grid_data);

CTabItem beta_item = new CTabItem(tab_folder, SWT.NULL);
chat_item = new CTabItem(tab_folder, SWT.NULL);

beta_item.setText( lu.getLocalisedMessageText( "azbuddy.dchat.decentralized" ));
chat_item.setText( lu.getLocalisedMessageText( "azbuddy.dchat.decentralized" ));

ScrolledComposite beta_area = new ScrolledComposite( tab_folder, SWT.V_SCROLL | SWT.H_SCROLL );

Expand All @@ -160,7 +159,7 @@

beta_area.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

beta_item.setControl( beta_area );
chat_item.setControl( beta_area );

Composite beta_area_comp = new Composite( beta_area, SWT.NULL );

Expand Down Expand Up @@ -228,7 +227,7 @@ public void enabledStateChanged(boolean _classic_enabled, boolean _beta_enabled)

int sel = COConfigurationManager.getIntParameter( "buddy.plugin.ui.selected.tab", 0 );

tab_folder.setSelection(sel==0?beta_item:classic_item);
tab_folder.setSelection(sel==0?chat_item:classic_item);

tab_folder.addSelectionListener(
new SelectionAdapter(){
Expand All @@ -246,16 +245,15 @@ public void widgetSelected(SelectionEvent arg0){
protected void
selectClassicTab()
{
Utils.execSWTThread(
new Runnable() {

@Override
public void run() {
tab_folder.setSelection( classic_item );
}
});
Utils.execSWTThread(()->tab_folder.setSelection( classic_item ));
}

protected void
selectChatTab()
{
Utils.execSWTThread(()->tab_folder.setSelection( chat_item ));;
}

private void
createBeta(
Composite main )
Expand Down
23 changes: 20 additions & 3 deletions uis/src/com/biglybt/ui/swt/plugin/net/buddy/swt/FriendsView.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public class FriendsView implements UISWTViewCoreEventListener
{
public static final String VIEW_ID = "azbuddy";

public static final String DS_SELECT_CLASSIC_TAB = "SelectClassicTab";
public static final String DS_SELECT_CLASSIC_TAB = "SelectClassicTab";
public static final String DS_SELECT_CHAT_TAB = "SelectChatTab";
private BuddyPlugin plugin;
private UISWTInstance ui_instance;
private BuddyPluginView buddyPluginView;
Expand Down Expand Up @@ -97,6 +98,8 @@ public FriendsView() {

if (DS_SELECT_CLASSIC_TAB.equals(datasource)) {
current_instance.selectClassicTab();
}else if (DS_SELECT_CHAT_TAB.equals(datasource)) {
current_instance.selectChatTab();
}

break;
Expand All @@ -117,13 +120,27 @@ public FriendsView() {
break;
}
case UISWTViewEvent.TYPE_DATASOURCE_CHANGED: {
if (current_instance != null && DS_SELECT_CLASSIC_TAB.equals(datasource)) {
current_instance.selectClassicTab();
datasource = event.getData();
if ( current_instance != null ){
if (DS_SELECT_CLASSIC_TAB.equals(datasource)) {
current_instance.selectClassicTab();
}else if (DS_SELECT_CHAT_TAB.equals(datasource)) {
current_instance.selectChatTab();
}
}

break;
}
}

return true;
}

@Override
public boolean
informOfDuplicates(
int type )
{
return( type == UISWTViewEvent.TYPE_DATASOURCE_CHANGED );
}
}
61 changes: 46 additions & 15 deletions uis/src/com/biglybt/ui/swt/shells/main/MainMDISetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import com.biglybt.core.tracker.host.TRHostTorrent;
import com.biglybt.core.util.*;
import com.biglybt.pifimpl.local.PluginInitializer;
import com.biglybt.plugin.net.buddy.BuddyPlugin;
import com.biglybt.plugin.net.buddy.BuddyPluginBeta;
import com.biglybt.plugin.net.buddy.BuddyPluginBeta.ChatInstance;
import com.biglybt.plugin.net.buddy.BuddyPluginUtils;
Expand All @@ -66,6 +67,7 @@
import com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT;
import com.biglybt.ui.swt.pif.UISWTViewEventListener;
import com.biglybt.ui.swt.pifimpl.UISWTViewBuilderCore;
import com.biglybt.ui.swt.plugin.net.buddy.swt.FriendsView;
import com.biglybt.ui.swt.plugin.net.buddy.swt.SBC_ChatOverview;
import com.biglybt.ui.swt.shells.MessageBoxShell;
import com.biglybt.ui.swt.views.*;
Expand Down Expand Up @@ -168,6 +170,8 @@ public void parameterChanged(String parameterName) {
COConfigurationManager.addAndFireParameterListener(
"Beta Programme Enabled", configBetaEnabledListener);

PluginInterface pi = PluginInitializer.getDefaultInterface();

// Note: We don't use ViewManagerSWT because it adds a menu item, and we
// manually do that for StatsView and others
// ViewManagerSWT vi = ViewManagerSWT.getInstance();
Expand Down Expand Up @@ -615,7 +619,9 @@ public MdiEntry createMDiEntry(String id) {
}
});

mdi.registerEntry(MultipleDocumentInterface.SIDEBAR_SECTION_CHAT,
if ( BuddyPluginUtils.isBetaChatEnabled()){

mdi.registerEntry(MultipleDocumentInterface.SIDEBAR_SECTION_CHAT,
new MdiEntryCreationListener() {
@Override
public MdiEntry createMDiEntry(String id) {
Expand Down Expand Up @@ -685,10 +691,33 @@ public MdiEntry createMDiEntry(String id) {
MdiEntry mdi_entry = mdi.createEntryFromSkinRef(
MultipleDocumentInterface.SIDEBAR_HEADER_DISCOVERY,
MultipleDocumentInterface.SIDEBAR_SECTION_CHAT, "chatsview",
"{mdi.entry.chatsoverview}", title_info, null, true, MultipleDocumentInterface.SIDEBAR_SECTION_SUBSCRIPTIONS );
"{mdi.entry.chatsoverview}", title_info, null, false, MultipleDocumentInterface.SIDEBAR_SECTION_SUBSCRIPTIONS );

mdi_entry.setImageLeftID("image.sidebar.chat-overview");

String parentID = "sidebar." + MultipleDocumentInterface.SIDEBAR_SECTION_CHAT;

MenuManager menu_manager = pi.getUIManager().getMenuManager();

MenuItem mi = menu_manager.addMenuItem( parentID, "MainWindow.menu.view.configuration" );
mi.setDisposeWithUIDetach(UIInstance.UIT_SWT);

mi.addListener(
new MenuItemListener()
{
@Override
public void
selected(
MenuItem menu, Object target )
{
UIFunctions uif = UIFunctionsManager.getUIFunctions();

if ( uif != null ){

uif.getMDI().loadEntryByID( BuddyPlugin.VIEW_ID, true, false, FriendsView.DS_SELECT_CHAT_TAB );
}
}
});

final TimerEventPeriodic timer =
SimpleTimer.addPeriodicEvent(
Expand Down Expand Up @@ -741,7 +770,8 @@ public MdiEntry createMDiEntry(String id) {
return mdi_entry;
}
});

}

mdi.registerEntry(MultipleDocumentInterface.SIDEBAR_SECTION_ARCHIVED_DOWNLOADS,
new MdiEntryCreationListener() {
@Override
Expand Down Expand Up @@ -1251,7 +1281,6 @@ public boolean handleExternalRequest(InetSocketAddress client_address,
return null;
});

PluginInterface pi = PluginInitializer.getDefaultInterface();
try {
if ( !COConfigurationManager.getBooleanParameter( "my.shares.view.auto.open.done", false )){

Expand Down Expand Up @@ -1364,17 +1393,19 @@ public void selected(MenuItem menu, Object target) {
}
});

menuItem = uim.getMenuManager().addMenuItem(
MenuManager.MENU_MENUBAR, "chats.view.heading");
menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
menuItem.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
UIFunctionsManager.getUIFunctions().getMDI().showEntryByID(
MultipleDocumentInterface.SIDEBAR_SECTION_CHAT);
}
});

if ( BuddyPluginUtils.isBetaChatEnabled()){
menuItem = uim.getMenuManager().addMenuItem(
MenuManager.MENU_MENUBAR, "chats.view.heading");
menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
menuItem.addListener(new MenuItemListener() {
@Override
public void selected(MenuItem menu, Object target) {
UIFunctionsManager.getUIFunctions().getMDI().showEntryByID(
MultipleDocumentInterface.SIDEBAR_SECTION_CHAT);
}
});
}

menuItem = uim.getMenuManager().addMenuItem(
MenuManager.MENU_MENUBAR, "archivedlsview.view.heading");
menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
Expand Down

0 comments on commit 36f3797

Please sign in to comment.