Krita Source Code Documentation
Loading...
Searching...
No Matches
KisDlgCustomTabletResolution Class Reference

#include <KisDlgCustomTabletResolution.h>

+ Inheritance diagram for KisDlgCustomTabletResolution:

Public Types

enum  Mode { USE_WINTAB = 0 , USE_VIRTUAL_SCREEN , USE_CUSTOM }
 

Public Member Functions

void accept () override
 
 KisDlgCustomTabletResolution (QWidget *parent=nullptr)
 
 ~KisDlgCustomTabletResolution () override
 

Static Public Member Functions

static void applyConfiguration (Mode mode, const QRect &customRect)
 
static QRect calcNativeScreenRect ()
 
static Mode getTabletMode (QRect *customRect)
 

Private Attributes

Ui::KisDlgCustomTabletResolution * ui
 

Detailed Description

Definition at line 17 of file KisDlgCustomTabletResolution.h.

Member Enumeration Documentation

◆ Mode

Constructor & Destructor Documentation

◆ KisDlgCustomTabletResolution()

KisDlgCustomTabletResolution::KisDlgCustomTabletResolution ( QWidget * parent = nullptr)
explicit

Definition at line 30 of file KisDlgCustomTabletResolution.cpp.

30 :
31 QDialog(parent),
32 ui(new Ui::KisDlgCustomTabletResolution)
33{
34 ui->setupUi(this);
35 KGuiItem::assign(ui->btnBox->button(QDialogButtonBox::Ok), KStandardGuiItem::ok());
36 KGuiItem::assign(ui->btnBox->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
37 connect(ui->btnBox, SIGNAL(rejected()), this, SLOT(reject()));
38 connect(ui->btnBox, SIGNAL(accepted()), this, SLOT(accept()));
39
40 connect(ui->radioCustomMapping, SIGNAL(toggled(bool)), ui->lblXOffset, SLOT(setEnabled(bool)));
41 connect(ui->radioCustomMapping, SIGNAL(toggled(bool)), ui->lblYOffset, SLOT(setEnabled(bool)));
42 connect(ui->radioCustomMapping, SIGNAL(toggled(bool)), ui->lblWidth, SLOT(setEnabled(bool)));
43 connect(ui->radioCustomMapping, SIGNAL(toggled(bool)), ui->lblHeight, SLOT(setEnabled(bool)));
44
45 connect(ui->radioCustomMapping, SIGNAL(toggled(bool)), ui->intXOffset, SLOT(setEnabled(bool)));
46 connect(ui->radioCustomMapping, SIGNAL(toggled(bool)), ui->intYOffset, SLOT(setEnabled(bool)));
47 connect(ui->radioCustomMapping, SIGNAL(toggled(bool)), ui->intWidth, SLOT(setEnabled(bool)));
48 connect(ui->radioCustomMapping, SIGNAL(toggled(bool)), ui->intHeight, SLOT(setEnabled(bool)));
49
50 const QRect virtualScreenRect = calcNativeScreenRect();
51
52 ui->radioMapToEntireScreen->setText(i18nc("@option:radio", "Map to entire virtual screen (%1)", rectToString(virtualScreenRect)));
53
54 QRect nativeScreenRect;
55 QPlatformScreen *screen = qGuiApp->primaryScreen()->handle();
56 Q_FOREACH (QPlatformScreen *scr, screen->virtualSiblings()) {
57 nativeScreenRect |= scr->geometry();
58 }
59
60 QRect customScreenRect = virtualScreenRect;
61 Mode mode = getTabletMode(&customScreenRect);
62
63 if (mode == USE_CUSTOM) {
64 ui->radioCustomMapping->setChecked(true);
65 } else if (mode == USE_VIRTUAL_SCREEN) {
66 ui->radioMapToEntireScreen->setChecked(true);
67 } else {
68 ui->radioMapAsWintab->setChecked(true);
69 }
70
71 ui->intXOffset->setValue(customScreenRect.x());
72 ui->intYOffset->setValue(customScreenRect.y());
73 ui->intWidth->setValue(customScreenRect.width());
74 ui->intHeight->setValue(customScreenRect.height());
75}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
static Mode getTabletMode(QRect *customRect)
Ui::KisDlgCustomTabletResolution * ui

References accept(), calcNativeScreenRect(), connect(), getTabletMode(), ui, USE_CUSTOM, and USE_VIRTUAL_SCREEN.

◆ ~KisDlgCustomTabletResolution()

KisDlgCustomTabletResolution::~KisDlgCustomTabletResolution ( )
override

Definition at line 105 of file KisDlgCustomTabletResolution.cpp.

106{
107 delete ui;
108}

References ui.

Member Function Documentation

◆ accept()

void KisDlgCustomTabletResolution::accept ( )
override

Definition at line 77 of file KisDlgCustomTabletResolution.cpp.

78{
79 const QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
80 QSettings cfg(configPath + QStringLiteral("/kritadisplayrc"), QSettings::IniFormat);
81
82 if (ui->radioMapAsWintab->isChecked()) {
83 cfg.setValue("wintabResolutionMode", "wintab");
84 } else if (ui->radioMapToEntireScreen->isChecked()) {
85 cfg.setValue("wintabResolutionMode", "virtual-screen");
86 } else if (ui->radioCustomMapping->isChecked()) {
87 cfg.setValue("wintabResolutionMode", "custom");
88
89 cfg.setValue("wintabCustomResolutionX", ui->intXOffset->value());
90 cfg.setValue("wintabCustomResolutionY", ui->intYOffset->value());
91 cfg.setValue("wintabCustomResolutionWidth", ui->intWidth->value());
92 cfg.setValue("wintabCustomResolutionHeight", ui->intHeight->value());
93 }
94
95 // apply the mode right now
96 {
97 QRect customTabletRect;
98 const Mode tabletMode = getTabletMode(&customTabletRect);
99 applyConfiguration(tabletMode, customTabletRect);
100 }
101
102 QDialog::accept();
103}
static void applyConfiguration(Mode mode, const QRect &customRect)

References applyConfiguration(), getTabletMode(), and ui.

◆ applyConfiguration()

void KisDlgCustomTabletResolution::applyConfiguration ( KisDlgCustomTabletResolution::Mode tabletMode,
const QRect & customRect )
static

Definition at line 146 of file KisDlgCustomTabletResolution.cpp.

147{
149 qputenv("QT_WINTAB_DESKTOP_RECT",
150 QString("%1;%2;%3;%4")
151 .arg(customTabletRect.x())
152 .arg(customTabletRect.y())
153 .arg(customTabletRect.width())
154 .arg(customTabletRect.height()).toLatin1());
155 qunsetenv("QT_IGNORE_WINTAB_MAPPING");
156 } else if (tabletMode == KisDlgCustomTabletResolution::USE_VIRTUAL_SCREEN) {
157 qputenv("QT_IGNORE_WINTAB_MAPPING", "1");
158 qunsetenv("QT_WINTAB_DESKTOP_RECT");
159 } else {
160 qunsetenv("QT_WINTAB_DESKTOP_RECT");
161 qunsetenv("QT_IGNORE_WINTAB_MAPPING");
162 }
163}

