add a meow action to the TextEditor program
This commit is contained in:
parent
b020fe9c7f
commit
e64edc5c5a
3 changed files with 26 additions and 2 deletions
|
@ -24,16 +24,33 @@ MainWindow::MainWindow(QWidget* parent)
|
||||||
void MainWindow::setupClearAction()
|
void MainWindow::setupClearAction()
|
||||||
{
|
{
|
||||||
QAction* clearAction = new QAction(this);
|
QAction* clearAction = new QAction(this);
|
||||||
|
|
||||||
clearAction->setText(i18n("&Clear"));
|
clearAction->setText(i18n("&Clear"));
|
||||||
clearAction->setIcon(QIcon::fromTheme("document-new"));
|
clearAction->setIcon(QIcon::fromTheme("document-new"));
|
||||||
|
|
||||||
actionCollection()->addAction("clear", clearAction);
|
actionCollection()->addAction("clear", clearAction);
|
||||||
actionCollection()->setDefaultShortcut(clearAction, Qt::CTRL + Qt::Key_W);
|
actionCollection()->setDefaultShortcut(clearAction, Qt::CTRL + Qt::Key_W);
|
||||||
|
|
||||||
connect(clearAction, &QAction::triggered, textArea, &KTextEdit::clear);
|
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()
|
void MainWindow::setupActions()
|
||||||
{
|
{
|
||||||
setupClearAction();
|
setupClearAction();
|
||||||
|
setupMeowAction();
|
||||||
|
|
||||||
KStandardAction::quit(qApp, &QCoreApplication::quit, actionCollection());
|
KStandardAction::quit(qApp, &QCoreApplication::quit, actionCollection());
|
||||||
KStandardAction::open(this, &MainWindow::openFile, actionCollection());
|
KStandardAction::open(this, &MainWindow::openFile, actionCollection());
|
||||||
|
@ -109,3 +126,7 @@ void MainWindow::downloadFinished(KJob* job)
|
||||||
textArea->setPlainText(QTextStream(storedJob->data(), QIODevice::ReadOnly).readAll());
|
textArea->setPlainText(QTextStream(storedJob->data(), QIODevice::ReadOnly).readAll());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::meow() {
|
||||||
|
KMessageBox::information(this, "Meow", "Meow");
|
||||||
|
}
|
||||||
|
|
|
@ -14,15 +14,17 @@ private:
|
||||||
void setupActions();
|
void setupActions();
|
||||||
void saveFileToDisk(const QString& outputFileName);
|
void saveFileToDisk(const QString& outputFileName);
|
||||||
void setupClearAction();
|
void setupClearAction();
|
||||||
|
void setupMeowAction();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void newFile();
|
void newFile();
|
||||||
void openFile();
|
void openFile();
|
||||||
void saveFile();
|
void saveFile();
|
||||||
void saveFileAs();
|
void saveFileAs();
|
||||||
|
|
||||||
void downloadFinished(KJob *job);
|
void downloadFinished(KJob *job);
|
||||||
|
|
||||||
|
void meow();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KTextEdit* textArea;
|
KTextEdit* textArea;
|
||||||
QString fileName;
|
QString fileName;
|
||||||
|
|
|
@ -8,11 +8,12 @@
|
||||||
</Menu>
|
</Menu>
|
||||||
<Menu>
|
<Menu>
|
||||||
<text>Another Meownu</text>
|
<text>Another Meownu</text>
|
||||||
<Action name="clear" />
|
<Action name="meow" />
|
||||||
</Menu>
|
</Menu>
|
||||||
</MenuBar>
|
</MenuBar>
|
||||||
<ToolBar name="mainToolBar">
|
<ToolBar name="mainToolBar">
|
||||||
<text>Main Toolbar</text>
|
<text>Main Toolbar</text>
|
||||||
<Action name="clear" />
|
<Action name="clear" />
|
||||||
|
<Action name="meow" />
|
||||||
</ToolBar>
|
</ToolBar>
|
||||||
</gui>
|
</gui>
|
||||||
|
|
Loading…
Reference in a new issue