FreeCAD

Форк
0
/
PrefWidgets.cpp 
821 строка · 21.2 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net>     *
3
 *                                                                         *
4
 *   This file is part of the FreeCAD CAx development system.              *
5
 *                                                                         *
6
 *   This library is free software; you can redistribute it and/or         *
7
 *   modify it under the terms of the GNU Library General Public           *
8
 *   License as published by the Free Software Foundation; either          *
9
 *   version 2 of the License, or (at your option) any later version.      *
10
 *                                                                         *
11
 *   This library  is distributed in the hope that it will be useful,      *
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14
 *   GNU Library General Public License for more details.                  *
15
 *                                                                         *
16
 *   You should have received a copy of the GNU Library General Public     *
17
 *   License along with this library; see the file COPYING.LIB. If not,    *
18
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
19
 *   Suite 330, Boston, MA  02111-1307, USA                                *
20
 *                                                                         *
21
 ***************************************************************************/
22

23
#include "PreCompiled.h"
24
#ifndef _PreComp_
25
# include <QContextMenuEvent>
26
# include <QMenu>
27
#endif
28

29
#include <cstring>
30

31
#include <Base/Console.h>
32
#include <Base/Tools.h>
33
#include <App/Color.h>
34

35
#include "PrefWidgets.h"
36

37

38
using Base::Console;
39
using namespace Gui;
40

41
/** Constructs a preference widget.
42
 */
43
PrefWidget::PrefWidget()
44
 : WindowParameter("")
45
{
46
}
47

48
/**
49
 * Destroys the widget and detaches it from its parameter group.
50
 */
51
PrefWidget::~PrefWidget()
52
{
53
  if (getWindowParameter().isValid())
54
    getWindowParameter()->Detach(this);
55
}
56

57
/** Sets the preference name to \a name. */
58
void PrefWidget::setEntryName( const QByteArray& name )
59
{
60
  m_sPrefName = name;
61
}
62

63
/** Sets the preference name to \a name. */
64
void PrefWidget::setPrefEntry(const QByteArray& name)
65
{
66
  setEntryName(name);
67
}
68

69
/** Returns the widget's preference name. */
70
QByteArray PrefWidget::entryName() const
71
{
72
  return m_sPrefName;
73
}
74

75
/** Sets the preference path to \a path. */
76
void PrefWidget::setParamGrpPath( const QByteArray& path )
77
{
78
#ifdef FC_DEBUG
79
  if (getWindowParameter().isValid())
80
  {
81
    if ( paramGrpPath() != path )
82
      Base::Console().Warning("Widget already attached\n");
83
  }
84
#endif
85

86
  if ( paramGrpPath() != path )
87
  {
88
    if ( setGroupName( path ) )
89
    {
90
      m_sPrefGrp = path;
91
      assert(getWindowParameter().isValid());
92
      getWindowParameter()->Attach(this);
93
    }
94
  }
95
}
96

97
/** Sets the preference path to \a path. */
98
void PrefWidget::setPrefPath(const QByteArray& name)
99
{
100
  setParamGrpPath(name);
101
}
102

103
/** Returns the widget's preferences path. */
104
QByteArray PrefWidget::paramGrpPath() const
105
{
106
  return m_sPrefGrp;
107
}
108

109
/**
110
 * This method is called if one or more values in the parameter settings are changed
111
 * where getParamGrp() points to.
112
 * Note: This method is called for each parameter inside the parameter group. So
113
 * you have to filter out the appropriate parameter with the name \a sReason.
114
 * \a rCaller calls this method.
115
 */
116
void PrefWidget::OnChange(Base::Subject<const char*> &rCaller, const char * sReason)
117
{
118
    Q_UNUSED(rCaller);
119
    if (std::strcmp(sReason,m_sPrefName) == 0)
120
        restorePreferences();
121
}
122

123
/**
124
 * Saves the current preferences of the widget.
125
 * All preference widget attached to the same parameter group are notified.
126
 */
127
void PrefWidget::onSave()
128
{
129
  savePreferences();
130
  if (getWindowParameter().isValid())
131
    getWindowParameter()->Notify( entryName() );
132
#ifdef FC_DEBUG
133
  else
134
    qFatal( "No parameter group specified!" );
135
#endif
136
}
137

138
/**
139
 * Restores the preferences of the widget.
140
 */
