| 1 | /**************************************************************************** |
| 2 | ** SASM - simple IDE for assembler development |
| 3 | ** Copyright (C) 2013 Dmitriy Manushin |
| 4 | ** Contact: site: http://dman95.github.io/SASM/ |
| 5 | ** e-mail: [email protected] |
| 6 | ** |
| 7 | ** This file is part of SASM. |
| 8 | ** |
| 9 | ** SASM is free software: you can redistribute it and/or modify |
| 10 | ** it under the terms of the GNU General Public License as published by |
| 11 | ** the Free Software Foundation, either version 3 of the License, or |
| 12 | ** (at your option) any later version. |
| 13 | ** |
| 14 | ** SASM is distributed in the hope that it will be useful, |
| 15 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | ** GNU General Public License for more details. |
| 18 | ** |
| 19 | ** You should have received a copy of the GNU General Public License |
| 20 | ** along with SASM. If not, see <http://www.gnu.org/licenses/>. |
| 21 | ** |
| 22 | ** Этот файл — часть SASM. |
| 23 | ** |
| 24 | ** SASM - свободная программа: вы можете перераспространять ее и/или |
| 25 | ** изменять ее на условиях Стандартной общественной лицензии GNU в том виде, |
| 26 | ** в каком она была опубликована Фондом свободного программного обеспечения; |
| 27 | ** либо версии 3 лицензии, либо (по вашему выбору) любой более поздней |
| 28 | ** версии. |
| 29 | ** |
| 30 | ** SASM распространяется в надежде, что она будет полезной, |
| 31 | ** но БЕЗО ВСЯКИХ ГАРАНТИЙ; даже без неявной гарантии ТОВАРНОГО ВИДА |
| 32 | ** или ПРИГОДНОСТИ ДЛЯ ОПРЕДЕЛЕННЫХ ЦЕЛЕЙ. Подробнее см. в Стандартной |
| 33 | ** общественной лицензии GNU. |
| 34 | ** |
| 35 | ** Вы должны были получить копию Стандартной общественной лицензии GNU |
| 36 | ** вместе с этой программой. Если это не так, см. |
| 37 | ** <http://www.gnu.org/licenses/>.) |
| 38 | ** |
| 39 | ****************************************************************************/ |
| 40 | |
| 41 | #include "watchsettingswidget.h" |
| 42 | /** |
| 43 | * @file watchsettingswidget.cpp |
| 44 | * Implements the WatchSettingsWidget class. |
| 45 | */ |
| 46 | |
| 47 | /*! \brief This defines the layout such as spacing and items of the variable watch |
| 48 | * area. |
| 49 | * |
| 50 | * |
| 51 | * First, the parent widget is passed to the class. Next, the form items are added |
| 52 | * and spaced appropriately. The form items are then further defined and then connected. |
| 53 | */ |
| 54 | WatchSettingsWidget::WatchSettingsWidget(QWidget *parent) : |
| 55 | QWidget(parent) |
| 56 | { |
| 57 | layout = new QHBoxLayout(this); |
| 58 | typeComboBox = new QComboBox; |
| 59 | sizeComboBox = new QComboBox; |
| 60 | arraySizeEdit = new QLineEdit; |
| 61 | addressCheckbox = new QCheckBox(tr("Address")); |
| 62 | layout->addSpacing(3); |
| 63 | layout->addWidget(typeComboBox); |
| 64 | layout->addWidget(sizeComboBox); |
| 65 | layout->addWidget(arraySizeEdit); |
| 66 | layout->addSpacing(5); |
| 67 | layout->addWidget(addressCheckbox); |
| 68 | |
| 69 | arraySizeEdit->setPlaceholderText(tr("Array size")); |
| 70 | |
| 71 | QStringList comboBoxList; |
| 72 | comboBoxList << tr("Smart") << tr("Hex") << tr("Bin") << tr("Char") << |
| 73 | tr("Int") << tr("UInt") << tr("Float"); |
| 74 | typeComboBox->insertItems(0, comboBoxList); |
| 75 | |
| 76 | QStringList sizeBoxList; |
| 77 | sizeBoxList << tr("d") << tr("w") << tr("b") << tr("q"); |
| 78 | sizeComboBox->insertItems(0, sizeBoxList); |
| 79 | |
| 80 | addressCheckbox->setChecked(false); |
| 81 | |
| 82 | layout->setSpacing(0); |
| 83 | layout->setMargin(0); |
| 84 | |
| 85 | connect(typeComboBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(settingsChanged())); |
| 86 | connect(sizeComboBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(settingsChanged())); |
| 87 | connect(arraySizeEdit, SIGNAL(textChanged(QString)), this, SIGNAL(settingsChanged())); |
| 88 | connect(addressCheckbox, SIGNAL(stateChanged(int)), this, SIGNAL(settingsChanged())); |
| 89 | |
| 90 | setLayout(layout); |
| 91 | } |
| 92 | |
| 93 | int WatchSettingsWidget::sumSize() |
| 94 | { |
| 95 | return typeComboBox->sizeHint().width() + sizeComboBox->sizeHint().width() |
| 96 | + arraySizeEdit->fontMetrics().horizontalAdvance(arraySizeEdit->placeholderText()) |
| 97 | + addressCheckbox->sizeHint().width() + 50; |
| 98 | } |
| 99 | |
| 100 | QSize WatchSettingsWidget::sizeHint() const |
| 101 | { |
| 102 | return QSize(typeComboBox->sizeHint().width() + sizeComboBox->sizeHint().width() |
| 103 | + arraySizeEdit->fontMetrics().horizontalAdvance(arraySizeEdit->placeholderText()) |
| 104 | + addressCheckbox->sizeHint().width() + 50, 0); |
| 105 | } |
| 106 | |
| 107 | WatchSettingsWidget::~WatchSettingsWidget() |
| 108 | { |
| 109 | delete arraySizeEdit; |
| 110 | delete typeComboBox; |
| 111 | delete sizeComboBox; |
| 112 | delete addressCheckbox; |
| 113 | delete layout; |
| 114 | } |