Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style and preferences fixes #1861

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions core/src/emuwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,11 @@ void EmuWidget::setEnableDemo(bool en)

void EmuWidget::browseFile(QLineEdit *lineEditPath)
{
QString filePath =
QFileDialog::getOpenFileName(this, "Open a file", "directoryToOpen",
"All (*);;XML Files (*.xml);;Text Files (*.txt);;BIN Files (*.bin)");
bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool();
QString filePath = QFileDialog::getOpenFileName(
this, "Open a file", "directoryToOpen",
"All (*);;XML Files (*.xml);;Text Files (*.txt);;BIN Files (*.bin)", nullptr,
(useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog));
lineEditPath->setText(filePath);
m_enDemoBtn->setFocus();
}
Expand Down
10 changes: 8 additions & 2 deletions core/src/scopymainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,22 @@ void ScopyMainWindow::deviceAutoconnect()

void ScopyMainWindow::save()
{
bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool();
QString selectedFilter;
QString fileName = QFileDialog::getSaveFileName(this, tr("Save"), "", "", &selectedFilter);
QString fileName = QFileDialog::getSaveFileName(
this, tr("Save"), "", "", &selectedFilter,
(useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog));
save(fileName);
ScopyTitleManager::setIniFileName(fileName);
}

void ScopyMainWindow::load()
{
bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool();
QString selectedFilter;
QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), "", "", &selectedFilter);
QString fileName = QFileDialog::getOpenFileName(
this, tr("Open"), "", "", &selectedFilter,
(useNativeDialogs ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog));
load(fileName);
ScopyTitleManager::setIniFileName(fileName);
}
Expand Down
24 changes: 15 additions & 9 deletions core/src/scopypreferencespage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ QWidget *ScopyPreferencesPage::buildGeneralPreferencesPage()
lay->addWidget(generalWidget);
lay->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));

generalSection->contentLayout()->addWidget(buildSaveSessionPreference());
generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox(
p, "general_save_attached", "Save/Load tool attached state", generalSection));
generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox(
Expand All @@ -266,9 +265,6 @@ QWidget *ScopyPreferencesPage::buildGeneralPreferencesPage()
p, "iiowidgets_use_lazy_loading", "Use Lazy Loading", generalSection));
generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCheckBox(
p, "general_use_native_dialogs", "Use native dialogs", generalSection));
QWidget *autoConnectCb = PreferencesHelper::addPreferenceCheckBox(
p, "autoconnect_previous", "Auto-connect to previous session", generalSection);
generalSection->contentLayout()->addWidget(autoConnectCb);
generalSection->contentLayout()->addWidget(PreferencesHelper::addPreferenceCombo(
p, "font_scale", "Font scale (EXPERIMENTAL)", {"1", "1.15", "1.3", "1.45", "1.6", "1.75", "1.9"},
generalSection));
Expand All @@ -283,20 +279,30 @@ QWidget *ScopyPreferencesPage::buildGeneralPreferencesPage()
p, "general_scan_for_devices", "Regularly scan for new devices", generalSection));

// Auto-connect
m_autoConnectWidget = new MenuSectionCollapseWidget("Session devices", MenuCollapseSection::MHCW_NONE,
m_autoConnectWidget = new MenuSectionCollapseWidget("Session ", MenuCollapseSection::MHCW_NONE,
MenuCollapseSection::MHW_COMPOSITEWIDGET, page);
MenuCollapseHeader *autoConnectHeader =
dynamic_cast<MenuCollapseHeader *>(m_autoConnectWidget->collapseSection()->header());
autoConnectHeader->headerWidget()->layout()->addWidget(
new QLabel("At each auto-connect session, it will try to connect to the checked devices"));
m_autoConnectWidget->contentLayout()->setSpacing(10);
lay->addWidget(m_autoConnectWidget);
lay->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));

QWidget *autoConnectCb = PreferencesHelper::addPreferenceCheckBox(
p, "autoconnect_previous", "Auto-connect to previous session", generalSection);
m_autoConnectWidget->contentLayout()->addWidget(autoConnectCb);

m_autoConnectWidget->contentLayout()->addWidget(buildSaveSessionPreference());

