6 #include <QColorDialog>
8 #include <QFontComboBox>
10 #include <QStyleFactory>
12 #include "ui_settingsguicomponent.h"
19 using namespace swift::gui::settings;
20 using namespace swift::core::context;
24 CSettingsGuiComponent::CSettingsGuiComponent(QWidget *parent) : QFrame(parent), ui(new Ui::
CSettingsGuiComponent)
28 ui->cb_SettingsGuiWidgetStyle->clear();
29 ui->cb_SettingsGuiWidgetStyle->insertItems(0, QStyleFactory::keys());
33 connect(ui->cb_SettingsGuiWidgetStyle, qOverload<int>(&QComboBox::currentIndexChanged),
this,
34 &CSettingsGuiComponent::widgetStyleChanged, Qt::QueuedConnection);
36 ui->comp_SettingsFonts->setStyleSheetDefaultColor();
39 connect(ui->rb_PreferExtendedSelection, &QRadioButton::released,
this,
40 &CSettingsGuiComponent::selectionChanged);
41 connect(ui->rb_PreferMultiSelection, &QRadioButton::released,
this, &CSettingsGuiComponent::selectionChanged);
43 this->guiSettingsChanged();
50 ui->hs_SettingsGuiOpacity->setVisible(!hide);
51 ui->lbl_SettingsGuiOpacity->setVisible(!hide);
56 ui->hs_SettingsGuiOpacity->setValue(
static_cast<int>(value));
59 void CSettingsGuiComponent::selectionChanged()
61 QAbstractItemView::SelectionMode sm = QAbstractItemView::NoSelection;
62 if (ui->rb_PreferExtendedSelection->isChecked()) { sm = QAbstractItemView::ExtendedSelection; }
63 else if (ui->rb_PreferMultiSelection->isChecked()) { sm = QAbstractItemView::MultiSelection; }
64 if (sm == m_guiSettings.get().getPreferredSelection()) {
return; }
66 m_guiSettings.setAndSaveProperty(CGeneralGuiSettings::IndexPreferredSelection, CVariant::fromValue(sm));
67 CLogMessage::preformatted(m);
70 void CSettingsGuiComponent::guiSettingsChanged()
73 const int index = ui->cb_SettingsGuiWidgetStyle->findText(settings.getWidgetStyle());
74 if (index != ui->cb_SettingsGuiWidgetStyle->currentIndex())
76 ui->cb_SettingsGuiWidgetStyle->setCurrentIndex(index);
79 switch (settings.getPreferredSelection())
81 case QAbstractItemView::ExtendedSelection: ui->rb_PreferExtendedSelection->setChecked(
true);
break;
82 case QAbstractItemView::MultiSelection: ui->rb_PreferMultiSelection->setChecked(
true);
break;
87 void CSettingsGuiComponent::widgetStyleChanged(
int index)
89 const QString widgetStyle = ui->cb_SettingsGuiWidgetStyle->itemText(index);
100 const int ret = QMessageBox::information(
this, tr(
"Change style?"),
101 tr(
"Changing style requires a restart.\nChanges will be visible a the "
102 "next start.\nDo you want to save your changes?"),
103 QMessageBox::Ok | QMessageBox::Cancel);
105 if (ret != QMessageBox::Ok)
107 ui->cb_SettingsGuiWidgetStyle->setCurrentText(settings.
getWidgetStyle());
115 ui->cb_SettingsGuiWidgetStyle->setCurrentText(settings.
getWidgetStyle());
118 const CStatusMessage m = m_guiSettings.setAndSaveProperty(CGeneralGuiSettings::IndexWidgetStyle, widgetStyle);
119 CLogMessage::preformatted(m);
const context::IContextNetwork * getIContextNetwork() const
Direct access to contexts if a CCoreFacade has been initialized.
virtual bool isConnected() const =0
Network connected?
void changedWindowsOpacity(int opacity)
Change the windows opacity 0..100.
void setGuiOpacity(double value)
GUI Opacity 0-100%.
virtual ~CSettingsGuiComponent()
Destructor.
void hideOpacity(bool hide)
Hide opacity elements.
bool isDifferentValidWidgetStyle(const QString &style) const
Has changed widget style.
const QString & getWidgetStyle() const
Widget style.
Class for emitting a log message.
Derived & validationError(const char16_t(&format)[N])
Set the severity to error, providing a format string, and adding the validation category.
Streamable status message, e.g.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
High level reusable GUI components.
Free functions in swift::misc.