141
void PrefWidget::onRestore()
142
{
143
#ifdef FC_DEBUG
144
  if (getWindowParameter().isNull())
145
    qWarning( "No parameter group specified!" );
146
#endif
147
  restorePreferences();
148
  m_Restored = true;
149
}
150

151
void PrefWidget::failedToSave(const QString& name) const
152
{
153
    QByteArray objname = name.toLatin1();
154
    if (objname.isEmpty())
155
        objname = "Undefined";
156
    Console().Warning("Cannot save %s (%s)\n", typeid(*this).name(), objname.constData());
157
}
158

159
void PrefWidget::failedToRestore(const QString& name) const
160
{
161
    QByteArray objname = name.toLatin1();
162
    if (objname.isEmpty())
163
        objname = "Undefined";
164
    Console().Warning("Cannot restore %s (%s)\n", typeid(*this).name(), objname.constData());
165
}
166

167
// --------------------------------------------------------------------
168

169
PrefSpinBox::PrefSpinBox ( QWidget * parent )
170
  : QSpinBox(parent), PrefWidget()
171
{
172
}
173

174
PrefSpinBox::~PrefSpinBox() = default;
175

176
void PrefSpinBox::restorePreferences()
177
{
178
  if ( getWindowParameter().isNull() )
179
  {
180
    failedToRestore(objectName());
181
    return;
182
  }
183

184
  int nVal = getWindowParameter()->GetInt( entryName(), QSpinBox::value() );
185
  setValue( nVal );
186
}
187

188
void PrefSpinBox::savePreferences()
189
{
190
  if (getWindowParameter().isNull())
191
  {
192
    failedToSave(objectName());
193
    return;
194
  }
195

196
  getWindowParameter()->SetInt( entryName() , (int)value() );
197
}
198

199
// --------------------------------------------------------------------
200

201
PrefDoubleSpinBox::PrefDoubleSpinBox ( QWidget * parent )
202
  : QDoubleSpinBox(parent), PrefWidget()
203
{
204
}
205

206
PrefDoubleSpinBox::~PrefDoubleSpinBox() = default;
207

208
void PrefDoubleSpinBox::restorePreferences()
209
{
210
  if ( getWindowParameter().isNull() )
211
  {
212
    failedToRestore(objectName());
213
    return;
214
  }
215

216
  double fVal = (double)getWindowParameter()->GetFloat( entryName() , value() );
217
  setValue(fVal);
218
}
219

220
void PrefDoubleSpinBox::savePreferences()
221
{
222
  if (getWindowParameter().isNull())
223
  {
224
    failedToSave(objectName());
225
    return;
226
  }
227

228
  getWindowParameter()->SetFloat( entryName(), value() );
229
}
230

231
// --------------------------------------------------------------------
232

233
PrefLineEdit::PrefLineEdit ( QWidget * parent )
234
  : QLineEdit(parent), PrefWidget()
235
{
236
}
237

238
PrefLineEdit::~PrefLineEdit() = default;
239

240
void PrefLineEdit::restorePreferences()
241
{
242
  if (getWindowParameter().isNull())
243
  {
244
    failedToRestore(objectName());
245
    return;
246
  }
247

248
  QString text = this->text();
249
  text = QString::fromUtf8(getWindowParameter()->GetASCII(entryName(), text.toUtf8()).c_str());
250
  setText(text);
251
}
252

253
void PrefLineEdit::savePreferences()
254
{
255
  if (getWindowParameter().isNull())
256
  {
257
    failedToSave(objectName());
258
    return;
259
  }
260

261
  getWindowParameter()->SetASCII(entryName(), text().toUtf8());
262
}
263

264
// --------------------------------------------------------------------
265

266
PrefTextEdit::PrefTextEdit(QWidget* parent)
267
    : QTextEdit(parent), PrefWidget()
268
{
269
}
270

271
PrefTextEdit::~PrefTextEdit() = default;
272

273
void PrefTextEdit::restorePreferences()
274
{
275
    if (getWindowParameter().isNull())
276
    {
277
        failedToRestore(objectName());
278
        return;
279
    }
280

281
    QString text = this->toPlainText();
282
    text = QString::fromUtf8(getWindowParameter()->GetASCII(entryName(), text.toUtf8()).c_str());
283
    setText(text);
284
}
285

