File indexing completed on 2024-05-19 04:59:18
0001 /* ============================================================ 0002 * Mouse Gestures plugin for Falkon 0003 * Copyright (C) 2012-2014 David Rosca <nowrep@gmail.com> 0004 * 0005 * This program is free software: you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation, either version 3 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0017 * ============================================================ */ 0018 #include "mousegesturessettingsdialog.h" 0019 #include "ui_mousegesturessettingsdialog.h" 0020 #include "licenseviewer.h" 0021 #include "mousegestures.h" 0022 0023 #include <QLabel> 0024 0025 MouseGesturesSettingsDialog::MouseGesturesSettingsDialog(MouseGestures* gestures, QWidget* parent) 0026 : QDialog(parent) 0027 , ui(new Ui::MouseGesturesSettingsDialog) 0028 , m_gestures(gestures) 0029 { 0030 setAttribute(Qt::WA_DeleteOnClose); 0031 ui->setupUi(this); 0032 0033 if (QApplication::isRightToLeft()) { 0034 ui->label_5->setPixmap(QPixmap(QSL(":/mousegestures/data/right.gif"))); 0035 ui->label_6->setPixmap(QPixmap(QSL(":/mousegestures/data/left.gif"))); 0036 ui->label_18->setPixmap(QPixmap(QSL(":/mousegestures/data/up-right.gif"))); 0037 ui->label_20->setPixmap(QPixmap(QSL(":/mousegestures/data/up-left.gif"))); 0038 } 0039 0040 m_gestures->loadSettings(); 0041 ui->mouseButtonComboBox->setCurrentIndex(m_gestures->buttonToIndex()); 0042 ui->enableRockerNavigation->setChecked(m_gestures->rockerNavigationEnabled()); 0043 0044 setAttribute(Qt::WA_DeleteOnClose); 0045 0046 connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accepted())); 0047 connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QWidget::close); 0048 connect(ui->licenseButton, &QAbstractButton::clicked, this, &MouseGesturesSettingsDialog::showLicense); 0049 } 0050 0051 MouseGesturesSettingsDialog::~MouseGesturesSettingsDialog() 0052 { 0053 delete ui; 0054 } 0055 0056 void MouseGesturesSettingsDialog::showLicense() 0057 { 0058 auto* v = new LicenseViewer(this); 0059 v->setLicenseFile(QSL(":mousegestures/data/copyright")); 0060 0061 v->show(); 0062 } 0063 0064 void MouseGesturesSettingsDialog::accepted() 0065 { 0066 m_gestures->setGestureButtonByIndex(ui->mouseButtonComboBox->currentIndex()); 0067 m_gestures->setRockerNavigationEnabled(ui->enableRockerNavigation->isChecked()); 0068 m_gestures->saveSettings(); 0069 close(); 0070 }