diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 1dce44c0f..99f356724 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -533,6 +533,15 @@ class Application(QApplication): qutescheme.pyeval_output = out self.mainwindow.tabs.cmd.openurl('qute:pyeval') + @cmdutils.register(instance='', debug=True) + def all_widgets(self): + """Print a list of all widgets to debug log.""" + widgets = self.allWidgets() + log.misc.debug("{} widgets".format(len(widgets))) + widgets.sort(key=lambda e: repr(e)) + for w in widgets: + log.misc.debug(w) + @pyqtSlot() def shutdown(self): """Try to shutdown everything cleanly. diff --git a/qutebrowser/widgets/completion.py b/qutebrowser/widgets/completion.py index 08acc6200..f3b4112d6 100644 --- a/qutebrowser/widgets/completion.py +++ b/qutebrowser/widgets/completion.py @@ -112,6 +112,9 @@ class CompletionView(QTreeView): self.hide() # FIXME set elidemode + def __repr__(self): + return '' + def _resize_columns(self): """Resize the completion columns based on COLUMN_WIDTHS.""" width = self.size().width() diff --git a/qutebrowser/widgets/downloads.py b/qutebrowser/widgets/downloads.py index cd401b053..ff124210b 100644 --- a/qutebrowser/widgets/downloads.py +++ b/qutebrowser/widgets/downloads.py @@ -60,6 +60,10 @@ class DownloadView(QListView): self.setContextMenuPolicy(Qt.CustomContextMenu) self.customContextMenuRequested.connect(self.show_context_menu) + def __repr__(self): + return ''.format( + self.model().rowCount()) + @pyqtSlot('QPoint') def show_context_menu(self, point): """Show the context menu.""" diff --git a/qutebrowser/widgets/mainwindow.py b/qutebrowser/widgets/mainwindow.py index 8a9023b1c..5bb5409ac 100644 --- a/qutebrowser/widgets/mainwindow.py +++ b/qutebrowser/widgets/mainwindow.py @@ -88,6 +88,9 @@ class MainWindow(QWidget): #self.tabWidget.setCurrentIndex(0) #QtCore.QMetaObject.connectSlotsByName(MainWindow) + def __repr__(self): + return '' + def _set_default_geometry(self): """Set some sensible default geometry.""" self.setGeometry(QRect(50, 50, 800, 600)) diff --git a/qutebrowser/widgets/misc.py b/qutebrowser/widgets/misc.py index 6ab2f07f8..240574f98 100644 --- a/qutebrowser/widgets/misc.py +++ b/qutebrowser/widgets/misc.py @@ -33,3 +33,6 @@ class MinimalLineEdit(QLineEdit): background-color: transparent; } """) + + def __repr__(self): + return '<{} "{}">'.format(self.__class__.__name__, self.text()) diff --git a/qutebrowser/widgets/statusbar/bar.py b/qutebrowser/widgets/statusbar/bar.py index ea16cb5b4..a2f04cbb2 100644 --- a/qutebrowser/widgets/statusbar/bar.py +++ b/qutebrowser/widgets/statusbar/bar.py @@ -158,6 +158,9 @@ class StatusBar(QWidget): self.prog = Progress(self) self._hbox.addWidget(self.prog) + def __repr__(self): + return '' + @pyqtProperty(bool) def error(self): """Getter for self.error, so it can be used as Qt property.""" diff --git a/qutebrowser/widgets/statusbar/progress.py b/qutebrowser/widgets/statusbar/progress.py index 8dcfc0bb9..d129e6c61 100644 --- a/qutebrowser/widgets/statusbar/progress.py +++ b/qutebrowser/widgets/statusbar/progress.py @@ -53,6 +53,9 @@ class Progress(QProgressBar): self.setTextVisible(False) self.hide() + def __repr__(self): + return ''.format(self.value()) + @pyqtSlot() def on_load_started(self): """Clear old error and show progress, used as slot to loadStarted.""" diff --git a/qutebrowser/widgets/statusbar/prompt.py b/qutebrowser/widgets/statusbar/prompt.py index 5b56243b5..e9c20c4fc 100644 --- a/qutebrowser/widgets/statusbar/prompt.py +++ b/qutebrowser/widgets/statusbar/prompt.py @@ -63,6 +63,9 @@ class Prompt(QWidget): self._input = MinimalLineEdit() self._hbox.addWidget(self._input) + def __repr__(self): + return '' + def on_mode_left(self, mode): """Clear and reset input when the mode was left.""" if mode in ('prompt', 'yesno'): diff --git a/qutebrowser/widgets/statusbar/textbase.py b/qutebrowser/widgets/statusbar/textbase.py index 6baef2588..c3accb888 100644 --- a/qutebrowser/widgets/statusbar/textbase.py +++ b/qutebrowser/widgets/statusbar/textbase.py @@ -42,6 +42,9 @@ class TextBase(QLabel): self._elidemode = elidemode self._elided_text = '' + def __repr__(self): + return '<{} "{}">'.format(self.__class__.__name__, self.text()) + def _update_elided_text(self, width): """Update the elided text when necessary. diff --git a/qutebrowser/widgets/tabbedbrowser.py b/qutebrowser/widgets/tabbedbrowser.py index eb259b2bc..2ae863525 100644 --- a/qutebrowser/widgets/tabbedbrowser.py +++ b/qutebrowser/widgets/tabbedbrowser.py @@ -107,6 +107,9 @@ class TabbedBrowser(TabWidget): # FIXME adjust this to font size self.setIconSize(QSize(12, 12)) + def __repr__(self): + return ''.format(self.count()) + @property def widgets(self): """Get a list of open tab widgets. diff --git a/qutebrowser/widgets/tabwidget.py b/qutebrowser/widgets/tabwidget.py index 9669f15c0..8b98248f4 100644 --- a/qutebrowser/widgets/tabwidget.py +++ b/qutebrowser/widgets/tabwidget.py @@ -123,6 +123,9 @@ class TabBar(QTabBar): """Custom tabbar to close tabs on right click.""" + def __repr__(self): + return ''.format(self.count()) + def mousePressEvent(self, e): """Override mousePressEvent to emit tabCloseRequested on rightclick.""" if e.button() != Qt.RightButton: