diff --git a/.gitignore b/.gitignore index e1e1299ad..e9ea22d11 100644 --- a/.gitignore +++ b/.gitignore @@ -57,5 +57,6 @@ __pycache__ .vscode/settings.json .vscode/tasks.json /cmake-build-debug/ - +.cache/ +/qt/ build-qucs-s-spar-viewer-Desktop-Debug/ diff --git a/qucs-activefilter/qucsactivefilter.cpp b/qucs-activefilter/qucsactivefilter.cpp index 341cf5253..1e7323f02 100644 --- a/qucs-activefilter/qucsactivefilter.cpp +++ b/qucs-activefilter/qucsactivefilter.cpp @@ -222,8 +222,9 @@ QucsActiveFilter::QucsActiveFilter(QWidget *parent) QSize sz; QString s1 = ":/images/bitmaps/AFR.svg"; imgAFR = new QSvgWidget(s1); + imgAFR->setStyleSheet("background-color: white;"); sz = gpbPar->size(); // take left box size as reference size - sz *= 0.6; + sz *= 0.75; imgAFR->setFixedSize(sz); vl1->addWidget(imgAFR); vl1->setAlignment(imgAFR, Qt::AlignHCenter); @@ -234,6 +235,7 @@ QucsActiveFilter::QucsActiveFilter(QWidget *parent) gpbSCH->setLayout(vl2); s1 = ":/images/bitmaps/cauer.svg"; sch_pic = new QSvgWidget(s1); + sch_pic->setStyleSheet("background-color: white;"); sz = gpbFunc->size(); // take lefbox size as reference size sz *= 0.95; sch_pic->setFixedSize(sz); diff --git a/qucs-attenuator/qucsattenuator.cpp b/qucs-attenuator/qucsattenuator.cpp index 68ec7af05..401bc2103 100644 --- a/qucs-attenuator/qucsattenuator.cpp +++ b/qucs-attenuator/qucsattenuator.cpp @@ -97,6 +97,7 @@ QucsAttenuator::QucsAttenuator() topoGrid->addWidget(ComboTopology, 1,0,1,2); pixTopology = new QLabel(TopoGroup);//====================Pixmap for Topology + pixTopology->setStyleSheet("background-color: white;"); pixTopology->setPixmap(QPixmap((":/bitmaps/att_pi.png"))); topoGrid->addWidget(pixTopology,2,0,3,2); diff --git a/qucs-powercombining/qucspowercombiningtool.cpp b/qucs-powercombining/qucspowercombiningtool.cpp index 72d65469e..0786bd323 100644 --- a/qucs-powercombining/qucspowercombiningtool.cpp +++ b/qucs-powercombining/qucspowercombiningtool.cpp @@ -280,6 +280,7 @@ QucsPowerCombiningTool::QucsPowerCombiningTool() QString s1 = ":/bitmaps/Wilkinson_idealTL.svg"; QGridLayout * imgLayout = new QGridLayout(); imgWidget = new QSvgWidget(s1); + imgWidget->setStyleSheet("background-color: white;"); sz = imgWidget->size(); imgWidget->setFixedSize(.6*sz); imgLayout->addWidget(imgWidget); diff --git a/qucs/dialogs/qucssettingsdialog.cpp b/qucs/dialogs/qucssettingsdialog.cpp index b539a615e..416266170 100644 --- a/qucs/dialogs/qucssettingsdialog.cpp +++ b/qucs/dialogs/qucssettingsdialog.cpp @@ -54,9 +54,24 @@ #include #include #include +#include +#include +#include using namespace std; +auto getFontDescription = [](const auto& Font) -> QString { + const QChar comma(u','); + QString fontDescription = Font.family() + comma + + QString::number(Font.pointSize()); + + QString fontStyle = Font.styleName(); + if (!fontStyle.isEmpty()) + fontDescription += comma + fontStyle; + + return fontDescription; +}; + QucsSettingsDialog::QucsSettingsDialog(QucsApp *parent) : QDialog(parent) { @@ -75,30 +90,34 @@ QucsSettingsDialog::QucsSettingsDialog(QucsApp *parent) QWidget *appSettingsTab = new QWidget(t); QGridLayout *appSettingsGrid = new QGridLayout(appSettingsTab); + const QStringList appLanguages = { + tr("system language"), + tr("English") + " (en)", + tr("Arabic") + " (ar)", + tr("Catalan") + " (ca)", + tr("Chinese") + " (zh_CN)", + tr("Czech") + " (cs)", + tr("French") + " (fr)", + tr("German") + " (de)", + tr("Hebrew") + " (he)", + tr("Hungarian") + " (hu)", + tr("Italian") + " (it)", + tr("Japanese") + " (jp)", + tr("Kazakh") + " (kk)", + tr("Polish") + " (pl)", + tr("Portuguese-BR") + " (pt_BR)", + tr("Portuguese-PT") + " (pt_PT)", + tr("Romanian") + " (ro)", + tr("Russian") + " (ru)", + tr("Spanish") + " (es)", + tr("Swedish") + " (sv)", + tr("Turkish") + " (tr)", + tr("Ukrainian") + " (uk)" + }; + appSettingsGrid->addWidget(new QLabel(tr("Language (set after reload):"), appSettingsTab) ,1, 0); LanguageCombo = new QComboBox(appSettingsTab); - LanguageCombo->insertItem(-1, tr("Ukrainian")+" (uk)"); - LanguageCombo->insertItem(-1, tr("Turkish")+" (tr)"); - LanguageCombo->insertItem(-1, tr("Swedish")+" (sv)"); - LanguageCombo->insertItem(-1, tr("Spanish")+" (es)"); - LanguageCombo->insertItem(-1, tr("Russian")+" (ru)"); - LanguageCombo->insertItem(-1, tr("Romanian")+" (ro)"); - LanguageCombo->insertItem(-1, tr("Portuguese-PT")+" (pt_PT)"); - LanguageCombo->insertItem(-1, tr("Portuguese-BR")+" (pt_BR)"); - LanguageCombo->insertItem(-1, tr("Polish")+" (pl)"); - LanguageCombo->insertItem(-1, tr("Kazakh")+" (kk)"); - LanguageCombo->insertItem(-1, tr("Japanese")+" (jp)"); - LanguageCombo->insertItem(-1, tr("Italian")+" (it)"); - LanguageCombo->insertItem(-1, tr("Hungarian")+" (hu)"); - LanguageCombo->insertItem(-1, tr("Hebrew")+" (he)"); - LanguageCombo->insertItem(-1, tr("German")+" (de)"); - LanguageCombo->insertItem(-1, tr("French")+" (fr)"); - LanguageCombo->insertItem(-1, tr("Chinese")+" (zh_CN)"); - LanguageCombo->insertItem(-1, tr("Czech")+" (cs)"); - LanguageCombo->insertItem(-1, tr("Catalan")+" (ca)"); - LanguageCombo->insertItem(-1, tr("Arabic")+" (ar)"); - LanguageCombo->insertItem(-1, tr("English")+" (en)"); - LanguageCombo->insertItem(-1, tr("system language")); + LanguageCombo->addItems(appLanguages); appSettingsGrid->addWidget(LanguageCombo, 1, 1); val200 = new QIntValidator(0, 200, this); @@ -181,7 +200,21 @@ QucsSettingsDialog::QucsSettingsDialog(QucsApp *parent) appAppearanceGrid->addWidget(new QLabel(tr("Default graph line thickness:"), appSettingsTab), 8, 0); graphLineWidthEdit = new QLineEdit(appSettingsTab); graphLineWidthEdit->setValidator(val50); - appAppearanceGrid->addWidget(graphLineWidthEdit, 8, 1); + appAppearanceGrid->addWidget(graphLineWidthEdit, 8, 1); + + appAppearanceGrid->addWidget(new QLabel(tr("App Style:"), appSettingsTab), 9, 0); + QStringList styles = QStyleFactory::keys(); // Get available styles + StyleCombo = new QComboBox(appSettingsTab); + StyleCombo->addItems(styles); + appAppearanceGrid->addWidget(StyleCombo,9,1); + + + // Retrieve the current style and set it as selected + QString currentStyle = QApplication::style()->objectName(); + int index = StyleCombo->findText(currentStyle, Qt::MatchFixedString); + if (index != -1) { + StyleCombo->setCurrentIndex(index); + } t->addTab(appAppearanceTab, tr("Appearance")); @@ -456,9 +489,12 @@ QucsSettingsDialog::QucsSettingsDialog(QucsApp *parent) Font = QucsSettings.font; AppFont = QucsSettings.appFont; TextFont = QucsSettings.textFont; - FontButton->setText(Font.toString()); - AppFontButton->setText(AppFont.toString()); - TextFontButton->setText(TextFont.toString()); + + + + FontButton->setText(getFontDescription(Font)); + AppFontButton->setText(getFontDescription(AppFont)); + TextFontButton->setText(getFontDescription(TextFont)); QString s = QString::number(QucsSettings.largeFontSize, 'f', 1); LargeFontSizeEdit->setText(s); graphLineWidthEdit->setText(_settings::Get().item("DefaultGraphLineWidth")); @@ -595,10 +631,22 @@ void QucsSettingsDialog::slotApply() QPalette p = vp->palette(); p.setColor(vp->backgroundRole(), QucsSettings.BGColor); vp->setPalette(p); + } changed = true; } + QString selectedStyle = StyleCombo->currentText(); + if (_settings::Get().item("AppStyle") != selectedStyle ) + { + QStyle* style = QStyleFactory::create(selectedStyle); + if (style) { + QApplication::setStyle(style); + _settings::Get().setItem("AppStyle", selectedStyle); + changed = true; + } + } + // Update all open schematics with the new grid color. if (_settings::Get().item("GridColor") != GridColorButton->palette().color(GridColorButton->backgroundRole())) { _settings::Get().setItem("GridColor", GridColorButton->palette().color(GridColorButton->backgroundRole())); @@ -769,7 +817,7 @@ void QucsSettingsDialog::slotFontDialog() if(ok) { Font = tmpFont; - FontButton->setText(Font.toString()); + FontButton->setText(getFontDescription(Font)); } } @@ -780,7 +828,7 @@ void QucsSettingsDialog::slotAppFontDialog() if(ok) { AppFont = tmpFont; - AppFontButton->setText(AppFont.toString()); + AppFontButton->setText(getFontDescription(AppFont)); } } @@ -791,7 +839,7 @@ void QucsSettingsDialog::slotTextFontDialog() if(ok) { TextFont = tmpFont; - TextFontButton->setText(TextFont.toString()); + TextFontButton->setText(getFontDescription(TextFont)); } } @@ -828,13 +876,13 @@ void QucsSettingsDialog::slotDefaultValues() Font = QApplication::font(); AppFont = QucsSettings.sysDefaultFont; TextFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); - FontButton->setText(Font.toString()); - AppFontButton->setText(AppFont.toString()); - TextFontButton->setText(TextFont.toString()); + FontButton->setText(getFontDescription(Font)); + AppFontButton->setText(getFontDescription(AppFont)); + TextFontButton->setText(getFontDescription(TextFont)); LargeFontSizeEdit->setText(QString::number(16.0)); LanguageCombo->setCurrentIndex(0); - + p = BGColorButton->palette(); p.setColor(BGColorButton->backgroundRole(), QColor(255,250,225)); BGColorButton->setPalette(p); diff --git a/qucs/dialogs/qucssettingsdialog.h b/qucs/dialogs/qucssettingsdialog.h index 318882bf8..b928a5bdd 100644 --- a/qucs/dialogs/qucssettingsdialog.h +++ b/qucs/dialogs/qucssettingsdialog.h @@ -88,7 +88,8 @@ private slots: QCheckBox *checkWiring, *checkLoadFromFutureVersions, *checkAntiAliasing, *checkTextAntiAliasing, *checkFullTraceNames; - QComboBox *LanguageCombo; + QComboBox *LanguageCombo, + *StyleCombo; QPushButton *FontButton, *AppFontButton, *TextFontButton, *BGColorButton, *GridColorButton; QLineEdit *LargeFontSizeEdit, *undoNumEdit, *editorEdit, *Input_Suffix, *Input_Program, *homeEdit, *admsXmlEdit, *ascoEdit, *octaveEdit, @@ -108,7 +109,7 @@ private slots: private: QStringList currentPaths; - + private: void makePathTable(); diff --git a/qucs/main.cpp b/qucs/main.cpp index 287cd5b83..cf0797f84 100644 --- a/qucs/main.cpp +++ b/qucs/main.cpp @@ -783,6 +783,14 @@ int main(int argc, char *argv[]) // load existing settings (if any) loadSettings(); + /* restore saved style */ + QString savedStyle = _settings::Get().item("AppStyle"); + QStyle* style = QStyleFactory::create(savedStyle); + if (style) { + QApplication::setStyle(style); + } + /* restore saved style */ + QDir().mkpath(QucsSettings.qucsWorkspaceDir.absolutePath()); QDir().mkpath(QucsSettings.tempFilesDir.absolutePath()); diff --git a/qucs/qucs.cpp b/qucs/qucs.cpp index 07d0eb4f4..7b41af555 100644 --- a/qucs/qucs.cpp +++ b/qucs/qucs.cpp @@ -364,6 +364,7 @@ void QucsApp::initView() QHBoxLayout *CompSearchLayout = new QHBoxLayout(); simulatorsCombobox = new QComboBox(this); + simulatorsCombobox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); connect(simulatorsCombobox, SIGNAL(activated(int)), SLOT(slotChangeSimulator(int))); CompChoose = new QComboBox(this); diff --git a/qucs/qucs_actions.cpp b/qucs/qucs_actions.cpp index 25b664941..af0d8d6e7 100644 --- a/qucs/qucs_actions.cpp +++ b/qucs/qucs_actions.cpp @@ -841,19 +841,22 @@ void QucsApp::slotCallEditor() // Is called to start the filter synthesis program. void QucsApp::slotCallFilter() { - launchTool(QUCS_NAME "filter", "filter synthesis"); + auto currentStyle = QApplication::style()->objectName(); + launchTool(QUCS_NAME "filter", "filter synthesis",(QStringList() << "-style" << currentStyle)); } void QucsApp::slotCallActiveFilter() { - launchTool(QUCS_NAME "activefilter", "active filter synthesis"); + auto currentStyle = QApplication::style()->objectName(); + launchTool(QUCS_NAME "activefilter", "active filter synthesis",(QStringList() << "-style" << currentStyle)); } // ------------------------------------------------------------------------ // Is called to start the transmission line calculation program. void QucsApp::slotCallLine() { - launchTool(QUCS_NAME "trans", "line calculation",QStringList()); + auto currentStyle = QApplication::style()->objectName(); + launchTool(QUCS_NAME "trans", "line calculation",(QStringList() << "-style" << currentStyle)); } // -------------------------------------------------------------- @@ -868,17 +871,20 @@ void QucsApp::slotCallMatch() // Is called to start the attenuator calculation program. void QucsApp::slotCallAtt() { - launchTool(QUCS_NAME "attenuator", "attenuator calculation",QStringList()); + auto currentStyle = QApplication::style()->objectName(); + launchTool(QUCS_NAME "attenuator", "attenuator calculation",(QStringList() << "-style" << currentStyle)); } void QucsApp::slotCallPwrComb() { - launchTool(QUCS_NAME "powercombining", "power combining calculation",QStringList()); + auto currentStyle = QApplication::style()->objectName(); + launchTool(QUCS_NAME "powercombining", "power combining calculation",(QStringList() << "-style" << currentStyle)); } void QucsApp::slotCallSPAR_Viewer() { - launchTool(QUCS_NAME "spar-viewer", "s-parameter viewer",QStringList()); + auto currentStyle = QApplication::style()->objectName(); + launchTool(QUCS_NAME "spar-viewer", "s-parameter viewer",(QStringList() << "-style" << currentStyle)); } diff --git a/qucs/settings.cpp b/qucs/settings.cpp index 6df63fb93..7e462d766 100644 --- a/qucs/settings.cpp +++ b/qucs/settings.cpp @@ -61,7 +61,11 @@ void settingsManager::initDefaults() m_Defaults["OctaveExecutable"] = "octave.exe"; #else m_Defaults["NgspiceExecutable"] = "ngspice"; - m_Defaults["XyceExecutable"] = "/usr/local/Xyce-Release-6.8.0-OPENSOURCE/bin/Xyce"; + #ifndef Q_OS_MACOS + m_Defaults["XyceExecutable"] = "/usr/local/Xyce-Release-6.8.0-OPENSOURCE/bin/Xyce"; + #else + m_Defaults["XyceExecutable"] = "Xyce"; + #endif m_Defaults["RFLayoutExecutable"] = "qucsrflayout"; m_Defaults["OctaveExecutable"] = "octave"; #endif