286
void PrefTextEdit::savePreferences()
287
{
288
    if (getWindowParameter().isNull())
289
    {
290
        failedToSave(objectName());
291
        return;
292
    }
293

294
    QString text = this->toPlainText();
295
    getWindowParameter()->SetASCII(entryName(), text.toUtf8());
296
}
297

298
// --------------------------------------------------------------------
299

300
PrefFileChooser::PrefFileChooser ( QWidget * parent )
301
  : FileChooser(parent), PrefWidget()
302
{
303
}
304

305
PrefFileChooser::~PrefFileChooser() = default;
306

307
void PrefFileChooser::restorePreferences()
308
{
309
  if (getWindowParameter().isNull())
310
  {
311
    failedToRestore(objectName());
312
    return;
313
  }
314

315
  QString txt = QString::fromUtf8(getWindowParameter()->GetASCII(entryName(), fileName().toUtf8()).c_str());
316
  setFileName(txt);
317
}
318

319
void PrefFileChooser::savePreferences()
320
{
321
  if (getWindowParameter().isNull())
322
  {
323
    failedToSave(objectName());
324
    return;
325
  }
326

327
  getWindowParameter()->SetASCII(entryName(), fileName().toUtf8());
328
}
329

330
// --------------------------------------------------------------------
331

332
PrefComboBox::PrefComboBox ( QWidget * parent )
333
  : QComboBox(parent), PrefWidget()
334
{
335
}
336

337
PrefComboBox::~PrefComboBox() = default;
338

339
QMetaType::Type PrefComboBox::getParamType() const
340
{
341
  return static_cast<QMetaType::Type>(property("prefType").userType());
342
}
343

344
void PrefComboBox::restorePreferences()
345
{
346
  if (getWindowParameter().isNull())
347
  {
348
    failedToRestore(objectName());
349
    return;
350
  }
351
  if (!m_Restored) {
352
    m_Default = currentData();
353
    m_DefaultText = currentText();
354
    m_DefaultIndex = currentIndex();
355
  }
356
  int index = -1;
357
  switch(static_cast<int>(getParamType())) {
358
  case QMetaType::Int:
359
  case QMetaType::LongLong:
360
    index = findData(static_cast<int>(getWindowParameter()->GetInt(entryName(), m_Default.toInt())));
361
    break;
362
  case QMetaType::UInt:
363
  case QMetaType::ULongLong:
364
    index = findData(static_cast<uint>(getWindowParameter()->GetUnsigned(entryName(), m_Default.toUInt())));
365
    break;
366
  case QMetaType::Bool:
367
    index = findData(getWindowParameter()->GetBool(entryName(), m_Default.toBool()));
368
    break;
369
  case QMetaType::Double:
370
    index = findData(getWindowParameter()->GetFloat(entryName(), m_Default.toDouble()));
371
    break;
372
  case QMetaType::QString:
373
    index = findText(QString::fromUtf8(
374
          getWindowParameter()->GetASCII(entryName(), m_DefaultText.toUtf8().constData()).c_str()));
375
    break;
376
  case QMetaType::QByteArray:
377
    index = findData(QByteArray(getWindowParameter()->GetASCII(entryName(),
378
          m_Default.toByteArray().constData()).c_str()));
379
    break;
380
  default:
381
    index = getWindowParameter()->GetInt(entryName(), m_DefaultIndex);
382
    break;
383
  }
384
  if (index >= 0 && index < count())
385
    setCurrentIndex(index);
386
}
387

388
void PrefComboBox::savePreferences()
389
{
390
  if (getWindowParameter().isNull())
391
  {
392
    failedToSave(objectName());
393
    return;
394
  }
395

396
  switch(static_cast<int>(getParamType())) {
397
  case QMetaType::Int:
398
  case QMetaType::LongLong:
399
    getWindowParameter()->SetInt(entryName(), currentData().toInt());
400
    break;
401
  case QMetaType::UInt:
402
  case QMetaType::ULongLong:
403
    getWindowParameter()->SetUnsigned(entryName(), currentData().toUInt());
404
    break;
405
  case QMetaType::Bool:
406
    getWindowParameter()->SetBool(entryName(), currentData().toBool());
407
    break;
408
  case QMetaType::Double:
409
    getWindowParameter()->SetFloat(entryName(), currentData().toDouble());
410
    break;
411
  case QMetaType::QString:
412
    getWindowParameter()->SetASCII(entryName(), currentText().toUtf8().constData());
413
    break;
414
  case QMetaType::QByteArray:
415
    getWindowParameter()->SetASCII(entryName(), currentData().toByteArray().constData());
416
    break;
417
  default:
418
    getWindowParameter()->SetInt(entryName(), currentIndex());
419
    break;
420
  }
421
}
422

