Skip to content

Commit

Permalink
iiodebugplugin: Visual improvements
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei-Fabian-Pop <[email protected]>
  • Loading branch information
Andrei-Fabian-Pop committed Mar 26, 2024
1 parent 941c4f7 commit 79ebc28
Show file tree
Hide file tree
Showing 20 changed files with 344 additions and 176 deletions.
7 changes: 7 additions & 0 deletions gui/include/gui/stylehelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#include <QPushButton>
#include <QHBoxLayout>
#include <QStatusBar>
#include <QTableWidget>
#include <QSplitter>
#include <QTreeView>

#include <scopy-gui_export.h>
#include <utils.h>
Expand Down Expand Up @@ -102,6 +105,10 @@ class SCOPY_GUI_EXPORT StyleHelper : public QObject
static void HoverToolTip(QWidget *w, QString info, QString objectName = "");
static void WarningLabel(QLabel *w, QString objectName = "");
static void NoBackgroundIconButton(QPushButton *w, QIcon icon, QString objectName = "");
static void TabWidgetBarUnderline(QTabWidget *w, QString objectName = "");
static void TableWidgetDebugger(QTableWidget *w, QString objectName = "");
static void SplitterStyle(QSplitter *w, QString objectName = "");
static void TreeViewDebugger(QTreeView *w, QString objectName = "");

private:
QMap<QString, QString> colorMap;
Expand Down
4 changes: 4 additions & 0 deletions gui/res/icons/green_add.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions gui/res/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<file>icons/level_trigger_handle.svg</file>
<file>icons/level_trigger_up.svg</file>
<file>icons/orange_close.svg</file>
<file>icons/green_add.svg</file>
<file>icons/measurements/amplitude.svg</file>
<file>icons/measurements/area.svg</file>
<file>icons/measurements/cycle_area.svg</file>
Expand Down
75 changes: 75 additions & 0 deletions gui/src/stylehelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1263,4 +1263,79 @@ void StyleHelper::NoBackgroundIconButton(QPushButton *w, QIcon icon, QString obj
w->setStyleSheet(style);
}

void StyleHelper::TabWidgetBarUnderline(QTabWidget *w, QString objectName)
{
if(!objectName.isEmpty()) {
w->setObjectName(objectName);
}

QString style = R"css(QTabBar::tab:selected { border-bottom-color: &&ScopyBlue&&; })css";
style.replace("&&ScopyBlue&&", StyleHelper::getColor("ScopyBlue"));
w->setStyleSheet(style);
}

void StyleHelper::TableWidgetDebugger(QTableWidget *w, QString objectName)
{
if(!objectName.isEmpty()) {
w->setObjectName(objectName);
}

QString style = QString(R"css(
QHeaderView::section {
font: 11pt;
border: none;
background-color:&&ScopyBackground&&;
font-family: Open Sans;
}
QTableWidget::item {
border-left: 1px solid &&UIElementHighlight&&;
font-family: Open Sans;
}
QTableWidget::item::selected {
background-color: &&ScopyBlue&&;
font-family: Open Sans;
}
QHeaderView::section {
border-left: 1px solid &&UIElementHighlight&&;
font-family: Open Sans;
}
)css");
style.replace("&&ScopyBackground&&", StyleHelper::getColor("ScopyBackground"));
style.replace("&&UIElementHighlight&&", StyleHelper::getColor("UIElementHighlight"));
style.replace("&&ScopyBlue&&", StyleHelper::getColor("ScopyBlue"));
w->setStyleSheet(style);
}

void StyleHelper::SplitterStyle(QSplitter *w, QString objectName)
{
if(!objectName.isEmpty()) {
w->setStyleSheet(objectName);
}

QString style = QString(R"css(
QSplitter::handle:horizontal { width: 6px; }
QSplitter::handle:vertical { height: 6px; }
QSplitter::handle:hover { background-color: rgba(0, 0, 0, 40); }
QSplitter::handle:pressed { background-color: rgba(0, 0, 0, 70); }
QSplitter::handle:disabled { background-color: transparent; }
)css");

w->setStyleSheet(style);
}

void StyleHelper::TreeViewDebugger(QTreeView *w, QString objectName)
{
if(!objectName.isEmpty()) {
w->setStyleSheet(objectName);
}

QString style = R"css(
QTreeView { color: white; show-decoration-selected: 0; }
QTreeView::item:selected { background-color: &&ScopyBlue&& }
)css";
style.replace("&&ScopyBlue&&", StyleHelper::getColor("ScopyBlue"));

w->setStyleSheet(style);
}

#include "moc_stylehelper.cpp"
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef DEBUGGERLOGGINGCATEGORIES_H
#define DEBUGGERLOGGINGCATEGORIES_H

#include <QLoggingCategory>

// Used fo the tree view visual part
Q_LOGGING_CATEGORY(CAT_TREEVIEW, "DebuggerTreeView")

// Used for the details view visual part
Q_LOGGING_CATEGORY(CAT_DETAILSVIEW, "DebuggerDetailsView")

