Pencil2D Animation
Download Community News Docs Contribute
  • Overview
  • Articles
  • Code
  •  
  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • File List
Loading...
Searching...
No Matches
  • app
  • src
app_util.cpp
1/*
2
3Pencil2D - Traditional Animation Software
4Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5Copyright (C) 2012-2020 Matthew Chiawen Chang
6
7This program is free software; you can redistribute it and/or
8modify it under the terms of the GNU General Public License
9as published by the Free Software Foundation; version 2 of the License.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16*/
17#include "app_util.h"
18#include <QAction>
19#include <QDialog>
20#include "preferencemanager.h"
21
22void hideQuestionMark(QDialog& dlg)
23{
24 dlg.setWindowFlags(dlg.windowFlags() & ~Qt::WindowContextHelpButtonHint);
25}
26
27void setMenuActionChecked(QAction* action, bool checked)
28{
29 QSignalBlocker b(action);
30 action->setChecked(checked);
31}
32
33void bindPreferenceSetting(QAction* action, PreferenceManager* prefs, const SETTING& setting)
34{
35 Q_ASSERT(action->isCheckable());
36 Q_ASSERT(prefs);
37
38 QSignalBlocker b(action);
39 action->setChecked(prefs->isOn(setting)); // set initial state
40
41 // 2-way binding
42 QObject::connect(action, &QAction::triggered, [=](bool b) { prefs->set(setting, b); });
43 QObject::connect(prefs, &PreferenceManager::optionChanged, [=](SETTING s)
44 {
45 if (s == setting)
46 {
47 action->setChecked(prefs->isOn(setting));
48 }
49 });
50}
PreferenceManager
Definition: preferencemanager.h:28
QAction
QAction::isCheckable
bool isCheckable() const const
QAction::setChecked
void setChecked(bool)
QAction::triggered
void triggered(bool checked)
QDialog
QObject::connect
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QSignalBlocker
Qt::WindowContextHelpButtonHint
WindowContextHelpButtonHint
QWidget::setWindowFlags
void setWindowFlags(Qt::WindowFlags type)
Generated on Thu May 8 2025 04:47:53 for Pencil2D by doxygen 1.9.6 based on revision 4513250b1d5b1a3676ec0e67b06b7a885ceaae39