423
// --------------------------------------------------------------------
424

425
PrefCheckBox::PrefCheckBox ( QWidget * parent )
426
  : QCheckBox(parent), PrefWidget()
427
{
428
}
429

430
PrefCheckBox::~PrefCheckBox() = default;
431

432
void PrefCheckBox::restorePreferences()
433
{
434
  if (getWindowParameter().isNull())
435
  {
436
    failedToRestore(objectName());
437
    return;
438
  }
439

440
  bool enable = getWindowParameter()->GetBool( entryName(), isChecked() );
441
  setChecked(enable);
442
}
443

444
void PrefCheckBox::savePreferences()
445
{
446
  if (getWindowParameter().isNull())
447
  {
448
    failedToSave(objectName());
449
    return;
450
  }
451

452
  getWindowParameter()->SetBool( entryName(), isChecked() );
453
}
454

455
// --------------------------------------------------------------------
456

457
PrefRadioButton::PrefRadioButton ( QWidget * parent )
458
  : QRadioButton(parent), PrefWidget()
459
{
460
}
461

462
PrefRadioButton::~PrefRadioButton() = default;
463

464
void PrefRadioButton::restorePreferences()
465
{
466
  if (getWindowParameter().isNull())
467
  {
468
    failedToRestore(objectName());
469
    return;
470
  }
471

472
  bool enable = getWindowParameter()->GetBool( entryName(), isChecked() );
473
  setChecked(enable);
474
}
475

476
void PrefRadioButton::savePreferences()
477
{
478
  if (getWindowParameter().isNull())
479
  {
480
    failedToSave(objectName());
481
    return;
482
  }
483

484
  getWindowParameter()->SetBool( entryName() , isChecked() );
485
}
486

487
// --------------------------------------------------------------------
488

489
PrefSlider::PrefSlider ( QWidget * parent )
490
  : QSlider(parent), PrefWidget()
491
{
492
}
493

494
PrefSlider::~PrefSlider() = default;
495

496
void PrefSlider::restorePreferences()
497
{
498
  if ( getWindowParameter().isNull() )
499
  {
500
    failedToRestore(objectName());
501
    return;
502
  }
503

504
  int nVal = getWindowParameter()->GetInt(entryName(), QSlider::value());
505
  setValue(nVal);
506
}
507

508
void PrefSlider::savePreferences()
509
{
510
  if (getWindowParameter().isNull())
511
  {
512
    failedToSave(objectName());
513
    return;
514
  }
515

516
  getWindowParameter()->SetInt(entryName() , (int)value());
517
}
518

519
// --------------------------------------------------------------------
520

521
PrefColorButton::PrefColorButton ( QWidget * parent )
522
  : ColorButton(parent), PrefWidget()
523
{
524
}
525

526
PrefColorButton::~PrefColorButton() = default;
527

528
void PrefColorButton::restorePreferences()
529
{
530
  if (getWindowParameter().isNull()) {
531
    failedToRestore(objectName());
532
    return;
533
  }
534

535
  if (!m_Restored)
536
    m_Default = color();
537

538
  unsigned int icol = App::Color::asPackedRGBA<QColor>(m_Default);
539

540
  unsigned long lcol = static_cast<unsigned long>(icol);
541
  lcol = getWindowParameter()->GetUnsigned(entryName(), lcol);
542
  icol = static_cast<unsigned int>(lcol);
543
  QColor value = App::Color::fromPackedRGBA<QColor>(icol);
544
  if (!this->allowTransparency())
545
    value.setAlpha(0xff);
546
  setColor(value);
547
}
548

549
void PrefColorButton::savePreferences()
550
{
551
  if (getWindowParameter().isNull())
552
  {
553
    failedToSave(objectName());
554
    return;
555
  }
556

557
  QColor col = color();
558
  // (r,g,b,a) with a = 255 (opaque)
559
  unsigned int icol = App::Color::asPackedRGBA<QColor>(col);
560
  unsigned long lcol = static_cast<unsigned long>(icol);
561
  getWindowParameter()->SetUnsigned( entryName(), lcol );
562
}
563

