Adds Qinputdialog (#381)

* wip

* Adds qinputdialog

* fix lint

* revert package.json
This commit is contained in:
Atul R 2020-01-30 23:05:29 +01:00 committed by GitHub
parent d95fe53d78
commit ba088d441a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 610 additions and 30 deletions

View File

@ -99,6 +99,7 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QTreeWidget/qtreewidget_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QTreeWidgetItem/qtreewidgetitem_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QMessageBox/qmessagebox_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QInputDialog/qinputdialog_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QButtonGroup/qbuttongroup_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/QtWidgets/QStatusBar/qstatusbar_wrap.cpp"
"${PROJECT_SOURCE_DIR}/src/cpp/lib/core/FlexLayout/flexlayout_wrap.cpp"
@ -122,6 +123,7 @@ add_library(${CORE_WIDGETS_ADDON} SHARED
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QProgressBar/nprogressbar.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QPushButton/npushbutton.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QMessageBox/nmessagebox.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QInputDialog/ninputdialog.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QToolButton/ntoolbutton.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QSpinBox/nspinbox.hpp"
"${PROJECT_SOURCE_DIR}/src/cpp/include/nodegui/QtWidgets/QRadioButton/nradiobutton.hpp"

View File

@ -1,5 +1,7 @@
#pragma once
#include <QDebug>
#include "Extras/Utils/nutils.h"
#include "QtCore/QVariant/qvariant_wrap.h"
#include "core/Events/eventwidget_macro.h"
@ -29,8 +31,9 @@
Napi::Value value = info[1]; \
auto variant = \
QSharedPointer<QVariant>(extrautils::convertToQVariant(env, value)); \
this->instance->setProperty(name.Utf8Value().c_str(), *variant); \
return env.Null(); \
auto result = \
this->instance->setProperty(name.Utf8Value().c_str(), *variant); \
return Napi::Value::From(env, result); \
} \
Napi::Value property(const Napi::CallbackInfo& info) { \
Napi::Env env = info.Env(); \

View File

@ -0,0 +1,58 @@
#pragma once
#include <QInputDialog>
#include "Extras/Utils/nutils.h"
#include "QtWidgets/QDialog/qdialog_macro.h"
#include "core/NodeWidget/nodewidget.h"
#include "napi.h"
class DLL_EXPORT NInputDialog : public QInputDialog, public NodeWidget {
public:
Q_OBJECT
NODEWIDGET_IMPLEMENTATIONS(QInputDialog)
using QInputDialog::QInputDialog;
void connectSignalsToEventEmitter() {
QDIALOG_SIGNALS
QObject::connect(this, &QInputDialog::doubleValueChanged, [=](double val) {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
auto value = Napi::Number::New(env, val);
this->emitOnNode.Call(
{Napi::String::New(env, "doubleValueChanged"), value});
});
QObject::connect(this, &QInputDialog::doubleValueSelected, [=](double val) {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
auto value = Napi::Number::New(env, val);
this->emitOnNode.Call(
{Napi::String::New(env, "doubleValueSelected"), value});
});
QObject::connect(this, &QInputDialog::intValueChanged, [=](int val) {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
auto value = Napi::Number::New(env, val);
this->emitOnNode.Call({Napi::String::New(env, "intValueChanged"), value});
});
QObject::connect(this, &QInputDialog::intValueSelected, [=](int val) {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
auto value = Napi::Number::New(env, val);
this->emitOnNode.Call(
{Napi::String::New(env, "intValueSelected"), value});
});
QObject::connect(this, &QInputDialog::textValueChanged, [=](QString text) {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
auto value = Napi::String::New(env, text.toStdString());
this->emitOnNode.Call(
{Napi::String::New(env, "textValueChanged"), value});
});
QObject::connect(this, &QInputDialog::textValueSelected, [=](QString text) {
Napi::Env env = this->emitOnNode.Env();
Napi::HandleScope scope(env);
auto value = Napi::String::New(env, text.toStdString());
this->emitOnNode.Call(
{Napi::String::New(env, "textValueSelected"), value});
});
}
};

View File

@ -0,0 +1,58 @@
#pragma once
#include <napi.h>
#include <QPointer>
#include "Extras/Utils/nutils.h"
#include "QtWidgets/QInputDialog/ninputdialog.hpp"
#include "QtWidgets/QWidget/qwidget_macro.h"
class DLL_EXPORT QInputDialogWrap : public Napi::ObjectWrap<QInputDialogWrap> {
QDIALOG_WRAPPED_METHODS_DECLARATION
private:
QPointer<NInputDialog> instance;
public:
static Napi::Object init(Napi::Env env, Napi::Object exports);
QInputDialogWrap(const Napi::CallbackInfo& info);
~QInputDialogWrap();
NInputDialog* getInternalInstance();
// class constructor
static Napi::FunctionReference constructor;
// members
Napi::Value setCancelButtonText(const Napi::CallbackInfo& info);
Napi::Value cancelButtonText(const Napi::CallbackInfo& info);
Napi::Value setComboBoxEditable(const Napi::CallbackInfo& info);
Napi::Value isComboBoxEditable(const Napi::CallbackInfo& info);
Napi::Value setDoubleDecimals(const Napi::CallbackInfo& info);
Napi::Value doubleDecimals(const Napi::CallbackInfo& info);
Napi::Value setDoubleMaximum(const Napi::CallbackInfo& info);
Napi::Value doubleMaximum(const Napi::CallbackInfo& info);
Napi::Value setDoubleMinimum(const Napi::CallbackInfo& info);
Napi::Value doubleMinimum(const Napi::CallbackInfo& info);
Napi::Value doubleStep(const Napi::CallbackInfo& info);
Napi::Value setDoubleStep(const Napi::CallbackInfo& info);
Napi::Value doubleValue(const Napi::CallbackInfo& info);
Napi::Value setDoubleValue(const Napi::CallbackInfo& info);
Napi::Value inputMode(const Napi::CallbackInfo& info);
Napi::Value setInputMode(const Napi::CallbackInfo& info);
Napi::Value intMaximum(const Napi::CallbackInfo& info);
Napi::Value setIntMaximum(const Napi::CallbackInfo& info);
Napi::Value intMinimum(const Napi::CallbackInfo& info);
Napi::Value setIntMinimum(const Napi::CallbackInfo& info);
Napi::Value intStep(const Napi::CallbackInfo& info);
Napi::Value setIntStep(const Napi::CallbackInfo& info);
Napi::Value intValue(const Napi::CallbackInfo& info);
Napi::Value setIntValue(const Napi::CallbackInfo& info);
Napi::Value labelText(const Napi::CallbackInfo& info);
Napi::Value setLabelText(const Napi::CallbackInfo& info);
Napi::Value okButtonText(const Napi::CallbackInfo& info);
Napi::Value setOkButtonText(const Napi::CallbackInfo& info);
Napi::Value options(const Napi::CallbackInfo& info);
Napi::Value setOptions(const Napi::CallbackInfo& info);
Napi::Value textEchoMode(const Napi::CallbackInfo& info);
Napi::Value setTextEchoMode(const Napi::CallbackInfo& info);
Napi::Value textValue(const Napi::CallbackInfo& info);
Napi::Value setTextValue(const Napi::CallbackInfo& info);
};

View File

@ -1,6 +1,7 @@
#include "Extras/Utils/nutils.h"
#include <QApplication>
#include <QDebug>
#include <QFont>
#include <QMetaType>
#include <QWidget>

View File

@ -0,0 +1,312 @@
#include "QtWidgets/QInputDialog/qinputdialog_wrap.h"
#include <QDebug>
#include <QLineEdit>
#include <QWidget>
#include "Extras/Utils/nutils.h"
#include "QtCore/QObject/qobject_wrap.h"
#include "QtWidgets/QWidget/qwidget_wrap.h"
Napi::FunctionReference QInputDialogWrap::constructor;
Napi::Object QInputDialogWrap::init(Napi::Env env, Napi::Object exports) {
Napi::HandleScope scope(env);
char CLASSNAME[] = "QInputDialog";
Napi::Function func = DefineClass(
env, CLASSNAME,
{InstanceMethod("setCancelButtonText",
&QInputDialogWrap::setCancelButtonText),
InstanceMethod("cancelButtonText", &QInputDialogWrap::cancelButtonText),
InstanceMethod("setComboBoxEditable",
&QInputDialogWrap::setComboBoxEditable),
InstanceMethod("isComboBoxEditable",
&QInputDialogWrap::isComboBoxEditable),
InstanceMethod("setDoubleDecimals",
&QInputDialogWrap::setDoubleDecimals),
InstanceMethod("doubleDecimals", &QInputDialogWrap::doubleDecimals),
InstanceMethod("setDoubleMaximum", &QInputDialogWrap::setDoubleMaximum),
InstanceMethod("doubleMaximum", &QInputDialogWrap::doubleMaximum),
InstanceMethod("setDoubleMinimum", &QInputDialogWrap::setDoubleMinimum),
InstanceMethod("doubleMinimum", &QInputDialogWrap::doubleMinimum),
InstanceMethod("doubleStep", &QInputDialogWrap::doubleStep),
InstanceMethod("setDoubleStep", &QInputDialogWrap::setDoubleStep),
InstanceMethod("doubleValue", &QInputDialogWrap::doubleValue),
InstanceMethod("setDoubleValue", &QInputDialogWrap::setDoubleValue),
InstanceMethod("inputMode", &QInputDialogWrap::inputMode),
InstanceMethod("setInputMode", &QInputDialogWrap::setInputMode),
InstanceMethod("intMaximum", &QInputDialogWrap::intMaximum),
InstanceMethod("setIntMaximum", &QInputDialogWrap::setIntMaximum),
InstanceMethod("intMinimum", &QInputDialogWrap::intMinimum),
InstanceMethod("setIntMinimum", &QInputDialogWrap::setIntMinimum),
InstanceMethod("intStep", &QInputDialogWrap::intStep),
InstanceMethod("setIntStep", &QInputDialogWrap::setIntStep),
InstanceMethod("intValue", &QInputDialogWrap::intValue),
InstanceMethod("setIntValue", &QInputDialogWrap::setIntValue),
InstanceMethod("labelText", &QInputDialogWrap::labelText),
InstanceMethod("setLabelText", &QInputDialogWrap::setLabelText),
InstanceMethod("okButtonText", &QInputDialogWrap::okButtonText),
InstanceMethod("setOkButtonText", &QInputDialogWrap::setOkButtonText),
InstanceMethod("options", &QInputDialogWrap::options),
InstanceMethod("setOptions", &QInputDialogWrap::setOptions),
InstanceMethod("textEchoMode", &QInputDialogWrap::textEchoMode),
InstanceMethod("setTextEchoMode", &QInputDialogWrap::setTextEchoMode),
InstanceMethod("textValue", &QInputDialogWrap::textValue),
InstanceMethod("setTextValue", &QInputDialogWrap::setTextValue),
QDIALOG_WRAPPED_METHODS_EXPORT_DEFINE(QInputDialogWrap)});
constructor = Napi::Persistent(func);
exports.Set(CLASSNAME, func);
return exports;
}
NInputDialog* QInputDialogWrap::getInternalInstance() { return this->instance; }
QInputDialogWrap::~QInputDialogWrap() {
extrautils::safeDelete(this->instance);
}
QInputDialogWrap::QInputDialogWrap(const Napi::CallbackInfo& info)
: Napi::ObjectWrap<QInputDialogWrap>(info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
if (info.Length() == 1) {
Napi::Object parentObject = info[0].As<Napi::Object>();
QWidgetWrap* parentWidgetWrap =
Napi::ObjectWrap<QWidgetWrap>::Unwrap(parentObject);
this->instance = new NInputDialog(parentWidgetWrap->getInternalInstance());
} else if (info.Length() == 0) {
this->instance = new NInputDialog();
} else {
Napi::TypeError::New(env, "Wrong number of arguments")
.ThrowAsJavaScriptException();
}
this->rawData = extrautils::configureQWidget(
this->getInternalInstance(), this->getInternalInstance()->getFlexNode(),
false);
}
Napi::Value QInputDialogWrap::setCancelButtonText(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto value = info[0].As<Napi::String>().Utf8Value().c_str();
this->instance->setCancelButtonText(value);
return env.Null();
}
Napi::Value QInputDialogWrap::cancelButtonText(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto retValue = this->instance->cancelButtonText().toStdString();
return Napi::Value::From(env, retValue);
}
Napi::Value QInputDialogWrap::setComboBoxEditable(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto value = info[0].As<Napi::Boolean>().Value();
this->instance->setComboBoxEditable(value);
return env.Null();
}
Napi::Value QInputDialogWrap::isComboBoxEditable(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto retValue = this->instance->isComboBoxEditable();
return Napi::Value::From(env, retValue);
}
Napi::Value QInputDialogWrap::setDoubleDecimals(
const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto value = info[0].As<Napi::Number>().DoubleValue();
this->instance->setDoubleDecimals(value);
return env.Null();
}
Napi::Value QInputDialogWrap::doubleDecimals(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto retValue = this->instance->doubleDecimals();
return Napi::Value::From(env, retValue);
}
Napi::Value QInputDialogWrap::setDoubleMaximum(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto value = info[0].As<Napi::Number>().DoubleValue();
this->instance->setDoubleMaximum(value);
return env.Null();
}
Napi::Value QInputDialogWrap::doubleMaximum(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto retValue = this->instance->doubleMaximum();
return Napi::Value::From(env, retValue);
}
Napi::Value QInputDialogWrap::setDoubleMinimum(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto value = info[0].As<Napi::Number>().DoubleValue();
this->instance->setDoubleMinimum(value);
return env.Null();
}
Napi::Value QInputDialogWrap::doubleMinimum(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto retValue = this->instance->doubleMinimum();
return Napi::Value::From(env, retValue);
}
Napi::Value QInputDialogWrap::doubleStep(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto retValue = this->instance->doubleStep();
return Napi::Value::From(env, retValue);
}
Napi::Value QInputDialogWrap::setDoubleStep(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto value = info[0].As<Napi::Number>().DoubleValue();
this->instance->setDoubleStep(value);
return env.Null();
}
Napi::Value QInputDialogWrap::doubleValue(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto retValue = this->instance->doubleValue();
return Napi::Value::From(env, retValue);
}
Napi::Value QInputDialogWrap::setDoubleValue(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto value = info[0].As<Napi::Number>().DoubleValue();
this->instance->setDoubleValue(value);
return env.Null();
}
Napi::Value QInputDialogWrap::inputMode(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto retValue = this->instance->inputMode();
return Napi::Value::From(env, static_cast<int>(retValue));
}
Napi::Value QInputDialogWrap::setInputMode(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto value = info[0].As<Napi::Number>().Int32Value();
this->instance->setInputMode(static_cast<QInputDialog::InputMode>(value));
return env.Null();
}
Napi::Value QInputDialogWrap::intMaximum(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto retValue = this->instance->intMaximum();
return Napi::Value::From(env, retValue);
}
Napi::Value QInputDialogWrap::setIntMaximum(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto value = info[0].As<Napi::Number>().Int32Value();
this->instance->setIntMaximum(value);
return env.Null();
}
Napi::Value QInputDialogWrap::intMinimum(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto retValue = this->instance->intMinimum();
return Napi::Value::From(env, retValue);
}
Napi::Value QInputDialogWrap::setIntMinimum(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto value = info[0].As<Napi::Number>().Int32Value();
this->instance->setIntMinimum(value);
return env.Null();
}
Napi::Value QInputDialogWrap::intStep(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto retValue = this->instance->intStep();
return Napi::Value::From(env, retValue);
}
Napi::Value QInputDialogWrap::setIntStep(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto value = info[0].As<Napi::Number>().Int32Value();
this->instance->setIntStep(value);
return env.Null();
}
Napi::Value QInputDialogWrap::intValue(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto retValue = this->instance->intValue();
return Napi::Value::From(env, retValue);
}
Napi::Value QInputDialogWrap::setIntValue(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto value = info[0].As<Napi::Number>().Int32Value();
this->instance->setIntValue(value);
return env.Null();
}
Napi::Value QInputDialogWrap::labelText(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto retValue = this->instance->labelText().toStdString();
return Napi::Value::From(env, retValue);
}
Napi::Value QInputDialogWrap::setLabelText(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto value = info[0].As<Napi::String>().Utf8Value().c_str();
this->instance->setLabelText(value);
return env.Null();
}
Napi::Value QInputDialogWrap::okButtonText(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto retValue = this->instance->okButtonText().toStdString();
return Napi::Value::From(env, retValue);
}
Napi::Value QInputDialogWrap::setOkButtonText(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto value = info[0].As<Napi::String>().Utf8Value().c_str();
this->instance->setOkButtonText(value);
return env.Null();
}
Napi::Value QInputDialogWrap::options(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto retValue = this->instance->options();
return Napi::Value::From(env, static_cast<int>(retValue));
}
Napi::Value QInputDialogWrap::setOptions(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto value = info[0].As<Napi::Number>().Int32Value();
this->instance->setOptions(
static_cast<QInputDialog::InputDialogOptions>(value));
return env.Null();
}
Napi::Value QInputDialogWrap::textEchoMode(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto retValue = this->instance->textEchoMode();
return Napi::Value::From(env, static_cast<int>(retValue));
}
Napi::Value QInputDialogWrap::setTextEchoMode(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto value = info[0].As<Napi::Number>().Int32Value();
this->instance->setTextEchoMode(static_cast<QLineEdit::EchoMode>(value));
return env.Null();
}
Napi::Value QInputDialogWrap::textValue(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto retValue = this->instance->textValue().toStdString();
return Napi::Value::From(env, retValue);
}
Napi::Value QInputDialogWrap::setTextValue(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
auto value = info[0].As<Napi::String>().Utf8Value().c_str();
this->instance->setTextValue(value);
return env.Null();
}

View File

@ -37,6 +37,7 @@
#include "QtWidgets/QFileDialog/qfiledialog_wrap.h"
#include "QtWidgets/QGridLayout/qgridlayout_wrap.h"
#include "QtWidgets/QGroupBox/qgroupbox_wrap.h"
#include "QtWidgets/QInputDialog/qinputdialog_wrap.h"
#include "QtWidgets/QLabel/qlabel_wrap.h"
#include "QtWidgets/QLayout/qlayout_wrap.h"
#include "QtWidgets/QLineEdit/qlineedit_wrap.h"
@ -137,6 +138,7 @@ Napi::Object Main(Napi::Env env, Napi::Object exports) {
QMenuWrap::init(env, exports);
QMenuBarWrap::init(env, exports);
QMessageBoxWrap::init(env, exports);
QInputDialogWrap::init(env, exports);
QSliderWrap::init(env, exports);
QTimeEditWrap::init(env, exports);
QButtonGroupWrap::init(env, exports);

View File

@ -1,7 +1,7 @@
import { QMainWindow } from './index';
import { QInputDialog } from './index';
const win = new QMainWindow();
const dialog = new QInputDialog();
dialog.setLabelText('Click that Omg button');
dialog.exec();
win.show();
(global as any).win = win;
// (global as any).win = win;

View File

@ -58,7 +58,9 @@ export { QTreeWidget, QTreeWidgetSignals } from './lib/QtWidgets/QTreeWidget';
export { QTreeWidgetItem } from './lib/QtWidgets/QTreeWidgetItem';
export { QPainter, RenderHint } from './lib/QtWidgets/QPainter';
export { QDialog, QDialogSignals } from './lib/QtWidgets/QDialog';
export { QMessageBox, StandardButton, Icon, ButtonRole } from './lib/QtWidgets/QMessageBox';
export { QMessageBox, QMessageBoxSignals, QMessageBoxIcon, ButtonRole } from './lib/QtWidgets/QMessageBox';
export { QInputDialog, QInputDialogSignals, InputDialogOptions, InputMode } from './lib/QtWidgets/QInputDialog';
export { QButtonGroup, QButtonGroupSignals } from './lib/QtWidgets/QButtonGroup';
export {

View File

@ -0,0 +1,163 @@
import addon from '../utils/addon';
import { NodeWidget } from './QWidget';
import { NativeElement } from '../core/Component';
import { NodeDialog, QDialogSignals } from './QDialog';
import { EchoMode } from './QLineEdit';
/**
> Create and control input modal dialogs.
* **This class is a JS wrapper around Qt's [QInputDialog class](https://doc.qt.io/qt-5/qinputdialog.html)**
### Example
```javascript
import { QInputDialog } from '@nodegui/nodegui';
const dialog = new QInputDialog();
dialog.setLabelText('Click that Ok button');
dialog.exec();
```
*/
export class QInputDialog extends NodeDialog<QInputDialogSignals> {
native: NativeElement;
constructor();
constructor(parent: NodeWidget<any>);
constructor(parent?: NodeWidget<any>) {
let native;
if (parent) {
native = new addon.QInputDialog(parent.native);
} else {
native = new addon.QInputDialog();
}
super(native);
this.native = native;
this.setNodeParent(parent);
}
setCancelButtonText(text: string): void {
this.native.setCancelButtonText(text);
}
cancelButtonText(): string {
return this.native.cancelButtonText();
}
setComboBoxEditable(editable: boolean): void {
this.native.setComboxBoxEditable(editable);
}
isComboBoxEditable(): boolean {
return this.native.isComboxBoxEditable();
}
setDoubleDecimals(decimals: number): void {
this.native.setDoubleDecimals(decimals);
}
doubleDecimals(): number {
return this.native.doubleDecimals();
}
setDoubleMaximum(value: number): void {
this.native.setDoubleMaximum(value);
}
doubleMaximum(): number {
return this.native.doubleMaximum();
}
setDoubleMinimum(value: number): void {
this.native.setDoubleMinimum(value);
}
doubleMinimum(): number {
return this.native.doubleMinimum();
}
doubleStep(): number {
return this.native.doubleStep();
}
setDoubleStep(value: number): void {
this.native.setDoubleStep(value);
}
doubleValue(): number {
return this.native.doubleValue();
}
setDoubleValue(value: number): void {
this.native.setDoubleValue(value);
}
inputMode(): InputMode {
return this.native.inputMode();
}
setInputMode(value: InputMode): void {
this.native.setInputMode(value);
}
intMaximum(): number {
return this.native.intMaximum();
}
setIntMaximum(value: number): void {
this.native.setIntMaximum(value);
}
intMinimum(): number {
return this.native.intMinimum();
}
setIntMinimum(value: number): void {
this.native.setIntMinimum(value);
}
intStep(): number {
return this.native.intStep();
}
setIntStep(value: number): void {
this.native.setIntStep(value);
}
intValue(): number {
return this.native.intValue();
}
setIntValue(value: number): void {
this.native.setIntValue(value);
}
labelText(): string {
return this.native.labelText();
}
setLabelText(value: string): void {
this.native.setLabelText(value);
}
okButtonText(): string {
return this.native.okButtonText();
}
setOkButtonText(value: string): void {
this.native.setOkButtonText(value);
}
options(): InputDialogOptions {
return this.native.options();
}
setOptions(value: InputDialogOptions): void {
this.native.setOptions(value);
}
textEchoMode(): EchoMode {
return this.native.textEchoMode();
}
setTextEchoMode(value: EchoMode): void {
this.native.setTextEchoMode(value);
}
textValue(): string {
return this.native.textValue();
}
setTextValue(value: string): void {
this.native.setTextValue(value);
}
}
export interface QInputDialogSignals extends QDialogSignals {
doubleValueChanged: (value: number) => void;
doubleValueSelected: (value: number) => void;
intValueChanged: (value: number) => void;
intValueSelected: (value: number) => void;
textValueChanged: (text: string) => void;
textValueSelected: (text: string) => void;
}
export enum InputMode {
TextInput = 0,
IntInput = 1,
DoubleInput = 2,
}
export enum InputDialogOptions {
NoButtons = 1,
UseListViewForComboBoxItems = 2,
UsePlainTextEditForTextInput = 3,
}

View File

@ -103,28 +103,7 @@ export interface QMessageBoxSignals extends QDialogSignals {
buttonClicked: (buttonRawPointer: NativeRawPointer<'QAbstractButton*'>) => void;
}
export enum StandardButton {
Ok = 0x00000400,
Open = 0x00002000,
Save = 0x00000800,
Cancel = 0x00400000,
Close = 0x00200000,
Discard = 0x00800000,
Apply = 0x02000000,
Reset = 0x04000000,
RestoreDefaults = 0x08000000,
Help = 0x01000000,
SaveAll = 0x00001000,
Yes = 0x00004000,
YesToAll = 0x00008000,
No = 0x00010000,
NoToAll = 0x00020000,
Abort = 0x00040000,
Retry = 0x00080000,
Ignore = 0x00100000,
NoButton = 0x00000000,
}
export enum Icon {
export enum QMessageBoxIcon {
NoIcon = 0,
Question = 4,
Information = 1,