@Meta(description = "The external viewer for non-images documents (or empty to use the system default program for the given file type)",//
format = Format.STRING)
NON_IMAGES_DOCUMENT_READER, //
+ //
+ // GUI settings (hidden in config)
+ //
+ @Meta(description = "Show the side panel by default",//
+ format = Format.BOOLEAN, def = "true")
+ SHOW_SIDE_PANEL, //
+ @Meta(description = "Show the details panel by default",//
+ format = Format.BOOLEAN, def = "true")
+ SHOW_DETAILS_PANEL, //
+ @Meta(description = "Show thumbnails by default in the books view",//
+ format = Format.BOOLEAN, def = "false")
+ SHOW_THUMBNAILS, //
+ //
+ // Deprecated
+ //
@Meta(description = "The background colour of the library if you don't like the default system one",//
hidden = true, format = Format.COLOR)
+ @Deprecated
BACKGROUND_COLOR, //
}
private Map<BookInfo, BookLine> books = new HashMap<BookInfo, BookLine>();
private boolean seeWordCount;
- private boolean listMode;
+ private boolean showThumbnails;
private JList6<BookInfo> list;
private ListModel<BookInfo> data;
private ReloadData lastLoad = new ReloadData();
- public BooksPanel(boolean listMode) {
+ public BooksPanel(boolean showThumbnails) {
setLayout(new BorderLayout());
final SearchBar search = new SearchBar();
bookCoverUpdater.start();
list = initList();
- setListMode(listMode);
+ setShowThumbnails(showThumbnails);
add(UIUtils.scroll(list, false), BorderLayout.CENTER);
}
boolean cellHasFocus) {
BookLine book = books.get(value);
if (book == null) {
- if (listMode) {
+ if (!showThumbnails) {
book = new BookLine(value, seeWordCount);
} else {
book = new BookBlock(value, seeWordCount);
});
}
- public boolean isListMode() {
- return listMode;
+ public boolean isShowThumbnails() {
+ return showThumbnails;
}
- public void setListMode(boolean listMode) {
- this.listMode = listMode;
+ public void setShowThumbnails(boolean showThumbnails) {
+ this.showThumbnails = showThumbnails;
books.clear();
list.setLayoutOrientation(
- listMode ? JList6.VERTICAL : JList6.HORIZONTAL_WRAP);
+ showThumbnails ? JList6.HORIZONTAL_WRAP : JList6.VERTICAL);
StringBuilder longString = new StringBuilder();
for (int i = 0; i < 20; i++) {
longString.append(
"Some long string, which is 50 chars long itself...");
}
- if (listMode) {
+ if (!showThumbnails) {
bookCoverUpdater.clear();
Dimension sz = new BookLine(
BookInfo.fromSource(null, longString.toString()), true)
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
private boolean detailsPanel;
private Runnable onCrumbsbreadChange;
- public MainFrame(boolean sidePanel, boolean detailsPanel) {
+ public MainFrame() {
super("Fanfix " + Version.getCurrentVersion());
if (importer == null) {
});
browser = new BrowserPanel();
- books = new BooksPanel(true); // TODO: very slow here!!
+ books = new BooksPanel(Instance.getInstance().getUiConfig()
+ .getBoolean(UiConfig.SHOW_THUMBNAILS, false));
details = new DetailsPanel();
goBack = new BreadCrumbsPanel();
}
});
+ // Check config
+ boolean sidePanel = Instance.getInstance().getUiConfig()
+ .getBoolean(UiConfig.SHOW_SIDE_PANEL, true);
+ boolean detailsPanel = Instance.getInstance().getUiConfig()
+ .getBoolean(UiConfig.SHOW_DETAILS_PANEL, true);
+
// To force an update
this.sidePanel = !sidePanel;
this.detailsPanel = !detailsPanel;
final JMenuItem mnuListMode = new JCheckBoxMenuItem("Show thumbnails");
mnuListMode.setMnemonic(KeyEvent.VK_T);
- mnuListMode.setSelected(!books.isListMode());
+ mnuListMode.setSelected(books.isShowThumbnails());
mnuListMode.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- books.setListMode(!books.isListMode());
- mnuListMode.setSelected(!books.isListMode());
+ boolean newValue = !books.isShowThumbnails();
+ books.setShowThumbnails(newValue);
+ mnuListMode.setSelected(newValue);
+
+ saveConfig(UiConfig.SHOW_THUMBNAILS, newValue);
}
});
mnuSidePane.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- setSidePanel(!sidePanel);
- mnuSidePane.setSelected(sidePanel);
+ boolean newValue = !sidePanel;
+ setSidePanel(newValue);
+ mnuSidePane.setSelected(newValue);
+
+ saveConfig(UiConfig.SHOW_SIDE_PANEL, newValue);
}
});
mnuDetailsPane.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- setDetailsPanel(!detailsPanel);
- mnuDetailsPane.setSelected(detailsPanel);
+ boolean newValue = !detailsPanel;
+ setDetailsPanel(newValue);
+ mnuDetailsPane.setSelected(newValue);
+
+ saveConfig(UiConfig.SHOW_DETAILS_PANEL, newValue);
}
});
return bar;
}
+ private void saveConfig(UiConfig option, boolean value) {
+ Instance.getInstance().getUiConfig().setBoolean(option, value);
+ try {
+ Instance.getInstance().getUiConfig().updateFile();
+ } catch (IOException ioe) {
+ Instance.getInstance().getTraceHandler().error(
+ new IOException("Cannot save configuration file", ioe));
+ }
+ }
+
private void setMode(boolean sidePanel, boolean detailsPanel) {
if (this.sidePanel == sidePanel && this.detailsPanel == detailsPanel) {
return;