564
// --------------------------------------------------------------------
565

566
PrefUnitSpinBox::PrefUnitSpinBox ( QWidget * parent )
567
  : QuantitySpinBox(parent), PrefWidget()
568
{
569
}
570

571
PrefUnitSpinBox::~PrefUnitSpinBox() = default;
572

573
void PrefUnitSpinBox::restorePreferences()
574
{
575
    if (getWindowParameter().isNull()) {
576
        failedToRestore(objectName());
577
        return;
578
    }
579

580
    double fVal = (double)getWindowParameter()->GetFloat( entryName() ,rawValue() );
581
    setValue(fVal);
582
}
583

584
void PrefUnitSpinBox::savePreferences()
585
{
586
    if (getWindowParameter().isNull()) {
587
        failedToSave(objectName());
588
        return;
589
    }
590

591
    double q = rawValue();
592
    getWindowParameter()->SetFloat( entryName(), q );
593
}
594

595
// --------------------------------------------------------------------
596

597
namespace Gui {
598
class HistoryList {
599
    QStringList list;
600
    int max_size = 5;
601
public:
602
    const QStringList& asStringList() const {
603
        return list;
604
    }
605
    int maximumSize() const {
606
        return max_size;
607
    }
608
    void setMaximumSize(int num) {
609
        max_size = num;
610
        while (list.size() > num)
611
            list.pop_front();
612
    }
613
    void clear() {
614
        list.clear();
615
    }
616
    void append(const QString& value) {
617
        if (!list.isEmpty() && list.back() == value)
618
            return;
619
        auto it = std::find(list.begin(), list.end(), value);
620
        if (it != list.end())
621
            list.erase(it);
622
        else if (list.size() == max_size)
623
            list.pop_front();
624
        list.push_back(value);
625
    }
626
};
627

628
class PrefQuantitySpinBoxPrivate
629
{
630
public:
631
    HistoryList history;
632
    bool isSaving = false;
633

634
    QByteArray getHistoryGroupName(QByteArray name) const {
635
        return name + "_History";
636
    }
637

638
    void restoreHistory(ParameterGrp::handle hGrp) {
639
        std::vector<std::string> hist = hGrp->GetASCIIs("Hist");
640
        for (const auto& it : hist)
641
            history.append(QString::fromStdString(it));
642
    }
643
    void clearHistory(ParameterGrp::handle hGrp) {
644
        std::vector<std::string> hist = hGrp->GetASCIIs("Hist");
645
        for (const auto& it : hist)
646
            hGrp->RemoveASCII(it.c_str());
647
    }
648
    void saveHistory(ParameterGrp::handle hGrp) {
649
        clearHistory(hGrp);
650

651
        const QStringList& list = history.asStringList();
652
        for (int i = 0; i < list.size(); i++) {
653
            QByteArray key("Hist");
654
            key.append(QByteArray::number(i));
655
            hGrp->SetASCII(key, list[i].toUtf8());
656
        }
657
    }
658
};
659
}
660

661
PrefQuantitySpinBox::PrefQuantitySpinBox (QWidget * parent)
662
  : QuantitySpinBox(parent)
663
  , d_ptr(new PrefQuantitySpinBoxPrivate())
664
{
665
}
666

667
PrefQuantitySpinBox::~PrefQuantitySpinBox() = default;
668

669
void PrefQuantitySpinBox::contextMenuEvent(QContextMenuEvent *event)
670
{
671
    Q_D(PrefQuantitySpinBox);
672

673
    QMenu *editMenu = lineEdit()->createStandardContextMenu();
674
    editMenu->setTitle(tr("Edit"));
675
    std::unique_ptr<QMenu> menu(new QMenu(QString::fromLatin1("PrefQuantitySpinBox")));
676

677
    menu->addMenu(editMenu);
678
    menu->addSeparator();
679

680
    // data structure to remember actions for values
681
    QStringList history = d->history.asStringList();
682
    for (const auto & it : history) {
683
        QAction* action = menu->addAction(it);
684
        action->setProperty("history_value", it);
685
    }
686

687
    // add the save value portion of the menu
688
    menu->addSeparator();
689
    QAction *saveValueAction = menu->addAction(tr("Save value"));
690
    QAction *clearListAction = menu->addAction(tr("Clear list"));
691
    clearListAction->setDisabled(history.empty());
692

693
    // call the menu
694
    QAction *userAction = menu->exec(event->globalPos());
695

696
    // look what the user has chosen
697
    if (userAction == saveValueAction) {
698
        pushToHistory(this->text());
699
    }
700
    else if (userAction == clearListAction) {
701
        d->history.clear();
702
    }
703
    else if (userAction) {
704
        QVariant prop = userAction->property("history_value");
705
        if (prop.isValid()) {
706
            lineEdit()->setText(prop.toString());
707
        }
708
    }
709
}
710