// Used for the watch list view visual part
Q_LOGGING_CATEGORY(CAT_WATCHLIST, "DebuggerWatchList")

// Used for the creation / access of the internal model or any internal configurations
Q_LOGGING_CATEGORY(CAT_DEBUGGERIIOMODEL, "DebuggerIIOModel")

#endif // DEBUGGERLOGGINGCATEGORIES_H
9 changes: 9 additions & 0 deletions plugins/iiodebugplugin/include/iiodebugplugin/detailsview.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ class DetailsView : public QWidget
void setIIOStandardItem(IIOStandardItem *item);
void refreshIIOView();

QPushButton *readBtn();
QPushButton *addToWatchlistBtn();

// add:true = +, add:false = X
void setAddToWatchlistState(bool add);

private:
void setupUi();

Expand All @@ -27,7 +33,10 @@ class DetailsView : public QWidget
QTabWidget *m_tabWidget;
QWidget *m_guiView;
QWidget *m_iioView;
QWidget *m_titleContainer;
QLabel *m_titleLabel;
QPushButton *m_readBtn;
QPushButton *m_addToWatchlistBtn;
};
} // namespace scopy::iiodebugplugin

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ private Q_SLOTS:
IIOSortFilterProxyModel *m_proxyModel;
WatchListView *m_watchListView;
ApiObject *m_apiObject;
QPushButton *m_readBtn;
QPushButton *m_addToWatchlistBtn;
IIOStandardItem *m_currentlySelectedItem;
SaveContextSetup *m_saveContextSetup;

Expand Down
2 changes: 2 additions & 0 deletions plugins/iiodebugplugin/include/iiodebugplugin/iiomodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class IIOModel : public QObject

private:
void iioTreeSetup();
void setupCtx();
void generateCtxAttributes();
void setupCurrentDevice();
void generateDeviceAttributes();
Expand All @@ -46,6 +47,7 @@ class IIOModel : public QObject
int m_currentDeviceIndex;
int m_currentChannelIndex;

QList<IIOWidget *> m_ctxList;
QList<IIOWidget *> m_devList;
QList<IIOWidget *> m_chnlList;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class IIOStandardItem : public QStandardItem
QString path();
QString format();
QString trigger();
QString triggerStatus(); // TODO: look into making this an enum
QString triggerStatus();
IIOStandardItem::Type type();