m_devRefresh = new QPushButton("Refresh", m_autoConnectWidget);
m_devRefresh->setMaximumWidth(Style::getDimension(json::global::unit_5));
Style::setStyle(m_devRefresh, style::properties::button::basicButton);
m_autoConnectWidget->add(m_devRefresh);
Style::setStyle(m_devRefresh, style::properties::button::borderButton);
QWidget *refreshWidget = new QWidget(m_autoConnectWidget);
QHBoxLayout *refreshLayout = new QHBoxLayout(refreshWidget);
refreshLayout->setMargin(0);
refreshLayout->addWidget(
new QLabel("At each auto-connect session, it will try to connect to the checked devices"));
refreshLayout->addWidget(m_devRefresh);
m_autoConnectWidget->contentLayout()->addWidget(refreshWidget);

connect(m_devRefresh, &QPushButton::pressed, this, &ScopyPreferencesPage::refreshDevicesPressed);

Expand Down
5 changes: 0 additions & 5 deletions gui/include/gui/stylehelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,9 @@ class SCOPY_GUI_EXPORT StyleHelper : public QObject
static void MeasurementSelectorItemWidget(QString iconPath, MeasurementSelectorItem *w,
QString objectName = "");
static void HoverWidget(QWidget *w, bool draggable = false, QString objectName = "");
static void TransparentWidget(QWidget *w, QString objectName = "");
static void HoverToolTip(QWidget *w, QString info, QString objectName = "");
static void NoBackgroundIconButton(QPushButton *w, QIcon icon, QString objectName = "");
static void BrowseButton(QPushButton *btn, QString objectName = "");
static void OrangeWidget(QWidget *w, QString objectName = "");
static void ActiveStoredLabel(QLabel *w, QString objectName = "");
static void FaultsFrame(QFrame *w, QString objectName = "");
static void FaultsExplanation(QWidget *w, QString objectName = "");

private:
static StyleHelper *pinstance_;
Expand Down
1 change: 0 additions & 1 deletion gui/include/gui/widgets/menulineedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class SCOPY_GUI_EXPORT MenuLineEdit : public QWidget
virtual ~MenuLineEdit();

QLineEdit *edit();
void applyStylesheet();

private:
QLineEdit *m_edit;
Expand Down
3 changes: 3 additions & 0 deletions gui/include/gui/widgets/toolbuttons.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,12 @@ class SCOPY_GUI_EXPORT InfoBtn : public QPushButton
QPushButton *getDocumentationButton();
void generateInfoPopup(QWidget *parent);

virtual bool eventFilter(QObject *watched, QEvent *event);

private:
PopupWidget *m_popupWidget;
bool m_hasTutorial;
QString m_iconPath;
};

class SCOPY_GUI_EXPORT RunBtn : public QPushButton
Expand Down
1 change: 0 additions & 1 deletion gui/src/plotnavigator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ void PlotNavigator::initResetButton()
m_resetButton = new QPushButton(m_plot->canvas());
QIcon icon(QPixmap(":/gui/icons/search_crossed.svg"));
m_resetButton->setFlat(true);
StyleHelper::TransparentWidget(m_resetButton);
m_resetButton->setIcon(icon);
m_resetButton->hide();

Expand Down
1 change: 0 additions & 1 deletion gui/src/plotwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ PlotWidget::PlotWidget(QWidget *parent)
setupPlotButtonManager();

m_plot->canvas()->installEventFilter(this);
Style::setBackgroundColor(m_plot, QString("transparent"));
Style::setBackgroundColor(m_plot->canvas(), json::theme::background_plot, true);
}

Expand Down
10 changes: 7 additions & 3 deletions gui/src/printplotmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <QFileDialog>
#include <QDateTime>
#include <QCoreApplication>
#include <pluginbase/preferences.h>

using namespace scopy;

