From e64edc5c5a1e0afa7f6598f41caf1cf320471548 Mon Sep 17 00:00:00 2001 From: Fries Date: Mon, 26 Jun 2023 19:49:48 -0700 Subject: [PATCH] add a meow action to the TextEditor program --- src/TextEditor/MainWindow.cc | 21 +++++++++++++++++++++ src/TextEditor/MainWindow.hh | 4 +++- src/TextEditor/TextEditorUI.rc | 3 ++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/TextEditor/MainWindow.cc b/src/TextEditor/MainWindow.cc index 59bdb09..c913189 100644 --- a/src/TextEditor/MainWindow.cc +++ b/src/TextEditor/MainWindow.cc @@ -24,16 +24,33 @@ MainWindow::MainWindow(QWidget* parent) void MainWindow::setupClearAction() { QAction* clearAction = new QAction(this); + clearAction->setText(i18n("&Clear")); clearAction->setIcon(QIcon::fromTheme("document-new")); + actionCollection()->addAction("clear", clearAction); actionCollection()->setDefaultShortcut(clearAction, Qt::CTRL + Qt::Key_W); + connect(clearAction, &QAction::triggered, textArea, &KTextEdit::clear); } +void MainWindow::setupMeowAction() +{ + QAction* meowAction = new QAction(this); + + meowAction->setText(i18n("&Meow")); + meowAction->setIcon(QIcon::fromTheme("network-wireless-signal-excellent")); + + actionCollection()->addAction("meow", meowAction); + actionCollection()->setDefaultShortcut(meowAction, Qt::CTRL + Qt::Key_M); + + connect(meowAction, &QAction::triggered, this, &MainWindow::meow); +} + void MainWindow::setupActions() { setupClearAction(); + setupMeowAction(); KStandardAction::quit(qApp, &QCoreApplication::quit, actionCollection()); KStandardAction::open(this, &MainWindow::openFile, actionCollection()); @@ -109,3 +126,7 @@ void MainWindow::downloadFinished(KJob* job) textArea->setPlainText(QTextStream(storedJob->data(), QIODevice::ReadOnly).readAll()); } } + +void MainWindow::meow() { + KMessageBox::information(this, "Meow", "Meow"); +} diff --git a/src/TextEditor/MainWindow.hh b/src/TextEditor/MainWindow.hh index 40609e4..5708efa 100644 --- a/src/TextEditor/MainWindow.hh +++ b/src/TextEditor/MainWindow.hh @@ -14,15 +14,17 @@ private: void setupActions(); void saveFileToDisk(const QString& outputFileName); void setupClearAction(); + void setupMeowAction(); private Q_SLOTS: void newFile(); void openFile(); void saveFile(); void saveFileAs(); - void downloadFinished(KJob *job); + void meow(); + private: KTextEdit* textArea; QString fileName; diff --git a/src/TextEditor/TextEditorUI.rc b/src/TextEditor/TextEditorUI.rc index 0e4433c..2ed638e 100644 --- a/src/TextEditor/TextEditorUI.rc +++ b/src/TextEditor/TextEditorUI.rc @@ -8,11 +8,12 @@ Another Meownu - + Main Toolbar +