-
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented "Are you sure?" dialog when closing a tool.
- Loading branch information
1 parent
b41a54c
commit 51c57c9
Showing
12 changed files
with
100 additions
and
14 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef QDIALOGCUSTOM_H | ||
#define QDIALOGCUSTOM_H | ||
|
||
#include <QDialog> | ||
#include <QCloseEvent> | ||
#include <QMoveEvent> | ||
#include <QEvent> | ||
#include <QMessageBox> | ||
#include <QSettings> | ||
#include <KBusyIndicatorWidget> | ||
|
||
extern "C" QDialog* new_q_dialog_custom(QWidget *parent = nullptr, bool (*are_you_sure)(QDialog* dialog) = nullptr); | ||
|
||
class QDialogCustom : public QDialog | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit QDialogCustom(QWidget *parent = nullptr, bool (*are_you_sure)(QDialog* dialog) = nullptr); | ||
void closeEvent(QCloseEvent *event) override; | ||
|
||
private: | ||
bool (*are_you_sure)(QDialog* dialog); | ||
|
||
}; | ||
|
||
#endif // QDIALOGCUSTOM_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include "q_dialog_custom.h" | ||
#include <QApplication> | ||
#include <QDebug> | ||
#include <QFileInfo> | ||
#include <QIcon> | ||
#include <QResource> | ||
#include <QMimeData> | ||
|
||
// Fuction to be able to create a custom QMainWindow. | ||
extern "C" QDialog* new_q_dialog_custom(QWidget *parent, bool (*are_you_sure) (QDialog* dialog)) { | ||
return dynamic_cast<QDialog*>(new QDialogCustom(parent, are_you_sure)); | ||
} | ||
|
||
QDialogCustom::QDialogCustom(QWidget *parent, bool (*are_you_sure_fn) (QDialog* dialog)) : QDialog(parent) { | ||
are_you_sure = are_you_sure_fn; | ||
} | ||
|
||
// Overload of the close event so we can put a dialog there. | ||
void QDialogCustom::closeEvent(QCloseEvent *event) { | ||
event->ignore(); | ||
|
||
if (are_you_sure(this)) { | ||
event->accept(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters