mirror of https://github.com/laurent22/joplin.git
Switched to using properties
parent
1abab26041
commit
30480a8029
|
@ -38,7 +38,7 @@ class AppGui {
|
||||||
this.renderer_ = new Renderer(this.term(), this.rootWidget_);
|
this.renderer_ = new Renderer(this.term(), this.rootWidget_);
|
||||||
|
|
||||||
this.renderer_.on('renderDone', async (event) => {
|
this.renderer_.on('renderDone', async (event) => {
|
||||||
if (this.widget('console').hasFocus()) this.widget('console').resetCursor();
|
if (this.widget('console').hasFocus) this.widget('console').resetCursor();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.app_.on('modelAction', async (event) => {
|
this.app_.on('modelAction', async (event) => {
|
||||||
|
@ -58,9 +58,9 @@ class AppGui {
|
||||||
this.rootWidget_.name = 'root';
|
this.rootWidget_.name = 'root';
|
||||||
|
|
||||||
const folderList = new FolderListWidget();
|
const folderList = new FolderListWidget();
|
||||||
folderList.setStyle({ borderBottomWidth: 1 });
|
folderList.style = { borderBottomWidth: 1 };
|
||||||
folderList.name = 'folderList';
|
folderList.name = 'folderList';
|
||||||
folderList.setVStretch(true);
|
folderList.vStretch = true;
|
||||||
folderList.on('currentItemChange', async () => {
|
folderList.on('currentItemChange', async () => {
|
||||||
const folder = folderList.currentItem;
|
const folder = folderList.currentItem;
|
||||||
this.store_.dispatch({
|
this.store_.dispatch({
|
||||||
|
@ -77,20 +77,20 @@ class AppGui {
|
||||||
|
|
||||||
const noteList = new ListWidget();
|
const noteList = new ListWidget();
|
||||||
noteList.items = [];
|
noteList.items = [];
|
||||||
noteList.setItemRenderer((note) => {
|
noteList.itemRenderer = (note) => {
|
||||||
let label = note.title;
|
let label = note.title;
|
||||||
if (note.is_todo) {
|
if (note.is_todo) {
|
||||||
label = '[' + (note.todo_completed ? 'X' : ' ') + '] ' + label;
|
label = '[' + (note.todo_completed ? 'X' : ' ') + '] ' + label;
|
||||||
}
|
}
|
||||||
return label;
|
return label;
|
||||||
});
|
};
|
||||||
noteList.name = 'noteList';
|
noteList.name = 'noteList';
|
||||||
noteList.setVStretch(true);
|
noteList.vStretch = true;
|
||||||
noteList.setStyle({
|
noteList.style = {
|
||||||
borderBottomWidth: 1,
|
borderBottomWidth: 1,
|
||||||
borderLeftWidth: 1,
|
borderLeftWidth: 1,
|
||||||
borderRightWidth: 1,
|
borderRightWidth: 1,
|
||||||
});
|
};
|
||||||
noteList.on('currentItemChange', async () => {
|
noteList.on('currentItemChange', async () => {
|
||||||
let note = noteList.currentItem;
|
let note = noteList.currentItem;
|
||||||
this.store_.dispatch({
|
this.store_.dispatch({
|
||||||
|
@ -106,15 +106,15 @@ class AppGui {
|
||||||
});
|
});
|
||||||
|
|
||||||
const noteText = new NoteWidget();
|
const noteText = new NoteWidget();
|
||||||
noteText.setVStretch(true);
|
noteText.vStretch = true;
|
||||||
noteText.name = 'noteText';
|
noteText.name = 'noteText';
|
||||||
noteText.setStyle({ borderBottomWidth: 1 });
|
noteText.style = { borderBottomWidth: 1 };
|
||||||
this.rootWidget_.connect(noteText, (state) => {
|
this.rootWidget_.connect(noteText, (state) => {
|
||||||
return { noteId: state.selectedNoteId };
|
return { noteId: state.selectedNoteId };
|
||||||
});
|
});
|
||||||
|
|
||||||
const consoleWidget = new ConsoleWidget();
|
const consoleWidget = new ConsoleWidget();
|
||||||
consoleWidget.setHStretch(true);
|
consoleWidget.hStretch = true;
|
||||||
consoleWidget.name = 'console';
|
consoleWidget.name = 'console';
|
||||||
consoleWidget.on('accept', (event) => {
|
consoleWidget.on('accept', (event) => {
|
||||||
this.processCommand(event.input, 'console');
|
this.processCommand(event.input, 'console');
|
||||||
|
@ -167,7 +167,7 @@ class AppGui {
|
||||||
shortcuts['ENTER'] = {
|
shortcuts['ENTER'] = {
|
||||||
description: null,
|
description: null,
|
||||||
action: () => {
|
action: () => {
|
||||||
const w = this.widget('mainWindow').focusedWidget();
|
const w = this.widget('mainWindow').focusedWidget;
|
||||||
if (w.name == 'folderList') {
|
if (w.name == 'folderList') {
|
||||||
this.widget('noteList').focus();
|
this.widget('noteList').focus();
|
||||||
} else if (w.name == 'noteList') {
|
} else if (w.name == 'noteList') {
|
||||||
|
@ -220,7 +220,7 @@ class AppGui {
|
||||||
|
|
||||||
let constraints = {
|
let constraints = {
|
||||||
type: 'fixed',
|
type: 'fixed',
|
||||||
factor: !doMaximize ? 5 : this.widget('vLayout').height() - 4,
|
factor: !doMaximize ? 5 : this.widget('vLayout').height - 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
consoleWidget.isMaximized__ = doMaximize;
|
consoleWidget.isMaximized__ = doMaximize;
|
||||||
|
@ -262,7 +262,7 @@ class AppGui {
|
||||||
}
|
}
|
||||||
|
|
||||||
activeListItem() {
|
activeListItem() {
|
||||||
const widget = this.widget('mainWindow').focusedWidget();
|
const widget = this.widget('mainWindow').focusedWidget;
|
||||||
if (!widget) return null;
|
if (!widget) return null;
|
||||||
|
|
||||||
if (widget.name == 'noteList' || widget.name == 'folderList') {
|
if (widget.name == 'noteList' || widget.name == 'folderList') {
|
||||||
|
@ -366,7 +366,7 @@ class AppGui {
|
||||||
|
|
||||||
// Don't process shortcut keys if the console is active, except if the shortcut
|
// Don't process shortcut keys if the console is active, except if the shortcut
|
||||||
// starts with CTRL (eg. CTRL+J CTRL+Z to maximize the console window).
|
// starts with CTRL (eg. CTRL+J CTRL+Z to maximize the console window).
|
||||||
if (!consoleWidget.hasFocus() || this.currentShortcutKeys_.indexOf('CTRL') === 0) {
|
if (!consoleWidget.hasFocus || this.currentShortcutKeys_.indexOf('CTRL') === 0) {
|
||||||
this.logger().debug('Now: ' + name + ', Keys: ' + this.currentShortcutKeys_);
|
this.logger().debug('Now: ' + name + ', Keys: ' + this.currentShortcutKeys_);
|
||||||
|
|
||||||
if (this.currentShortcutKeys_ in this.shortcuts_) {
|
if (this.currentShortcutKeys_ in this.shortcuts_) {
|
||||||
|
|
|
@ -7,9 +7,9 @@ class FolderListWidget extends ListWidget {
|
||||||
super();
|
super();
|
||||||
this.selectedFolderId_ = 0;
|
this.selectedFolderId_ = 0;
|
||||||
|
|
||||||
this.setItemRenderer((item) => {
|
this.itemRenderer = (item) => {
|
||||||
return item.title;
|
return item.title;
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
get selectedFolderId() {
|
get selectedFolderId() {
|
||||||
|
|
|
@ -6,9 +6,9 @@ class NoteListWidget extends ListWidget {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.selectedNoteId_ = 0;
|
this.selectedNoteId_ = 0;
|
||||||
this.setItemRenderer((item) => {
|
this.itemRenderer = (item) => {
|
||||||
return item.title;
|
return item.title;
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
get selectedNoteId() {
|
get selectedNoteId() {
|
||||||
|
|
|
@ -20,7 +20,7 @@ class NoteWidget extends TextWidget {
|
||||||
this.invalidate();
|
this.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
async willRender() {
|
async onWillRender() {
|
||||||
if (!this.note_ && this.noteId_) {
|
if (!this.note_ && this.noteId_) {
|
||||||
this.note_ = await Note.load(this.noteId_);
|
this.note_ = await Note.load(this.noteId_);
|
||||||
this.text = this.note_.title + "\n\n" + this.note_.body;
|
this.text = this.note_.title + "\n\n" + this.note_.body;
|
||||||
|
|
Loading…
Reference in New Issue