711
void PrefQuantitySpinBox::restorePreferences()
712
{
713
    Q_D(PrefQuantitySpinBox);
714

715
    // Do not restore values while saving them
716
    if (d->isSaving)
717
        return;
718

719
    if (getWindowParameter().isNull() || entryName().isEmpty()) {
720
        failedToRestore(objectName());
721
        return;
722
    }
723

724
    QString text = this->text();
725
    text = QString::fromUtf8(getWindowParameter()->GetASCII(entryName(), text.toUtf8()).c_str());
726
    lineEdit()->setText(text);
727

728
    // Restore history
729
    auto hGrp = getWindowParameter()->GetGroup(d->getHistoryGroupName(entryName()));
730
    d->restoreHistory(hGrp);
731
}
732

733
void PrefQuantitySpinBox::savePreferences()
734
{
735
    Q_D(PrefQuantitySpinBox);
736
    if (getWindowParameter().isNull() || entryName().isEmpty()) {
737
        failedToSave(objectName());
738
        return;
739
    }
740

741
    getWindowParameter()->SetASCII( entryName(), text().toUtf8() );
742

743
    // Save history
744
    auto hGrp = getWindowParameter()->GetGroup(d->getHistoryGroupName(entryName()));
745
    d->saveHistory(hGrp);
746
}
747

748
void PrefQuantitySpinBox::pushToHistory(const QString &value)
749
{
750
    Q_D(PrefQuantitySpinBox);
751
    d->history.append(value.isEmpty() ? this->text() : value);
752

753
    Base::StateLocker lock(d->isSaving);
754
    onSave();
755
}
756

757
QStringList PrefQuantitySpinBox::getHistory() const
758
{
759
    Q_D(const PrefQuantitySpinBox);
760
    return d->history.asStringList();
761
}
762

763
void PrefQuantitySpinBox::setToLastUsedValue()
764
{
765
    QStringList hist = getHistory();
766
    if (!hist.empty())
767
        lineEdit()->setText(hist.front());
768
}
769

770
int PrefQuantitySpinBox::historySize() const
771
{
772
    Q_D(const PrefQuantitySpinBox);
773
    return d->history.maximumSize();
774
}
775

776
void PrefQuantitySpinBox::setHistorySize(int i)
777
{
778
    Q_D(PrefQuantitySpinBox);
779
    d->history.setMaximumSize(i);
780
}
781

782
// --------------------------------------------------------------------
783

784
PrefFontBox::PrefFontBox ( QWidget * parent )
785
  : QFontComboBox(parent), PrefWidget()
786
{
787
}
788

789
PrefFontBox::~PrefFontBox() = default;
790

791
void PrefFontBox::restorePreferences()
792
{
793
  if ( getWindowParameter().isNull() )
794
  {
795
    failedToRestore(objectName());
796
    return;
797
  }
798

799
  QFont currFont = currentFont();                         //QFont from selector widget
800
  QString currName = currFont.family();
801

802
  std::string prefName = getWindowParameter()->GetASCII(entryName(), currName.toUtf8());  //font name from cfg file
803

804
  currFont.setFamily(QString::fromStdString(prefName));
805
  setCurrentFont(currFont);                               //set selector widget to name from cfg file
806
}
807

808
void PrefFontBox::savePreferences()
809
{
810
  if (getWindowParameter().isNull())
811
  {
812
    failedToSave(objectName());
813
    return;
814
  }
815

816
  QFont currFont = currentFont();
817
  QString currName = currFont.family();
818
  getWindowParameter()->SetASCII(entryName(), currName.toUtf8());
819
}
820

821
#include "moc_PrefWidgets.cpp"
822

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.