mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-15 14:55:48 +00:00
initial plasma6 support
This commit is contained in:
@ -15,7 +15,6 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "awfloatformatter.h"
|
||||
#include "ui_awfloatformatter.h"
|
||||
|
||||
@ -26,24 +25,13 @@
|
||||
#include "awdebug.h"
|
||||
|
||||
|
||||
AWFloatFormatter::AWFloatFormatter(QWidget *_parent, const QString &_filePath)
|
||||
AWFloatFormatter::AWFloatFormatter(QObject *_parent, const QString &_filePath)
|
||||
: AWAbstractFormatter(_parent, _filePath)
|
||||
, ui(new Ui::AWFloatFormatter)
|
||||
{
|
||||
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
|
||||
|
||||
if (!_filePath.isEmpty())
|
||||
AWFloatFormatter::readConfiguration();
|
||||
ui->setupUi(this);
|
||||
AWFloatFormatter::translate();
|
||||
}
|
||||
|
||||
|
||||
AWFloatFormatter::~AWFloatFormatter()
|
||||
{
|
||||
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
@ -51,7 +39,7 @@ QString AWFloatFormatter::convert(const QVariant &_value) const
|
||||
{
|
||||
qCDebug(LOG_LIB) << "Convert value" << _value;
|
||||
|
||||
QString output
|
||||
auto output
|
||||
= QString("%1").arg(_value.toDouble() * multiplier() + summand(), count(), format(), precision(), fillChar());
|
||||
if (forceWidth())
|
||||
output = output.left(count());
|
||||
@ -64,7 +52,7 @@ AWFloatFormatter *AWFloatFormatter::copy(const QString &_fileName, const int _nu
|
||||
{
|
||||
qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number;
|
||||
|
||||
auto *item = new AWFloatFormatter(dynamic_cast<QWidget *>(parent()), _fileName);
|
||||
auto item = new AWFloatFormatter(parent(), _fileName);
|
||||
AWAbstractFormatter::copyDefaults(item);
|
||||
item->setCount(count());
|
||||
item->setFormat(format());
|
||||
@ -202,10 +190,15 @@ void AWFloatFormatter::readConfiguration()
|
||||
}
|
||||
|
||||
|
||||
int AWFloatFormatter::showConfiguration(const QVariant &_args)
|
||||
int AWFloatFormatter::showConfiguration(QWidget *_parent, const QVariant &_args)
|
||||
{
|
||||
Q_UNUSED(_args)
|
||||
|
||||
auto dialog = new QDialog(_parent);
|
||||
auto ui = new Ui::AWFloatFormatter();
|
||||
ui->setupUi(dialog);
|
||||
translate(ui);
|
||||
|
||||
ui->lineEdit_name->setText(name());
|
||||
ui->lineEdit_comment->setText(comment());
|
||||
ui->label_typeValue->setText("Float");
|
||||
@ -217,22 +210,26 @@ int AWFloatFormatter::showConfiguration(const QVariant &_args)
|
||||
ui->doubleSpinBox_multiplier->setValue(multiplier());
|
||||
ui->doubleSpinBox_summand->setValue(summand());
|
||||
|
||||
int ret = exec();
|
||||
if (ret != 1)
|
||||
return ret;
|
||||
setName(ui->lineEdit_name->text());
|
||||
setComment(ui->lineEdit_comment->text());
|
||||
setApiVersion(AW_FORMATTER_API);
|
||||
setStrType(ui->label_typeValue->text());
|
||||
setFormat(ui->comboBox_format->currentText().at(0).toLatin1());
|
||||
setPrecision(ui->spinBox_precision->value());
|
||||
setCount(ui->spinBox_width->value());
|
||||
setFillChar(ui->lineEdit_fill->text().at(0));
|
||||
setForceWidth(ui->checkBox_forceWidth->checkState() == Qt::Checked);
|
||||
setMultiplier(ui->doubleSpinBox_multiplier->value());
|
||||
setSummand(ui->doubleSpinBox_summand->value());
|
||||
auto ret = dialog->exec();
|
||||
if (ret == 1) {
|
||||
setName(ui->lineEdit_name->text());
|
||||
setComment(ui->lineEdit_comment->text());
|
||||
setApiVersion(AW_FORMATTER_API);
|
||||
setStrType(ui->label_typeValue->text());
|
||||
setFormat(ui->comboBox_format->currentText().at(0).toLatin1());
|
||||
setPrecision(ui->spinBox_precision->value());
|
||||
setCount(ui->spinBox_width->value());
|
||||
setFillChar(ui->lineEdit_fill->text().at(0));
|
||||
setForceWidth(ui->checkBox_forceWidth->checkState() == Qt::Checked);
|
||||
setMultiplier(ui->doubleSpinBox_multiplier->value());
|
||||
setSummand(ui->doubleSpinBox_summand->value());
|
||||
|
||||
writeConfiguration();
|
||||
}
|
||||
|
||||
dialog->deleteLater();
|
||||
delete ui;
|
||||
|
||||
writeConfiguration();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -258,8 +255,10 @@ void AWFloatFormatter::writeConfiguration() const
|
||||
}
|
||||
|
||||
|
||||
void AWFloatFormatter::translate()
|
||||
void AWFloatFormatter::translate(void *_ui)
|
||||
{
|
||||
auto ui = reinterpret_cast<Ui::AWFloatFormatter *>(_ui);
|
||||
|
||||
ui->label_name->setText(i18n("Name"));
|
||||
ui->label_comment->setText(i18n("Comment"));
|
||||
ui->label_type->setText(i18n("Type"));
|
||||
|
Reference in New Issue
Block a user