Пример #1
0
    def __init__(self, parent):
        super().__init__(parent)
        self.fullscreen = False
        self.setDisabled(True)

        hotkeypairs = (
            ('home', self.goto_index),
            ('toggle fullscreen', self.toggle_fullscreen),
            ('zoom in', self.zoom_in),
            ('zoom out', self.zoom_out),
            ('reset zoom', self.zoom_reset)
        )
        self.hotkeys = {
            key: QtGui.QShortcut(QtGui.QKeySequence(), self, callback)
            for key, callback in hotkeypairs
        }

        self.template = read_file(local_path(join('templates', 'viewer_page_template.html')))
        self.css = "" # Is set every time the config is reloaded
        self.rawtext = ""
        self.formatconverters = []
        self.chapterstrings = []

        # Layout
        layout = QtGui.QVBoxLayout(self)
        kill_theming(layout)

        self.webview = QtWebKit.QWebView(self)
        layout.addWidget(self.webview)
        layout.setStretchFactor(self.webview, 1)
        self.webview.settings().setDefaultTextEncoding('utf-8')

        self.info_panel = InfoPanel(self)
        layout.addWidget(self.info_panel, 0)
Пример #2
0
Файл: urd.py Проект: nycz/urd
    def __init__(self, file_to_open=""):
        super().__init__()
        self.setWindowTitle("New file")

        self.force_quit_flag = False

        self.config = read_config()
        self.setStyleSheet("background: " + self.config["theme"]["background"])

        layout = QtGui.QVBoxLayout(self)
        common.kill_theming(layout)

        scene_container = QtGui.QScrollArea(self)
        layout.addWidget(scene_container, stretch=1)

        self.scene = Scene(
            self.config, scene_container.horizontalScrollBar().value, scene_container.verticalScrollBar().value
        )

        scene_container.setWidget(self.scene)

        self.terminal = Terminal(self, lambda: self.scene.file_path)
        layout.addWidget(self.terminal)

        self.connect_signals(self.scene, self.terminal)

        common.set_hotkey("Escape", self, self.terminal.toggle)

        if file_to_open:
            self.scene.open_file(file_to_open)

        self.show()
Пример #3
0
    def __init__(self, configdir, activation_event, dry_run):
        super().__init__()
        self.setWindowTitle('Mneme')
        self.configdir = configdir
        activation_event.connect(self.reload_settings)
        self.force_quit_flag = False

        # Create layouts
        self.stack = QtGui.QStackedLayout(self)
        kill_theming(self.stack)

        # Index viewer
        self.index_viewer = IndexFrame(self, dry_run)
        self.stack.addWidget(self.index_viewer)

        # Popup viewer
        self.popup_viewer = FileViewer(self)
        self.stack.addWidget(self.popup_viewer)
        self.popuphomekey = QtGui.QShortcut(QtGui.QKeySequence(),
                                            self.popup_viewer,
                                            self.show_index)

        # Load settings
        self.defaultstyle = read_json(local_path('defaultstyle.json'))
        self.css_template = read_file(local_path(join('templates','template.css')))
        self.index_css_template = read_file(local_path(join('templates','index_page.css')))
        self.settings, self.style = {}, {}
        self.reload_settings()

        # Misc
        self.connect_signals()
        self.show()
Пример #4
0
 def create_layout(self, titlelabel, tabbar, tabcounter, revisionnotice,
                   textarea, terminal):
     layout = QtGui.QVBoxLayout(self)
     kill_theming(layout)
     # Title label
     titlelabel.setAlignment(Qt.AlignCenter)
     layout.addWidget(titlelabel)
     # Tab bar and tab counter
     tab_layout = QtGui.QHBoxLayout()
     tabbar.setDrawBase(False)
     tab_layout.addWidget(tabbar, stretch=1)
     tab_layout.addWidget(tabcounter, stretch=0)
     layout.addLayout(tab_layout)
     # Revision notice label
     revisionnotice.setAlignment(Qt.AlignCenter)
     layout.addWidget(revisionnotice)
     revisionnotice.hide()
     # Textarea
     textarea_layout = QtGui.QHBoxLayout()
     textarea_layout.addStretch()
     textarea_layout.addWidget(textarea, stretch=1)
     textarea_layout.addStretch()
     layout.addLayout(textarea_layout)
     # Terminal
     layout.addWidget(self.terminal)
