Skip to content

Commit 4615c48

Browse files
authored
Add overview widget (#159)
* Add overview widget * Use pixmap * Add changelog entry * Rename to simply "Overview" * Disable when no signal is open
1 parent 33cc720 commit 4615c48

11 files changed

Lines changed: 592 additions & 2 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
### ✨ Added
33
- Add DMG background and Applications shortcut for macOS installer
44
- Add new toolbar icons for zooming in/out all channels' amplitudes ([#158](https://github.com/cbrnr/sigviewer/pull/158) by [Clemens Brunner](https://github.com/cbrnr))
5+
- Add overview widget at the bottom of the window ([#159](https://github.com/cbrnr/sigviewer/pull/159) by [Clemens Brunner](https://github.com/cbrnr))
56

67
### 🔧 Fixed
78
- Show error message when loading EDF files containing only annotations instead of hanging in the loading dialog

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ qt_add_library(sigviewer_objects OBJECT
263263
src/gui/signal_browser/event_graphics_item.h
264264
src/gui/signal_browser/label_widget.cpp
265265
src/gui/signal_browser/label_widget.h
266+
src/gui/signal_browser/overview_widget.cpp
267+
src/gui/signal_browser/overview_widget.h
266268
src/gui/signal_browser/signal_browser_graphics_view.h
267269
src/gui/signal_browser/signal_browser_model_4.cpp
268270
src/gui/signal_browser/signal_browser_model_4.h

src/gui/main_window.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,20 @@ void MainWindow::toggleStatusBar (bool visible)
151151
}
152152

153153

154+
//-------------------------------------------------------------------
155+
void MainWindow::setOverviewActionEnabled (bool enabled)
156+
{
157+
overview_action_->setEnabled (enabled);
158+
}
159+
160+
//-----------------------------------------------------------------------------
161+
void MainWindow::toggleOverview (bool visible)
162+
{
163+
QSettings settings;
164+
settings.setValue ("MainWindow/overview", visible);
165+
emit overviewVisibilityChanged (visible);
166+
}
167+
154168
//-----------------------------------------------------------------------------
155169
void MainWindow::addBackgroundProcessToStatusBar (QString name, int max)
156170
{
@@ -239,9 +253,16 @@ void MainWindow::initMenus (QSharedPointer<ApplicationContext> application_conte
239253
toggle_status_bar->setChecked (settings.value ("MainWindow/statusbar", true).toBool());
240254
connect (toggle_status_bar, SIGNAL(toggled(bool)), this, SLOT(toggleStatusBar(bool)));
241255

256+
overview_action_ = new QAction (tr("Overview"), this);
257+
overview_action_->setCheckable (true);
258+
overview_action_->setChecked (settings.value ("MainWindow/overview", true).toBool());
259+
overview_action_->setEnabled (false);
260+
connect (overview_action_, SIGNAL(toggled(bool)), this, SLOT(toggleOverview(bool)));
261+
242262
view_menu_ = menuBar()->addMenu(tr("&View"));
243263
view_menu_->addAction(file_toolbar_->toggleViewAction());
244264
view_menu_->addAction(toggle_status_bar);
265+
view_menu_->addAction(overview_action_);
245266
#ifndef Q_OS_MACOS
246267
toggle_menubar_ = new QAction(tr("Menubar"), this);
247268
toggle_menubar_->setCheckable(true);

src/gui/main_window.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ class MainWindow : public QMainWindow
3131

3232
void setStatusBarSignalLength(float64 length);
3333
void setStatusBarNrChannels(int32 nr_channels);
34+
void setOverviewActionEnabled(bool enabled);
3435

3536
void setRecentFiles(const QStringList& recent_file_list);
3637

3738
signals:
3839
void recentFileActivated(QAction* recent_file_action);
3940
void recentFileMenuAboutToShow();
41+
void overviewVisibilityChanged(bool visible);
4042

4143

4244
protected:
@@ -48,6 +50,7 @@ class MainWindow : public QMainWindow
4850
private slots:
4951
void toggleStatusBar (bool visible);
5052
void toggleMenuBar ();
53+
void toggleOverview (bool visible);
5154
void addBackgroundProcessToStatusBar (QString name, int max);
5255
void updateBackgroundProcessonStatusBar (QString name, int value);
5356
void removeBackgroundProcessFromStatusBar (QString name);
@@ -77,6 +80,7 @@ private slots:
7780
QLabel* status_bar_signal_length_label_;
7881
QLabel* status_bar_nr_channels_label_;
7982

83+
QAction* overview_action_;
8084
QAction* toggle_menubar_;
8185
QAction* hamburger_spacer_action_;
8286
QAction* hamburger_action_;

src/gui/main_window_model.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ int const MainWindowModel::NUMBER_RECENT_FILES_ = 8;
2525
MainWindowModel::MainWindowModel (QSharedPointer<ApplicationContext> application_context)
2626
: application_context_ (application_context),
2727
main_window_ (new MainWindow (application_context)),
28-
tab_widget_ (0)
28+
tab_widget_ (0),
29+
current_signal_browser_view_ (nullptr)
2930
{
3031
connect (main_window_, SIGNAL(recentFileActivated(QAction*)), SLOT(recentFileActivated(QAction*)));
3132
connect (main_window_, SIGNAL(recentFileMenuAboutToShow()), SLOT(recentFileMenuAboutToShow()));
33+
connect (main_window_, SIGNAL(overviewVisibilityChanged(bool)), SLOT(setOverviewVisible(bool)));
3234
main_window_->show();
3335
loadSettings();
3436
}
@@ -197,14 +199,23 @@ void MainWindowModel::closeCurrentFileTabs ()
197199
// to be refactored as soon as multi file support is implemented
198200
main_window_->setCentralWidget (0);
199201
tab_widget_ = 0;
202+
current_signal_browser_view_ = nullptr;
200203
tab_contexts_.clear ();
201204
// --end
202205

203206
main_window_->setStatusBarSignalLength(-1);
204207
main_window_->setStatusBarNrChannels(-1);
208+
main_window_->setOverviewActionEnabled (false);
205209
resetCurrentFileName ("");
206210
}
207211

212+
//-----------------------------------------------------------------------------
213+
void MainWindowModel::setOverviewVisible (bool visible)
214+
{
215+
if (current_signal_browser_view_)
216+
current_signal_browser_view_->setOverviewVisible (visible);
217+
}
218+
208219
//-----------------------------------------------------------------------------
209220
QSharedPointer<SignalVisualisationModel> MainWindowModel::getCurrentSignalVisualisationModel ()
210221
{
@@ -250,6 +261,14 @@ int MainWindowModel::createSignalVisualisationImpl (ChannelManager const& channe
250261

251262
int tab_index = tab_widget_->addTab (view, tr("Signal"));
252263

264+
// Store the view and apply the persisted overview visibility.
265+
current_signal_browser_view_ = view;
266+
{
267+
QSettings settings;
268+
view->setOverviewVisible (settings.value ("MainWindow/overview", true).toBool());
269+
}
270+
main_window_->setOverviewActionEnabled (true);
271+
253272
model->setSignalBrowserView (view);
254273
browser_models_[tab_index] = model;
255274
event_views_[tab_index] = model;

src/gui/main_window_model.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ namespace sigviewer
2626

2727
class ApplicationContext;
2828
class MainWindow;
29+
class SignalBrowserView;
2930

3031
class MainWindowModel : public QObject
3132
{
@@ -51,6 +52,9 @@ public slots:
5152

5253
void closeTab (int tab_index);
5354

55+
/// Propagate overview visibility to the currently open signal browser view.
56+
void setOverviewVisible (bool visible);
57+
5458
private slots:
5559
void recentFileActivated(QAction* recent_file_action);
5660

@@ -73,6 +77,7 @@ private slots:
7377
QSharedPointer<ApplicationContext> application_context_;
7478
MainWindow* main_window_;
7579
QTabWidget* tab_widget_;
80+
SignalBrowserView* current_signal_browser_view_;
7681
QStringList recent_file_list_;
7782
std::map<int, QSharedPointer<SignalVisualisationModel> > browser_models_;
7883
QMap<int, QSharedPointer<EventView> > event_views_;

0 commit comments

Comments
 (0)