Advance Wayland and KDE package bring-up
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
add_executable(dialog dialogexample.cpp)
|
||||
target_link_libraries(dialog KF6::SonnetCore KF6::SonnetUi)
|
||||
|
||||
add_executable(highlighter highlighterexample.cpp)
|
||||
target_link_libraries(highlighter KF6::SonnetCore KF6::SonnetUi)
|
||||
|
||||
add_executable(configdialog configdialog.cpp)
|
||||
target_link_libraries(configdialog KF6::SonnetCore KF6::SonnetUi)
|
||||
|
||||
add_executable(dictionarycombobox dictionarycombobox.cpp)
|
||||
target_link_libraries(dictionarycombobox KF6::SonnetCore KF6::SonnetUi)
|
||||
|
||||
add_executable(textedit textedit.cpp)
|
||||
target_link_libraries(textedit KF6::SonnetCore KF6::SonnetUi)
|
||||
|
||||
add_executable(plaintextedit plaintextedit.cpp)
|
||||
target_link_libraries(plaintextedit KF6::SonnetCore KF6::SonnetUi)
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* test_configdialog.cpp
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2004 Zack Rusin <zack@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
#include "configdialog.h"
|
||||
#include "speller.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
using namespace Sonnet;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
ConfigDialog *dialog = new ConfigDialog(nullptr);
|
||||
|
||||
dialog->show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// krazy:excludeall=spelling
|
||||
/**
|
||||
* test_dialog.cpp
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2004 Zack Rusin <zack@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
#include "dialogexample.h"
|
||||
|
||||
#include "backgroundchecker.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
using namespace Sonnet;
|
||||
|
||||
TestDialog::TestDialog()
|
||||
: QObject(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
//@@snippet_begin(dictionary_combo_box_example)
|
||||
void TestDialog::check(const QString &buffer)
|
||||
{
|
||||
Sonnet::Dialog *dlg = new Sonnet::Dialog(new BackgroundChecker(this), nullptr);
|
||||
connect(dlg, &Dialog::spellCheckDone, this, &TestDialog::doneChecking);
|
||||
dlg->setBuffer(buffer);
|
||||
dlg->show();
|
||||
}
|
||||
|
||||
//@@snippet_end
|
||||
|
||||
void TestDialog::doneChecking(const QString &buf)
|
||||
{
|
||||
qDebug() << "Done with :" << buf;
|
||||
qApp->quit();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
TestDialog test;
|
||||
test.check(
|
||||
QString::fromLatin1("This is a sample buffer. Whih this thingg will "
|
||||
"be checkin for misstakes. Whih, Enviroment, govermant. Whih."));
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
#include "moc_dialogexample.cpp"
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* test_dialog.h
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2004 Zack Rusin <zack@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
#ifndef TEST_DIALOG_H
|
||||
#define TEST_DIALOG_H
|
||||
|
||||
#include "dialog.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class TestDialog : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TestDialog();
|
||||
|
||||
public Q_SLOTS:
|
||||
void check(const QString &buffer);
|
||||
void doneChecking(const QString &);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2008 Volker Krause <vkrause@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "dictionarycombobox.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
using namespace Sonnet;
|
||||
|
||||
class DictionaryComboBoxTest : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DictionaryComboBoxTest()
|
||||
{
|
||||
QHBoxLayout *topLayout = new QHBoxLayout(this);
|
||||
dcb = new DictionaryComboBox(this);
|
||||
topLayout->addWidget(dcb, 1);
|
||||
connect(dcb, &DictionaryComboBox::dictionaryChanged, this, &DictionaryComboBoxTest::dictChanged);
|
||||
connect(dcb, &DictionaryComboBox::dictionaryNameChanged, this, &DictionaryComboBoxTest::dictNameChanged);
|
||||
QPushButton *btn = new QPushButton(QStringLiteral("Dump"), this);
|
||||
topLayout->addWidget(btn);
|
||||
connect(btn, &QPushButton::clicked, this, &DictionaryComboBoxTest::dump);
|
||||
}
|
||||
|
||||
public Q_SLOTS:
|
||||
void dump()
|
||||
{
|
||||
qDebug() << "Current dictionary: " << dcb->currentDictionary();
|
||||
qDebug() << "Current dictionary name: " << dcb->currentDictionaryName();
|
||||
}
|
||||
|
||||
void dictChanged(const QString &name)
|
||||
{
|
||||
qDebug() << "Current dictionary changed: " << name;
|
||||
}
|
||||
|
||||
void dictNameChanged(const QString &name)
|
||||
{
|
||||
qDebug() << "Current dictionary name changed: " << name;
|
||||
}
|
||||
|
||||
private:
|
||||
DictionaryComboBox *dcb;
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
DictionaryComboBoxTest *test = new DictionaryComboBoxTest();
|
||||
test->show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
#include "dictionarycombobox.moc"
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* test_highlighter.cpp
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2004 Zack Rusin <zack@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
#include "highlighterexample.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QContextMenuEvent>
|
||||
#include <QDebug>
|
||||
#include <QMenu>
|
||||
|
||||
TestSpell::TestSpell()
|
||||
: QTextEdit()
|
||||
{
|
||||
hl = new Sonnet::Highlighter(this);
|
||||
}
|
||||
|
||||
void TestSpell::contextMenuEvent(QContextMenuEvent *e)
|
||||
{
|
||||
qDebug() << "TestSpell::contextMenuEvent";
|
||||
QMenu *popup = createStandardContextMenu();
|
||||
QMenu *subMenu = new QMenu(popup);
|
||||
subMenu->setTitle(QStringLiteral("Text highlighting"));
|
||||
connect(subMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotActivate()));
|
||||
QAction *action = new QAction(QStringLiteral("active or not"), popup);
|
||||
popup->addSeparator();
|
||||
popup->addMenu(subMenu);
|
||||
subMenu->addAction(action);
|
||||
popup->exec(e->globalPos());
|
||||
delete popup;
|
||||
}
|
||||
|
||||
void TestSpell::slotActivate()
|
||||
{
|
||||
qDebug() << "Activate or not highlight :";
|
||||
hl->setActive(!hl->isActive());
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QTextEdit *test = new TestSpell();
|
||||
test->show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
#include "moc_highlighterexample.cpp"
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* test_highlighter.h
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2006 Laurent Montel <montel@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
|
||||
#ifndef KTESTSPELL_H
|
||||
#define KTESTSPELL_H
|
||||
|
||||
#include "highlighter.h"
|
||||
#include <QTextEdit>
|
||||
|
||||
class QContextMenuEvent;
|
||||
class TestSpell : public QTextEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TestSpell();
|
||||
public Q_SLOTS:
|
||||
void slotActivate();
|
||||
|
||||
protected:
|
||||
void contextMenuEvent(QContextMenuEvent *) override;
|
||||
Sonnet::Highlighter *hl;
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,72 @@
|
||||
// krazy:excludeall=spelling
|
||||
/**
|
||||
* test_plaintextedit.cpp
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2015 Laurent Montel <montel@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
// Local
|
||||
#include <dictionarycombobox.h>
|
||||
#include <highlighter.h>
|
||||
#include <spellcheckdecorator.h>
|
||||
|
||||
// Qt
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
//@@snippet_begin(simple_email_example)
|
||||
class CommentCheckDecorator : public Sonnet::SpellCheckDecorator
|
||||
{
|
||||
public:
|
||||
explicit CommentCheckDecorator(QPlainTextEdit *edit)
|
||||
: Sonnet::SpellCheckDecorator(edit)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
bool isSpellCheckingEnabledForBlock(const QString &blockText) const override
|
||||
{
|
||||
qDebug() << blockText;
|
||||
return !blockText.startsWith(QLatin1Char('#'));
|
||||
}
|
||||
};
|
||||
//@@snippet_end
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QWidget window;
|
||||
|
||||
Sonnet::DictionaryComboBox *comboBox = new Sonnet::DictionaryComboBox;
|
||||
|
||||
//@@snippet_begin(simple_textedit_example)
|
||||
QPlainTextEdit *textEdit = new QPlainTextEdit;
|
||||
textEdit->setPlainText(
|
||||
QString::fromLatin1("This is a sample buffer. Whih this thingg will "
|
||||
"be checkin for misstakes. Whih, Enviroment, govermant. Whih."));
|
||||
|
||||
Sonnet::SpellCheckDecorator *installer = new Sonnet::SpellCheckDecorator(textEdit);
|
||||
installer->highlighter()->setCurrentLanguage(QStringLiteral("en"));
|
||||
//@@snippet_end
|
||||
|
||||
QObject::connect(comboBox, &Sonnet::DictionaryComboBox::dictionaryChanged, installer->highlighter(), &Sonnet::Highlighter::setCurrentLanguage);
|
||||
|
||||
QPlainTextEdit *commentTextEdit = new QPlainTextEdit;
|
||||
commentTextEdit->setPlainText(QStringLiteral("John Doe said:\n# Hello how aree you?\nI am ffine thanks"));
|
||||
|
||||
installer = new CommentCheckDecorator(commentTextEdit);
|
||||
installer->highlighter()->setCurrentLanguage(QStringLiteral("en"));
|
||||
QObject::connect(comboBox, &Sonnet::DictionaryComboBox::dictionaryChanged, installer->highlighter(), &Sonnet::Highlighter::setCurrentLanguage);
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout(&window);
|
||||
layout->addWidget(comboBox);
|
||||
layout->addWidget(textEdit);
|
||||
layout->addWidget(commentTextEdit);
|
||||
|
||||
window.show();
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
// krazy:excludeall=spelling
|
||||
/**
|
||||
* test_textedit.cpp
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2013 Aurélien Gâteau <agateau@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*/
|
||||
// Local
|
||||
#include <dictionarycombobox.h>
|
||||
#include <highlighter.h>
|
||||
#include <spellcheckdecorator.h>
|
||||
|
||||
// Qt
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
//@@snippet_begin(simple_email_example)
|
||||
class MailSpellCheckDecorator : public Sonnet::SpellCheckDecorator
|
||||
{
|
||||
public:
|
||||
explicit MailSpellCheckDecorator(QTextEdit *edit)
|
||||
: Sonnet::SpellCheckDecorator(edit)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
bool isSpellCheckingEnabledForBlock(const QString &blockText) const override
|
||||
{
|
||||
qDebug() << blockText;
|
||||
return !blockText.startsWith(QLatin1Char('>'));
|
||||
}
|
||||
};
|
||||
//@@snippet_end
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QWidget window;
|
||||
|
||||
Sonnet::DictionaryComboBox *comboBox = new Sonnet::DictionaryComboBox;
|
||||
|
||||
//@@snippet_begin(simple_textedit_example)
|
||||
QTextEdit *textEdit = new QTextEdit;
|
||||
textEdit->setText(
|
||||
QString::fromLatin1("This is a sample buffer. Whih this thingg will "
|
||||
"be checkin for misstakes. Whih, Enviroment, govermant. Whih."));
|
||||
|
||||
Sonnet::SpellCheckDecorator *installer = new Sonnet::SpellCheckDecorator(textEdit);
|
||||
installer->highlighter()->setCurrentLanguage(QStringLiteral("en_US"));
|
||||
//@@snippet_end
|
||||
|
||||
QObject::connect(comboBox, &Sonnet::DictionaryComboBox::dictionaryChanged, installer->highlighter(), &Sonnet::Highlighter::setCurrentLanguage);
|
||||
|
||||
QTextEdit *mailTextEdit = new QTextEdit;
|
||||
mailTextEdit->setText(QStringLiteral("John Doe said:\n> Hello how aree you?\nI am ffine thanks"));
|
||||
|
||||
installer = new MailSpellCheckDecorator(mailTextEdit);
|
||||
installer->highlighter()->setCurrentLanguage(QStringLiteral("en_US"));
|
||||
QObject::connect(comboBox, &Sonnet::DictionaryComboBox::dictionaryChanged, installer->highlighter(), &Sonnet::Highlighter::setCurrentLanguage);
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout(&window);
|
||||
layout->addWidget(comboBox);
|
||||
layout->addWidget(textEdit);
|
||||
layout->addWidget(mailTextEdit);
|
||||
|
||||
window.show();
|
||||
return app.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user