Пример #5
0
 def __init__(self, themefile, styleconfig, activation_event):
     super().__init__()
     self.setWindowTitle('fckthms and not in a good way')
     self.themefile = themefile
     validate_theme(themefile, styleconfig)
     activation_event.connect(self.reload_data)
     layout = QtGui.QHBoxLayout(self)
     common.kill_theming(layout)
     paintstack = generate_paintstack(themefile)
     self.listwidget = ColorList(self, paintstack)
     self.canvas = Canvas(self, paintstack, self.listwidget.get_color)
     self.listwidget.request_repaint.connect(self.canvas.update)
     layout.addWidget(self.canvas, stretch=1)
     listlayout = QtGui.QVBoxLayout()
     common.kill_theming(listlayout)
     listlayout.addWidget(self.listwidget)
     highlightbtn = QtGui.QPushButton('Highlight items')
     highlightbtn.setCheckable(True)
     highlightbtn.toggled.connect(self.listwidget.set_highlight)
     listlayout.addWidget(highlightbtn)
     colorbtn = QtGui.QPushButton('Set color')
     colorbtn.clicked.connect(self.listwidget.set_color)
     listlayout.addWidget(colorbtn)
     resetbtn = QtGui.QPushButton('Reset color')
     resetbtn.clicked.connect(self.listwidget.reset_color)
     listlayout.addWidget(resetbtn)
     layout.addLayout(listlayout)
     self.show()
Пример #6
0
 def __init__(self, parent, dryrun, configdir):
     super().__init__(parent)
     self.configdir = configdir
     layout = QtGui.QVBoxLayout(self)
     kill_theming(layout)
     self.entrylist = NomiaEntryList(dryrun)
     self.coverimagepath = join(configdir, 'coverimages')
     self.view = NomiaHTMLEntryView(self.coverimagepath, self, '#entry{}', '#hr{}',
                                    join(configdir, '.index.css'))
     self.view.templates = load_html_templates()
     layout.addWidget(self.view.webview, stretch=1)
     self.terminal = Terminal(self)
     layout.addWidget(self.terminal)
     self.connect_signals()
     #self.view.set_stylesheet()
     self.currentfilter = None
     self.attributes = self.init_attributes()
     self.autocompleted_attributes = [
         'rating',
         'status',
         'studio',
         'tags',
         'type'
     ]
     self.autocompleter = self.init_autocompleter()
Пример #7
0
 def __init__(self, parent):
     super().__init__(parent)
     layout = QtGui.QGridLayout(self)
     kill_theming(layout)
     class InfoPanelLabel(QtGui.QLabel): pass
     self.label = InfoPanelLabel()
     layout.addWidget(self.label, 1, 0, Qt.AlignHCenter)
     self.show()
Пример #8
0
    def create_ui(self, chaptersidebar, textarea, terminal):
        self.textarea = textarea
        self.outer_v_layout = QtGui.QVBoxLayout(self)
        common.kill_theming(self.outer_v_layout)

        self.inner_h_layout = QtGui.QHBoxLayout()
        common.kill_theming(self.inner_h_layout)
        self.outer_v_layout.addLayout(self.inner_h_layout)
        self.inner_h_layout.addStretch()
        self.inner_h_layout.addWidget(textarea, stretch=1)
        self.inner_h_layout.addStretch()
        self.inner_h_layout.addWidget(chaptersidebar)
        self.outer_v_layout.addWidget(terminal)