Expand All @@ -35,9 +36,12 @@ PrintPlotManager::PrintPlotManager(QObject *parent)
void PrintPlotManager::printPlots(QList<PlotWidget *> plotList, QString toolName)
{
// select folder where to save
QString folderPath = QFileDialog::getExistingDirectory(
nullptr, "Select Folder", "",
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks | QFileDialog::DontUseNativeDialog);
bool useNativeDialogs = Preferences::get("general_use_native_dialogs").toBool();
QString folderPath = QFileDialog::getExistingDirectory(nullptr, "Select Folder", "",
(useNativeDialogs ? QFileDialog::Options()
: QFileDialog::ShowDirsOnly |
QFileDialog::DontResolveSymlinks |
QFileDialog::DontUseNativeDialog));

if(!folderPath.isEmpty()) {
// use current date and tool name to crete the file name
Expand Down
65 changes: 0 additions & 65 deletions gui/src/stylehelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,6 @@ void StyleHelper::HoverWidget(QWidget *w, bool draggable, QString objectName)
w->setStyleSheet(style);
}

void StyleHelper::TransparentWidget(QWidget *w, QString objectName)
{
if(!objectName.isEmpty())
w->setObjectName(objectName);
QString style = QString(R"css(background-color: transparent;)css");
w->setStyleSheet(style);
}

void StyleHelper::HoverToolTip(QWidget *w, QString info, QString objectName)
{
if(!objectName.isEmpty())
Expand Down Expand Up @@ -362,61 +354,4 @@ void StyleHelper::BrowseButton(QPushButton *btn, QString objectName)
btn->setFixedSize(size, size);
}

// TODO: move these functions to SWIOT specicfic style structure
// SWIOT -------------------------------------------------------
void StyleHelper::OrangeWidget(QWidget *w, QString objectName)
{
if(!objectName.isEmpty())
w->setObjectName(objectName);
QString style = QString(R"css(
QWidget{
color:&&orange&&
}
)css");
style.replace("&&orange&&", Style::getAttribute(json::theme::interactive_primary_idle));
w->setStyleSheet(style);
}

void StyleHelper::ActiveStoredLabel(QLabel *w, QString objectName)
{
if(!objectName.isEmpty())
w->setObjectName(objectName);
QString style = QString(R"css(
QLabel{
background-color: transparent; width: 40px; height: 14px; border: 2px solid ; border-radius: 8px; border-color: &&content_default&&;
}
QLabel[high=false] { border-color: &&content_default&&; background-color: transparent; }
QLabel[high=true] { border-color: &&content_default&&; background-color: &&content_default&&; }
)css");
style.replace("&&content_default&&", Style::getAttribute(json::theme::content_default));
w->setStyleSheet(style);
}

void StyleHelper::FaultsFrame(QFrame *w, QString objectName)
{
if(!objectName.isEmpty())
w->setObjectName(objectName);
QString style = QString(R"css(
QFrame[pressed=true] { background-color: &&elementHighlight&&; border: 1px solid &&elementBackground&&; border-radius:5px; }
)css");
style.replace("&&elementHighlight&&", Style::getAttribute(json::theme::content_subtle));
style.replace("&&elementBackground&&", Style::getAttribute(json::theme::background_primary));

w->setStyleSheet(style);
}

void StyleHelper::FaultsExplanation(QWidget *w, QString objectName)
{
if(!objectName.isEmpty())
w->setObjectName(objectName);
QString style = QString(R"css(
QWidget[highlighted=true]{color:&&content_default&&;}
QWidget{color:&&defaultColor&&;}
)css");
style.replace("&&defaultColor&&", Style::getAttribute(json::theme::interactive_subtle_idle));
style.replace("&&content_default&&", Style::getAttribute(json::theme::content_default));
w->setStyleSheet(style);
}
// SWIOT -------------------------------------------------------

#include "moc_stylehelper.cpp"
1 change: 0 additions & 1 deletion gui/src/tooltemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ ToolTemplate::ToolTemplate(QWidget *parent)
m_rightStack->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_topStack->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_bottomStack->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
Style::setBackgroundColor(m_ui->leftContainer, QString("transparent"));
Style::setBackgroundColor(m_ui->topContainerMenuControl, json::theme::background_primary);
}

Expand Down
1 change: 0 additions & 1 deletion gui/src/widgets/cursorsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ CursorSettings::~CursorSettings() {}
void CursorSettings::initUI()
{
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
StyleHelper::TransparentWidget(this, "cursorSettings");
setFixedWidth(200);
layout = new QVBoxLayout(this);
layout->setMargin(0);
Expand Down
2 changes: 1 addition & 1 deletion gui/src/widgets/menucontrolbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void MenuControlButton::setDoubleClickToOpenMenu(bool b)
dblClickToOpenMenu = connect(this, &MenuControlButton::doubleClicked, this, [=]() {
setChecked(true);
if(m_btn->isVisible()) {
m_btn->toggle();
m_btn->click();
}
});
} else {
Expand Down
8 changes: 1 addition & 7 deletions gui/src/widgets/menulineedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,11 @@ MenuLineEdit::MenuLineEdit(QWidget *parent)
m_edit = new QLineEdit(this);

lay->addWidget(m_edit);
applyStylesheet();
Style::setStyle(m_edit, style::properties::lineedit::menuLineEdit);
}

