File indexing completed on 2025-01-26 05:09:32
0001 /* 0002 * This file is part of the KDE wacomtablet project. For copyright 0003 * information and license terms see the AUTHORS and COPYING files 0004 * in the top-level directory of this distribution. 0005 * 0006 * This program is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU General Public License as 0008 * published by the Free Software Foundation; either version 2 of 0009 * the License, or (at your option) any later version. 0010 * 0011 * This program is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 * GNU General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU General Public License 0017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0018 */ 0019 0020 #include "tabletareaselectiondialog.h" 0021 0022 #include "tabletareaselectionwidget.h" 0023 0024 #include "screensinfo.h" 0025 #include "stringutils.h" 0026 0027 #include <KLocalizedString> 0028 0029 #include <QDialogButtonBox> 0030 #include <QIcon> 0031 #include <QVBoxLayout> 0032 0033 using namespace Wacom; 0034 0035 namespace Wacom 0036 { 0037 class TabletAreaSelectionDialogPrivate 0038 { 0039 public: 0040 TabletAreaSelectionWidget *selectionWidget = nullptr; // no need to delete this widget as it is properly parented. 0041 }; // PRIVATE CLASS 0042 } // NAMESPACE 0043 0044 TabletAreaSelectionDialog::TabletAreaSelectionDialog() 0045 : QDialog(nullptr) 0046 , d_ptr(new TabletAreaSelectionDialogPrivate) 0047 { 0048 setupUi(); 0049 } 0050 0051 TabletAreaSelectionDialog::~TabletAreaSelectionDialog() 0052 { 0053 delete this->d_ptr; 0054 } 0055 0056 const ScreenMap &TabletAreaSelectionDialog::getScreenMap() 0057 { 0058 Q_D(TabletAreaSelectionDialog); 0059 0060 return d->selectionWidget->getScreenMap(); 0061 } 0062 0063 const ScreenSpace TabletAreaSelectionDialog::getScreenSpace() const 0064 { 0065 Q_D(const TabletAreaSelectionDialog); 0066 0067 return d->selectionWidget->getScreenSpace(); 0068 } 0069 0070 void TabletAreaSelectionDialog::select(QString output) 0071 { 0072 Q_D(TabletAreaSelectionDialog); 0073 0074 d->selectionWidget->select(output); 0075 } 0076 0077 void TabletAreaSelectionDialog::select(const ScreenSpace &screenSpace) 0078 { 0079 Q_D(TabletAreaSelectionDialog); 0080 0081 d->selectionWidget->select(screenSpace); 0082 } 0083 0084 void TabletAreaSelectionDialog::setupWidget(const ScreenMap &mappings, const QString &deviceName, const ScreenRotation &rotation) 0085 { 0086 Q_D(TabletAreaSelectionDialog); 0087 0088 d->selectionWidget->setupWidget(mappings, deviceName, rotation); 0089 } 0090 0091 void TabletAreaSelectionDialog::setupUi() 0092 { 0093 Q_D(TabletAreaSelectionDialog); 0094 0095 d->selectionWidget = new TabletAreaSelectionWidget(this); 0096 0097 QVBoxLayout *layout = new QVBoxLayout; 0098 QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); 0099 layout->addWidget(d->selectionWidget); 0100 layout->addWidget(buttonBox); 0101 setLayout(layout); 0102 0103 connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); 0104 connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); 0105 setWindowTitle( 0106 i18nc("Dialog title from a dialog which lets the user select an area of the tablet where the screen space will be mapped to.", "Select a Tablet Area")); 0107 setWindowIcon(QIcon::fromTheme(QLatin1String("preferences-desktop-tablet"))); 0108 0109 // connect( this, SIGNAL(okClicked()), this, SLOT(onOkClicked()) ); 0110 } 0111 0112 #include "moc_tabletareaselectiondialog.cpp"