Пример #9
0
    def __init__(
        self,
        parent: QtGui.QWidget,
        input_term_constructor: Callable[[], GenericTerminalInputBox],
        output_term_constructor: Callable[[], GenericTerminalOutputBox],
    ) -> None:
        super().__init__(parent)

        layout = QtGui.QVBoxLayout(self)
        kill_theming(layout)

        self.input_term = input_term_constructor()
        self.output_term = output_term_constructor()
        self.output_term.setDisabled(True)

        layout.addWidget(self.input_term)
        layout.addWidget(self.output_term)

        self.input_term.setFocus()
        self.input_term.returnPressed.connect(self.parse_command)

        # Log
        self.log = []  # type: List[Tuple[datetime, str, str]]

        # History
        self.history = [""]
        self.history_index = 0
        self.input_term.reset_history_travel.connect(self.reset_history_travel)
        self.input_term.history_up.connect(self.history_up)
        self.input_term.history_down.connect(self.history_down)

        # Autocomplete
        self.ac_suggestions = []  # type: List[str]
        self.ac_index = 0
        self.ac_reset_flag = True
        self.input_term.tab_pressed.connect(self.autocomplete)
        self.input_term.reset_ac_suggestions.connect(self.reset_ac_suggestions)

        # Each post in self.commands is (callback/signal, helptext[, options])
        # options is an optional dict with - surprise - options
        self.commands = {}  # type: Any
Пример #10
0
 def __init__(self, parent, dry_run, statepath):
     super().__init__(parent)
     # Layout and shit
     layout = QtGui.QVBoxLayout(self)
     kill_theming(layout)
     self.webview = QtWebKit.QWebView(self)
     self.webview.setDisabled(True)
     layout.addWidget(self.webview, stretch=1)
     self.terminal = Terminal(self, self.get_tags)
     layout.addWidget(self.terminal)
     self.connect_signals()
     # Misc shizzle
     self.print_ = self.terminal.print_
     self.error = self.terminal.error
     self.set_terminal_text = self.terminal.prompt
     self.dry_run = dry_run
     self.htmltemplates = load_html_templates()
     self.css = None # Is set every time the config is reloaded
     self.defaulttagcolor = None # Is set every time the style is reloaded
     # Hotkeys
     hotkeypairs = (
         ('reload', self.reload_view),
         ('zoom in', self.zoom_in),
         ('zoom out', self.zoom_out),
         ('reset zoom', self.zoom_reset)
     )
     self.hotkeys = {
         key: QtGui.QShortcut(QtGui.QKeySequence(), self, callback)
         for key, callback in hotkeypairs
     }
     # State
     self.statepath = statepath
     state = self.load_state()
     # Entries and stuff
     self.entries = ()
     self.visible_entries = ()
     activefilters = namedtuple('activefilters', 'title description tags wordcount backstorywordcount backstorypages')
     self.active_filters = activefilters(**state['active filters'])
     self.sorted_by = state['sorted by'] #('title', False)
     self.undostack = ()
Пример #11
0
Файл: urd.py Проект: cefyr/urd
    def __init__(self, file_to_open=''):
        super().__init__()
        self.setWindowTitle('New file')

        self.force_quit_flag = False

        self.config = read_config()
        self.setStyleSheet('background: '+self.config['theme']['background'])

        layout = QtGui.QVBoxLayout(self)
        common.kill_theming(layout)

        self.scene_container = QtGui.QScrollArea(self)
        layout.addWidget(self.scene_container, stretch=1)

        self.scene = Scene(self.config,
                self.scene_container.horizontalScrollBar().value,
                self.scene_container.verticalScrollBar().value)

        self.scene_container.setWidget(self.scene)
        self.scene_container.setDisabled(True)

        self.terminal = Terminal(self, lambda: self.scene.file_path)
        layout.addWidget(self.terminal)

        self.connect_signals(self.scene, self.terminal)

#        common.set_hotkey('Escape', self, self.terminal.toggle)
        common.set_hotkey('Ctrl+N', self, self.scene.request_new_file)
        common.set_hotkey('Ctrl+O', self, lambda:self.terminal.prompt('o '))
        common.set_hotkey('Ctrl+S', self, self.scene.request_save_file)
        common.set_hotkey('Ctrl+Shift+S', self,
                          lambda:self.terminal.prompt('s '))

        if file_to_open:
            self.scene.open_file(file_to_open)

        self.show()