# HG changeset patch # User Hasan Yavuz ÖZDERYA # Date 2018-06-24 18:05:10 # Node ID 6acb6d6f037c668efab73c82d9be2f05f830c51d # Parent fff236a1193a6ae0a8c14b7934405d090f97ce8f add buttons to quickly hide/show all channels diff --git a/src/channelinfomodel.cpp b/src/channelinfomodel.cpp --- a/src/channelinfomodel.cpp +++ b/src/channelinfomodel.cpp @@ -326,12 +326,12 @@ void ChannelInfoModel::resetColors() endResetModel(); } -void ChannelInfoModel::resetVisibility() +void ChannelInfoModel::resetVisibility(bool visible) { beginResetModel(); for (unsigned ci = 0; (int) ci < infos.length(); ci++) { - infos[ci].visibility = true; + infos[ci].visibility = visible; } endResetModel(); } diff --git a/src/channelinfomodel.h b/src/channelinfomodel.h --- a/src/channelinfomodel.h +++ b/src/channelinfomodel.h @@ -69,7 +69,7 @@ public slots: /// reset all channel colors void resetColors(); /// reset visibility - void resetVisibility(); + void resetVisibility(bool visible); private: struct ChannelInfo diff --git a/src/plotcontrolpanel.cpp b/src/plotcontrolpanel.cpp --- a/src/plotcontrolpanel.cpp +++ b/src/plotcontrolpanel.cpp @@ -1,5 +1,5 @@ /* - Copyright © 2017 Hasan Yavuz Özderya + Copyright © 2018 Hasan Yavuz Özderya This file is part of serialplot. @@ -47,6 +47,7 @@ PlotControlPanel::PlotControlPanel(QWidg resetNamesAct(tr("Reset Names"), this), resetColorsAct(tr("Reset Colors"), this), showAllAct(tr("Show All"), this), + hideAllAct(tr("Hide All"), this), resetMenu(tr("Reset Menu"), this) { ui->setupUi(this); @@ -138,12 +139,17 @@ PlotControlPanel::PlotControlPanel(QWidg ui->colorSelector->setDisplayMode(color_widgets::ColorPreview::AllAlpha); ui->colorSelector->setDisabled(true); - // reset button + // reset buttons + resetAct.setToolTip(tr("Reset channel names and colors")); resetMenu.addAction(&resetNamesAct); resetMenu.addAction(&resetColorsAct); - resetMenu.addAction(&showAllAct); resetAct.setMenu(&resetMenu); ui->tbReset->setDefaultAction(&resetAct); + + showAllAct.setToolTip(tr("Show all channels")); + hideAllAct.setToolTip(tr("Hide all channels")); + ui->tbShowAll->setDefaultAction(&showAllAct); + ui->tbHideAll->setDefaultAction(&hideAllAct); } PlotControlPanel::~PlotControlPanel() @@ -395,7 +401,8 @@ void PlotControlPanel::setChannelInfoMod connect(&resetAct, &QAction::triggered, model, &ChannelInfoModel::resetInfos); connect(&resetNamesAct, &QAction::triggered, model, &ChannelInfoModel::resetNames); connect(&resetColorsAct, &QAction::triggered, model, &ChannelInfoModel::resetColors); - connect(&showAllAct, &QAction::triggered, model, &ChannelInfoModel::resetVisibility); + connect(&showAllAct, &QAction::triggered, [model]{model->resetVisibility(true);}); + connect(&hideAllAct, &QAction::triggered, [model]{model->resetVisibility(false);}); } void PlotControlPanel::saveSettings(QSettings* settings) diff --git a/src/plotcontrolpanel.h b/src/plotcontrolpanel.h --- a/src/plotcontrolpanel.h +++ b/src/plotcontrolpanel.h @@ -1,5 +1,5 @@ /* - Copyright © 2017 Hasan Yavuz Özderya + Copyright © 2018 Hasan Yavuz Özderya This file is part of serialplot. @@ -70,7 +70,7 @@ private: /// User can disable this setting in the checkbox bool warnNumOfSamples; - QAction resetAct, resetNamesAct, resetColorsAct, showAllAct; + QAction resetAct, resetNamesAct, resetColorsAct, showAllAct, hideAllAct; QMenu resetMenu; /// Show a confirmation dialog before setting #samples to a big value diff --git a/src/plotcontrolpanel.ui b/src/plotcontrolpanel.ui --- a/src/plotcontrolpanel.ui +++ b/src/plotcontrolpanel.ui @@ -6,7 +6,7 @@ 0 0 - 706 + 704 195 @@ -62,6 +62,9 @@ + + 3 + QLayout::SetMaximumSize @@ -95,12 +98,32 @@ 1 - 20 + 1 + + + Show all channels + + + Show All + + + + + + + Hide all channels + + + Hide All + + + + Reset