Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
matrixcombopopup.h
Go to the documentation of this file.
1
8
9#ifndef MATRIXCOMBOBOX_H
10#define MATRIXCOMBOBOX_H
11
12#include <QComboBox>
13#include <QFrame>
14#include <QGridLayout>
15#include <QPaintEvent>
16#include <QPushButton>
17#include <QStringList>
18#include <QVBoxLayout>
19#include <QApplication>
20#include <QEvent>
21#include <QFrame>
22#include <QGraphicsDropShadowEffect>
23#include <QHoverEvent>
24#include <QScreen>
25#include <QScrollArea>
26#include <QStyle>
27#include <QStyleOptionComboBox>
28#include <cmath> // for sqrt
29
31class MatrixComboPopup : public QFrame {
32 Q_OBJECT
33
34public:
35
40 MatrixComboPopup(const QStringList& sParams, const QStringList& otherParams,
41 QComboBox* parent = nullptr);
42
45 void showBelow(QWidget* widget);
46
47private slots:
48
50 void selectItem();
51
52private:
53 QComboBox* parentCombo;
54};
55
57class MatrixComboBox : public QComboBox {
58 Q_OBJECT
59
60public:
61
64 explicit MatrixComboBox(QWidget* parent = nullptr);
65
69 void setParameters(const QStringList& sParams,
70 const QStringList& otherParams);
71
72protected:
74 void showPopup() override;
75
77 void hidePopup() override;
78
81 void paintEvent(QPaintEvent* event) override;
82
83private:
84 QStringList sParams;
85 QStringList otherParams;
86 bool popupVisible;
87 MatrixComboPopup* popup;
88};
89
91class HoverButton : public QPushButton {
92public:
93
97 HoverButton(const QString& text, QWidget* parent = nullptr)
98 : QPushButton(text, parent) {
99 setFlat(true);
100 setMouseTracking(true);
101
102 // Create initial style
103 setStyleSheet("QPushButton {"
104 " padding: 5px;"
105 " border: none;"
106 " background-color: transparent;"
107 " text-align: left;"
108 "}"
109 "QPushButton:hover {"
110 " background-color: rgba(0, 0, 0, 10%);"
111 " border-radius: 3px;"
112 "}");
113
114 // Create shadow effect (hidden by default)
115 shadowEffect = new QGraphicsDropShadowEffect(this);
116 shadowEffect->setBlurRadius(10);
117 shadowEffect->setColor(QColor(0, 0, 0, 80));
118 shadowEffect->setOffset(0, 0);
119 shadowEffect->setEnabled(false);
120 setGraphicsEffect(shadowEffect);
121 }
122
123protected:
124
128 bool event(QEvent* event) override {
129 if (event->type() == QEvent::HoverEnter) {
130 shadowEffect->setEnabled(true);
131 } else if (event->type() == QEvent::HoverLeave) {
132 shadowEffect->setEnabled(false);
133 }
134 return QPushButton::event(event);
135 }
136
137private:
138 QGraphicsDropShadowEffect* shadowEffect;
139};
140
141
142
143#endif // MATRIXCOMBOBOX_H
Custom button with hover effect and shadow.
Definition matrixcombopopup.h:91
HoverButton(const QString &text, QWidget *parent=nullptr)
Constructor.
Definition matrixcombopopup.h:97
bool event(QEvent *event) override
Handles hover events to show/hide shadow.
Definition matrixcombopopup.h:128
ComboBox with custom matrix-style popup for parameter selection.
Definition matrixcombopopup.h:57
void showPopup() override
Shows custom matrix popup instead of standard dropdown.
Definition matrixcombopopup.cpp:135
void hidePopup() override
Hides the custom popup.
Definition matrixcombopopup.cpp:158
void setParameters(const QStringList &sParams, const QStringList &otherParams)
Sets parameters to display in popup.
Definition matrixcombopopup.cpp:125
void paintEvent(QPaintEvent *event) override
Custom paint to show popup state.
Definition matrixcombopopup.cpp:167
Custom popup displaying S-parameters in matrix layout with other parameters below.
Definition matrixcombopopup.h:31
void showBelow(QWidget *widget)
Shows popup below specified widget.
Definition matrixcombopopup.cpp:81