MenuLineEdit::~MenuLineEdit() {}

QLineEdit *MenuLineEdit::edit() { return m_edit; }

void MenuLineEdit::applyStylesheet()
{
Style::setStyle(m_edit, style::properties::lineedit::menuLineEdit);
Style::setBackgroundColor(this, QString("transparent"));
}

#include "moc_menulineedit.cpp"
3 changes: 2 additions & 1 deletion gui/src/widgets/plotcursorreadouts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*
*/

#include <style.h>
#include <widgets/plotcursorreadouts.h>

using namespace scopy;
Expand Down Expand Up @@ -143,7 +144,7 @@ void PlotCursorReadouts::initContent()
x_contents_lay->addWidget(invDeltaX_val, 3, 1);

for(auto w : this->findChildren<QWidget *>()) {
StyleHelper::TransparentWidget(w);
Style::setBackgroundColor(w, QString("transparent"), true);
}
}

Expand Down
1 change: 0 additions & 1 deletion gui/src/widgets/scopystatusbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ void ScopyStatusBar::initUi()

m_stackedWidget = new QStackedWidget(this);
layout()->addWidget(m_stackedWidget);
Style::setStyle(this, style::properties::widget::basicComponent);

hide();
}
Expand Down
30 changes: 23 additions & 7 deletions gui/src/widgets/toolbuttons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,32 @@ InfoBtn::InfoBtn(QWidget *parent, bool hasTutorial)
, m_hasTutorial(hasTutorial)
{

QString iconPath = ":/gui/icons/" + Style::getAttribute(json::theme::icon_theme_folder) + "/icons/info.svg";
setIcon(Style::getPixmap(iconPath, Style::getColor(json::theme::content_default)));

connect(this, &QPushButton::toggled, this, [=](bool toggle) {
const char *color = toggle ? json::theme::content_inverse : json::theme::content_default;
setIcon(Style::getPixmap(iconPath, Style::getColor(color)));
});
m_iconPath = ":/gui/icons/" + Style::getAttribute(json::theme::icon_theme_folder) + "/icons/info.svg";
setIcon(Style::getPixmap(m_iconPath, Style::getColor(json::theme::content_default)));

setCheckable(false);
Style::setStyle(this, style::properties::button::squareIconButton);
installEventFilter(this);
}

bool InfoBtn::eventFilter(QObject *watched, QEvent *event)
{
QPushButton *button = qobject_cast<QPushButton *>(watched);
if(!button) {
return false;
}

if(event->type() == QEvent::Enter) {
setIcon(Style::getPixmap(m_iconPath, Style::getColor(json::theme::content_inverse)));
return true;
}

if(event->type() == QEvent::Leave) {
setIcon(Style::getPixmap(m_iconPath, Style::getColor(json::theme::content_default)));
return true;
}

return false;
}

bool InfoBtn::hasTutorial() { return m_hasTutorial; }
Expand Down
2 changes: 1 addition & 1 deletion gui/style/json/Harmonic dark.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"icon_theme_folder": "scopy-default",
"pixmap_color": "#FFFFFF",
"interactive_subtle_idle": "#9FA4AD",
"interactive_subtle_idle": "#797d85",
"interactive_subtle_hover": "#B7BBC3",
"interactive_subtle_pressed": "#c5c9d1",
"interactive_subtle_disabled": "#4B545D",
Expand Down
27 changes: 27 additions & 0 deletions gui/style/qss/properties/button/darkGrayButton.qss
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
QPushButton[&&property&&=true] {
text-align:left;
height: &unit_3&;
background-color: #80&color_inverse_hexcode&;;
color: &white&;
border-radius: &radius_1&;
text-align:center;
}
QPushButton[&&property&&=true]:hover {
background-color: #C8&color_inverse_hexcode&;
color: &white&;
}

QPushButton[&&property&&=true]:pressed {
background-color: #C8&color_inverse_hexcode&;
color: &white&;
}

QPushButton[&&property&&=true]:checked {
background-color: #C8&color_inverse_hexcode&;
color: &white&;
}

QPushButton[&&property&&=true]:disabled {
background-color: #C8&color_inverse_hexcode&;
color: &white&;
}
Loading
Loading