/**
Expand All @@ -63,12 +63,12 @@ class IIOStandardItem : public QStandardItem
bool isWatched();
void setWatched(bool isWatched);

QString typeString();

private:
void buildDetails();
void generateToolTip();

// TODO: this approach would make 2 almost similar calls, rethink this
// maybe only extracting data if the extract funtcions are called ?
void extractDataFromDevice();
void extractDataFromChannel();

Expand Down
17 changes: 13 additions & 4 deletions plugins/iiodebugplugin/include/iiodebugplugin/watchlistentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,33 @@ class WatchListEntry : public QObject
QTableWidgetItem *name();
void setName(QString name);

QTableWidgetItem *value();
void setValue(QString value);

QTableWidgetItem *path();
void setPath(QString path);

IIOStandardItem *item();

QTableWidgetItem *type() const;
void setType(QString type);

// the value entry can only be lineedit or combo box, other options do not have enough space to look good
QWidget *valueUi() const;
void setValueUi(QWidget *newValueUi);

private Q_SLOTS:
void setNewData(QString data, QString optionalData);

private:
void setupUi();
void setupWidget(IIOWidget *widget);

IIOStandardItem *m_item;
QTableWidgetItem *m_name;
QTableWidgetItem *m_value;
QWidget *m_valueUi;
QTableWidgetItem *m_type;
QTableWidgetItem *m_path;

QComboBox *m_combo;
QLineEdit *m_lineedit;
};
} // namespace scopy::iiodebugplugin

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public Q_SLOTS:
void resizeEvent(QResizeEvent *event) override;

private:
QList<int> m_offsets = {0, 0, 0, 0}; // TODO: prettify

QList<int> m_offsets;
ApiObject *m_apiObject;
QMap<QString, WatchListEntry *> m_entryObjects;
};
Expand Down
10 changes: 5 additions & 5 deletions plugins/iiodebugplugin/src/clidetailsview.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "clidetailsview.h"
#include <QLoggingCategory>
#include "debuggerloggingcategories.h"

using namespace scopy::iiodebugplugin;

Expand Down Expand Up @@ -164,8 +164,8 @@ void CliDetailsView::setupDevice()

setupDeviceAttr();
} else {
// TODO: improve this message
qWarning() << "Logic error";
qWarning(CAT_DETAILSVIEW)
<< "Error when setting up the device, the type is not Channel nor DeviceAttribute";
}
}
m_currentText.append(m_deviceAttrsString);
Expand Down Expand Up @@ -193,8 +193,8 @@ void CliDetailsView::setupContext()
QStandardItem *child = m_currentItem->child(i);
m_contextIIOItem = dynamic_cast<IIOStandardItem *>(child);

// FIXME: if the list is device,attr,device the print will not be correct
// but can this happen?
// we consider that the list of children is divided in 2 sections: the
// attributes and the devices/triggers and they cannot be interleaved
if(m_contextIIOItem->type() == IIOStandardItem::ContextAttribute) {
setupContextAttr();
} else if(m_contextIIOItem->type() == IIOStandardItem::Device ||
Expand Down
44 changes: 39 additions & 5 deletions plugins/iiodebugplugin/src/detailsview.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "detailsview.h"
#include <QVBoxLayout>

#define ADD_ICON ":/gui/icons/green_add.svg"
#define REMOVE_ICON ":/gui/icons/orange_close.svg"

using namespace scopy::iiodebugplugin;

DetailsView::DetailsView(QWidget *parent)
Expand All @@ -11,6 +14,9 @@ DetailsView::DetailsView(QWidget *parent)
, m_tabWidget(new QTabWidget(this))
, m_guiView(new QWidget(this))
, m_iioView(new QWidget(this))
, m_readBtn(new QPushButton("Read", this))
, m_addToWatchlistBtn(new QPushButton(this))
, m_titleContainer(new QWidget(this))
{
setupUi();
}
Expand All @@ -20,11 +26,18 @@ void DetailsView::setupUi()
setLayout(new QVBoxLayout(this));
layout()->setContentsMargins(0, 6, 0, 0);

m_titleContainer->setLayout(new QHBoxLayout(this));
m_titleContainer->layout()->setContentsMargins(0, 0, 0, 0);

m_titleLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
m_titleLabel->setStyleSheet("color: white;");
m_titleLabel->setAlignment(Qt::AlignCenter);
m_titleLabel->setStyleSheet("font-size: 14pt");

m_readBtn->setFixedWidth(50);
m_addToWatchlistBtn->setMaximumSize(25, 25);
m_addToWatchlistBtn->setDisabled(true);

m_guiView->setLayout(new QVBoxLayout(m_guiView));
m_iioView->setLayout(new QVBoxLayout(m_iioView));

Expand All @@ -38,12 +51,17 @@ void DetailsView::setupUi()
m_tabWidget->addTab(m_iioView, "IIO View");
m_tabWidget->tabBar()->setDocumentMode(true);
m_tabWidget->tabBar()->setExpanding(true);
// TODO: this will move to StyleHelper
QString style = "QTabBar::tab:selected { border-bottom-color: &&ScopyBlue&&; }";
style.replace("&&ScopyBlue&&", StyleHelper::getColor("ScopyBlue"));
m_tabWidget->setStyleSheet(style);

layout()->addWidget(m_titleLabel);
StyleHelper::TabWidgetBarUnderline(m_tabWidget, "DetailsTabWidget");
StyleHelper::BlueButton(m_readBtn, "ReadCurrentSelectionButton");
m_addToWatchlistBtn->setStyleSheet("QPushButton { background-color: transparent; border: 0px; }");

m_titleContainer->layout()->addWidget(m_titleLabel);
m_titleContainer->layout()->addWidget(m_addToWatchlistBtn);
m_titleContainer->layout()->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Preferred));
m_titleContainer->layout()->addWidget(m_readBtn);

layout()->addWidget(m_titleContainer);
layout()->addWidget(m_tabWidget);
}

Expand All @@ -55,3 +73,19 @@ void DetailsView::setIIOStandardItem(IIOStandardItem *item)
}

void DetailsView::refreshIIOView() { m_cliDetailsView->refreshView(); }

QPushButton *DetailsView::readBtn() { return m_readBtn; }

QPushButton *DetailsView::addToWatchlistBtn() { return m_addToWatchlistBtn; }

void DetailsView::setAddToWatchlistState(bool add)
{
m_addToWatchlistBtn->setEnabled(true);
if(add) {
m_addToWatchlistBtn->setIcon(QIcon(ADD_ICON));
m_addToWatchlistBtn->setToolTip("Add to Watchlist");
} else {
m_addToWatchlistBtn->setIcon(QIcon(REMOVE_ICON));
m_addToWatchlistBtn->setToolTip("Remove from Watchlist");
}
}
4 changes: 3 additions & 1 deletion plugins/iiodebugplugin/src/guidetailsview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void GuiDetailsView::setupUi()
m_attrSeparator->getContentWidget()->layout()->addWidget(m_scrollArea);
m_attrSeparator->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);

m_detailsSeparator->setLabel("Device info");
m_detailsSeparator->setLabel("General info");
m_detailsSeparator->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);

layout()->addWidget(m_attrSeparator);
Expand All @@ -53,6 +53,8 @@ void GuiDetailsView::setIIOStandardItem(IIOStandardItem *item)
m_detailsList.append(label);
m_detailsSeparator->getContentWidget()->layout()->addWidget(label);
}

m_detailsSeparator->setLabel(m_currentItem->typeString() + " info");
}

void GuiDetailsView::clearWidgets()
Expand Down
Loading

0 comments on commit 79ebc28

Please sign in to comment.