Notepad example: Wrap clipboard functions with QT_CONFIG(clipboard)

And disable menu actions for functionality that's not available.

Task-number: QTBUG-68168
Change-Id: I153487860e8dda8271ae04e9cd2ad8b26a4b130f
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Topi Reinio 2018-06-22 16:22:45 +02:00 committed by Topi Reiniö
parent d2c0ba3f30
commit 6601939713

View File

@ -73,6 +73,17 @@ Notepad::Notepad(QWidget *parent) :
{
ui->setupUi(this);
this->setCentralWidget(ui->textEdit);
// Disable menu actions for unavailable features
#if !QT_CONFIG(printer)
ui->actionPrint->setEnabled(false);
#endif
#if !QT_CONFIG(clipboard)
ui->actionCut->setEnabled(false);
ui->actionCopy->setEnabled(false);
ui->actionPaste->setEnabled(false);
#endif
}
Notepad::~Notepad()
@ -161,17 +172,23 @@ void Notepad::on_actionExit_triggered()
void Notepad::on_actionCopy_triggered()
{
#if QT_CONFIG(clipboard)
ui->textEdit->copy();
#endif
}
void Notepad::on_actionCut_triggered()
{
#if QT_CONFIG(clipboard)
ui->textEdit->cut();
#endif
}
void Notepad::on_actionPaste_triggered()
{
#if QT_CONFIG(clipboard)
ui->textEdit->paste();
#endif
}
void Notepad::on_actionUndo_triggered()