mirror of
https://github.com/epasveer/seer.git
synced 2026-08-29 08:34:42 +08:00
Modify other managers with Tab settings.
This commit is contained in:
@@ -6,12 +6,12 @@
|
||||
#include "SeerHelpPageDialog.h"
|
||||
#include "QHContainerWidget.h"
|
||||
#include <QtWidgets/QToolButton>
|
||||
#include <QtWidgets/QMenu>
|
||||
#include <QtWidgets/QCheckBox>
|
||||
#include <QtWidgets/QWidgetAction>
|
||||
#include <QtGui/QIcon>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QMenu>
|
||||
#include <QCheckBox>
|
||||
#include <QWidgetAction>
|
||||
|
||||
SeerSourceSymbolLibraryManagerWidget::SeerSourceSymbolLibraryManagerWidget (QWidget* parent) : QWidget(parent) {
|
||||
|
||||
@@ -40,10 +40,10 @@ SeerSourceSymbolLibraryManagerWidget::SeerSourceSymbolLibraryManagerWidget (QWid
|
||||
tabWidget->addTab(_adaExceptionsBrowserWidget, "AdaExceptions");
|
||||
tabWidget->addTab(_skipBrowserWidget, "Skips");
|
||||
|
||||
QToolButton* contextMenuButton = new QToolButton(tabWidget);
|
||||
contextMenuButton->setIcon(QIcon(":/seer/resources/thenounproject/preferences.svg"));
|
||||
contextMenuButton->setToolTip("Show/Hide tabs.");
|
||||
contextMenuButton->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
QToolButton* tabsContextMenuButton = new QToolButton(tabWidget);
|
||||
tabsContextMenuButton->setIcon(QIcon(":/seer/resources/thenounproject/preferences.svg"));
|
||||
tabsContextMenuButton->setToolTip("Show/Hide tabs.");
|
||||
tabsContextMenuButton->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
QToolButton* refreshToolButton = new QToolButton(tabWidget);
|
||||
refreshToolButton->setIcon(QIcon(":/seer/resources/RelaxLightIcons/view-refresh.svg"));
|
||||
@@ -55,7 +55,7 @@ SeerSourceSymbolLibraryManagerWidget::SeerSourceSymbolLibraryManagerWidget (QWid
|
||||
|
||||
QHContainerWidget* hcontainer = new QHContainerWidget(this);
|
||||
hcontainer->setSpacing(3);
|
||||
hcontainer->addWidget(contextMenuButton);
|
||||
hcontainer->addWidget(tabsContextMenuButton);
|
||||
hcontainer->addWidget(refreshToolButton);
|
||||
hcontainer->addWidget(helpToolButton);
|
||||
|
||||
@@ -65,7 +65,7 @@ SeerSourceSymbolLibraryManagerWidget::SeerSourceSymbolLibraryManagerWidget (QWid
|
||||
readSettings();
|
||||
|
||||
// Connect things.
|
||||
QObject::connect(contextMenuButton, &QToolButton::clicked, this, &SeerSourceSymbolLibraryManagerWidget::handleShowTabsContextMenuButtonClicked);
|
||||
QObject::connect(tabsContextMenuButton, &QToolButton::clicked, this, &SeerSourceSymbolLibraryManagerWidget::handleTabsContextMenuButtonClicked);
|
||||
QObject::connect(refreshToolButton, &QToolButton::clicked, this, &SeerSourceSymbolLibraryManagerWidget::handleRefreshToolButtonClicked);
|
||||
QObject::connect(helpToolButton, &QToolButton::clicked, this, &SeerSourceSymbolLibraryManagerWidget::handleHelpToolButtonClicked);
|
||||
QObject::connect(tabWidget->tabBar(), &QTabBar::tabMoved, this, &SeerSourceSymbolLibraryManagerWidget::handleTabMoved);
|
||||
@@ -234,7 +234,7 @@ void SeerSourceSymbolLibraryManagerWidget::readSettings () {
|
||||
}
|
||||
}
|
||||
|
||||
void SeerSourceSymbolLibraryManagerWidget::handleShowTabsContextMenuButtonClicked() {
|
||||
void SeerSourceSymbolLibraryManagerWidget::handleTabsContextMenuButtonClicked() {
|
||||
|
||||
// Build the menu and execute it.
|
||||
QMenu contextMenu;
|
||||
|
||||
@@ -41,7 +41,7 @@ class SeerSourceSymbolLibraryManagerWidget : public QWidget, protected Ui::SeerS
|
||||
void handleHelpToolButtonClicked ();
|
||||
void handleTabMoved (int from, int to);
|
||||
void handleTabChanged (int index);
|
||||
void handleShowTabsContextMenuButtonClicked ();
|
||||
void handleTabsContextMenuButtonClicked ();
|
||||
|
||||
private:
|
||||
SeerSourceBrowserWidget* _sourceBrowserWidget;
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
#include "SeerUtl.h"
|
||||
#include "QHContainerWidget.h"
|
||||
#include <QtWidgets/QToolButton>
|
||||
#include <QtWidgets/QMenu>
|
||||
#include <QtWidgets/QCheckBox>
|
||||
#include <QtWidgets/QWidgetAction>
|
||||
#include <QtGui/QIcon>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QDebug>
|
||||
@@ -32,6 +35,11 @@ SeerStackManagerWidget::SeerStackManagerWidget (QWidget* parent) : QWidget(paren
|
||||
tabWidget->addTab(_stackLocalsBrowserWidget, "Locals");
|
||||
tabWidget->addTab(_stackDumpBrowserWidget, "Stack");
|
||||
|
||||
QToolButton* tabsContextMenuButton = new QToolButton(tabWidget);
|
||||
tabsContextMenuButton->setIcon(QIcon(":/seer/resources/thenounproject/preferences.svg"));
|
||||
tabsContextMenuButton->setToolTip("Show/Hide tabs.");
|
||||
tabsContextMenuButton->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
QToolButton* refreshToolButton = new QToolButton(tabWidget);
|
||||
refreshToolButton->setIcon(QIcon(":/seer/resources/RelaxLightIcons/view-refresh.svg"));
|
||||
refreshToolButton->setToolTip("Refresh the stack information.");
|
||||
@@ -42,6 +50,7 @@ SeerStackManagerWidget::SeerStackManagerWidget (QWidget* parent) : QWidget(paren
|
||||
|
||||
QHContainerWidget* hcontainer = new QHContainerWidget(this);
|
||||
hcontainer->setSpacing(3);
|
||||
hcontainer->addWidget(tabsContextMenuButton);
|
||||
hcontainer->addWidget(refreshToolButton);
|
||||
hcontainer->addWidget(helpToolButton);
|
||||
|
||||
@@ -51,10 +60,11 @@ SeerStackManagerWidget::SeerStackManagerWidget (QWidget* parent) : QWidget(paren
|
||||
readSettings();
|
||||
|
||||
// Connect things.
|
||||
QObject::connect(refreshToolButton, &QToolButton::clicked, this, &SeerStackManagerWidget::handleRefreshToolButtonClicked);
|
||||
QObject::connect(helpToolButton, &QToolButton::clicked, this, &SeerStackManagerWidget::handleHelpToolButtonClicked);
|
||||
QObject::connect(tabWidget->tabBar(), &QTabBar::tabMoved, this, &SeerStackManagerWidget::handleTabMoved);
|
||||
QObject::connect(tabWidget->tabBar(), &QTabBar::currentChanged, this, &SeerStackManagerWidget::handleTabChanged);
|
||||
QObject::connect(tabsContextMenuButton, &QToolButton::clicked, this, &SeerStackManagerWidget::handleTabsContextMenuButtonClicked);
|
||||
QObject::connect(refreshToolButton, &QToolButton::clicked, this, &SeerStackManagerWidget::handleRefreshToolButtonClicked);
|
||||
QObject::connect(helpToolButton, &QToolButton::clicked, this, &SeerStackManagerWidget::handleHelpToolButtonClicked);
|
||||
QObject::connect(tabWidget->tabBar(), &QTabBar::tabMoved, this, &SeerStackManagerWidget::handleTabMoved);
|
||||
QObject::connect(tabWidget->tabBar(), &QTabBar::currentChanged, this, &SeerStackManagerWidget::handleTabChanged);
|
||||
}
|
||||
|
||||
SeerStackManagerWidget::~SeerStackManagerWidget () {
|
||||
@@ -111,13 +121,21 @@ void SeerStackManagerWidget::handleTabChanged (int index) {
|
||||
|
||||
void SeerStackManagerWidget::writeSettings () {
|
||||
|
||||
// Write tab order to settings.
|
||||
// Build up visible list.
|
||||
QStringList visible;
|
||||
|
||||
for (int i=0; i<tabWidget->tabBar()->count(); i++) {
|
||||
visible.append(tabWidget->isTabVisible(i) ? "true" : "false");
|
||||
}
|
||||
|
||||
// Build up tab order.
|
||||
QStringList tabs;
|
||||
|
||||
for (int i=0; i<tabWidget->tabBar()->count(); i++) {
|
||||
tabs.append(tabWidget->tabBar()->tabText(i));
|
||||
}
|
||||
|
||||
// Build up current tab.
|
||||
QString current = tabWidget->tabBar()->tabText(tabWidget->tabBar()->currentIndex());
|
||||
|
||||
//qDebug() << "Tabs" << tabs;
|
||||
@@ -127,6 +145,7 @@ void SeerStackManagerWidget::writeSettings () {
|
||||
|
||||
settings.beginGroup("stackmanagerwindow"); {
|
||||
settings.setValue("taborder", tabs.join(','));
|
||||
settings.setValue("tabvisible", visible.join(','));
|
||||
settings.setValue("tabcurrent", current);
|
||||
} settings.endGroup();
|
||||
}
|
||||
@@ -141,10 +160,12 @@ void SeerStackManagerWidget::readSettings () {
|
||||
// Read tab order from settings.
|
||||
QSettings settings;
|
||||
QStringList tabs;
|
||||
QStringList visible;
|
||||
QString current;
|
||||
|
||||
settings.beginGroup("stackmanagerwindow"); {
|
||||
tabs = settings.value("taborder").toString().split(',');
|
||||
visible = settings.value("tabvisible").toString().split(',');
|
||||
current = settings.value("tabcurrent").toString();
|
||||
} settings.endGroup();
|
||||
|
||||
@@ -169,6 +190,18 @@ void SeerStackManagerWidget::readSettings () {
|
||||
}
|
||||
}
|
||||
|
||||
// Show/Hide tabs.
|
||||
for (int i=0; i<visible.count(); i++) {
|
||||
QString flag = visible[i];
|
||||
if (flag == "true") {
|
||||
tabWidget->setTabVisible(i,true);
|
||||
}else if (flag == "false") {
|
||||
tabWidget->setTabVisible(i,false);
|
||||
}else{
|
||||
tabWidget->setTabVisible(i,true);
|
||||
}
|
||||
}
|
||||
|
||||
// Make a tab current.
|
||||
if (current != "") {
|
||||
for (int i=0; i<tabWidget->tabBar()->count(); i++) {
|
||||
@@ -242,4 +275,59 @@ void SeerStackManagerWidget::refresh () {
|
||||
emit refreshThreadFrames();
|
||||
}
|
||||
|
||||
void SeerStackManagerWidget::handleTabsContextMenuButtonClicked() {
|
||||
|
||||
// Build the menu and execute it.
|
||||
QMenu contextMenu;
|
||||
QWidget* container = new QWidget(&contextMenu);
|
||||
QVBoxLayout* layout = new QVBoxLayout(container);
|
||||
|
||||
for (int i = 0; i < tabWidget->count(); i++) {
|
||||
|
||||
QString title = tabWidget->tabText(i);
|
||||
QCheckBox* showTabCheckBox = new QCheckBox(title, container);
|
||||
showTabCheckBox->setChecked(tabWidget->isTabVisible(i));
|
||||
layout->addWidget(showTabCheckBox);
|
||||
|
||||
QObject::connect(showTabCheckBox, &QCheckBox::toggled, [this, showTabCheckBox, i](bool checked) {
|
||||
|
||||
// Count visible tabs.
|
||||
int count=0;
|
||||
|
||||
for (int x=0; x<tabWidget->count(); x++) {
|
||||
if (tabWidget->isTabVisible(x)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
// Adjust the count. The 'checked' is made before the UI is updated.
|
||||
if (checked == true) {
|
||||
count++;
|
||||
}else{
|
||||
count--;
|
||||
}
|
||||
|
||||
// Reset the checkbox UI if the last visible tab was clicked.
|
||||
if (checked == false and count == 0) {
|
||||
showTabCheckBox->setChecked(true);
|
||||
// Don't hide last visible tab.
|
||||
}else if (checked == false and count > 1) {
|
||||
tabWidget->setTabVisible(i, checked);
|
||||
// Always show tabs when asked.
|
||||
}else{
|
||||
tabWidget->setTabVisible(i, checked);
|
||||
}
|
||||
|
||||
writeSettings();
|
||||
});
|
||||
}
|
||||
container->setLayout(layout);
|
||||
|
||||
QWidgetAction* action = new QWidgetAction(&contextMenu);
|
||||
action->setDefaultWidget(container);
|
||||
contextMenu.addAction(action);
|
||||
|
||||
contextMenu.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ class SeerStackManagerWidget : public QWidget, protected Ui::SeerStackManagerWid
|
||||
void handleHelpToolButtonClicked ();
|
||||
void handleTabMoved (int from, int to);
|
||||
void handleTabChanged (int index);
|
||||
void handleTabsContextMenuButtonClicked ();
|
||||
|
||||
private:
|
||||
SeerStackFramesBrowserWidget* _stackFramesBrowserWidget;
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
#include "QHContainerWidget.h"
|
||||
#include <QtWidgets/QToolButton>
|
||||
#include <QtWidgets/QTextBrowser>
|
||||
#include <QtWidgets/QMenu>
|
||||
#include <QtWidgets/QCheckBox>
|
||||
#include <QtWidgets/QWidgetAction>
|
||||
#include <QtGui/QIcon>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QSettings>
|
||||
@@ -33,6 +36,11 @@ SeerThreadManagerWidget::SeerThreadManagerWidget (QWidget* parent) : QWidget(par
|
||||
tabWidget->addTab(_threadGroupsBrowserWidget, "Groups");
|
||||
tabWidget->addTab(_adaTasksBrowserWidget, "AdaTasks");
|
||||
|
||||
QToolButton* tabsContextMenuButton = new QToolButton(tabWidget);
|
||||
tabsContextMenuButton->setIcon(QIcon(":/seer/resources/thenounproject/preferences.svg"));
|
||||
tabsContextMenuButton->setToolTip("Show/Hide tabs.");
|
||||
tabsContextMenuButton->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
QToolButton* refreshToolButton = new QToolButton(tabWidget);
|
||||
refreshToolButton->setIcon(QIcon(":/seer/resources/RelaxLightIcons/view-refresh.svg"));
|
||||
refreshToolButton->setToolTip("Refresh the thread information.");
|
||||
@@ -43,6 +51,7 @@ SeerThreadManagerWidget::SeerThreadManagerWidget (QWidget* parent) : QWidget(par
|
||||
|
||||
QHContainerWidget* hcontainer = new QHContainerWidget(this);
|
||||
hcontainer->setSpacing(3);
|
||||
hcontainer->addWidget(tabsContextMenuButton);
|
||||
hcontainer->addWidget(refreshToolButton);
|
||||
hcontainer->addWidget(helpToolButton);
|
||||
|
||||
@@ -52,6 +61,7 @@ SeerThreadManagerWidget::SeerThreadManagerWidget (QWidget* parent) : QWidget(par
|
||||
readSettings();
|
||||
|
||||
// Connect things.
|
||||
QObject::connect(tabsContextMenuButton, &QToolButton::clicked, this, &SeerThreadManagerWidget::handleTabsContextMenuButtonClicked);
|
||||
QObject::connect(refreshToolButton, &QToolButton::clicked, this, &SeerThreadManagerWidget::handleRefreshToolButtonClicked);
|
||||
QObject::connect(helpToolButton, &QToolButton::clicked, this, &SeerThreadManagerWidget::handleHelpToolButtonClicked);
|
||||
QObject::connect(schedulerLockingComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &SeerThreadManagerWidget::handleSchedulerLockingComboBox);
|
||||
@@ -164,13 +174,21 @@ void SeerThreadManagerWidget::handleTabChanged (int index) {
|
||||
|
||||
void SeerThreadManagerWidget::writeSettings () {
|
||||
|
||||
// Write tab order to settings.
|
||||
// Build up visible list.
|
||||
QStringList visible;
|
||||
|
||||
for (int i=0; i<tabWidget->tabBar()->count(); i++) {
|
||||
visible.append(tabWidget->isTabVisible(i) ? "true" : "false");
|
||||
}
|
||||
|
||||
// Build up tab order.
|
||||
QStringList tabs;
|
||||
|
||||
for (int i=0; i<tabWidget->tabBar()->count(); i++) {
|
||||
tabs.append(tabWidget->tabBar()->tabText(i));
|
||||
}
|
||||
|
||||
// Build up current tab.
|
||||
QString current = tabWidget->tabBar()->tabText(tabWidget->tabBar()->currentIndex());
|
||||
|
||||
//qDebug() << "Tabs" << tabs;
|
||||
@@ -180,6 +198,7 @@ void SeerThreadManagerWidget::writeSettings () {
|
||||
|
||||
settings.beginGroup("threadmanagerwindow"); {
|
||||
settings.setValue("taborder", tabs.join(','));
|
||||
settings.setValue("tabvisible", visible.join(','));
|
||||
settings.setValue("tabcurrent", current);
|
||||
} settings.endGroup();
|
||||
}
|
||||
@@ -194,10 +213,12 @@ void SeerThreadManagerWidget::readSettings () {
|
||||
// Read tab order from settings.
|
||||
QSettings settings;
|
||||
QStringList tabs;
|
||||
QStringList visible;
|
||||
QString current;
|
||||
|
||||
settings.beginGroup("threadmanagerwindow"); {
|
||||
tabs = settings.value("taborder").toString().split(',');
|
||||
visible = settings.value("tabvisible").toString().split(',');
|
||||
current = settings.value("tabcurrent").toString();
|
||||
} settings.endGroup();
|
||||
|
||||
@@ -222,6 +243,18 @@ void SeerThreadManagerWidget::readSettings () {
|
||||
}
|
||||
}
|
||||
|
||||
// Show/Hide tabs.
|
||||
for (int i=0; i<visible.count(); i++) {
|
||||
QString flag = visible[i];
|
||||
if (flag == "true") {
|
||||
tabWidget->setTabVisible(i,true);
|
||||
}else if (flag == "false") {
|
||||
tabWidget->setTabVisible(i,false);
|
||||
}else{
|
||||
tabWidget->setTabVisible(i,true);
|
||||
}
|
||||
}
|
||||
|
||||
// Make a tab current.
|
||||
if (current != "") {
|
||||
for (int i=0; i<tabWidget->tabBar()->count(); i++) {
|
||||
@@ -235,3 +268,58 @@ void SeerThreadManagerWidget::readSettings () {
|
||||
}
|
||||
}
|
||||
|
||||
void SeerThreadManagerWidget::handleTabsContextMenuButtonClicked() {
|
||||
|
||||
// Build the menu and execute it.
|
||||
QMenu contextMenu;
|
||||
QWidget* container = new QWidget(&contextMenu);
|
||||
QVBoxLayout* layout = new QVBoxLayout(container);
|
||||
|
||||
for (int i = 0; i < tabWidget->count(); i++) {
|
||||
|
||||
QString title = tabWidget->tabText(i);
|
||||
QCheckBox* showTabCheckBox = new QCheckBox(title, container);
|
||||
showTabCheckBox->setChecked(tabWidget->isTabVisible(i));
|
||||
layout->addWidget(showTabCheckBox);
|
||||
|
||||
QObject::connect(showTabCheckBox, &QCheckBox::toggled, [this, showTabCheckBox, i](bool checked) {
|
||||
|
||||
// Count visible tabs.
|
||||
int count=0;
|
||||
|
||||
for (int x=0; x<tabWidget->count(); x++) {
|
||||
if (tabWidget->isTabVisible(x)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
// Adjust the count. The 'checked' is made before the UI is updated.
|
||||
if (checked == true) {
|
||||
count++;
|
||||
}else{
|
||||
count--;
|
||||
}
|
||||
|
||||
// Reset the checkbox UI if the last visible tab was clicked.
|
||||
if (checked == false and count == 0) {
|
||||
showTabCheckBox->setChecked(true);
|
||||
// Don't hide last visible tab.
|
||||
}else if (checked == false and count > 1) {
|
||||
tabWidget->setTabVisible(i, checked);
|
||||
// Always show tabs when asked.
|
||||
}else{
|
||||
tabWidget->setTabVisible(i, checked);
|
||||
}
|
||||
|
||||
writeSettings();
|
||||
});
|
||||
}
|
||||
container->setLayout(layout);
|
||||
|
||||
QWidgetAction* action = new QWidgetAction(&contextMenu);
|
||||
action->setDefaultWidget(container);
|
||||
contextMenu.addAction(action);
|
||||
|
||||
contextMenu.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ class SeerThreadManagerWidget : public QWidget, protected Ui::SeerThreadManagerW
|
||||
void handleForkFollowComboBox (int index);
|
||||
void handleTabMoved (int from, int to);
|
||||
void handleTabChanged (int index);
|
||||
void handleTabsContextMenuButtonClicked ();
|
||||
|
||||
private:
|
||||
SeerThreadFramesBrowserWidget* _threadFramesBrowserWidget;
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
#include "SeerHelpPageDialog.h"
|
||||
#include "QHContainerWidget.h"
|
||||
#include <QtWidgets/QToolButton>
|
||||
#include <QtWidgets/QMenu>
|
||||
#include <QtWidgets/QCheckBox>
|
||||
#include <QtWidgets/QWidgetAction>
|
||||
#include <QtGui/QIcon>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QDebug>
|
||||
@@ -31,6 +34,11 @@ SeerVariableManagerWidget::SeerVariableManagerWidget (QWidget* parent) : QWidget
|
||||
tabWidget->addTab(_registerValuesBrowserWidget, "Registers");
|
||||
tabWidget->addTab(_signalValuesBrowserWidget, "Signals");
|
||||
|
||||
QToolButton* tabsContextMenuButton = new QToolButton(tabWidget);
|
||||
tabsContextMenuButton->setIcon(QIcon(":/seer/resources/thenounproject/preferences.svg"));
|
||||
tabsContextMenuButton->setToolTip("Show/Hide tabs.");
|
||||
tabsContextMenuButton->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
QToolButton* refreshToolButton = new QToolButton(tabWidget);
|
||||
refreshToolButton->setIcon(QIcon(":/seer/resources/RelaxLightIcons/view-refresh.svg"));
|
||||
refreshToolButton->setToolTip("Refresh the variable/register/signal information.");
|
||||
@@ -41,6 +49,7 @@ SeerVariableManagerWidget::SeerVariableManagerWidget (QWidget* parent) : QWidget
|
||||
|
||||
QHContainerWidget* hcontainer = new QHContainerWidget(this);
|
||||
hcontainer->setSpacing(3);
|
||||
hcontainer->addWidget(tabsContextMenuButton);
|
||||
hcontainer->addWidget(refreshToolButton);
|
||||
hcontainer->addWidget(helpToolButton);
|
||||
|
||||
@@ -50,6 +59,7 @@ SeerVariableManagerWidget::SeerVariableManagerWidget (QWidget* parent) : QWidget
|
||||
readSettings();
|
||||
|
||||
// Connect things.
|
||||
QObject::connect(tabsContextMenuButton, &QToolButton::clicked, this, &SeerVariableManagerWidget::handleTabsContextMenuButtonClicked);
|
||||
QObject::connect(refreshToolButton, &QToolButton::clicked, this, &SeerVariableManagerWidget::handleRefreshToolButtonClicked);
|
||||
QObject::connect(helpToolButton, &QToolButton::clicked, this, &SeerVariableManagerWidget::handleHelpToolButtonClicked);
|
||||
QObject::connect(tabWidget->tabBar(), &QTabBar::tabMoved, this, &SeerVariableManagerWidget::handleTabMoved);
|
||||
@@ -131,13 +141,21 @@ void SeerVariableManagerWidget::handleRaiseTrackerTab () {
|
||||
|
||||
void SeerVariableManagerWidget::writeSettings () {
|
||||
|
||||
// Write tab order to settings.
|
||||
// Build up visible list.
|
||||
QStringList visible;
|
||||
|
||||
for (int i=0; i<tabWidget->tabBar()->count(); i++) {
|
||||
visible.append(tabWidget->isTabVisible(i) ? "true" : "false");
|
||||
}
|
||||
|
||||
// Build up tab order.
|
||||
QStringList tabs;
|
||||
|
||||
for (int i=0; i<tabWidget->tabBar()->count(); i++) {
|
||||
tabs.append(tabWidget->tabBar()->tabText(i));
|
||||
}
|
||||
|
||||
// Build up current tab.
|
||||
QString current = tabWidget->tabBar()->tabText(tabWidget->tabBar()->currentIndex());
|
||||
|
||||
//qDebug() << "Tabs" << tabs;
|
||||
@@ -147,6 +165,7 @@ void SeerVariableManagerWidget::writeSettings () {
|
||||
|
||||
settings.beginGroup("variablemanagerwindow"); {
|
||||
settings.setValue("taborder", tabs.join(','));
|
||||
settings.setValue("tabvisible", visible.join(','));
|
||||
settings.setValue("tabcurrent", current);
|
||||
} settings.endGroup();
|
||||
}
|
||||
@@ -161,10 +180,12 @@ void SeerVariableManagerWidget::readSettings () {
|
||||
// Read tab order from settings.
|
||||
QSettings settings;
|
||||
QStringList tabs;
|
||||
QStringList visible;
|
||||
QString current;
|
||||
|
||||
settings.beginGroup("variablemanagerwindow"); {
|
||||
tabs = settings.value("taborder").toString().split(',');
|
||||
visible = settings.value("tabvisible").toString().split(',');
|
||||
current = settings.value("tabcurrent").toString();
|
||||
} settings.endGroup();
|
||||
|
||||
@@ -189,6 +210,18 @@ void SeerVariableManagerWidget::readSettings () {
|
||||
}
|
||||
}
|
||||
|
||||
// Show/Hide tabs.
|
||||
for (int i=0; i<visible.count(); i++) {
|
||||
QString flag = visible[i];
|
||||
if (flag == "true") {
|
||||
tabWidget->setTabVisible(i,true);
|
||||
}else if (flag == "false") {
|
||||
tabWidget->setTabVisible(i,false);
|
||||
}else{
|
||||
tabWidget->setTabVisible(i,true);
|
||||
}
|
||||
}
|
||||
|
||||
// Make a tab current.
|
||||
if (current != "") {
|
||||
for (int i=0; i<tabWidget->tabBar()->count(); i++) {
|
||||
@@ -202,3 +235,58 @@ void SeerVariableManagerWidget::readSettings () {
|
||||
}
|
||||
}
|
||||
|
||||
void SeerVariableManagerWidget::handleTabsContextMenuButtonClicked() {
|
||||
|
||||
// Build the menu and execute it.
|
||||
QMenu contextMenu;
|
||||
QWidget* container = new QWidget(&contextMenu);
|
||||
QVBoxLayout* layout = new QVBoxLayout(container);
|
||||
|
||||
for (int i = 0; i < tabWidget->count(); i++) {
|
||||
|
||||
QString title = tabWidget->tabText(i);
|
||||
QCheckBox* showTabCheckBox = new QCheckBox(title, container);
|
||||
showTabCheckBox->setChecked(tabWidget->isTabVisible(i));
|
||||
layout->addWidget(showTabCheckBox);
|
||||
|
||||
QObject::connect(showTabCheckBox, &QCheckBox::toggled, [this, showTabCheckBox, i](bool checked) {
|
||||
|
||||
// Count visible tabs.
|
||||
int count=0;
|
||||
|
||||
for (int x=0; x<tabWidget->count(); x++) {
|
||||
if (tabWidget->isTabVisible(x)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
// Adjust the count. The 'checked' is made before the UI is updated.
|
||||
if (checked == true) {
|
||||
count++;
|
||||
}else{
|
||||
count--;
|
||||
}
|
||||
|
||||
// Reset the checkbox UI if the last visible tab was clicked.
|
||||
if (checked == false and count == 0) {
|
||||
showTabCheckBox->setChecked(true);
|
||||
// Don't hide last visible tab.
|
||||
}else if (checked == false and count > 1) {
|
||||
tabWidget->setTabVisible(i, checked);
|
||||
// Always show tabs when asked.
|
||||
}else{
|
||||
tabWidget->setTabVisible(i, checked);
|
||||
}
|
||||
|
||||
writeSettings();
|
||||
});
|
||||
}
|
||||
container->setLayout(layout);
|
||||
|
||||
QWidgetAction* action = new QWidgetAction(&contextMenu);
|
||||
action->setDefaultWidget(container);
|
||||
contextMenu.addAction(action);
|
||||
|
||||
contextMenu.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ class SeerVariableManagerWidget : public QWidget, protected Ui::SeerVariableMana
|
||||
void handleTabChanged (int index);
|
||||
void handleRaiseLoggerTab ();
|
||||
void handleRaiseTrackerTab ();
|
||||
void handleTabsContextMenuButtonClicked ();
|
||||
|
||||
private:
|
||||
SeerVariableTrackerBrowserWidget* _variableTrackerBrowserWidget;
|
||||
|
||||
Reference in New Issue
Block a user