References USE_CUSTOM, and USE_VIRTUAL_SCREEN.

◆ calcNativeScreenRect()

QRect KisDlgCustomTabletResolution::calcNativeScreenRect ( )
static

Definition at line 110 of file KisDlgCustomTabletResolution.cpp.

111{
112 QRect nativeScreenRect;
113 QPlatformScreen *screen = qGuiApp->primaryScreen()->handle();
114 Q_FOREACH (QPlatformScreen *scr, screen->virtualSiblings()) {
115 nativeScreenRect |= scr->geometry();
116 }
117 return nativeScreenRect;
118}

◆ getTabletMode()

KisDlgCustomTabletResolution::Mode KisDlgCustomTabletResolution::getTabletMode ( QRect * customRect)
static

Definition at line 120 of file KisDlgCustomTabletResolution.cpp.

121{
122 const QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
123 QSettings cfg(configPath + QStringLiteral("/kritadisplayrc"), QSettings::IniFormat);
124
125 const QString mode = cfg.value("wintabResolutionMode", QString("wintab")).toString();
126 Mode modeValue = USE_WINTAB;
127
128 if (mode == "custom") {
129 modeValue = USE_CUSTOM;
130 } else if (mode == "virtual-screen") {
131 modeValue = USE_VIRTUAL_SCREEN;
132 } else {
133 modeValue = USE_WINTAB;
134 }
135
136 if (mode == "custom") {
137 customRect->setX(cfg.value("wintabCustomResolutionX", customRect->x()).toInt());
138 customRect->setY(cfg.value("wintabCustomResolutionY", customRect->y()).toInt());
139 customRect->setWidth(cfg.value("wintabCustomResolutionWidth", customRect->width()).toInt());
140 customRect->setHeight(cfg.value("wintabCustomResolutionHeight", customRect->height()).toInt());
141 }
142
143 return modeValue;
144}

References USE_CUSTOM, USE_VIRTUAL_SCREEN, and USE_WINTAB.

Member Data Documentation

◆ ui

Ui::KisDlgCustomTabletResolution* KisDlgCustomTabletResolution::ui
private

Definition at line 40 of file KisDlgCustomTabletResolution.h.


The documentation for this class was generated from the following files: