mirror of
https://github.com/theCheeseboard/thedesk.git
synced 2025-01-22 10:22:02 -05:00
Fix dialog boxes blocking input
This commit is contained in:
parent
416c215da0
commit
d1d96d0624
6 changed files with 26 additions and 14 deletions
|
@ -38,7 +38,7 @@ MessageDialog::MessageDialog(QWidget* parent) :
|
|||
d = new MessageDialogPrivate();
|
||||
|
||||
// this->setWindowFlags(Qt::Widget);
|
||||
ui->frame->setMinimumWidth(SC_DPI(400));
|
||||
ui->frame->setMinimumWidth(400);
|
||||
|
||||
d->opacity = new QGraphicsOpacityEffect(this);
|
||||
d->opacity->setEnabled(false);
|
||||
|
@ -46,7 +46,7 @@ MessageDialog::MessageDialog(QWidget* parent) :
|
|||
|
||||
ui->detailsWidget->setVisible(false);
|
||||
|
||||
ui->dialogTypeWidget->setFixedWidth(SC_DPI(3));
|
||||
ui->dialogTypeWidget->setFixedWidth(3);
|
||||
}
|
||||
|
||||
MessageDialog::~MessageDialog() {
|
||||
|
@ -129,7 +129,7 @@ void MessageDialog::setOptions(const QSharedPointer<QMessageDialogOptions>& opti
|
|||
buttons.append(QMessageDialogOptions::CustomButton(QPlatformDialogHelper::Ok, tr("OK"), QPlatformDialogHelper::AcceptRole));
|
||||
}
|
||||
|
||||
for (QMessageDialogOptions::CustomButton btn : buttons) {
|
||||
for (const QMessageDialogOptions::CustomButton& btn : buttons) {
|
||||
QPushButton* button = new QPushButton(this);
|
||||
button->setText(btn.label);
|
||||
if (btn.role == QPlatformDialogHelper::DestructiveRole) button->setProperty("type", "destructive");
|
||||
|
@ -159,7 +159,7 @@ void MessageDialog::animateIn() {
|
|||
d->opacity->setOpacity(value.toReal());
|
||||
|
||||
QRect geometry = frameGeometry();
|
||||
geometry.moveTop(geometry.top() - SC_DPI(10) * (1.0 - value.toReal()));
|
||||
geometry.moveTop(geometry.top() - 10 * (1.0 - value.toReal()));
|
||||
this->setFixedSize(QSize(0, 0));
|
||||
this->setFixedSize(geometry.size());
|
||||
this->setGeometry(geometry);
|
||||
|
@ -183,7 +183,7 @@ void MessageDialog::animateOut() {
|
|||
d->opacity->setOpacity(value.toReal());
|
||||
|
||||
QRect geometry = frameGeometry();
|
||||
geometry.moveTop(geometry.top() + SC_DPI(10) * (1.0 - value.toReal()));
|
||||
geometry.moveTop(geometry.top() + 10 * (1.0 - value.toReal()));
|
||||
this->setFixedSize(QSize(0, 0));
|
||||
this->setFixedSize(geometry.size());
|
||||
this->setGeometry(geometry);
|
||||
|
@ -198,17 +198,17 @@ void MessageDialog::animateOut() {
|
|||
QRect MessageDialog::frameGeometry() {
|
||||
QRect geometry = this->geometry();
|
||||
if (d->showingDetails) {
|
||||
if (ui->detailsContents->sizeHint().width() > SC_DPI(400)) {
|
||||
if (ui->detailsContents->sizeHint().width() > 400) {
|
||||
geometry.setSize(ui->detailsContents->sizeHint());
|
||||
} else {
|
||||
geometry.setSize(QSize(SC_DPI(400), ui->detailsContents->heightForWidth(SC_DPI(400))));
|
||||
geometry.setSize(QSize(400, ui->detailsContents->heightForWidth(400)));
|
||||
}
|
||||
if (this->parentWidget() && geometry.height() > this->parentWidget()->height()) geometry.setHeight(this->parentWidget()->height());
|
||||
} else {
|
||||
if (ui->frame->sizeHint().width() > SC_DPI(400)) {
|
||||
if (ui->frame->sizeHint().width() > 400) {
|
||||
geometry.setSize(ui->frame->sizeHint());
|
||||
} else {
|
||||
geometry.setSize(QSize(SC_DPI(400), ui->frame->heightForWidth(SC_DPI(400))));
|
||||
geometry.setSize(QSize(400, ui->frame->heightForWidth(400)));
|
||||
}
|
||||
}
|
||||
if (this->parentWidget()) {
|
||||
|
|
|
@ -34,8 +34,9 @@ class MessageDialog : public QWidget {
|
|||
public:
|
||||
explicit MessageDialog(QWidget* parent = nullptr);
|
||||
~MessageDialog();
|
||||
|
||||
void setOptions(const QSharedPointer<QMessageDialogOptions>& options);
|
||||
|
||||
void extracted(QVector<QMessageDialogOptions::CustomButton> &buttons);
|
||||
void setOptions(const QSharedPointer<QMessageDialogOptions> &options);
|
||||
void setParent(QWidget* parent);
|
||||
|
||||
void animateIn();
|
||||
|
|
|
@ -143,3 +143,10 @@ void MessageDialogHelper::setOptions(const QSharedPointer<QMessageDialogOptions>
|
|||
QPlatformMessageDialogHelper::setOptions(options);
|
||||
d->dlg->setOptions(options);
|
||||
}
|
||||
|
||||
QVariant MessageDialogHelper::styleHint(StyleHint hint) const {
|
||||
if (hint == DialogIsQtWindow) {
|
||||
return true;
|
||||
}
|
||||
return QPlatformMessageDialogHelper::StyleHint(hint);
|
||||
}
|
||||
|
|
|
@ -42,6 +42,10 @@ class MessageDialogHelper : public QPlatformMessageDialogHelper {
|
|||
bool show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow* parent);
|
||||
void hide();
|
||||
void setOptions(const QSharedPointer<QMessageDialogOptions>& options);
|
||||
|
||||
// QPlatformDialogHelper interface
|
||||
public:
|
||||
QVariant styleHint(StyleHint hint) const;
|
||||
};
|
||||
|
||||
#endif // MESSAGEDIALOGHELPER_H
|
||||
|
|
|
@ -149,7 +149,7 @@ bool PlatformTheme::usePlatformNativeDialog(QPlatformTheme::DialogType type) con
|
|||
case QPlatformTheme::FontDialog:
|
||||
return false;
|
||||
case QPlatformTheme::MessageDialog:
|
||||
// return true;
|
||||
return true;
|
||||
case QPlatformTheme::FileDialog:
|
||||
if (d->flatpakPlatformTheme) return d->flatpakPlatformTheme->usePlatformNativeDialog(type);
|
||||
return false;
|
||||
|
@ -159,7 +159,7 @@ bool PlatformTheme::usePlatformNativeDialog(QPlatformTheme::DialogType type) con
|
|||
QPlatformDialogHelper* PlatformTheme::createPlatformDialogHelper(QPlatformTheme::DialogType type) const {
|
||||
switch (type) {
|
||||
case QPlatformTheme::MessageDialog:
|
||||
// return new MessageDialogHelper();
|
||||
return new MessageDialogHelper();
|
||||
case QPlatformTheme::FileDialog:
|
||||
if (d->flatpakPlatformTheme && d->flatpakPlatformTheme->usePlatformNativeDialog(type)) return d->flatpakPlatformTheme->createPlatformDialogHelper(type);
|
||||
return QPlatformTheme::createPlatformDialogHelper(type);
|
||||
|
|
|
@ -22,7 +22,7 @@ add_subdirectory(DefaultsPlugin)
|
|||
add_subdirectory(InputPlugin)
|
||||
add_subdirectory(TimeDatePlugin)
|
||||
add_subdirectory(AccessibilityPlugin)
|
||||
add_subdirectory(AudioPlugin)
|
||||
#add_subdirectory(AudioPlugin)
|
||||
add_subdirectory(BluetoothPlugin)
|
||||
add_subdirectory(NetworkPlugin)
|
||||
add_subdirectory(UsersPlugin)
|
||||
|
|
Loading…
Reference in a new issue