generic: purge most manual tests

long overdue, have no use for them

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-07-03 06:59:48 +03:00
parent 693febf429
commit ee0d50c901
168 changed files with 7 additions and 14226 deletions

View file

@ -43,10 +43,6 @@ target_link_libraries(kdeclarative PUBLIC
kdeui kdeui
) )
if(ENABLE_TESTING)
add_subdirectory(tests)
endif()
generate_export_header(kdeclarative) generate_export_header(kdeclarative)
install( install(

View file

@ -1,2 +0,0 @@
kde4_add_manual_test(kdeclarative-test test.cpp)
target_link_libraries(kdeclarative-test kdeclarative)

View file

@ -1,65 +0,0 @@
/*
* Copyright 2011 Marco Martin <mart@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <QApplication>
#include <QDeclarativeView>
#include <QDeclarativeContext>
#include <QScriptEngine>
#include "kdeclarative.h"
#include "kaboutdata.h"
#include "kcmdlineargs.h"
#include "testobject_p.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
KAboutData about("kdeclarative-test", QByteArray(), ki18n("kdeclarative-test"), "1.0");
KCmdLineArgs::init(argc, argv, &about);
QDeclarativeView view;
QDeclarativeContext *context = view.rootContext();
context->setContextProperty("backgroundColor",
QColor(Qt::yellow));
KDeclarative kdeclarative;
kdeclarative.setDeclarativeEngine(view.engine());
kdeclarative.initialize();
//binds things like kconfig and icons
kdeclarative.setupBindings();
//If all gone well, the QScriptEngine has been extracted
QScriptEngine *scriptEngine = kdeclarative.scriptEngine();
Q_ASSERT(scriptEngine);
//Bind a test QObject in the "QtScript way"
QScriptValue global = scriptEngine->globalObject();
TestObject *testObject = new TestObject();
QScriptValue testValue = scriptEngine->newQObject(testObject);
global.setProperty("testObject", testValue);
view.setSource(QUrl::fromLocalFile(KDESRCDIR "test.qml"));
view.show();
return app.exec();
}
#include "moc_testobject_p.cpp"

View file

@ -1,54 +0,0 @@
/*
* Copyright 2011 Marco Martin <mart@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 1.1
import org.kde.plasma.core 0.1 as PlasmaCore
import org.kde.plasma.graphicswidgets 0.1 as PlasmaWidgets
Rectangle {
width: 300
height: 300
color: "red"
Component.onCompleted: {
print(testObject.prop)
testObject.prop = i18n("New text")
print(testObject.prop)
//QtScript binded elements don't appear to notify
textElement.text = testObject.prop
//test urls
var url = new Url("https://osdn.net/projects/kde/")
print(url.protocol)
print(url.host)
//test icons
iconWidget.icon = new QIcon("konqueror")
}
Column {
anchors.fill: parent
Text {
id: textElement
text: testObject.prop
}
PlasmaWidgets.IconWidget {
id: iconWidget
}
}
}

View file

@ -1,49 +0,0 @@
/*
* Copyright 2011 Marco Martin <mart@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef TESTOBJECT_P_H
#define TESTOBJECT_P_H
#include <QObject>
class TestObject : public QObject
{
Q_OBJECT
Q_PROPERTY(QString prop READ prop WRITE setProp NOTIFY propChanged)
public:
void setProp(const QString &prop)
{
m_prop = prop;
emit propChanged();
}
QString prop() const
{
return m_prop;
}
Q_SIGNALS:
void propChanged();
private:
QString m_prop;
};
#endif

View file

@ -60,9 +60,6 @@ KDECORE_UNIT_TESTS(
) )
KDECORE_EXECUTABLE_TESTS( KDECORE_EXECUTABLE_TESTS(
kcmdlineargstest
dbuscalltest
startserviceby
klockfile_testlock # helper for klockfiletest klockfile_testlock # helper for klockfiletest
) )

View file

@ -1,26 +0,0 @@
#include <kcmdlineargs.h>
#include <kaboutdata.h>
//#include <kapplication.h>
#include <kdebug.h>
#include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusReply>
int main( int argc, char** argv )
{
KAboutData about("DBusCallTest", 0, ki18n("DBusCallTest"), "version");
KCmdLineArgs::init(argc, argv, &about);
// KApplication app(false);
QDBusConnectionInterface *bus = 0;
if (!QDBusConnection::sessionBus().isConnected() || !(bus = QDBusConnection::sessionBus().interface())) {
kFatal() << "Session bus not found";
return 125;
}
kDebug() << "sending reparseConfiguration to object Konqueror in konqueror";
QDBusMessage message = QDBusMessage::createSignal("/Konqueror", "org.kde.Konqueror", "reparseConfiguration");
if(!QDBusConnection::sessionBus().send(message))
kDebug() << "void expected, " << QDBusConnection::sessionBus().lastError().name() << " returned";
return 0;
}

View file

@ -1,105 +0,0 @@
#include <kcmdlineargs.h>
#include <QtCore/QCoreApplication>
#include <kurl.h>
#include <stdio.h>
#include <assert.h>
#include <QtCore/QDir>
#include <kdebug.h>
#if 1
int
main(int argc, char *argv[])
{
KCmdLineOptions options;
options.add("test", ki18n("do a short test only, note that\n"
"this is rather long comment"));
options.add("b");
options.add("baud <baudrate>", ki18n("set baudrate"), "9600");
options.add("+file(s)", ki18n("Files to load"));
KCmdLineArgs::init(argc, argv, "testapp", 0,
ki18n("TestApp"), "v0.0.2",
ki18n("This is a test program.\n"
"1999 (c) Waldo Bastian"));
KCmdLineArgs::addCmdLineOptions( options ); // Add my own options.
// MyWidget::addCmdLineOptions();
//KApplication app( false );
QCoreApplication app( KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() );
// Get application specific arguments
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
// Check if an option is set
if (args->isSet("test"))
{
// Do stuff
printf("Option 'test' is set.\n");
}
if (args->isSet("baud"))
{
// Do stuff
printf("Option 'baud' is set.\n");
}
kDebug() << "allArguments:" << KCmdLineArgs::allArguments();
// Read the value of an option.
QString baudrate = args->getOption("baud"); // 9600 is the default value.
printf("Baudrate = %s\n", baudrate.toLocal8Bit().data());
printf("Full list of baudrates:\n");
QStringList result = args->getOptionList("baud");
Q_FOREACH(const QString& it, result) {
printf("Baudrate = %s\n", it.toLocal8Bit().data());
}
printf("End of list\n");
for(int i = 0; i < args->count(); i++)
{
printf("%d: %s\n", i, args->arg(i).toLocal8Bit().data());
printf("%d: %s\n", i, args->url(i).url().toLocal8Bit().data());
}
// Check how KCmdLineArgs::url() works
KUrl u = KCmdLineArgs::makeURL("/tmp");
kDebug() << u;
assert(u.toLocalFile() == "/tmp");
u = KCmdLineArgs::makeURL("foo");
kDebug() << u << " expected: " << KUrl(QDir::currentPath()+"/foo");
assert(u.toLocalFile() == QDir::currentPath()+"/foo");
u = KCmdLineArgs::makeURL("http://www.kde.org");
kDebug() << u;
assert(u.url() == "http://www.kde.org");
QFile file("a:b");
bool ok = file.open(QIODevice::WriteOnly);
assert(ok);
u = KCmdLineArgs::makeURL("a:b");
qDebug() << u.toLocalFile();
assert(u.isLocalFile());
assert(u.toLocalFile().endsWith(QLatin1String("a:b")));
args->clear(); // Free up memory.
Q_UNUSED(ok);
// return app.exec();
return 0;
}
#else
int
main(int argc, char *argv[])
{
KCmdLineArgs::init( argc, argv, "testapp", description, version);
QApplication app( KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv(), false );
return app.exec();
}
#endif

View file

@ -1,47 +0,0 @@
/* This file is part of the KDE libraries
Copyright (c) 1999 Waldo Bastian <bastian@kde.org>
Copyright (c) 2009 David Faure <faure@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <kcomponentdata.h>
#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include <ktoolinvocation.h>
#include <kdebug.h>
int main(int argc, char *argv[])
{
KAboutData about("ktoolinvocationtest", 0, ki18n("ktoolinvocationtest"), "version");
KComponentData cData(&about);
//KCmdLineArgs::init(argc, argv, &about);
//KApplication a;
QString serviceId = "kwrite.desktop";
if (argc > 1) {
serviceId = QString::fromLocal8Bit(argv[1]);
}
QString url;
if (argc > 2) {
url = QString::fromLocal8Bit(argv[2]);
}
QString error;
KToolInvocation::startServiceByDesktopPath( serviceId, url, &error );
kDebug() << "Started. error=" << error;
return 0;
}

View file

@ -73,81 +73,8 @@ KDEUI_UNIT_TESTS(
) )
KDEUI_EXECUTABLE_TESTS( KDEUI_EXECUTABLE_TESTS(
kaccelgentest
kactionselectortest
kapptest
kassistantdialogtest
kcategorizedviewtest
kcodecactiontest
kcolorcollectiontest
kcolordlgtest
kcolorcombotest
kcomboboxtest
kdatepicktest
klanguagebuttontest
kdatetabletest
kdatetimewidgettest
kdatewidgettest
kdebugtest_gui
kdialogbuttonboxtest
kdialogtest
kfontdialogtest
kglobalsettingsclient # helper program for kglobalsettingstest kglobalsettingsclient # helper program for kglobalsettingstest
khboxtest
kiconeffecttest
kiconloadertest
kinputdialogtest
kjobtrackerstest
kledtest
klineedittest
kmessageboxtest
kmessagetest
kmessagewidgettest
knewpassworddialogtest
kstatusnotifieritemtest
knotificationrestrictionstest
knuminputtest
kpagedialogtest
kpagewidgettest
kpassivepopuptest
kpassworddialogtest
kpixmapregionselectordialogtest
kpopuptest
kprogressdialogtest
krulertest
kselectactiontest
kseparatortest
kstatusbartest
ksqueezedtextlabeltest
ksystemtraytest
ktabwidgettest
ktextedittest
ktitlewidgettest
ktoolbartest
ktoolbarlabelactiontest
kwidgetitemdelegatetest
kwindowtest kwindowtest
kxmlguitest
kxmlguiwindowtest
testqtargs
kpixmapsequenceoverlaypaintertest
ktreewidgetsearchlinetest
kcompletionuitest
kmainwindowrestoretest
kmainwindowtest
fixx11h_test fixx11h_test
fixx11h_test2 fixx11h_test2
kxerrorhandlertest
) )
target_link_libraries(kdeui-kxerrorhandlertest ${X11_X11_LIB})
## kcolorutilsdemo
set(kcolorUtilsDemoSources
kcolorutilsdemo.cpp
kimageframe.cpp
../colors/kcolorspaces.cpp
)
kde4_add_manual_test(kcolorutilsdemo ${kcolorUtilsDemoSources})
target_link_libraries(kcolorutilsdemo kdeui)

View file

@ -1,68 +0,0 @@
/*
Copyright 2004 Frerich Raabe <raabe@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) version 3.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "kaccelgen.h"
#include <QtCore/QStringList>
#include <iostream>
using std::cout;
using std::endl;
void check( const QString &what, const QStringList &expected, const QStringList &received )
{
cout << "Testing " << qPrintable( what ) << ": ";
if ( expected == received ) {
cout << "ok" << endl;
} else {
cout << "ERROR!" << endl;
cout << "Expected: " << qPrintable( expected.join( "," ) ) << endl;
cout << "Received: " << qPrintable( received.join( "," ) ) << endl;
}
}
int main()
{
QStringList input;
input << "foo" << "bar item" << "&baz" << "bif" << "boz" << "boz 2"
<< "yoyo && dyne";
QStringList expected;
expected << "&foo" << "bar &item" << "&baz" << "bif" << "b&oz" << "boz &2"
<< "&yoyo && dyne";
QStringList output;
KAccelGen::generate( input, output );
check( "QStringList value generation", expected, output );
QMap<QString,QString> map;
for (QStringList::ConstIterator it = input.constBegin(); it != input.constEnd(); ++it) {
map.insert(*it, *it);
}
input.sort();
expected.clear();
KAccelGen::generate( input, expected );
output.clear();
KAccelGen::generateFromValues( map, output );
check( "map value generation", expected, output );
output.clear();
KAccelGen::generateFromKeys( map, output );
check( "map key generation", expected, output );
}

View file

@ -1,41 +0,0 @@
/*
Copyright (c) 2006 David Faure <faure@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <kactionselector.h>
#include <kcomponentdata.h>
#include <kaboutdata.h>
#include <kdebug.h>
#include <QtGui/QApplication>
#include <QtGui/QListWidget>
int main( int argc, char *argv[] )
{
QApplication app( argc, argv );
KAboutData aboutData( "kactionselectortest", 0, ki18n("kactionselectortest"), "1.0" );
KComponentData i( &aboutData );
KActionSelector actionSelector(0);
actionSelector.availableListWidget()->addItems(QStringList() << "A" << "B" << "C" << "D" << "E");
actionSelector.selectedListWidget()->addItems(QStringList() << "1" << "2");
actionSelector.show();
return app.exec();
}

View file

@ -1,39 +0,0 @@
/* This file is part of the KDE libraries
Copyright (c) 1999 Waldo Bastian <bastian@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "kapplication.h"
#include <stdio.h>
#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include <kglobalsettings.h>
#include <ksycoca.h>
int
main(int argc, char *argv[])
{
KAboutData about("kapptest", 0, ki18n("kapptest"), "version");
KCmdLineArgs::init(argc, argv, &about);
KApplication a;
KSycoca *s = KSycoca::self();
qDebug("s->language() %s", s->language().toLatin1().constData());
}

View file

@ -1,54 +0,0 @@
/*
* kassistantdialogtest - a test program for the KAssistantDialog class
* Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include <QtGui/QLabel>
#include <QtGui/QLayout>
//Added by qt3to4:
#include <QtGui/QBoxLayout>
#include <kcmdlineargs.h>
#include <kapplication.h>
#include <kassistantdialog.h>
int main(int argc, char **argv)
{
KCmdLineArgs::init( argc, argv, "test", 0, ki18n("Test"), "1.0",
ki18n("test app") );
KApplication a;
KAssistantDialog *dlg = new KAssistantDialog();
QObject::connect(dlg, SIGNAL(finished(int)), &a, SLOT(quit()));
for(int i = 1; i < 11; i++)
{
QWidget *p = new QWidget;
QString msg = QString("This is page %1 out of 10").arg(i);
QLabel *label = new QLabel(msg, p);
QHBoxLayout *layout = new QHBoxLayout(p);
label->setAlignment(Qt::AlignCenter);
label->setFixedSize(300, 200);
layout->addWidget(label);
QString title = QString("%1. page").arg(i);
dlg->addPage(p, title);
}
dlg->show();
return a.exec();
}

View file

@ -1,102 +0,0 @@
/**
* This file is part of the KDE project
* Copyright (C) 2007, 2009 Rafael Fernández López <ereslibre@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <QMainWindow>
#include <QStringListModel>
#include <kapplication.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kiconloader.h>
#include <kcategorizedview.h>
#include <kcategorydrawer.h>
#include <kcategorizedsortfilterproxymodel.h>
QStringList icons;
class MyModel
: public QStringListModel
{
public:
virtual QVariant data(const QModelIndex &index, int role) const
{
switch (role) {
case KCategorizedSortFilterProxyModel::CategoryDisplayRole: {
return QString::number(index.row() / 10);
}
case KCategorizedSortFilterProxyModel::CategorySortRole: {
return index.row() / 10;
}
case Qt::DecorationRole:
return DesktopIcon(icons[index.row() % 4], KIconLoader::Desktop);
default:
break;
}
return QStringListModel::data(index, role);
}
};
int main(int argc, char **argv)
{
icons << "konqueror";
icons << "okular";
icons << "plasma";
icons << "system-file-manager";
KAboutData aboutData("KCategorizedViewTest",
0,
ki18n("KCategorizedViewTest"),
"1.0",
ki18n("KCategorizedViewTest"),
KAboutData::License_LGPL_V3,
ki18n("(c) 2009 Rafael Fernández López"),
ki18n("KCategorizedViewTest"),
"http://www.kde.org");
KCmdLineArgs::init(argc, argv, &aboutData);
KApplication app;
QMainWindow *mainWindow = new QMainWindow();
mainWindow->setMinimumSize(640, 480);
KCategorizedView *listView = new KCategorizedView();
listView->setCategoryDrawer(new KCategoryDrawer(listView));
listView->setViewMode(QListView::IconMode);
MyModel *model = new MyModel();
model->insertRows(0, 100);
for (int i = 0; i < 100; ++i)
{
model->setData(model->index(i, 0), QString::number(i), Qt::DisplayRole);
}
KCategorizedSortFilterProxyModel *proxyModel = new KCategorizedSortFilterProxyModel();
proxyModel->setCategorizedModel(true);
proxyModel->setSourceModel(model);
listView->setModel(proxyModel);
mainWindow->setCentralWidget(listView);
mainWindow->show();
return app.exec();
}

View file

@ -1,78 +0,0 @@
#include <QtGui/QToolBar>
#include <QtGui/QMenuBar>
#include <QtCore/QTextCodec>
#include <kcmdlineargs.h>
#include <kapplication.h>
#include <kdebug.h>
#include "kcodecactiontest.h"
#include <kcodecaction.h>
#include <kactioncollection.h>
int main( int argc, char **argv )
{
KCmdLineArgs::init( argc, argv, "kcodecactiontest", 0, ki18n("KCodecActionTest"), "1.0", ki18n("kselectaction test app"));
KApplication app;
CodecActionTest* test = new CodecActionTest;
test->show();
return app.exec();
}
CodecActionTest::CodecActionTest(QWidget *parent)
: KXmlGuiWindow(parent)
, m_comboCodec(new KCodecAction("Combo Codec Action", this))
, m_buttonCodec(new KCodecAction("Button Codec Action", this))
{
actionCollection()->addAction("combo", m_comboCodec);
actionCollection()->addAction("button", m_buttonCodec);
m_comboCodec->setToolBarMode(KCodecAction::ComboBoxMode);
connect(m_comboCodec, SIGNAL(triggered(QAction*)), SLOT(triggered(QAction*)));
connect(m_comboCodec, SIGNAL(triggered(int)), SLOT(triggered(int)));
connect(m_comboCodec, SIGNAL(triggered(QString)), SLOT(triggered(QString)));
connect(m_comboCodec, SIGNAL(triggered(QTextCodec*)), SLOT(triggered(QTextCodec*)));
m_buttonCodec->setToolBarMode(KCodecAction::MenuMode);
connect(m_buttonCodec, SIGNAL(triggered(QAction*)), SLOT(triggered(QAction*)));
connect(m_buttonCodec, SIGNAL(triggered(int)), SLOT(triggered(int)));
connect(m_buttonCodec, SIGNAL(triggered(QString)), SLOT(triggered(QString)));
connect(m_buttonCodec, SIGNAL(triggered(QTextCodec*)), SLOT(triggered(QTextCodec*)));
menuBar()->addAction(m_comboCodec);
menuBar()->addAction(m_buttonCodec);
QToolBar* toolBar = addToolBar("Test");
toolBar->addAction(m_comboCodec);
toolBar->addAction(m_buttonCodec);
}
void CodecActionTest::triggered(QAction* action)
{
kDebug() << action;
}
void CodecActionTest::triggered(int index)
{
kDebug() << index;
}
void CodecActionTest::triggered(const QString& text)
{
kDebug() << '"' << text << '"';
}
void CodecActionTest::triggered(QTextCodec *codec)
{
kDebug() << codec->name() << ':' << codec->mibEnum();
}
void CodecActionTest::slotActionTriggered(bool state)
{
kDebug() << sender() << " state " << state;
}
#include "moc_kcodecactiontest.cpp"

View file

@ -1,28 +0,0 @@
#ifndef KSELECTACTION_TEST_H
#define KSELECTACTION_TEST_H
#include <kxmlguiwindow.h>
class KCodecAction;
class CodecActionTest : public KXmlGuiWindow
{
Q_OBJECT
public:
CodecActionTest(QWidget* parent = 0);
public Q_SLOTS:
void triggered(QAction* action);
void triggered(int index);
void triggered(const QString& text);
void triggered(QTextCodec *codec);
void slotActionTriggered(bool state);
private:
KCodecAction* m_comboCodec;
KCodecAction* m_buttonCodec;
};
#endif

View file

@ -1,42 +0,0 @@
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kapplication.h>
#include <QtGui/QWidget>
#include <QtCore/QTimer>
#include <stdlib.h>
#include "kcolorcollection.h"
#include "kledtest.h"
#include <stdio.h>
#include <QtCore/QStringList>
int main( int argc, char **argv )
{
KAboutData about("KColorCollectionTest", 0, ki18n("KColorCollectionTest"), "version");
KCmdLineArgs::init(argc, argv, &about);
KApplication a;
QStringList collections = KColorCollection::installedCollections();
for(QStringList::ConstIterator it = collections.constBegin();
it != collections.constEnd(); ++it)
{
printf("Palette = %s\n", (*it).toLatin1().constData());
KColorCollection myColorCollection = KColorCollection(*it);
printf("Palette Name = \"%s\"\n", myColorCollection.name().toLatin1().constData());
printf("Description:\n\"%s\"\n", myColorCollection.description().toLatin1().constData());
printf("Nr of Colors = %d\n", myColorCollection.count());
for(int i = 0; i < myColorCollection.count(); i++)
{
int r,g,b;
myColorCollection.color(i).getRgb(&r, &g, &b);
printf("#%d Name = \"%s\" #%02x%02x%02x\n",
i, myColorCollection.name(i).toLatin1().constData(), r,g,b);
}
}
}

View file

@ -1,147 +0,0 @@
/*
This file is part of the KDE Libraries
Copyright (c) 2007 David Jarvie <software@astrojar.org.uk>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "kcolorcombotest.h"
#include <assert.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kapplication.h>
#include <kdebug.h>
#include <kdialog.h>
#include <kconfig.h>
#include <QtGui/QPushButton>
#include <QtGui/QLayout>
#include <QtGui/QLabel>
#include <khbox.h>
#include <QtGui/QBoxLayout>
#include <kcolorcombo.h>
KColorComboTest::KColorComboTest(QWidget* widget)
: QWidget(widget)
{
QVBoxLayout *vbox = new QVBoxLayout(this);
// Standard color list
KHBox *hbox = new KHBox(this);
hbox->setSpacing(-1);
QLabel *lbl = new QLabel("&Standard colors:", hbox);
lbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
mStandard = new KColorCombo(hbox);
mStandard->setObjectName("StandardColors");
lbl->setBuddy(mStandard);
new QLabel("Preset to green (0,255,0)", hbox);
vbox->addWidget(hbox);
// Custom color list
hbox = new KHBox(this);
hbox->setSpacing(-1);
lbl = new QLabel("&Reds, greens, blues:", hbox);
lbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
mCustom = new KColorCombo(hbox);
mCustom->setObjectName("CustomColors");
lbl->setBuddy(mCustom);
new QLabel("Preset to green (0,192,0)", hbox);
vbox->addWidget(hbox);
// Create an exit button
hbox = new KHBox(this);
mExit = new QPushButton("E&xit", hbox);
QObject::connect(mExit, SIGNAL(clicked()), SLOT(quitApp()));
vbox->addWidget(hbox);
// Populate the custom list
QList<QColor> standardList;
standardList << Qt::red << Qt::green << Qt::blue << Qt::cyan << Qt::magenta << Qt::yellow << Qt::darkRed
<< Qt::darkGreen << Qt::darkBlue << Qt::darkCyan << Qt::darkMagenta << Qt::darkYellow
<< Qt::white << Qt::lightGray << Qt::gray << Qt::darkGray << Qt::black;
QList<QColor> list;
list << QColor(255,0,0) << QColor(192,0,0) << QColor(128,0,0) << QColor(64,0,0)
<< QColor(0,255,0) << QColor(0,192,0) << QColor(0,128,0) << QColor(0,64,0)
<< QColor(0,0,255) << QColor(0,0,192) << QColor(0,0,128) << QColor(0,0,64);
mCustom->setColors(list);
if (mCustom->colors() != list)
kError() << "Custom combo: setColors() != colors()";
mCustom->setColors(QList<QColor>());
if (mCustom->colors() != standardList)
kError() << "Custom combo: setColors(empty) != standard colors";
mCustom->setColors(list);
if (mCustom->colors() != list)
kError() << "Custom combo: setColors() != colors()";
if (mStandard->colors() != standardList)
kError() << "Standard combo: colors()";
QColor col = QColor(1,2,3);
mStandard->setColor(col);
if (mStandard->color() != col)
kError() << "Standard combo: set custom color -> " << mStandard->color().red() << "," << mStandard->color().green() << "," << mStandard->color().blue();
if (!mStandard->isCustomColor())
kError() << "Standard combo: custom color: isCustomColor() -> false";
mStandard->setColor(Qt::green);
if (mStandard->color() != Qt::green)
kError() << "Standard combo: color() -> " << mStandard->color().red() << "," << mStandard->color().green() << "," << mStandard->color().blue();
if (mStandard->isCustomColor())
kError() << "Standard combo: standard color: isCustomColor() -> true";
col = QColor(1,2,3);
mCustom->setColor(col);
if (mCustom->color() != col)
kError() << "Custom combo: set custom color -> " << mCustom->color().red() << "," << mCustom->color().green() << "," << mCustom->color().blue();
if (!mCustom->isCustomColor())
kError() << "Custom combo: custom color: isCustomColor() -> false";
col = QColor(0,192,0);
mCustom->setColor(col);
if (mCustom->color() != col)
kError() << "Custom combo: color() -> " << mCustom->color().red() << "," << mCustom->color().green() << "," << mCustom->color().blue();
if (mCustom->isCustomColor())
kError() << "Custom combo: standard color: isCustomColor() -> true";
}
KColorComboTest::~KColorComboTest()
{
}
void KColorComboTest::quitApp()
{
kapp->closeAllWindows();
}
int main(int argc, char **argv)
{
KAboutData about("kcolorcombotest", 0, ki18n("kcolorcombotest"), "version");
KCmdLineArgs::init(argc, argv, &about);
KApplication a;
KColorComboTest* t= new KColorComboTest;
t->show();
return a.exec();
}
#include "moc_kcolorcombotest.cpp"

View file

@ -1,26 +0,0 @@
#ifndef KCOLORCOMBOTEST_H
#define KCOLORCOMBOTEST_H
#include <QtGui/QWidget>
#include <QPushButton>
class KColorCombo;
class KColorComboTest : public QWidget
{
Q_OBJECT
public:
KColorComboTest(QWidget *parent = 0);
~KColorComboTest();
private Q_SLOTS:
void quitApp();
protected:
KColorCombo* mStandard;
KColorCombo* mCustom;
QPushButton* mExit;
};
#endif

View file

@ -1,40 +0,0 @@
/* This file is part of the KDE libraries
Copyright (C) 1997 Martin Jones (mjones@kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kapplication.h>
#include "kcolordialog.h"
#include <kconfig.h>
#include <klocale.h>
int main( int argc, char *argv[] )
{
KAboutData about("KColorDialogTest", "kdelibs4", ki18n("KColorDialogTest"), "version");
KCmdLineArgs::init(argc, argv, &about);
//KApplication::disableAutoDcopRegistration();
KApplication a;
QColor color;
int nRet = KColorDialog::getColor( color, Qt::red /*testing default color*/ );
return nRet;
}

View file

@ -1,220 +0,0 @@
/*
* Copyright 2009 Matthew Woehlke <mw_triad@users.sourceforge.net>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "kcolorutilsdemo.h"
#include "../colors/kcolorspaces.h"
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kapplication.h>
#include <kcolorutils.h>
#include <kcolorscheme.h>
KColorUtilsDemo::KColorUtilsDemo(QWidget *parent) : QWidget(parent),
_leOutImg(128, 128, QImage::Format_RGB32),
_mtMixOutImg(128, 16, QImage::Format_RGB32),
_mtTintOutImg(128, 16, QImage::Format_RGB32)
{
_noUpdate = true;
setupUi(this);
_noUpdate = false;
inputSpinChanged();
targetSpinChanged();
}
void KColorUtilsDemo::inputChanged()
{
KColorSpaces::KHCY c(inColor->color());
ifHue->setValue(c.h);
ifChroma->setValue(c.c);
ifLuma->setValue(c.y);
ifGray->setValue(qGray(inColor->color().rgb()));
lumaChanged();
mixChanged();
shadeChanged();
}
void KColorUtilsDemo::lumaChanged()
{
QColor base = inColor->color();
for (int y = 0; y < 128; ++y)
{
qreal k = qreal(y - 64) / 64.0;
for (int x = 0; x < 128; ++x)
{
qreal c;
QColor r;
if (leOpLighten->isChecked())
{
c = qreal(128 - x) / 64.0;
r = KColorUtils::lighten(base, k, c);
}
else if (leOpDarken->isChecked())
{
c = qreal(x) / 64.0;
r = KColorUtils::darken(base, -k, c);
}
else
{
c = qreal(x - 64) / 64.0;
r = KColorUtils::shade(base, k, c);
}
_leOutImg.setPixel(x, y, r.rgb());
}
}
leOut->setImage(_leOutImg);
}
void KColorUtilsDemo::mixChanged()
{
QColor base = inColor->color();
QColor target = mtTarget->color();
for (int x = 0; x < 128; ++x)
{
qreal k = qreal(x) / 128.0;
QRgb m = KColorUtils::mix(base, target, k).rgb();
QRgb t = KColorUtils::tint(base, target, k).rgb();
for (int y = 0; y < 16; ++y)
{
_mtMixOutImg.setPixel(x, y, m);
_mtTintOutImg.setPixel(x, y, t);
}
}
mtMixOut->setImage(_mtMixOutImg);
mtTintOut->setImage(_mtTintOutImg);
}
void setBackground(QWidget *widget, const QColor &color)
{
QPalette palette = widget->palette();
palette.setColor(widget->backgroundRole(), color);
widget->setPalette(palette);
QString name = color.name();
name += " (" + QString::number(color.red()) + ", "
+ QString::number(color.green()) + ", "
+ QString::number(color.blue()) + ")";
widget->setToolTip(name);
}
#define SET_SHADE(_n, _c, _cn, _ch) \
setBackground(ss##_n, KColorScheme::shade(_c, KColorScheme::_n##Shade, _cn, _ch));
void KColorUtilsDemo::shadeChanged()
{
qreal cn = ssContrast->value();
qreal ch = ssChroma->value();
QColor base = inColor->color();
setBackground(ssOut, base);
setBackground(ssBase, base);
SET_SHADE(Light, base, cn, ch);
SET_SHADE(Midlight, base, cn, ch);
SET_SHADE(Mid, base, cn, ch);
SET_SHADE(Dark, base, cn, ch);
SET_SHADE(Shadow, base, cn, ch);
}
void updateSwatch(KColorButton *s, const QSpinBox *r, const QSpinBox *g, const QSpinBox *b)
{
s->setColor(QColor(r->value(), g->value(), b->value()));
}
void updateSpins(const QColor &c, QSpinBox *r, QSpinBox *g, QSpinBox *b)
{
r->setValue(c.red());
g->setValue(c.green());
b->setValue(c.blue());
}
void KColorUtilsDemo::inputSpinChanged()
{
if (_noUpdate)
return;
_noUpdate = true;
updateSwatch(inColor, inRed, inGreen, inBlue);
inputChanged();
_noUpdate = false;
}
void KColorUtilsDemo::targetSpinChanged()
{
if (_noUpdate)
return;
_noUpdate = true;
updateSwatch(mtTarget, mtRed, mtGreen, mtBlue);
mixChanged();
_noUpdate = false;
}
void KColorUtilsDemo::inputSwatchChanged(const QColor &color)
{
if (_noUpdate)
return;
_noUpdate = true;
updateSpins(color, inRed, inGreen, inBlue);
inputChanged();
_noUpdate = false;
}
void KColorUtilsDemo::targetSwatchChanged(const QColor &color)
{
if (_noUpdate)
return;
_noUpdate = true;
updateSpins(color, mtRed, mtGreen, mtBlue);
mixChanged();
_noUpdate = false;
}
int main(int argc, char* argv[]) {
KAboutData about("kcolorutilsdemo", 0, ki18n("kcolorutilsdemo"), "0.1",
ki18n("KColorUtils demo/test application"),
KAboutData::License_GPL, ki18n("Copyright 2009 Matthew Woehlke"),
KLocalizedString(), 0, "mw_triad@users.sourceforge.net");
about.addAuthor(ki18n("Matthew Woehlke"), KLocalizedString(),
"mw_triad@users.sourceforge.net");
KCmdLineArgs::init(argc, argv, &about);
KApplication app;
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
Q_UNUSED(args);
KColorUtilsDemo *d = new KColorUtilsDemo;
d->show();
return app.exec();
}
#include "moc_kcolorutilsdemo.cpp"
// kate: hl C++; indent-width 4; replace-tabs on;

View file

@ -1,48 +0,0 @@
/*
* Copyright 2009 Matthew Woehlke <mw_triad@users.sourceforge.net>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KCOLORUTILSDEMO_H
#define KCOLORUTILSDEMO_H
#include "ui_kcolorutilsdemo.h"
class KColorUtilsDemo: public QWidget, Ui::form
{
Q_OBJECT
public:
KColorUtilsDemo(QWidget* parent = 0);
virtual ~KColorUtilsDemo() {}
public Q_SLOTS:
void inputChanged();
void lumaChanged();
void mixChanged();
void shadeChanged();
void inputSpinChanged();
void inputSwatchChanged(const QColor&);
void targetSpinChanged();
void targetSwatchChanged(const QColor&);
protected:
QImage _leOutImg, _mtMixOutImg, _mtTintOutImg;
bool _noUpdate;
};
#endif
// kate: hl C++; indent-width 4; replace-tabs on;

View file

@ -1,966 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>form</class>
<widget class="QWidget" name="form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>428</width>
<height>344</height>
</rect>
</property>
<property name="windowTitle">
<string>KColorUtils Demo</string>
</property>
<layout class="QGridLayout" name="gridLayout_9">
<item row="0" column="0">
<widget class="QGroupBox" name="gInput">
<property name="title">
<string>Input</string>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Red</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="inRed">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="maximum">
<number>255</number>
</property>
<property name="value">
<number>128</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Green</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="inGreen">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="maximum">
<number>255</number>
</property>
<property name="value">
<number>128</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Blue</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="inBlue">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="maximum">
<number>255</number>
</property>
<property name="value">
<number>128</number>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="KColorButton" name="inColor">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1" rowspan="2">
<widget class="QTabWidget" name="tabs">
<property name="tabPosition">
<enum>QTabWidget::West</enum>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tabLuma">
<attribute name="title">
<string>&amp;Luma Effects</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0">
<widget class="QGroupBox" name="gleOp">
<property name="title">
<string>Operation</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="leOpDarken">
<property name="text">
<string>Darken</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="leOpLighten">
<property name="text">
<string>Lighten</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="leOpShade">
<property name="text">
<string>Shade</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="gleOut">
<property name="title">
<string>Output</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="KImageFrame" name="leOut">
<property name="minimumSize">
<size>
<width>144</width>
<height>144</height>
</size>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>&amp;Mix/Tint</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_11">
<item row="0" column="0">
<widget class="QGroupBox" name="gmtTarget">
<property name="title">
<string>Target</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Red</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="mtRed">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="maximum">
<number>255</number>
</property>
<property name="value">
<number>128</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Green</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="mtGreen">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="maximum">
<number>255</number>
</property>
<property name="value">
<number>128</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Blue</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="mtBlue">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="maximum">
<number>255</number>
</property>
<property name="value">
<number>128</number>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="KColorButton" name="mtTarget"/>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="gmtMixOut">
<property name="title">
<string>Mix Output</string>
</property>
<layout class="QGridLayout" name="gridLayout_10">
<item row="0" column="0">
<widget class="KImageFrame" name="mtMixOut">
<property name="minimumSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="gmtTintOut">
<property name="title">
<string>Tint Output</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="KImageFrame" name="mtTintOut">
<property name="minimumSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>&amp;Scheme Shade</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QGroupBox" name="gssParam">
<property name="title">
<string>Parameters</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Contrast</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="ssContrast">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
<property name="value">
<double>0.700000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Chroma Adjust</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="ssChroma">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gssOut">
<property name="title">
<string>Output</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="rightMargin">
<number>8</number>
</property>
<property name="horizontalSpacing">
<number>8</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Light</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Midlight</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Base</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Mid</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Dark</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Shadow</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="1" rowspan="8">
<widget class="QFrame" name="ssOut">
<property name="minimumSize">
<size>
<width>40</width>
<height>120</height>
</size>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>12</number>
</property>
<item>
<widget class="QWidget" name="ssLight" native="true">
<property name="minimumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="ssMidlight" native="true">
<property name="minimumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="ssBase" native="true">
<property name="minimumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="ssMid" native="true">
<property name="minimumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="ssDark" native="true">
<property name="minimumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="ssShadow" native="true">
<property name="minimumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
<zorder>label_8</zorder>
<zorder>label_3</zorder>
<zorder>label_4</zorder>
<zorder>label_10</zorder>
<zorder>label_5</zorder>
<zorder>label_6</zorder>
<zorder>label_7</zorder>
<zorder>label_9</zorder>
<zorder>ssOut</zorder>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="gInfo">
<property name="title">
<string>Information</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Hue</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="ifHue">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="decimals">
<number>3</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Chroma</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="ifChroma">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="decimals">
<number>3</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_18">
<property name="text">
<string>Luma</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="ifLuma">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="decimals">
<number>3</number>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Gray Value</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="ifGray">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
<zorder>label_17</zorder>
<zorder>ifHue</zorder>
<zorder>label_19</zorder>
<zorder>ifChroma</zorder>
<zorder>label_18</zorder>
<zorder>ifLuma</zorder>
<zorder>label_20</zorder>
<zorder>ifGray</zorder>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KColorButton</class>
<extends>QPushButton</extends>
<header>kcolorbutton.h</header>
</customwidget>
<customwidget>
<class>KImageFrame</class>
<extends>QFrame</extends>
<header>kimageframe.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<connections>
<connection>
<sender>inRed</sender>
<signal>valueChanged(int)</signal>
<receiver>form</receiver>
<slot>inputSpinChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>126</x>
<y>52</y>
</hint>
<hint type="destinationlabel">
<x>209</x>
<y>171</y>
</hint>
</hints>
</connection>
<connection>
<sender>inGreen</sender>
<signal>valueChanged(int)</signal>
<receiver>form</receiver>
<slot>inputSpinChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>126</x>
<y>84</y>
</hint>
<hint type="destinationlabel">
<x>209</x>
<y>171</y>
</hint>
</hints>
</connection>
<connection>
<sender>inBlue</sender>
<signal>valueChanged(int)</signal>
<receiver>form</receiver>
<slot>inputSpinChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>126</x>
<y>116</y>
</hint>
<hint type="destinationlabel">
<x>209</x>
<y>171</y>
</hint>
</hints>
</connection>
<connection>
<sender>inColor</sender>
<signal>changed(QColor)</signal>
<receiver>form</receiver>
<slot>inputSwatchChanged(QColor)</slot>
<hints>
<hint type="sourcelabel">
<x>126</x>
<y>146</y>
</hint>
<hint type="destinationlabel">
<x>209</x>
<y>171</y>
</hint>
</hints>
</connection>
<connection>
<sender>leOpDarken</sender>
<signal>clicked()</signal>
<receiver>form</receiver>
<slot>lumaChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>307</x>
<y>60</y>
</hint>
<hint type="destinationlabel">
<x>209</x>
<y>171</y>
</hint>
</hints>
</connection>
<connection>
<sender>leOpLighten</sender>
<signal>clicked()</signal>
<receiver>form</receiver>
<slot>lumaChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>307</x>
<y>88</y>
</hint>
<hint type="destinationlabel">
<x>209</x>
<y>171</y>
</hint>
</hints>
</connection>
<connection>
<sender>leOpShade</sender>
<signal>clicked()</signal>
<receiver>form</receiver>
<slot>lumaChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>307</x>
<y>116</y>
</hint>
<hint type="destinationlabel">
<x>209</x>
<y>171</y>
</hint>
</hints>
</connection>
<connection>
<sender>mtRed</sender>
<signal>valueChanged(int)</signal>
<receiver>form</receiver>
<slot>targetSpinChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>353</x>
<y>129</y>
</hint>
<hint type="destinationlabel">
<x>209</x>
<y>171</y>
</hint>
</hints>
</connection>
<connection>
<sender>mtGreen</sender>
<signal>valueChanged(int)</signal>
<receiver>form</receiver>
<slot>targetSpinChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>353</x>
<y>161</y>
</hint>
<hint type="destinationlabel">
<x>209</x>
<y>171</y>
</hint>
</hints>
</connection>
<connection>
<sender>mtBlue</sender>
<signal>valueChanged(int)</signal>
<receiver>form</receiver>
<slot>targetSpinChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>353</x>
<y>193</y>
</hint>
<hint type="destinationlabel">
<x>209</x>
<y>171</y>
</hint>
</hints>
</connection>
<connection>
<sender>mtTarget</sender>
<signal>changed(QColor)</signal>
<receiver>form</receiver>
<slot>targetSwatchChanged(QColor)</slot>
<hints>
<hint type="sourcelabel">
<x>353</x>
<y>222</y>
</hint>
<hint type="destinationlabel">
<x>209</x>
<y>171</y>
</hint>
</hints>
</connection>
<connection>
<sender>ssContrast</sender>
<signal>valueChanged(double)</signal>
<receiver>form</receiver>
<slot>shadeChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>362</x>
<y>60</y>
</hint>
<hint type="destinationlabel">
<x>209</x>
<y>171</y>
</hint>
</hints>
</connection>
<connection>
<sender>ssChroma</sender>
<signal>valueChanged(double)</signal>
<receiver>form</receiver>
<slot>shadeChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>362</x>
<y>92</y>
</hint>
<hint type="destinationlabel">
<x>209</x>
<y>171</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>inputChanged()</slot>
<slot>inputSpinChanged()</slot>
<slot>inputSwatchChanged(QColor)</slot>
<slot>targetSpinChanged()</slot>
<slot>targetSwatchChanged(QColor)</slot>
<slot>lumaChanged()</slot>
<slot>mixChanged()</slot>
<slot>shadeChanged()</slot>
</slots>
</ui>

View file

@ -1,240 +0,0 @@
#include "kcomboboxtest.h"
#include <assert.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kapplication.h>
#include <kdebug.h>
#include <kconfiggroup.h>
#include <kdialog.h>
#include <klocale.h>
#include <kiconloader.h>
#include <kconfig.h>
#include <QtGui/QPushButton>
#include <QtGui/QLayout>
#include <QtGui/QPixmap>
#include <QtGui/QLabel>
#include <khbox.h>
#include <QtCore/QTimer>
#include <QtGui/QBoxLayout>
#include <kcombobox.h>
#include <khistorycombobox.h>
KComboBoxTest::KComboBoxTest(QWidget* widget)
:QWidget(widget)
{
QVBoxLayout *vbox = new QVBoxLayout (this);
// Qt combobox
KHBox* hbox = new KHBox(this);
hbox->setSpacing (-1);
QLabel* lbl = new QLabel("&QCombobox:", hbox);
lbl->setSizePolicy (QSizePolicy::Maximum, QSizePolicy::Preferred);
m_qc = new QComboBox(hbox);
m_qc->setObjectName( QLatin1String( "QtReadOnlyCombo" ) );
lbl->setBuddy (m_qc);
connectComboSignals(m_qc);
vbox->addWidget (hbox);
// Read-only combobox
hbox = new KHBox(this);
hbox->setSpacing (-1);
lbl = new QLabel("&Read-Only Combo:", hbox);
lbl->setSizePolicy (QSizePolicy::Maximum, QSizePolicy::Preferred);
m_ro = new KComboBox(hbox );
m_ro->setObjectName( "ReadOnlyCombo" );
lbl->setBuddy (m_ro);
m_ro->setCompletionMode( KGlobalSettings::CompletionAuto );
connectComboSignals(m_ro);
vbox->addWidget (hbox);
// Read-write combobox
hbox = new KHBox(this);
hbox->setSpacing (-1);
lbl = new QLabel("&Editable Combo:", hbox);
lbl->setSizePolicy (QSizePolicy::Maximum, QSizePolicy::Preferred);
m_rw = new KComboBox( true, hbox );
m_rw->setObjectName( "ReadWriteCombo" );
lbl->setBuddy (m_rw);
m_rw->setDuplicatesEnabled( true );
m_rw->setInsertPolicy( QComboBox::NoInsert );
m_rw->setTrapReturnKey( true );
connectComboSignals(m_rw);
vbox->addWidget (hbox);
// History combobox...
hbox = new KHBox(this);
hbox->setSpacing (-1);
lbl = new QLabel("&History Combo:", hbox);
lbl->setSizePolicy (QSizePolicy::Maximum, QSizePolicy::Preferred);
m_hc = new KHistoryComboBox( hbox );
m_hc->setObjectName( "HistoryCombo" );
lbl->setBuddy (m_hc);
m_hc->setDuplicatesEnabled( true );
m_hc->setInsertPolicy( QComboBox::NoInsert );
connectComboSignals(m_hc);
vbox->addWidget (hbox);
m_hc->setTrapReturnKey(true);
// Read-write combobox that is a replica of code in konqueror...
hbox = new KHBox(this);
hbox->setSpacing (-1);
lbl = new QLabel( "&Completion Combo:", hbox);
lbl->setSizePolicy (QSizePolicy::Maximum, QSizePolicy::Preferred);
m_comp = new KComboBox( true, hbox );
m_comp->setObjectName( "CompletionCombo" );
lbl->setBuddy (m_comp);
m_comp->setMaxCount( 10 );
connectComboSignals(m_comp);
vbox->addWidget (hbox);
// Create an exit button
hbox = new KHBox (this);
m_btnExit = new QPushButton( "E&xit", hbox );
QObject::connect( m_btnExit, SIGNAL(clicked()), SLOT(quitApp()) );
// Create a disable button...
m_btnEnable = new QPushButton( "Disa&ble", hbox );
QObject::connect (m_btnEnable, SIGNAL(clicked()), SLOT(slotDisable()));
vbox->addWidget (hbox);
// Popuplate the select-only list box
QStringList list;
list << "Stone" << "Tree" << "Peables" << "Ocean" << "Sand" << "Chips"
<< "Computer" << "Mankind";
list.sort();
// Setup the qcombobox
m_qc->addItems(list );
// Setup read-only combo
m_ro->addItems( list );
m_ro->completionObject()->setItems( list );
// Setup read-write combo
m_rw->addItems( list );
m_rw->completionObject()->setItems( list );
// Setup history combo
m_hc->addItems( list );
m_hc->completionObject()->setItems( list + QStringList() << "One" << "Two" << "Three" );
// Setup completion combobox
QStringList urls;
urls << "https://www.google.com/" << "https://github.com/" << "https://www.youtube.com/";
KCompletion * s_pCompletion = new KCompletion;
s_pCompletion->setOrder( KCompletion::Weighted );
s_pCompletion->setItems( urls );
s_pCompletion->setCompletionMode( KGlobalSettings::completionMode() );
m_comp->setCompletionObject( s_pCompletion );
QPixmap pix = SmallIcon("www");
m_comp->addItem( pix, "http://www.kde.org" );
m_comp->setCurrentIndex( m_comp->count()-1 );
m_timer = new QTimer (this);
connect (m_timer, SIGNAL (timeout()), SLOT (slotTimeout()));
}
KComboBoxTest::~KComboBoxTest()
{
delete m_timer;
m_timer = 0;
}
void KComboBoxTest::connectComboSignals(QComboBox* combo)
{
QObject::connect(combo, SIGNAL(activated(int)), SLOT(slotActivated(int)));
QObject::connect(combo, SIGNAL(activated(QString)), SLOT(slotActivated(QString)));
QObject::connect(combo, SIGNAL(currentIndexChanged(int)), SLOT(slotCurrentIndexChanged(int)));
QObject::connect(combo, SIGNAL(currentIndexChanged(QString)), SLOT(slotCurrentIndexChanged(QString)));
QObject::connect(combo, SIGNAL(returnPressed()), SLOT(slotReturnPressed()));
QObject::connect(combo, SIGNAL(returnPressed(QString)), SLOT(slotReturnPressed(QString)));
}
void KComboBoxTest::slotDisable ()
{
if (m_timer->isActive())
return;
m_btnEnable->setEnabled (!m_btnEnable->isEnabled());
m_timer->setSingleShot(true);
m_timer->start (5000);
}
void KComboBoxTest::slotTimeout ()
{
bool enabled = m_ro->isEnabled();
if (enabled)
m_btnEnable->setText ("Ena&ble");
else
m_btnEnable->setText ("Disa&ble");
m_qc->setEnabled (!enabled);
m_ro->setEnabled (!enabled);
m_rw->setEnabled (!enabled);
m_hc->setEnabled (!enabled);
m_comp->setEnabled (!enabled);
m_btnEnable->setEnabled (!m_btnEnable->isEnabled());
}
void KComboBoxTest::slotCurrentIndexChanged(int index)
{
kDebug() << qPrintable(sender()->objectName()) << ", index:" << index;
}
void KComboBoxTest::slotCurrentIndexChanged(const QString& item)
{
kDebug() << qPrintable(sender()->objectName()) << ", item:" << item;
}
void KComboBoxTest::slotActivated( int index )
{
kDebug() << "Activated Combo:" << qPrintable(sender()->objectName()) << ", index:" << index;
}
void KComboBoxTest::slotActivated (const QString& item)
{
kDebug() << "Activated Combo:" << qPrintable(sender()->objectName()) << ", item:" << item;
}
void KComboBoxTest::slotReturnPressed ()
{
kDebug() << "Return Pressed:" << qPrintable(sender()->objectName());
}
void KComboBoxTest::slotReturnPressed(const QString& item)
{
kDebug() << "Return Pressed:" << qPrintable(sender()->objectName()) << ", value =" << item;
}
void KComboBoxTest::quitApp()
{
kapp->closeAllWindows();
}
int main ( int argc, char **argv)
{
KAboutData about("kcomboboxtest", 0, ki18n("kcomboboxtest"), "version");
KCmdLineArgs::init(argc, argv, &about);
KApplication a;
KComboBoxTest* t= new KComboBoxTest;
t->show ();
return a.exec();
}
#include "moc_kcomboboxtest.cpp"

View file

@ -1,49 +0,0 @@
#ifndef KCOMBOBOXTEST_H
#define KCOMBOBOXTEST_H
#include <QtGui/QWidget>
#include <QTimer>
#include <QComboBox>
#include <QPushButton>
class KComboBox;
class KComboBoxTest : public QWidget
{
Q_OBJECT
public:
KComboBoxTest ( QWidget *parent=0);
~KComboBoxTest();
private Q_SLOTS:
void quitApp();
void slotTimeout();
void slotDisable();
void slotReturnPressed();
void slotReturnPressed(const QString&);
void slotActivated( int );
void slotActivated( const QString& );
void slotCurrentIndexChanged(int);
void slotCurrentIndexChanged(const QString&);
private:
void connectComboSignals(QComboBox* combo);
QComboBox* m_qc;
KComboBox* m_ro;
KComboBox* m_rw;
KComboBox* m_hc;
KComboBox* m_comp;
QPushButton* m_btnExit;
QPushButton* m_btnEnable;
QTimer* m_timer;
};
#endif

View file

@ -1,208 +0,0 @@
#include <QtGui/QLabel>
#include <QtGui/QListWidget>
#include <QtGui/QPushButton>
#include <QtGui/QLayout>
#include <QtGui/QGroupBox>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kapplication.h>
#include <klineedit.h>
#include <khistorycombobox.h>
#include <klocale.h>
#include "kcompletionuitest.h"
/*
* Constructs a Form1 which is a child of 'parent', with the
* widget flags set to 'f'
*/
Form1::Form1( QWidget* parent )
: QWidget( parent )
{
setAttribute( Qt::WA_DeleteOnClose );
setObjectName( "Form1" );
resize( 559, 465 );
setWindowTitle( "Form1" );
Form1Layout = new QVBoxLayout( this );
GroupBox1 = new QGroupBox( this );
GroupBox1->setLayout( new QVBoxLayout() );
GroupBox1->setTitle( "Completion Test" );
GroupBox1->layout()->setSpacing( 0 );
GroupBox1->layout()->setMargin( 0 );
GroupBox1Layout = new QVBoxLayout;
GroupBox1Layout->setAlignment( Qt::AlignTop );
GroupBox1Layout->setSpacing( 6 );
GroupBox1Layout->setMargin( 11 );
GroupBox1->layout()->addItem( GroupBox1Layout );
GroupBox1Layout->setParent(GroupBox1->layout());
Layout9 = new QVBoxLayout;
Layout9->setSpacing( 6 );
Layout9->setMargin( 0 );
Layout1 = new QHBoxLayout;
Layout1->setSpacing( 6 );
Layout1->setMargin( 0 );
TextLabel1 = new QLabel( GroupBox1 );
TextLabel1->setObjectName( "TextLabel1" );
TextLabel1->setText( "Completion" );
Layout1->addWidget( TextLabel1 );
edit = new KLineEdit( GroupBox1 );
edit->setObjectName( "edit" );
Layout1->addWidget( edit );
Layout9->addLayout( Layout1 );
edit->completionObject()->setItems( defaultItems() );
edit->completionObject()->setIgnoreCase( true );
edit->setFocus();
edit->setToolTip( "right-click to change completion mode" );
Layout2 = new QHBoxLayout;
Layout2->setSpacing( 6 );
Layout2->setMargin( 0 );
combo = new KHistoryComboBox( GroupBox1 );
combo->setObjectName( "history combo" );
combo->setCompletionObject( edit->completionObject() );
// combo->setMaxCount( 5 );
combo->setHistoryItems( defaultItems(), true );
connect( combo, SIGNAL(activated(QString)),
combo, SLOT(addToHistory(QString)));
combo->setToolTip( "KHistoryComboBox" );
Layout2->addWidget( combo );
LineEdit1 = new KLineEdit( GroupBox1 );
LineEdit1->setObjectName( "LineEdit1" );
Layout2->addWidget( LineEdit1 );
PushButton1 = new QPushButton( GroupBox1 );
PushButton1->setObjectName( "PushButton1" );
PushButton1->setText( "Add" );
connect( PushButton1, SIGNAL(clicked()), SLOT(slotAdd()));
Layout2->addWidget( PushButton1 );
Layout9->addLayout( Layout2 );
Layout3 = new QHBoxLayout;
Layout3->setSpacing( 6 );
Layout3->setMargin( 0 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
Layout3->addItem( spacer );
PushButton1_4 = new QPushButton( GroupBox1 );
PushButton1_4->setObjectName( "PushButton1_4" );
PushButton1_4->setText( "Remove" );
connect( PushButton1_4, SIGNAL(clicked()), SLOT(slotRemove()));
Layout3->addWidget( PushButton1_4 );
Layout9->addLayout( Layout3 );
Layout8 = new QHBoxLayout;
Layout8->setSpacing( 6 );
Layout8->setMargin( 0 );
ListBox1 = new QListWidget( GroupBox1 );
Layout8->addWidget( ListBox1 );
connect( ListBox1, SIGNAL(currentRowChanged(int)),
SLOT(slotHighlighted(int)));
ListBox1->setToolTip("Contains the contents of the completion object.\n:x is the weighting, i.e. how often an item has been inserted");
Layout7 = new QVBoxLayout;
Layout7->setSpacing( 6 );
Layout7->setMargin( 0 );
PushButton1_3 = new QPushButton( GroupBox1 );
PushButton1_3->setObjectName( "PushButton1_3" );
PushButton1_3->setText( "Completion items" );
connect( PushButton1_3, SIGNAL(clicked()), SLOT(slotList()));
Layout7->addWidget( PushButton1_3 );
PushButton1_2 = new QPushButton( GroupBox1 );
PushButton1_2->setObjectName( "PushButton1_2" );
PushButton1_2->setText( "Clear" );
connect( PushButton1_2, SIGNAL(clicked()),
edit->completionObject(), SLOT(clear()));
Layout7->addWidget( PushButton1_2 );
Layout8->addLayout( Layout7 );
Layout9->addLayout( Layout8 );
GroupBox1Layout->addLayout( Layout9 );
Form1Layout->addWidget( GroupBox1 );
slotList();
}
/*
* Destroys the object and frees any allocated resources
*/
Form1::~Form1()
{
// no need to delete child widgets, Qt does it all for us
}
void Form1::slotAdd()
{
qDebug("** adding: %s", LineEdit1->text().toLatin1().constData() );
edit->completionObject()->addItem( LineEdit1->text() );
QStringList matches = edit->completionObject()->allMatches("S");
QStringList::ConstIterator it = matches.constBegin();
for ( ; it != matches.constEnd(); ++it )
qDebug("-- %s", (*it).toLatin1().constData());
}
void Form1::slotRemove()
{
edit->completionObject()->removeItem( LineEdit1->text() );
}
void Form1::slotList()
{
ListBox1->clear();
QStringList items = edit->completionObject()->items();
ListBox1->addItems( items );
}
void Form1::slotHighlighted( int row )
{
if (row == -1)
return;
QListWidgetItem *i = ListBox1->item( row );
Q_ASSERT(i != 0);
QString text = i->text();
// remove any "weighting"
int index = text.lastIndexOf( ':' );
if ( index > 0 )
LineEdit1->setText( text.left( index ) );
else
LineEdit1->setText( text );
}
QStringList Form1::defaultItems() const
{
QStringList items;
items << "Super" << "Sushi" << "Samson" << "Sucks" << "Sumo" << "Schumi";
items << "Slashdot" << "sUpEr" << "SUshi" << "sUshi" << "sUShi";
items << "sushI" << "SushI";
return items;
}
int main(int argc, char **argv )
{
KAboutData about("kcompletiontest", 0, ki18n("kcompletiontest"), "version");
KCmdLineArgs::init(argc, argv, &about);
KApplication app;
Form1 *form = new Form1();
form->show();
return app.exec();
}
#include "moc_kcompletionuitest.cpp"

View file

@ -1,57 +0,0 @@
#ifndef FORM1_H
#define FORM1_H
#include <QtCore/QStringList>
#include <QtCore/QVariant>
#include <QtGui/QWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGroupBox>
#include <QLabel>
#include <QListWidget>
#include <QPushButton>
class KHistoryComboBox;
class KLineEdit;
class Form1 : public QWidget
{
Q_OBJECT
public:
Form1( QWidget* parent = 0 );
~Form1();
QGroupBox* GroupBox1;
QLabel* TextLabel1;
KLineEdit* LineEdit1;
QPushButton* PushButton1;
QPushButton* PushButton1_4;
QListWidget* ListBox1;
QPushButton* PushButton1_3;
QPushButton* PushButton1_2;
KLineEdit* edit;
KHistoryComboBox *combo;
protected Q_SLOTS:
void slotList();
void slotAdd();
void slotRemove();
void slotHighlighted( int );
protected:
QStringList defaultItems() const;
QVBoxLayout* Form1Layout;
QVBoxLayout* GroupBox1Layout;
QVBoxLayout* Layout9;
QHBoxLayout* Layout1;
QHBoxLayout* Layout2;
QHBoxLayout* Layout3;
QHBoxLayout* Layout8;
QVBoxLayout* Layout7;
};
#endif // FORM1_H

View file

@ -1,20 +0,0 @@
#include "kdatepicker.h"
#include <QtGui/QLineEdit>
#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include <kapplication.h>
#include <klocale.h>
int main(int argc, char** argv)
{
KAboutData about("KDatePickertest", "kdelibs4", ki18n("KDatePickertest"), "version");
KCmdLineArgs::init(argc, argv, &about);
KApplication app;
KDatePicker picker;
picker.show();
// picker.setEnabled(false);
return app.exec();
}

View file

@ -1,17 +0,0 @@
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <klocale.h>
#include "kdatetable.h"
int main( int argc, char** argv )
{
KCmdLineArgs::init( argc, argv, "test", "kdelibs4", ki18n("Test"), "1.0", ki18n("test app"));
KApplication app;
KDateTable widget;
widget.setCustomDatePainting( QDate::currentDate().addDays(-3), QColor("green"), KDateTable::CircleMode, QColor("yellow") );
widget.show();
return app.exec();
}

View file

@ -1,14 +0,0 @@
#include "kdatetimewidget.h"
#include <kapplication.h>
#include <klocale.h>
#include <kcmdlineargs.h>
int main(int argc, char** argv)
{
KCmdLineArgs::init(argc, argv, "test", "kdelibs4", ki18n("Test"), "1.0", ki18n("test app"));
KApplication app;
KDateTimeWidget dateTimeWidget;
dateTimeWidget.show();
// dateTimeWidget.setEnabled(false);
return app.exec();
}

View file

@ -1,20 +0,0 @@
#include "kdatewidget.h"
#include <QtGui/QLineEdit>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kapplication.h>
#include <klocale.h>
int main(int argc, char** argv)
{
KAboutData about("KDateWidgettest", "kdelibs4", ki18n("KDateWidgettest"), "version");
KCmdLineArgs::init(argc, argv, &about);
KApplication app;
KDateWidget dateWidget;
dateWidget.show();
// dateWidget.setEnabled(false);
return app.exec();
}

View file

@ -1,26 +0,0 @@
#include "kdebug.h"
#include <QtGui/QWidget>
#include <QtGui/QApplication>
#include <QtCore/QVariant>
#include <QtGui/QPen>
int main(int argc, char** argv)
{
QApplication app(argc, argv);
QWidget widget(0);
widget.setGeometry(45, 54, 120, 80);
widget.show();
kDebug() << &widget;
QRect r(9,12,58,234);
QRegion reg(r);
reg += QRect(1,60,200,59);
kDebug() << reg;
QVariant v = QPen( Qt::red );
kDebug() << "Variant: " << v;
return 0;
}

View file

@ -1,102 +0,0 @@
/* This file is part of the KDE libraries
Copyright (C) 1997 Mario Weilguni (mweilguni@sime.com)
Copyright (C) 2006 Olivier Goffart
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kapplication.h>
#include "kdialogbuttonbox.h"
#include <QtGui/QLayout>
#include <QtGui/QLabel>
#include <QtGui/QDialog>
#include <QtGui/QPushButton>
#include <QtGui/QBoxLayout>
int main(int argc, char **argv) {
KAboutData about("kdialogbuttonboxtest", 0, ki18n("kbuttonboxtest"), "version");
KCmdLineArgs::init(argc, argv, &about);
KApplication a;
// example 1
{
QDialog *w = new QDialog;
w->setObjectName( "A common dialog" );
w->setModal(true);
w->setWindowTitle("Example 1");
QVBoxLayout *tl = new QVBoxLayout(w);
tl->setMargin(5);
QLabel *l = new QLabel("A very common dialog\n\n"\
"OK and Cancel are left aligned, Help\n"\
"is right aligned. Try resizing\n"\
"the window!\n"
"Press OK or Cancel when done"
, w);
l->setAlignment(Qt::AlignVCenter|Qt::AlignLeft);
l->setMinimumSize(l->sizeHint());
tl->addWidget(l,1);
KDialogButtonBox *bbox = new KDialogButtonBox(w);
QPushButton *b = bbox->addButton(QLatin1String("OK"), QDialogButtonBox::AcceptRole);
b->setDefault(true);
w->connect(b, SIGNAL(clicked()),
w, SLOT(accept()));
bbox->addButton(QLatin1String("Cancel"),QDialogButtonBox::RejectRole, w, SLOT(accept()));
bbox->addButton(QLatin1String("Help"), QDialogButtonBox::HelpRole);
tl->addWidget(bbox,0);
tl->activate();
w->exec();
delete w;
}
// example 2
{
QDialog *w = new QDialog(0);
w->setObjectName("Vertical");
w->setModal(true);
w->setWindowTitle("Example 2 ");
QHBoxLayout *tl = new QHBoxLayout(w);
tl->setMargin(5);
QLabel *l = new QLabel("Did I mention that it's possible\n"
"to make vertically aligned buttons\n"
"too?"
,w);
l->setAlignment(Qt::AlignVCenter|Qt::AlignLeft);
l->setMinimumSize(l->sizeHint());
tl->addWidget(l,1);
KDialogButtonBox *bbox = new KDialogButtonBox(w, Qt::Vertical);
QPushButton *b = bbox->addButton(QLatin1String("OK"), QDialogButtonBox::AcceptRole);
b->setDefault(true);
w->connect(b, SIGNAL(clicked()),
w, SLOT(accept()));
bbox->addButton(QLatin1String("Cancel"),QDialogButtonBox::RejectRole, w, SLOT(accept()));
bbox->addButton(QLatin1String("Help"), QDialogButtonBox::HelpRole);
tl->addWidget(bbox,0);
tl->activate();
w->exec();
delete w;
}
return 0;
}

View file

@ -1,84 +0,0 @@
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kapplication.h>
#include <kdialog.h>
#include <kguiitem.h>
#include <QtGui/QTextBrowser>
#include <QtGui/QLabel>
int main(int argc, char** argv)
{
KAboutData about("DialogTest", 0, ki18n("DialogTest"), "version");
KCmdLineArgs::init(argc, argv, &about);
KApplication app;
// -----
QString text= // the explanation shown by the example dialog
"<center><h1>KDialog Example</h1></center><hr><br>"
"This example shows the usage of the <i>KDialog</i> class. "
"<i>KDialog</i> is the KDE user interface class used to create "
"dialogs with simple layout without having to define an own dialog "
"style for your application. <br>"
"It provides some standards buttons that are needed in most dialogs. Each one may be "
"hidden, enabled or disabled, and tooltips and quickhelp texts might be"
" added. And you do not need to bother about geometry management, this "
"is all done automatically.<br>"
"The class supports the creation of dialogs without being forced "
"to derive an own class for it, but you may derive your own class "
"for a better code structure.<br>"
"If you wrote a help chapter explaining what your dialog does, you "
"should add a link to it to the dialog using <tt>setHelp</tt>. You do "
"not have to take care about launching the help viewer, just set the "
"help file and topic and of course copy it to your documentation "
"directory during the program installation.";
/* Create the dialog object. DialogBase is derived from QDialog, but
you do not need to derive it to create a nice-looking dialog. Mostly,
you already have a widget class representing the core of your dialog,
and you only need to add a frame around it and the default buttons.
If you want to derive it, you still can, moving all code shown here
inside of your new class. */
KDialog dialog;
dialog.setButtons( KDialog::Ok | KDialog::Cancel | KDialog::Details | KDialog::User1 | KDialog::Help );
dialog.setButtonGuiItem( KDialog::User1 , KGuiItem("Test") );
dialog.setCaption("dialog!");
/* Set a help chapter. If you do not set one, the link is not shown, and the
upper part of the frame shrinks as much as possible. The help window "
"will of course only pop up if you correctly installed kdebase. */
// I disabled it, as khcclient did not run for me.
dialog.setHelp("kdehelp/intro.html", "");
/* This QTextView is intended to be the main widget of our dialog. The
main widget is placed inside the dialogs frame, with the buttons below
it. You do not have to take care about the size handling, but it is a
good idea to set the main wigdets minimum size, since the sizes Qt and
the DialogBase class guess are sometimes ugly.
It is important that your main widget is created with the dialog object
as its parent! */
QTextBrowser view;
view.setHtml( text );
dialog.setMainWidget( &view );
QLabel label("this is a place for some advanced settings" ,&dialog);
dialog.setDetailsWidget( &label);
//view.setMinimumSize(400, view.heightForWidth(400)+20);
view.setMinimumSize( 250, 300 );
/* After finishing the setup of your main widget, the dialog needs to be
adjusted. It is not done automatically, since the layout of the main
widget may change before the dialog is shown. Additionally, setting a
help chapter may cause a need for adjustment since it modifies the height
of the upper frame. */
// dialog.resize(dialog.minimumSize());
/* The dialog object is used just as any other QDialog: */
if(dialog.exec())
{
qDebug("Accepted.");
} else {
qDebug("Rejected.");
}
return 0;
}

View file

@ -1,49 +0,0 @@
/*
Requires the Qt widget libraries, available at no cost at
http://www.troll.no
Copyright (C) 1996 Bernd Johannes Wuebben
wuebben@math.cornell.edu
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kapplication.h>
#include "kfontdialog.h"
#include <kconfig.h>
int main( int argc, char **argv )
{
KAboutData about("KFontDialogTest", 0, ki18n("KFontDialogTest"), "version");
KCmdLineArgs::init(argc, argv, &about);
KApplication app;
app.setFont(QFont("Helvetica",12));
// QFont font = QFont("Times",18,QFont::Bold);
QFont font;
int nRet = KFontDialog::getFont(font);
KFontChooser::FontDiffFlags diffFlags;
nRet = KFontDialog::getFontDiff(font, diffFlags);
return nRet;
}

View file

@ -1,43 +0,0 @@
#include "khboxtest.h"
#include <QtGui/QPushButton>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kapplication.h>
KHBoxTest::KHBoxTest( QWidget* parentWidget )
: KHBox( parentWidget )
{
pbAdd = new QPushButton( "Add a button", this );
connect( pbAdd, SIGNAL(clicked()), this, SLOT(slotAdd()) );
pbRemove = 0;
}
void KHBoxTest::slotAdd()
{
if ( !pbRemove ) {
pbRemove = new QPushButton( "Remove me", this );
connect( pbRemove, SIGNAL(clicked()), this, SLOT(slotRemove()) );
pbAdd->setEnabled( false );
}
}
void KHBoxTest::slotRemove()
{
pbAdd->setEnabled( true );
pbRemove->deleteLater();
pbRemove = 0;
}
int main( int argc, char ** argv )
{
KAboutData about("KHBoxTest", 0, ki18n("KHBoxTest"), "version");
KCmdLineArgs::init(argc, argv, &about);
KApplication app;
KHBoxTest *toplevel = new KHBoxTest(0);
toplevel->show();
app.exec();
}
#include "moc_khboxtest.cpp"

View file

@ -1,23 +0,0 @@
#ifndef KHBOXTEST_H
#define KHBOXTEST_H
#include "khbox.h"
#include <QPushButton>
class KHBoxTest : public KHBox {
Q_OBJECT
public:
KHBoxTest( QWidget* parentWidget );
public Q_SLOTS:
void slotAdd();
void slotRemove();
private:
QPushButton* pbAdd;
QPushButton* pbRemove;
};
#endif

View file

@ -1,154 +0,0 @@
#include <QtGui/QLabel>
#include <QtGui/QSlider>
#include <QtGui/QGridLayout>
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kiconloader.h>
#include <kiconeffect.h>
#include <kcolorbutton.h>
#include "kiconeffecttest.h"
KIconEffectTestWidget::KIconEffectTestWidget(QWidget *parent)
: QScrollArea(parent)
{
setAttribute(Qt::WA_DeleteOnClose);
QWidget *frame = new QWidget(this);
setWidget(frame);
setWidgetResizable(true);
QGridLayout *layout = new QGridLayout(frame);
layout->setColumnStretch(1, 1);
img = QImage(KIconLoader::global()->iconPath("application-x-cd-image", -128));
QImage tmp;
QSlider *slider;
tmp = img;
KIconEffect::toGray(tmp, 0.0);
lbl[0] = new QLabel(frame);
lbl[0]->setPixmap(QPixmap::fromImage(tmp));
layout->addWidget(lbl[0], 0, 0, 3, 1);
layout->addWidget(new QLabel("Grayscale", frame), 0, 1);
slider = new QSlider(Qt::Horizontal, frame);
slider->setRange(0, 100);
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(slotGray(int)));
layout->addWidget(slider, 1, 1);
tmp = img;
KIconEffect::toMonochrome(tmp, Qt::black, Qt::white, 0.0);
lbl[1] = new QLabel(frame);
lbl[1]->setPixmap(QPixmap::fromImage(tmp));
layout->addWidget(lbl[1], 4, 0, 3, 1);
layout->addWidget(new QLabel("Monochrome", frame), 4, 1);
slider = new QSlider(Qt::Horizontal, frame);
slider->setRange(0, 100);
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(slotMonochrome(int)));
layout->addWidget(slider, 5, 1);
tmp = img;
KIconEffect::deSaturate(tmp, 0.0);
lbl[2] = new QLabel(frame);
lbl[2]->setPixmap(QPixmap::fromImage(tmp));
layout->addWidget(lbl[2], 8, 0, 3, 1);
layout->addWidget(new QLabel("Desaturate", frame), 8, 1);
slider = new QSlider(Qt::Horizontal, frame);
slider->setRange(0, 100);
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(slotDesaturate(int)));
layout->addWidget(slider, 9, 1);
tmp = img;
KIconEffect::toGamma(tmp, 0.0);
lbl[3] = new QLabel(frame);
lbl[3]->setPixmap(QPixmap::fromImage(tmp));
layout->addWidget(lbl[3], 12, 0, 3, 1);
layout->addWidget(new QLabel("Gamma", frame), 12, 1);
slider = new QSlider(Qt::Horizontal, frame);
slider->setRange(0, 100);
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(slotGamma(int)));
layout->addWidget(slider, 13, 1);
tmp = img;
colorizedColor = Qt::blue;
colorizedValue = 0.0;
KIconEffect::colorize(tmp, colorizedColor, colorizedValue);
lbl[4] = new QLabel(frame);
lbl[4]->setPixmap(QPixmap::fromImage(tmp));
layout->addWidget(lbl[4], 16, 0, 4, 1);
layout->addWidget(new QLabel("Colorize", frame), 16, 1);
slider = new QSlider(Qt::Horizontal, frame);
slider->setRange(0, 100);
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(slotColorizeValue(int)));
layout->addWidget(slider, 17, 1);
KColorButton *btn = new KColorButton(colorizedColor, frame);
connect(btn, SIGNAL(changed(QColor)), this, SLOT(slotColorizeColor(QColor)));
layout->addWidget(btn, 18, 1);
tmp = img;
KIconEffect::semiTransparent(tmp);
lbl[5] = new QLabel(frame);
lbl[5]->setPixmap(QPixmap::fromImage(tmp));
layout->addWidget(lbl[5], 20, 0, 3, 1);
layout->addWidget(new QLabel("Semitransparent", frame), 20, 1);
layout->setRowStretch(21, 1);
frame->resize(frame->sizeHint());
}
void KIconEffectTestWidget::slotGray(int value)
{
QImage tmp(img);
KIconEffect::toGray(tmp, value*0.01);
lbl[0]->setPixmap(QPixmap::fromImage(tmp));
}
void KIconEffectTestWidget::slotMonochrome(int value)
{
QImage tmp(img);
KIconEffect::toMonochrome(tmp, Qt::black, Qt::white, value*0.01);
lbl[1]->setPixmap(QPixmap::fromImage(tmp));
}
void KIconEffectTestWidget::slotDesaturate(int value)
{
QImage tmp(img);
KIconEffect::deSaturate(tmp, value*0.01);
lbl[2]->setPixmap(QPixmap::fromImage(tmp));
}
void KIconEffectTestWidget::slotGamma(int value)
{
QImage tmp(img);
KIconEffect::toGamma(tmp, value*0.01);
lbl[3]->setPixmap(QPixmap::fromImage(tmp));
}
void KIconEffectTestWidget::slotColorizeColor(const QColor &c)
{
colorizedColor = c;
QImage tmp(img);
KIconEffect::colorize(tmp, colorizedColor, colorizedValue);
lbl[4]->setPixmap(QPixmap::fromImage(tmp));
}
void KIconEffectTestWidget::slotColorizeValue(int value)
{
colorizedValue = value*0.01f;
QImage tmp(img);
KIconEffect::colorize(tmp, colorizedColor, colorizedValue);
lbl[4]->setPixmap(QPixmap::fromImage(tmp));
}
int main( int argc, char **argv )
{
KCmdLineArgs::init( argc, argv, "kiconeffecttest", 0, ki18n("KIconEffectTest"), "1.0", ki18n("KDE icon effect test"));
KApplication app;
KIconEffectTestWidget *w = new KIconEffectTestWidget;
w->show();
return app.exec();
}
#include "moc_kiconeffecttest.cpp"

View file

@ -1,29 +0,0 @@
#ifndef KICONEFFECTTEST_H
#define KICONEFFECTTEST_H
#include <QtGui/QScrollArea>
#include <QtGui/QImage>
#include <QLabel>
class KIconEffectTestWidget : public QScrollArea
{
Q_OBJECT
public:
KIconEffectTestWidget(QWidget *parent=0);
private Q_SLOTS:
void slotGray(int);
void slotMonochrome(int);
void slotDesaturate(int);
void slotGamma(int);
void slotColorizeColor(const QColor &);
void slotColorizeValue(int);
private:
QImage img;
QLabel *lbl[6];
QColor colorizedColor;
float colorizedValue;
};
#endif

View file

@ -1,42 +0,0 @@
#include <kiconloader.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kapplication.h>
#include <kdebug.h>
#include <QtCore/QElapsedTimer>
#include <QtGui/QPixmap>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
KAboutData about("kiconloadertest", 0, ki18n("kiconloadertest"), "version");
KCmdLineArgs::init(argc, argv, &about);
KApplication app;
KIconLoader * mpLoader = KIconLoader::global();
KIconLoader::Context mContext = KIconLoader::Application;
QElapsedTimer dt;
dt.start();
int count = 0;
for ( int mGroup = 0; mGroup < KIconLoader::LastGroup ; ++mGroup )
{
kDebug() << "queryIcons " << mGroup << "," << mContext;
const QStringList filelist = mpLoader->queryIcons(mGroup, mContext);
kDebug() << " -> found " << filelist.count() << " icons.";
int i=0;
for(QStringList::ConstIterator it = filelist.begin();
it != filelist.end() /*&& i<10*/;
++it, ++i )
{
//kDebug() << ( i==9 ? "..." : (*it) );
mpLoader->loadIcon( (*it), (KIconLoader::Group)mGroup );
++count;
}
}
kDebug() << "Loading " << count << " icons took " << (float)(dt.elapsed()) / 1000 << " seconds";
}

View file

@ -1,76 +0,0 @@
/*
* Copyright Nadeem Hasan <nhasan@kde.org>
* Licensed under the GNU General Public License version 2
*/
#include <QtGui/QApplication>
#include <kcomponentdata.h>
#include <kaboutdata.h>
#include <kinputdialog.h>
#include <kdebug.h>
#include <klistwidget.h>
#include <QtCore/QString>
#include <QtGui/QValidator>
#include <kcmdlineargs.h>
int main( int argc, char *argv[] )
{
QApplication app( argc, argv );
// app.setApplicationName("kinputdialogtest"); //since there is no kapp usage, set the application name directly
KAboutData aboutData( "kinputdialogtest", 0, ki18n("kinputdialogtest"), "1.0" );
KComponentData i( &aboutData );
bool ok;
QString svalue;
int ivalue;
double dvalue;
svalue = KInputDialog::getText( "_caption", "_label:", "_value", &ok );
kDebug() << "value1: " << svalue << ", ok: " << ok;
QRegExpValidator validator( QRegExp( "[0-9]{3}\\-[0-9]{3}\\-[0-9]{4}" ), 0 );
svalue = KInputDialog::getText( "_caption", "_label:", "_value", &ok, 0L,
&validator );
kDebug() << "value2: " << svalue << ", ok: " << ok;
svalue = KInputDialog::getText( "_caption", "_label:", "_value", &ok, 0L, 0L,
QString(), "900.900.900.900" );
kDebug() << "value1: " << svalue << ", ok: " << ok;
ivalue = KInputDialog::getInteger( "_caption", "_label:", 64, 0, 255,
16, 16, &ok );
kDebug() << "value3: " << ivalue << ", ok: " << ok;
ivalue = KInputDialog::getInteger( "_caption", "_label:", 100, 0, 255,
10, 10, &ok );
kDebug() << "value4: " << ivalue << ", ok: " << ok;
dvalue = KInputDialog::getDouble( "_caption", "_label:", 10, 0, 100, 0.1,
2, &ok );
kDebug() << "value5: " << dvalue << ", ok: " << ok;
dvalue = KInputDialog::getDouble( "_caption", "_label:", 10, 0, 100, 2, &ok );
kDebug() << "value6: " << dvalue << ", ok: " << ok;
QStringList list, slvalue;
list << "Item 1" << "Item 2" << "Item 3" << "Item 4" << "Item 5";
svalue = KInputDialog::getItem( "_caption", "_label:", list, 1, false, &ok );
kDebug() << "value7: " << svalue << ", ok: " << ok;
svalue = KInputDialog::getItem( "_caption", "_label:", list, 1, true, &ok );
kDebug() << "value8: " << svalue << ", ok: " << ok;
QStringList select;
select << "Item 3";
list << "Item 6" << "Item 7" << "Item 8" << "Item 9" << "Item 10";
slvalue = KInputDialog::getItemList( "_caption", "_label:", list, select,
false, &ok );
kDebug() << "value9: " << slvalue << ", ok: " << ok;
select << "Item 5";
slvalue = KInputDialog::getItemList( "_caption", "_label:", list, select,
true, &ok );
kDebug() << "value10: " << slvalue << ", ok: " << ok;
}

View file

@ -1,182 +0,0 @@
/**
* This file is part of the KDE libraries
* Copyright (C) 2007 Kevin Ottens <ervin@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "kjobtrackerstest.h"
#include <QtGui/QMainWindow>
#include <QtGui/QStatusBar>
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kdebug.h>
#include <kwidgetjobtracker.h>
#include <kstatusbarjobtracker.h>
#include <kuiserverjobtracker.h>
KTestJob::KTestJob(int numberOfDirs)
: KJob(), m_numberOfDirs(numberOfDirs), m_currentSpeed(1000), m_state(Stopped)
{
setCapabilities(KJob::Killable|KJob::Suspendable);
}
KTestJob::~KTestJob()
{
}
void KTestJob::start()
{
connect(&m_timer, SIGNAL(timeout()),
this, SLOT(nextStep()));
m_state = StatingDirs;
m_timer.start(50);
emit description(this, QString("Copying"), qMakePair(QString("Source"), QString("file:/src")),
qMakePair(QString("Destination"), QString("file:/dest")));
}
void KTestJob::nextStep()
{
switch (m_state)
{
case StatingDirs:
emit infoMessage(this, QString("Initial listing"));
stateNextDir();
break;
case CreatingDirs:
emit infoMessage(this, QString("Folder creation"));
createNextDir();
break;
case CopyingFiles:
emit infoMessage(this, QString("Actual file copying"));
copyNextFile();
break;
case Stopped:
kDebug() << "Do nothing, we stopped";
}
}
void KTestJob::stateNextDir()
{
if (totalAmount(KJob::Directories)==m_numberOfDirs) {
m_state = CreatingDirs;
return;
}
QString directory_name = "dir"+QString::number(totalAmount(KJob::Directories));
kDebug() << "Stating " << directory_name;
setTotalAmount(KJob::Directories, totalAmount(KJob::Directories)+1);
setTotalAmount(KJob::Files, totalAmount(KJob::Directories)*10);
setTotalAmount(KJob::Bytes, totalAmount(KJob::Files)*1000);
emit description(this, QString("Stating"), qMakePair(QString("Stating"), QString("file:/src/"+directory_name)));
}
void KTestJob::createNextDir()
{
if (processedAmount(KJob::Directories)==totalAmount(KJob::Directories)) {
m_state = CopyingFiles;
return;
}
QString directory_name = "dir"+QString::number(processedAmount(KJob::Directories));
kDebug() << "Creating " << directory_name;
setProcessedAmount(KJob::Directories, processedAmount(KJob::Directories)+1);
emit description(this, QString("Creating Dir"), qMakePair(QString("Creating"), QString("file:/dest/"+directory_name)));
}
void KTestJob::copyNextFile()
{
if (processedAmount(KJob::Files)==totalAmount(KJob::Files)) {
m_state = Stopped;
m_timer.stop();
emitResult();
return;
}
QString file_name = "dir"+QString::number(processedAmount(KJob::Files)/10)
+"/file"+QString::number(processedAmount(KJob::Files)%10);
kDebug() << "Copying " << file_name;
setProcessedAmount(KJob::Files, processedAmount(KJob::Files)+1);
setProcessedAmount(KJob::Bytes, processedAmount(KJob::Bytes)+1000);
emit description(this, QString("Copying"), qMakePair(QString("Source"), QString("file:/src/"+file_name)),
qMakePair(QString("Destination"), QString("file:/dest/"+file_name)));
emitSpeed(m_currentSpeed);
}
bool KTestJob::doSuspend()
{
m_timer.stop();
return true;
}
bool KTestJob::doResume()
{
m_timer.start(50);
return true;
}
bool KTestJob::doKill()
{
m_timer.stop();
m_state = Stopped;
return true;
}
int main(int argc, char **argv)
{
KCmdLineArgs::init(argc, argv, "kjobtrackerstest", 0, ki18n("KJobTrackerTest"),
"0.0", ki18n("Test several job trackers at once"));
KApplication app;
KTestJob *testJob = new KTestJob(10 /* 100000 bytes to process */);
KWidgetJobTracker *tracker1 = new KWidgetJobTracker();
tracker1->registerJob(testJob);
QMainWindow *main = new QMainWindow;
main->setWindowTitle("Mainwindow with statusbar-job-tracker");
main->show();
QStatusBar *statusBar = new QStatusBar(main);
KStatusBarJobTracker *tracker2 = new KStatusBarJobTracker(main, true);
tracker2->registerJob(testJob);
tracker2->setStatusBarMode(KStatusBarJobTracker::ProgressOnly);
statusBar->addWidget(tracker2->widget(testJob));
main->setStatusBar(statusBar);
KUiServerJobTracker *tracker3 = new KUiServerJobTracker(main);
tracker3->registerJob(testJob);
testJob->start();
tracker1->widget(testJob)->show();
tracker2->widget(testJob)->show();
return app.exec();
}
#include "moc_kjobtrackerstest.cpp"

View file

@ -1,61 +0,0 @@
/**
* This file is part of the KDE libraries
* Copyright (C) 2007 Kevin Ottens <ervin@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KJOBTRACKERSTEST_H
#define KJOBTRACKERSTEST_H
#include <kjob.h>
#include <QtCore/QTimer>
class KTestJob : public KJob
{
Q_OBJECT
public:
enum State { StatingDirs, CreatingDirs, CopyingFiles, Stopped };
// 10 files per directory
// 1000 bytes per files
KTestJob(int numberOfDirs = 5);
~KTestJob();
void start();
private Q_SLOTS:
void nextStep();
protected:
void stateNextDir();
void createNextDir();
void copyNextFile();
void deleteNextFile();
bool doSuspend();
bool doResume();
bool doKill();
private:
qulonglong m_numberOfDirs;
qulonglong m_currentSpeed;
State m_state;
QTimer m_timer;
};
#endif

View file

@ -1,40 +0,0 @@
/* This file is part of the KDE libraries
Copyright (c) 2013 David Faure <faure+bluesystem@kde.org>
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2 of the License or ( at
your option ) version 3 or, at the discretion of KDE e.V. ( which shall
act as a proxy as in section 14 of the GPLv3 ), any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "klanguagebutton.h"
#include <QtGui/QLineEdit>
#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include <kapplication.h>
#include <klocale.h>
int main(int argc, char** argv)
{
KAboutData about("KLanguageButtonTest", "kdelibs4", ki18n("KLanguageButtonTest"), "version");
KCmdLineArgs::init(argc, argv, &about);
KApplication app;
KLanguageButton button;
button.loadAllLanguages();
button.show();
return app.exec();
}

View file

@ -1,164 +0,0 @@
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kapplication.h>
#include <QtGui/QWidget>
#include <QtCore/QTimer>
#include <stdlib.h>
#include "kled.h"
#include "kledtest.h"
KLedTest::KLedTest(QWidget* parent)
: QWidget(parent),
LedWidth(16),
LedHeight(10),
Grid(3),
ledcolor(0),
ledlook(KLed::Flat),
kled_round(true) // Switch HERE between rectangle and circular leds
{
if (kled_round) {
//KLed l(KLed::red, &qw); // create lamp
//KLed l(KLed::blue, &qw); // create lamp
l = new KLed(Qt::green, this); // create lamp
//KLed l(KLed::yellow, &qw); // create lamp
//KLed l(KLed::orange, &qw); // create lamp
l->resize(16,30);
//l.setLook(KLed::flat);
l->setShape(KLed::Circular);
//l->setShape(KLed::Rectangular);
//l->setLook(KLed::Flat);
//l->setLook(KLed::Flat);
//l->setLook(KLed::Flat);
l->move(5,5);
// ktmp tmpobj(l);
t_toggle.setSingleShot(false);
t_toggle.start(1000);
t_color.setSingleShot(false);
t_color.start(3500);
t_look.setSingleShot(false);
t_look.start(3500);
QObject::connect(&t_toggle, SIGNAL(timeout()), l, SLOT(toggle()));
QObject::connect(&t_color, SIGNAL(timeout()), this, SLOT(nextColor()));
QObject::connect(&t_look, SIGNAL(timeout()), this, SLOT(nextLook()));
l->show();
resize(240,140);
}
else {
y=Grid; index=0;
for( int shape=0; (int)shape<2; shape=(KLed::Shape)(shape+1)) {
x=Grid;
for( int look=0; (int)look<3; look=(KLed::Look)(look+1)) {
for(state=KLed::Off; (int)state<2; state=(KLed::State)(state+1))
{
leds[index]=new KLed(Qt::yellow, state,
(KLed::Look)(look+1),
(KLed::Shape)(shape+1), this);
leds[index]->setGeometry(x, y, LedWidth, LedHeight);
++index;
x+=Grid+LedWidth;
}
}
y+=Grid+LedHeight;
}
setFixedSize(x+Grid, y+Grid);
connect(&timer, SIGNAL(timeout()), SLOT(timeout()));
timer.start(500);
}
}
KLedTest::~KLedTest()
{
if (kled_round) {
delete l;
}
}
void
KLedTest::nextColor() {
ledcolor++;
ledcolor%=4;
switch(ledcolor) {
default:
case 0: l->setColor(Qt::green); break;
case 1: l->setColor(Qt::blue); break;
case 2: l->setColor(Qt::red); break;
case 3: l->setColor(Qt::yellow); break;
}
}
void
KLedTest::nextLook() {
int tmp;
if (kled_round) {
tmp = (static_cast<int>(ledlook) +1 ) % 3 ;
}
else {
tmp = (static_cast<int>(ledlook) + 1) % 3;
}
ledlook = static_cast<KLed::Look>(tmp);
l->setLook(ledlook);
//qDebug("painting look %i", ledlook);
//l->repaint();
}
void
KLedTest::timeout()
{
const int NoOfLeds=sizeof(leds)/sizeof(leds[0]);
int count;
// -----
for(count=0; count<NoOfLeds; ++count)
{
if(leds[count]->state()==KLed::Off)
{
leds[count]->setState(KLed::On);
} else {
leds[count]->setState(KLed::Off);
}
}
}
/*#include <stdio.h>*/
int main( int argc, char **argv )
{
KAboutData about("KLedTest", 0, ki18n("KLedTest"), "version");
KCmdLineArgs::init(argc, argv, &about);
KApplication a;
KLedTest widget;
// -----
/*
if (argc>1) { // look out for round or circular led command
if (strncmp(argv[1],"-c",2)) {
// paint circular
printf("painting circular led\n");
widget.kled_round = true;
}
else if (strncmp(argv[1],"-r",2)) {
// paint rectangle
printf("painting rectangular led\n");
widget.kled_round = false;
}
}
*/
widget.show();
return a.exec(); // go
}
#include "moc_kledtest.cpp"

View file

@ -1,51 +0,0 @@
#ifndef KLEDTEST_H
#define KLEDTEST_H
#include <QtGui/QWidget>
#include <QtCore/QTimer>
#include <stdlib.h>
#include <kled.h>
class KLedTest : public QWidget
{
Q_OBJECT
protected:
QTimer timer;
KLed *leds[/*KLed::NoOfShapes*/2* /*KLed::NoOfLooks*/3* /*KLed::NoOfStates*/2];
const int LedWidth;
const int LedHeight;
const int Grid;
KLed::Shape shape;
KLed::Look look;
KLed::State state;
int x, y, index;
QTimer t_toggle, t_color, t_look;
//KLed *l; // create lamp
//KLed *l; // create lamp
KLed *l; // create lamp
//KLed *l; // create lamp
//KLed *l; // create lamp
int ledcolor;
KLed::Look ledlook;
public:
KLedTest(QWidget* parent=0);
~KLedTest();
bool kled_round;
public Q_SLOTS:
void timeout();
void nextColor();
void nextLook();
};
#endif

View file

@ -1,186 +0,0 @@
#include <QtGui/QPushButton>
#include <QtCore/QTimer>
#include <QtGui/QBoxLayout>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kapplication.h>
#include <kdebug.h>
#include <kdialog.h>
#include <klocale.h>
#include <klineedit.h>
#include <kglobalsettings.h>
#include <kcompletionbox.h>
#include <khbox.h>
#include "klineedittest.h"
#include <QLabel>
#include <krestrictedline.h>
KLineEditTest::KLineEditTest ( QWidget* widget )
:QWidget( widget )
{
QVBoxLayout* layout = new QVBoxLayout( this );
QStringList list;
list << "Tree" << "Suuupa" << "Stroustrup" << "Stone" << "Slick"
<< "Slashdot" << "Send" << "Peables" << "Mankind" << "Ocean"
<< "Chips" << "Computer" << "Sandworm" << "Sandstorm" << "Chops";
list.sort();
m_lineedit = new KLineEdit( this );
m_lineedit->setObjectName( "klineedittest" );
m_lineedit->completionObject()->setItems( list );
m_lineedit->setSqueezedTextEnabled( true );
m_lineedit->setClearButtonShown( true );
connect( m_lineedit, SIGNAL(returnPressed()), SLOT(slotReturnPressed()) );
connect( m_lineedit, SIGNAL(returnPressed(QString)),
SLOT(slotReturnPressed(QString)) );
QHBoxLayout* restrictedHBox = new QHBoxLayout;
m_restrictedLine = new KRestrictedLine(this);
m_restrictedLine->setValidChars(QString::fromUtf8("aeiouyé"));
connect(m_restrictedLine, SIGNAL(invalidChar(int)), this, SLOT(slotInvalidChar(int)));
connect( m_restrictedLine, SIGNAL(returnPressed()), SLOT(slotReturnPressed()) );
connect( m_restrictedLine, SIGNAL(returnPressed(QString)),
SLOT(slotReturnPressed(QString)) );
restrictedHBox->addWidget(new QLabel("Vowels only:", this));
restrictedHBox->addWidget(m_restrictedLine);
m_invalidCharLabel = new QLabel(this);
restrictedHBox->addWidget(m_invalidCharLabel);
KHBox *hbox = new KHBox (this);
m_btnExit = new QPushButton( "E&xit", hbox );
connect( m_btnExit, SIGNAL(clicked()), SLOT(quitApp()) );
m_btnReadOnly = new QPushButton( "&Read Only", hbox );
m_btnReadOnly->setCheckable (true);
connect( m_btnReadOnly, SIGNAL(toggled(bool)), SLOT(slotReadOnly(bool)) );
m_btnPassword = new QPushButton( "&Password", hbox );
m_btnPassword->setCheckable (true);
connect( m_btnPassword, SIGNAL(toggled(bool)), SLOT(slotPassword(bool)) );
m_btnEnable = new QPushButton( "Dis&able", hbox );
m_btnEnable->setCheckable (true);
connect( m_btnEnable, SIGNAL(toggled(bool)), SLOT(slotEnable(bool)) );
m_btnHide = new QPushButton( "Hi&de", hbox );
connect( m_btnHide, SIGNAL(clicked()), SLOT(slotHide()) );
m_btnClickMessage = new QPushButton( "Clicked Message", hbox);
m_btnClickMessage->setCheckable (true);
connect( m_btnClickMessage, SIGNAL(toggled(bool)), SLOT(slotClickMessage(bool)) );
QPushButton *button = new QPushButton( "Stylesheet", hbox);
connect( button, SIGNAL(clicked()), SLOT(slotSetStyleSheet()));
layout->addWidget( m_lineedit );
layout->addLayout( restrictedHBox );
layout->addWidget( hbox );
setWindowTitle( "KLineEdit Unit Test" );
}
KLineEditTest::~KLineEditTest()
{
}
void KLineEditTest::quitApp()
{
kapp->closeAllWindows();
}
void KLineEditTest::slotSetStyleSheet()
{
m_lineedit->setStyleSheet("QLineEdit{ background-color:#baf9ce }");
}
void KLineEditTest::show()
{
if (m_lineedit->isHidden())
m_lineedit->show();
m_btnHide->setEnabled( true );
QWidget::show();
}
void KLineEditTest::slotReturnPressed()
{
kDebug() << "Return pressed";
}
void KLineEditTest::slotReturnPressed( const QString& text )
{
kDebug() << "Return pressed: " << text;
}
void KLineEditTest::resultOutput( const QString& text )
{
kDebug() << "KlineEditTest Debug: " << text;
}
void KLineEditTest::slotReadOnly( bool ro )
{
m_lineedit->setReadOnly (ro);
QString text = (ro) ? "&Read Write" : "&Read Only";
m_btnReadOnly->setText (text);
}
void KLineEditTest::slotPassword( bool pw )
{
m_lineedit->setPasswordMode (pw);
QString text = (pw) ? "&Normal Text" : "&Password";
m_btnPassword->setText (text);
}
void KLineEditTest::slotEnable (bool enable)
{
m_lineedit->setEnabled (!enable);
QString text = (enable) ? "En&able":"Dis&able";
m_btnEnable->setText (text);
}
void KLineEditTest::slotClickMessage(bool click)
{
if( click )
{
m_lineedit->setText(""); // Clear before to add message
m_lineedit->setClickMessage ("Click in this lineedit");
}
}
void KLineEditTest::slotHide()
{
m_lineedit->hide();
m_btnHide->setEnabled( false );
m_lineedit->setText( "My dog ate the homework, whaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaa! I want my mommy!" );
QTimer::singleShot( 1000, this, SLOT(show()) );
}
void KLineEditTest::slotInvalidChar(int key)
{
m_invalidCharLabel->setText(QString("Invalid char: %1").arg(key));
}
int main ( int argc, char **argv)
{
KAboutData aboutData( "klineedittest", 0, ki18n("klineedittest"), "1.0" );
KCmdLineArgs::init(argc, argv, &aboutData);
KCmdLineArgs::addStdCmdLineOptions();
KApplication a;
KLineEditTest *t = new KLineEditTest();
//t->lineEdit()->setTrapReturnKey( true );
//t->lineEdit()->completionBox()->setTabHandling( false );
t->lineEdit()->setSqueezedTextEnabled( true );
t->lineEdit()->setText ("This is a really really really really really really "
"really really long line because I am a talkative fool!"
"I mean ... REALLY talkative. If you don't believe me, ask my cousin.");
t->show();
return a.exec();
}
#include "moc_klineedittest.cpp"

View file

@ -1,51 +0,0 @@
#ifndef KLINEEDITTEST_H
#define KLINEEDITTEST_H
#include <QtGui/QWidget>
#include <QtCore/QPointer>
#include <QLabel>
class KRestrictedLine;
#include <QString>
#include <QPushButton>
class KLineEdit;
class KLineEditTest : public QWidget
{
Q_OBJECT
public:
KLineEditTest( QWidget *parent=0 );
~KLineEditTest();
KLineEdit* lineEdit() const { return m_lineedit; }
public Q_SLOTS:
virtual void show ();
private Q_SLOTS:
void quitApp();
void slotHide();
void slotEnable( bool );
void slotReadOnly( bool );
void slotPassword( bool );
void slotReturnPressed();
void resultOutput( const QString& );
void slotReturnPressed( const QString& );
void slotClickMessage(bool click);
void slotInvalidChar(int);
void slotSetStyleSheet();
protected:
KLineEdit* m_lineedit;
KRestrictedLine* m_restrictedLine;
QLabel* m_invalidCharLabel;
QPushButton* m_btnExit;
QPushButton* m_btnReadOnly;
QPushButton* m_btnPassword;
QPushButton* m_btnEnable;
QPushButton* m_btnHide;
QPushButton* m_btnClickMessage;
};
#endif

View file

@ -1,43 +0,0 @@
#include "kmainwindowrestoretest.h"
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <QtGui/QLabel>
#define MAKE_WINDOW( kind, title ) do { \
MainWin##kind * m = new MainWin##kind; \
m->setCaption( title ); \
m->setCentralWidget( new QLabel( title, m ) ); \
m->show(); \
} while ( false )
int main( int argc, char * argv[] ) {
KCmdLineArgs::init( argc, argv, "kmainwindowrestoretest", 0, ki18n("kmainwindowrestoretest"), "1.0", ki18n("kmainwindow test app"));
KApplication app;
if ( kapp->isSessionRestored() ) {
kRestoreMainWindows< MainWin1, MainWin2, MainWin3 >();
kRestoreMainWindows< MainWin4, MainWin5 >();
RESTORE(MainWin6);
//kRestoreMainWindows< MainWin6 >(); // should be equivalent to RESTORE()
} else {
MAKE_WINDOW( 1, "First 1" );
MAKE_WINDOW( 1, "Second 1" );
MAKE_WINDOW( 2, "Only 2" );
MAKE_WINDOW( 3, "First 3" );
MAKE_WINDOW( 4, "First 4" );
MAKE_WINDOW( 4, "Second 4" );
MAKE_WINDOW( 3, "Second 3" );
MAKE_WINDOW( 4, "Third 4" );
MAKE_WINDOW( 5, "First 5" );
MAKE_WINDOW( 5, "Second 5" );
MAKE_WINDOW( 1, "Only 6" );
}
return app.exec();
}
#include "moc_kmainwindowrestoretest.cpp"

View file

@ -1,48 +0,0 @@
#ifndef _KDEUI_TESTS_KMAINWINDOWRESTORETEST_H_
#define _KDEUI_TESTS_KMAINWINDOWRESTORETEST_H_
#include <kmainwindow.h>
class MainWin1 : public KMainWindow {
Q_OBJECT
public:
MainWin1() : KMainWindow() {}
virtual ~MainWin1() {}
};
class MainWin2 : public KMainWindow {
Q_OBJECT
public:
MainWin2() : KMainWindow() {}
virtual ~MainWin2() {}
};
class MainWin3 : public KMainWindow {
Q_OBJECT
public:
MainWin3() : KMainWindow() {}
virtual ~MainWin3() {}
};
class MainWin4 : public KMainWindow {
Q_OBJECT
public:
MainWin4() : KMainWindow() {}
virtual ~MainWin4() {}
};
class MainWin5 : public KMainWindow {
Q_OBJECT
public:
MainWin5() : KMainWindow() {}
virtual ~MainWin5() {}
};
class MainWin6 : public KMainWindow {
Q_OBJECT
public:
MainWin6() : KMainWindow() {}
virtual ~MainWin6() {}
};
#endif // _KDEUI_TESTS_KMAINWINDOWRESTORETEST_H_

View file

@ -1,60 +0,0 @@
/*
Copyright 2002 Simon Hausmann <hausmann@kde.org>
Copyright 2005-2006 David Faure <faure@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <QtCore/QTimer>
#include <QtGui/QLabel>
#include <QtGui/QMenuBar>
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kstatusbar.h>
#include "kmainwindowtest.h"
MainWindow::MainWindow()
{
QTimer::singleShot( 2*1000, this, SLOT(showMessage()) );
setCentralWidget( new QLabel( "foo", this ) );
menuBar()->addAction( "hi" );
}
void MainWindow::showMessage()
{
statusBar()->show();
statusBar()->showMessage( "test" );
}
int main( int argc, char **argv )
{
KCmdLineArgs::init( argc, argv, "kmainwindowtest", 0, ki18n("KMainWindowTest"), "1.0", ki18n("kmainwindow test app"));
KApplication app;
MainWindow* mw = new MainWindow; // deletes itself when closed
mw->show();
return app.exec();
}
#include "moc_kmainwindowtest.cpp"
/* vim: et sw=4 ts=4
*/

View file

@ -1,37 +0,0 @@
/*
Copyright 2002 Simon Hausmann <hausmann@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KMAINWINDOWTEST_H
#define KMAINWINDOWTEST_H
#include <kmainwindow.h>
class MainWindow : public KMainWindow
{
Q_OBJECT
public:
MainWindow();
private Q_SLOTS:
void showMessage();
};
#endif // KMAINWINDOWTEST_H
/* vim: et sw=4 ts=4
*/

View file

@ -1,364 +0,0 @@
#include "kmessagebox.h"
#include <QtGui/QLabel>
#include <stdlib.h>
#include <stdio.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kapplication.h>
class ExampleWidget : public QLabel
{
public:
ExampleWidget( QWidget *parent = 0 );
};
ExampleWidget::ExampleWidget( QWidget *parent )
: QLabel(parent )
{
// Make the top-level layout; a vertical box to contain all widgets
// and sub-layouts.
QSize sh;
setText("<p>Hello.</p>");
sh = sizeHint();
qWarning("SizeHint = %d x %d", sh.width(), sh.height());
setText("Hello.");
sh = sizeHint();
qWarning("SizeHint = %d x %d", sh.width(), sh.height());
setText("<p>Hello<br>World</p>");
sh = sizeHint();
qWarning("SizeHint = %d x %d", sh.width(), sh.height());
// setText("Hello\nWorld");
sh = sizeHint();
qWarning("SizeHint = %d x %d", sh.width(), sh.height());
setMinimumSize(sizeHint());
}
class Foo: public QDialog
{
public:
Foo() : QDialog(0) {
setObjectName("foo");
setModal(true);
resize(200,200);
new QLabel("Hello World", this);
show();
}
};
void showResult(int test, int i)
{
printf("%d. returned %d ", test, i);
switch( i) {
case KMessageBox::Ok : printf("(%s)\n", "Ok"); break;
case KMessageBox::Cancel : printf("(%s)\n", "Cancel"); break;
case KMessageBox::Yes : printf("(%s)\n", "Yes"); break;
case KMessageBox::No : printf("(%s)\n", "No"); break;
case KMessageBox::Continue : printf("(%s)\n", "Continue"); break;
default: printf("(%s)\n", "ERROR!"); exit(1);
}
}
int main( int argc, char *argv[] )
{
int i, test;
KAboutData about("KMessageBoxTest", 0, ki18n("KMessageBoxTest"), "version");
KCmdLineArgs::init(argc, argv, &about);
new KApplication();
ExampleWidget *w = new ExampleWidget();
w->show();
QStringList list; list.append("Hello"); list.append("World");
for( test = 1; true; test++)
{
switch(test)
{
case 1:
i = KMessageBox::warningContinueCancel(w,
"You are about to <Print>.\n"
"Are you sure?",
"Print", KGuiItem( QLatin1String("&Print") ), KStandardGuiItem::cancel(), "dontask", 0);
i = KMessageBox::warningContinueCancel(0,
"You are about to <Print>.\n"
"Are you sure?",
"Print", KGuiItem( QLatin1String("&Print") ), KStandardGuiItem::cancel(), "dontask", KMessageBox::AllowLink);
i = KMessageBox::questionYesNo(0, "<p>Do you have a printer? thisisaverylongdkldhklghklghklashgkllasghkdlsghkldfghklsabla bla bbla bla. It also has <a href=http://www.kde.org>this URL</a>.</p>",
QString("Bla"), KGuiItem(QString("Yes")), KGuiItem(QString("No")), "bla", KMessageBox::AllowLink);
break;
case 2:
i = KMessageBox::questionYesNo(0, "Do you have a printer?",
QString("Printer setup"));
break;
case 3:
i = KMessageBox::questionYesNo(0,
"Does your printer support color or only black and white?",
"Printer setup", KGuiItem( QLatin1String("&Color") ), KGuiItem(QString::fromLatin1("&Black & White")));
break;
case 4:
i = KMessageBox::warningYesNo(0,
"KDVI could not locate the program 'dvipdfm' on your computer. That program is "
"absolutely needed by the export function. You can, however, convert "
"the DVI-file to PDF using the print function of KDVI, but that will often "
"produce files which print ok, but are of inferior quality if viewed in the "
"Acrobat Reader. It may be wise to upgrade to a more recent version of your "
"TeX distribution which includes the 'dvipdfm' program.\n"
"Hint to the perplexed system administrator: KDVI uses the shell's PATH variable "
"when looking for programs."
);
break;
case 5:
i = KMessageBox::warningYesNo(0, "Your printer has been added.\n"
"Do you want to update your configuration?",
"Printer Setup");
break;
case 6:
i = KMessageBox::warningContinueCancel(0,
"You are about to print.\n"
"Are you sure?",
"Print", KGuiItem( QLatin1String("&Print") ) );
break;
case 7:
i = KMessageBox::warningContinueCancel(0,
"You are about to <Print>.\n"
"Are you sure?",
"Print", KGuiItem( QLatin1String("&Print") ), KStandardGuiItem::cancel(), "dontask", 0);
break;
case 8:
i = KMessageBox::warningYesNoCancel(0,
"Your document contains unsaved changes.\n"
"Do you want to save your changes?\n");
break;
case 9:
i = KMessageBox::warningYesNoCancel(0,
"Your document contains unsaved changes.\n"
"Do you want to save your changes?\n",
QLatin1String("Close"));
break;
case 10:
i = KMessageBox::warningYesNoCancel(0,
"Your document contains unsaved changes.\n"
"Do you want to save or discard your changes?\n",
"Close", KGuiItem( QLatin1String("&Save") ), KGuiItem( QLatin1String("&Discard") ) );
break;
case 11:
i = KMessageBox::Ok;
KMessageBox::error(0, "Oops, Your harddisk is unreadable.");
break;
case 12:
i = KMessageBox::Ok;
KMessageBox::error(0, "Oops, Your harddisk is unreadable." , "Uh ooh");
break;
case 13:
i = KMessageBox::Ok;
KMessageBox::sorry(0, "Sorry, Your harddisk appears to be empty.");
break;
case 14:
i = KMessageBox::Ok;
KMessageBox::sorry(0, "Sorry, Your harddisk appears to be empty.", "Oops");
break;
case 15:
i = KMessageBox::Ok;
KMessageBox::information(0, "You can enable the menubar again "
"with the right mouse button menu.");
break;
case 16:
i = KMessageBox::Ok;
KMessageBox::information(0, "You can enable the menubar again "
"with the right mouse button menu.", "Menubar Info");
break;
case 17:
i = KMessageBox::Ok;
KMessageBox::information(0, "You can enable the menubar again\nwith the right mouse button menu.", QString(), "Enable_Menubar");
break;
case 18:
i = KMessageBox::Ok;
KMessageBox::enableAllMessages();
break;
case 19:
i = KMessageBox::Ok;
KMessageBox::information(0, "Return of the annoying popup message.", QString(), "Enable_Menubar");
break;
case 20:
{
QStringList strlist;
strlist << "/dev/hda" << "/etc/inittab" << "/usr/somefile" << "/some/really/"
"long/file/name/which/is/in/a/really/deep/directory/in/a/really/large/"
"hard/disk/of/your/system" << "/and/another/one" ;
i = KMessageBox::questionYesNoList(0, "Do you want to delete the following files?",strlist);
}
break;
case 21:
{
QStringList strlist;
printf("Filling StringList...\n");
for (int j=1;j<=6000;j++) strlist.append(QString("/tmp/tmp.%1").arg(j));
printf("Completed...\n");
i = KMessageBox::questionYesNoList(0, "Do you want to delete the following files?",strlist);
}
break;
case 22:
i = KMessageBox::Ok;
KMessageBox::informationList(0, "The following words have been found:",list);
break;
case 23:
i = KMessageBox::Ok;
KMessageBox::informationList(0, "The following words have been found:", list, "Search Words");
break;
case 24:
i = KMessageBox::Ok;
KMessageBox::informationList(0, "The follwoing words have been found:", list, QString(), "Search_Words");
break;
default:
return 0;
} // Switch
showResult(test, i);
} // Test
}
#if 0
//this is my sequence for testing messagebox layout:
KMessageBox::questionYesNoCancel(
0, "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd", "long",
KStandardGuiItem::saveAs(), KGuiItem("dsdddddd"), KStandardGuiItem::cancel()
);
KMessageBox::questionYesNoCancel(
0, "ddddddddddddddddddddd ddddddddddddddddddddd dddddddddd dddddddddd ddddddddddddddddddd dddddddddddd ddddddddd", "long wrap",
KStandardGuiItem::saveAs(), KGuiItem("dsdddddd"), KStandardGuiItem::cancel()
);
KMessageBox::questionYesNoCancel(
0, "dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd", "height",
KStandardGuiItem::saveAs(), KGuiItem("dsdddddd"), KStandardGuiItem::cancel()
);
QStringList strlist;
strlist<<"fgfghghghgfhgf"<<"fgfghghghgfhgf"<<"fgfgh\nghghgfhgf"<<"f\ngfg\nhg\nhghgfhgf"<<"fgfghghghgfhgf"<<"fgfghghghgfhgf"<<"fgfghghghgfhgf"<<"fgfghghghgfhgf"<<"fgfghghghgfhgf"<<"fgfghghghgfhgf"<<"fgfghghghgfhgf"<<"fgfghghghgfhgf"<<"fgfghghghgfhgf"<<"fgfghghghgfhgf"<<"fgfghghghgfhgf"<<"fgfghghghgfhgf"<<"fgfghghghgfhgf"<<"fgfghghghgfhgf"<<"fgfghghghgfhgf"<<"fgfghghghgfhgf";
KMessageBox::errorList(0,
"short\n",
strlist,"short");
KMessageBox::errorList(0,
"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd",
strlist,"short");
KMessageBox::errorList(0,
"ddddddddddddddddddddd ddddddddddddddddddddd dddddddddd dddddddddd ddddddddddddddddddd dddddddddddd ddddddddd",
strlist,"short");
KMessageBox::errorList(0,
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd",
strlist,"short");
KMessageBox::detailedError(0,
"sss",
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
);
KMessageBox::detailedError(0,
"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd",
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
);
KMessageBox::detailedError(0,
"ddddddddddddddddddddd ddddddddddddddddddddd dddddddddd dddddddddd ddddddddddddddddddd dddddddddddd ddddddddd",
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
);
KMessageBox::detailedError(0,
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd",
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
"dddddd\ndddddd\nddddddddd ddddd\ndddd\ndddddddddddd \ndddddddddd dddddddddd dd\nddddddddddd\ndd\ndddd dddd\ndddddddd ddd\ndd\ndddd"
);
#endif

View file

@ -1,113 +0,0 @@
/* This file is part of the KDE libraries
Copyright (C) 2006 Michaël Larouche <michael.larouche@kdemail.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; version 2
of the License.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "kmessagetest.h"
#include <QtCore/QString>
#include <QtGui/QMessageBox>
#include <QtGui/QPushButton>
#include <QtGui/QBoxLayout>
#include <QtGui/QInputDialog>
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kdebug.h>
#include <kmessage.h>
#include <kmessageboxmessagehandler.h>
#include <kpassivepopupmessagehandler.h>
KMessage_Test::KMessage_Test(QWidget *parent)
: QWidget(parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
QPushButton *buttonError = new QPushButton( QLatin1String("Show error"), this );
connect(buttonError, SIGNAL(clicked()), this, SLOT(showError()));
QPushButton *buttonFatal = new QPushButton( QLatin1String("Show fatal"), this );
connect(buttonFatal, SIGNAL(clicked()), this, SLOT(showFatal()));
QPushButton *buttonInformation = new QPushButton( QLatin1String("Show information"), this );
connect(buttonInformation, SIGNAL(clicked()), this, SLOT(showInformation()));
QPushButton *buttonSorry = new QPushButton( QLatin1String("Show sorry"), this );
connect(buttonSorry, SIGNAL(clicked()), this, SLOT(showSorry()));
QPushButton *buttonWarning = new QPushButton( QLatin1String("Show warning"), this );
connect(buttonWarning, SIGNAL(clicked()), this, SLOT(showWarning()));
mainLayout->addWidget( buttonError );
mainLayout->addWidget( buttonFatal );
mainLayout->addWidget( buttonInformation );
mainLayout->addWidget( buttonSorry );
mainLayout->addWidget( buttonWarning );
}
void KMessage_Test::showError()
{
KMessage::message( KMessage::Error, QLatin1String("Error: Destruction of the Death Star failed."), QLatin1String("KMessage_Test") );
}
void KMessage_Test::showFatal()
{
KMessage::message( KMessage::Fatal, QLatin1String("Fatal: You have turn to the dark side of the Force."), QLatin1String("KMessage_Test") );
}
void KMessage_Test::showInformation()
{
KMessage::message( KMessage::Information, QLatin1String("Info: This is a demonstration of the new KMessage API for kdelibs. It abstract the display of message and you can develop custom mesage handle for your application"), QLatin1String("KMessage_Test") );
}
void KMessage_Test::showSorry()
{
KMessage::message( KMessage::Sorry, QLatin1String("Sorry but our princess is in another castle."), QLatin1String("KMessage_Test") );
}
void KMessage_Test::showWarning()
{
KMessage::message( KMessage::Warning, QLatin1String("Warning: Loading failed. Your user experience will be affected."), QLatin1String("KMessage_Test") );
}
int main(int argc, char **argv)
{
KCmdLineArgs::init(argc, argv, "kmessagetest", 0, ki18n("KMessage_Test"), "version", ki18n("description"));
KApplication app;
app.setQuitOnLastWindowClosed( false );
KMessage_Test *mainWidget = new KMessage_Test;
mainWidget->setAttribute( static_cast<Qt::WidgetAttribute>(Qt::WA_DeleteOnClose | Qt::WA_QuitOnClose) );
bool ok = false;
const QStringList choices = QStringList() << "KMessageBox" << "KPassivePopup" << "Default (stderr)";
QString result = QInputDialog::getItem(0, "Select", "Select type of MessageHandler", choices, 0, false, &ok);
if(ok && result == "KMessageBox") {
KMessage::setMessageHandler( new KMessageBoxMessageHandler(mainWidget) );
} else if(ok && result == "KPassivePopup") {
KMessage::setMessageHandler( new KPassivePopupMessageHandler(mainWidget) );
}
mainWidget->show();
return app.exec();
}
#include "moc_kmessagetest.cpp"
// kate: space-indent on; indent-width 4; encoding utf-8; replace-tabs on;

View file

@ -1,40 +0,0 @@
/* This file is part of the KDE libraries
Copyright (C) 2006 Michaël Larouche <michael.larouche@kdemail.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; version 2
of the License.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KMESSAGETEST_H
#define KMESSAGETEST_H
#include <QtGui/QWidget>
class KMessage_Test : public QWidget
{
Q_OBJECT
public:
KMessage_Test(QWidget *parent = 0);
private slots:
void showError();
void showFatal();
void showInformation();
void showSorry();
void showWarning();
};
#endif
// kate: space-indent on; indent-width 4; encoding utf-8; replace-tabs on;

View file

@ -1,65 +0,0 @@
/* This file is part of the KDE libraries
*
* Copyright 2012 Aurélien Gâteau <agateau@kde.org>
*
* Based on test program by Dominik Haumann <dhaumann@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QApplication>
#include <QWidget>
#include <QVBoxLayout>
#include <QFrame>
#include <QCheckBox>
#include <kmessagewidget.h>
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QWidget* mainWindow = new QWidget();
QVBoxLayout* l = new QVBoxLayout(mainWindow);
KMessageWidget* mw = new KMessageWidget(mainWindow);
mw->setWordWrap(true);
mw->setText(
"Test KMessageWidget is properly sized when word-wrap is enabled by default."
);
// A frame to materialize the end of the KMessageWidget
QFrame* frame = new QFrame(mainWindow);
frame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
frame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QCheckBox* wordWrapCb = new QCheckBox("wordWrap", mainWindow);
wordWrapCb->setChecked(true);
QObject::connect(wordWrapCb, SIGNAL(toggled(bool)), mw, SLOT(setWordWrap(bool)));
QCheckBox* closeButtonCb = new QCheckBox("closeButton", mainWindow);
closeButtonCb->setChecked(true);
QObject::connect(closeButtonCb, SIGNAL(toggled(bool)), mw, SLOT(setCloseButtonVisible(bool)));
l->addWidget(wordWrapCb);
l->addWidget(closeButtonCb);
l->addWidget(mw);
l->addWidget(frame);
mainWindow->resize(400, 300);
mainWindow->show();
return app.exec();
delete mainWindow;
}
// kate: replace-tabs on;

View file

@ -1,49 +0,0 @@
/* This file is part of the KDE libraries
Copyright (C) 2007 Olivier Goffart <ogoffart at kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kapplication.h>
#include <knewpassworddialog.h>
#include <klocale.h>
#include <iostream>
int main( int argc, char *argv[] )
{
KAboutData about("KNewPasswordDialogTest", 0, ki18n("KNewPasswordDialogTest"), "1");
KCmdLineArgs::init(argc, argv, &about);
KApplication a;
KNewPasswordDialog dlg;
dlg.setPrompt(i18n("Enter a password for the test"));
if( dlg.exec() )
{
std::cout << "Entered password: " << (const char*)dlg.password().toLatin1() << std::endl;
return 0;
}
else
{
std::cout << "No password" << std::endl;
return -1;
}
}

View file

@ -1,37 +0,0 @@
/*
Copyright 2006 Aaron J. Seigo <aseigo@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <knotificationrestrictions.h>
#include <QtGui/QApplication>
#include <QtGui/QLabel>
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QLabel* mainWidget = new QLabel();
mainWidget->setText("You should see on console debug outpout for KNotificationRestrictions");
KNotificationRestrictions knr(KNotificationRestrictions::ScreenSaver, 0);
mainWidget->show();
return app.exec();
}

View file

@ -1,184 +0,0 @@
/*
* Tests the KNumInput Widget class
*
* Copyright 1999 by Dirk A. Mueller <dmuell@gmx.net>
*
* Licensed under the GNU General Public License version 2 or later
*/
#include <QtGui/QLayout>
#include <QtGui/QGroupBox>
#include <QtGui/QBoxLayout>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kapplication.h>
#include <knuminput.h>
#include "knuminputtest.h"
KApplication *a;
#include <kdebug.h>
void TopLevel::slotPrint( int n ) {
kDebug() << "slotPrint( " << n << " )";
}
void TopLevel::slotPrint( double n ) {
kDebug() << "slotPrint( " << n << " )";
}
#define conn(x,y) connect( x, SIGNAL(valueChanged(y)), SLOT(slotPrint(y)))
TopLevel::TopLevel(QWidget *parent)
: QWidget(parent)
{
setWindowTitle("KNumInput test application");
QBoxLayout* l = new QHBoxLayout(this);
l->setMargin(10);
QGroupBox* b1 = new QGroupBox("KIntNumInput", this);
b1->setLayout( new QVBoxLayout() );
i1 = new KIntNumInput(42,b1,10 /*"perc_no_slider"*/);
i1->setLabel("percent of usage (no slider)");
i1->setRange(0, 100, 5);
i1->setSliderEnabled(false);
conn(i1,int);
b1->layout()->addWidget(i1);
i2 = new KIntNumInput(42, b1);
i2->setLabel("percentage of usage (with slider)");
i2->setRange(0, 100, 5);
i2->setSuffix(" %");
i2->setSliderEnabled(true);
conn(i2,int);
b1->layout()->addWidget(i2);
i3 = new KIntNumInput(0xAF, b1, 16);
i3->setLabel("Hex byte (no slider)");
i3->setRange(0, 255, 1);
i3->setSliderEnabled(false);
i3->setSuffix(" (hex)");
conn(i3,int);
b1->layout()->addWidget(i3);
i4 = new KIntNumInput(0xfe, b1, 16);
i4->setLabel("Hex byte (with slider)");
i4->setRange(0, 255, 1);
i4->setSliderEnabled(true);
conn(i4,int);
b1->layout()->addWidget(i4);
i5 = new KIntNumInput(10, b1,10);
i5->setLabel("Width (keeps aspect ratio):");
i5->setRange(0, 200);
i5->setSliderEnabled(false);
i5->setReferencePoint( 5 );
b1->layout()->addWidget(i5);
i6 = new KIntNumInput(20, b1, 10);
i6->setLabel("Height (should be 2xWidth value):");
i6->setRange(0, 200);
i6->setReferencePoint( 10 );
i6->setSliderEnabled(false);
b1->layout()->addWidget(i6);
connect( i5, SIGNAL(relativeValueChanged(double)),
i6, SLOT(setRelativeValue(double)) );
connect( i6, SIGNAL(relativeValueChanged(double)),
i5, SLOT(setRelativeValue(double)) );
i7 = new KIntNumInput(0, b1, 10);
i7->setLabel("math test:", Qt::AlignVCenter|Qt::AlignLeft );
i7->setRange( 0, 200, 1 );
conn(i7,int);
b1->layout()->addWidget(i7);
i8 = new KIntNumInput(0, b1, 10);
i8->setLabel("plural test:", Qt::AlignVCenter|Qt::AlignLeft);
i8->setRange(0, 100, 1);
i8->setSuffix( ki18np( " suffix", " suffixes" ) );
b1->layout()->addWidget(i8);
l->addWidget(b1);
QGroupBox* b2 = new QGroupBox("KDoubleNumInput", this);
b2->setLayout(new QVBoxLayout());
d1 = new KDoubleNumInput(10,4.0,1,b2,2 /*, "perc_double_no_slider"*/);
d1->setLabel("percent of usage (no slider)", Qt::AlignTop | Qt::AlignRight);
d1->setRange(0.0, 4000.0, 0.01, false);
//d1->setValue(1.00000000000000000001);
conn(d1,double);
b2->layout()->addWidget(d1);
d2 = new KDoubleNumInput(0,20,0.422,b2,0.1,3/*, "perc_double_with_slider"*/);
d2->setLabel("percentage of usage (with slider)", Qt::AlignBottom | Qt::AlignLeft);
d2->setRange(0, 0.05, 0.005);
d2->setSuffix("%");
conn(d2,double);
b2->layout()->addWidget(d2);
d3 = new KDoubleNumInput(0,20,16.20,b2);
d3->setLabel("cash: ", Qt::AlignVCenter | Qt::AlignHCenter);
d3->setRange(0.10, 100, 0.1);
d3->setPrefix("p");
d3->setSuffix("$");
conn(d3,double);
b2->layout()->addWidget(d3);
d4 = new KDoubleNumInput(0,INT_MAX,INT_MAX/10000.0,b2,1,1);
// d4->setPrecision(3);
d4->setRange(double(INT_MIN+1)/1000.0, double(INT_MAX)/1000.0, 1);
d4->setLabel("math test: ", Qt::AlignVCenter | Qt::AlignLeft);
// d4->setFormat("%g");
conn(d4,double);
b2->layout()->addWidget(d4);
d5 = new KDoubleNumInput(double(INT_MIN+1)/1e9, double(INT_MAX-1)/1e9,
0.1, b2,0.001, 9 /*, "d5"*/);
d5->setLabel("math test 2: ", Qt::AlignVCenter|Qt::AlignLeft);
conn(d5,double);
b2->layout()->addWidget(d5);
d6 = new KDoubleNumInput(-10, 10, 0, b2,0.001, 3 /*, "d6"*/);
d6->setLabel("aspect ratio test with a negative ratio:");
d6->setReferencePoint( 1 );
b2->layout()->addWidget(d6);
d7 = new KDoubleNumInput(-30, 30, 0, b2,0.001, 3 /*, "d7"*/);
d7->setReferencePoint( -3 );
b2->layout()->addWidget(d7);
connect( d6, SIGNAL(relativeValueChanged(double)),
d7, SLOT(setRelativeValue(double)) );
connect( d7, SIGNAL(relativeValueChanged(double)),
d6, SLOT(setRelativeValue(double)) );
l->addWidget(b2);
}
int main( int argc, char ** argv )
{
KAboutData about("KNuminputTest", 0, ki18n("KNuminputTest"), "version");
KCmdLineArgs::init(argc, argv, &about);
a = new KApplication ( );
TopLevel *toplevel = new TopLevel(0);
toplevel->show();
a->exec();
}
#include "moc_knuminputtest.cpp"

View file

@ -1,30 +0,0 @@
/*
* Tests the KNumInput Widget class
*
* Copyright 1999 by Dirk A. Mueller <dmuell@gmx.net>
*
* Licensed under the GNU General Public License version 2 or later
*/
#ifndef KNUMINPUTTEST_H
#define KNUMINPUTTEST_H
#include <QtGui/QWidget>
class KIntNumInput;
class KDoubleNumInput;
class TopLevel : public QWidget
{
Q_OBJECT
public:
TopLevel( QWidget *parent=0 );
protected:
KIntNumInput* i1, *i2, *i3, *i4, *i5, *i6, *i7, *i8;
KDoubleNumInput* d1, *d2, *d3, *d4, *d5, *d6, *d7;
protected Q_SLOTS:
void slotPrint( int );
void slotPrint( double );
};
#endif

View file

@ -1,71 +0,0 @@
/*
This file is part of the KDE Libraries
Copyright (C) 2006 Tobias Koenig (tokoe@kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kapplication.h>
#include <QtGui/QBoxLayout>
#include <QtGui/QLabel>
#include "kpagedialogtest.h"
KPageDialogTest::KPageDialogTest( QWidget *parent )
: KPageDialog( parent )
{
setFaceType( Tabbed );
QWidget *page = new QWidget( this );
QHBoxLayout *layout = new QHBoxLayout( page );
QLabel *label = new QLabel( "first page" );
layout->addWidget( label );
addPage( page, "First" );
page = new QWidget( this );
layout = new QHBoxLayout( page );
label = new QLabel( "second page" );
label->setMinimumSize( 300, 200 );
layout->addWidget( label );
addPage( page, "Second" );
}
KPageDialogTest::~KPageDialogTest()
{
}
int main( int argc, char **argv )
{
KAboutData about("KPageDialogTest", 0, ki18n("KPageDialogTest"), "version");
KCmdLineArgs::init( argc, argv, &about );
KApplication app;
KPageDialogTest testDialog( 0 );
testDialog.exec();
return 0;
}
#include "moc_kpagedialogtest.cpp"

View file

@ -1,36 +0,0 @@
/*
This file is part of the KDE Libraries
Copyright (C) 2006 Tobias Koenig (tokoe@kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KPAGEDIALOGTEST_H
#define KPAGEDIALOGTEST_H
#include "kpagedialog.h"
class KPageDialogTest : public KPageDialog
{
Q_OBJECT
public:
KPageDialogTest( QWidget *parent = 0 );
~KPageDialogTest();
};
#endif

View file

@ -1,212 +0,0 @@
/*
This file is part of the KDE Libraries
Copyright (C) 2006 Tobias Koenig (tokoe@kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <QtGui/QGridLayout>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
#include <kaboutdata.h>
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kicon.h>
#include "kpagewidgetmodel.h"
#include "kpagewidgettest.h"
KPageWidgetTest::KPageWidgetTest( QWidget *parent )
: QWidget( parent )
{
QGridLayout *layout = new QGridLayout( this );
mWidget = new KPageWidget( this );
layout->addWidget( mWidget, 0, 0, 7, 1 );
connect( mWidget, SIGNAL(currentPageChanged(KPageWidgetItem*,KPageWidgetItem*)),
this, SLOT(currentPageChanged(KPageWidgetItem*,KPageWidgetItem*)) );
connect( mWidget, SIGNAL(pageToggled(KPageWidgetItem*,bool)),
this, SLOT(pageToggled(KPageWidgetItem*,bool)) );
int rowCount = 0;
QPushButton *button = new QPushButton( "Auto", this );
layout->addWidget( button, rowCount, 1 );
connect( button, SIGNAL(clicked()), this, SLOT(setAutoFace()) );
rowCount++;
button = new QPushButton( "Plain", this );
layout->addWidget( button, rowCount, 1 );
connect( button, SIGNAL(clicked()), this, SLOT(setPlainFace()) );
rowCount++;
button = new QPushButton( "List", this );
layout->addWidget( button, rowCount, 1 );
connect( button, SIGNAL(clicked()), this, SLOT(setListFace()) );
rowCount++;
button = new QPushButton( "Tree", this );
layout->addWidget( button, rowCount, 1 );
connect( button, SIGNAL(clicked()), this, SLOT(setTreeFace()) );
rowCount++;
button = new QPushButton( "Tabbed", this );
layout->addWidget( button, rowCount, 1 );
connect( button, SIGNAL(clicked()), this, SLOT(setTabbedFace()) );
rowCount++;
button = new QPushButton( "Add Page", this );
layout->addWidget( button, rowCount, 1 );
connect( button, SIGNAL(clicked()), this, SLOT(addPage()) );
rowCount++;
button = new QPushButton( "Add Sub Page", this );
layout->addWidget( button, rowCount, 1 );
connect( button, SIGNAL(clicked()), this, SLOT(addSubPage()) );
rowCount++;
button = new QPushButton( "Insert Page", this );
layout->addWidget( button, rowCount, 1 );
connect( button, SIGNAL(clicked()), this, SLOT(insertPage()) );
rowCount++;
button = new QPushButton( "Delete Page", this );
layout->addWidget( button, rowCount, 1 );
connect( button, SIGNAL(clicked()), this, SLOT(deletePage()) );
rowCount++;
KPageWidgetItem *item = mWidget->addPage( new QPushButton( "folder" ), "folder" );
item->setIcon( KIcon( "folder" ) );
item = mWidget->addSubPage( item, new QPushButton( "subfolder" ), "subfolder" );
item->setIcon( KIcon( "folder" ) );
item = mWidget->addPage( new QLabel( "second folder" ), "second folder" );
item->setIcon( KIcon( "folder" ) );
}
KPageWidgetTest::~KPageWidgetTest()
{
}
void KPageWidgetTest::setAutoFace()
{
mWidget->setFaceType( KPageWidget::Auto );
}
void KPageWidgetTest::setPlainFace()
{
mWidget->setFaceType( KPageWidget::Plain );
}
void KPageWidgetTest::setListFace()
{
mWidget->setFaceType( KPageWidget::List );
}
void KPageWidgetTest::setTreeFace()
{
mWidget->setFaceType( KPageWidget::Tree );
}
void KPageWidgetTest::setTabbedFace()
{
mWidget->setFaceType( KPageWidget::Tabbed );
}
void KPageWidgetTest::addPage()
{
static int counter = 0;
const QString title = QString( "dynamic folder %1" ).arg( QString::number( counter ) );
KPageWidgetItem *item = mWidget->addPage( new QPushButton( title ) , title );
item->setIcon( KIcon( "folder" ) );
item->setHeader( QString( "Header Test No. %1" ).arg( QString::number( counter ) ) );
item->setCheckable( true );
counter++;
}
void KPageWidgetTest::addSubPage()
{
static int counter = 0;
KPageWidgetItem *item = mWidget->currentPage();
if ( !item )
return;
const QString title = QString( "subfolder %1" ).arg( QString::number( counter ) );
item = mWidget->addSubPage( item, new QLabel( title ) , title );
item->setIcon( KIcon( "folder" ) );
counter++;
}
void KPageWidgetTest::insertPage()
{
static int counter = 0;
KPageWidgetItem *item = mWidget->currentPage();
if ( !item )
return;
const QString title = QString( "before folder %1" ).arg( QString::number( counter ) );
item = mWidget->insertPage( item, new QLabel( title ) , title );
item->setIcon( KIcon( "folder" ) );
counter++;
}
void KPageWidgetTest::deletePage()
{
KPageWidgetItem *item = mWidget->currentPage();
if ( item )
mWidget->removePage( item );
}
void KPageWidgetTest::currentPageChanged( KPageWidgetItem *current, KPageWidgetItem *before )
{
if ( current )
qDebug( "Current item: %s", qPrintable( current->name() ) );
else
qDebug( "No current item" );
if ( before )
qDebug( "Item before: %s", qPrintable( before->name() ) );
else
qDebug( "No item before" );
}
void KPageWidgetTest::pageToggled( KPageWidgetItem *item, bool checked )
{
qDebug( "Item %s changed check state to: %s", qPrintable( item->name() ), checked ? "checked" : "unchecked" );
}
int main( int argc, char **argv )
{
KAboutData about("KPageWidgetTest", 0, ki18n("KPageWidgetTest"), "version");
KCmdLineArgs::init( argc, argv, &about );
KApplication app;
KPageWidgetTest testWidget( 0 );
testWidget.show();
return app.exec();
}
#include "moc_kpagewidgettest.cpp"

View file

@ -1,56 +0,0 @@
/*
This file is part of the KDE Libraries
Copyright (C) 2006 Tobias Koenig (tokoe@kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KPAGEWIDGETTEST_H
#define KPAGEWIDGETTEST_H
#include <QtGui/QWidget>
#include "kpagewidget.h"
class KPageWidgetTest : public QWidget
{
Q_OBJECT
public:
KPageWidgetTest( QWidget *parent = 0 );
~KPageWidgetTest();
private Q_SLOTS:
void setAutoFace();
void setPlainFace();
void setListFace();
void setTreeFace();
void setTabbedFace();
void addPage();
void addSubPage();
void insertPage();
void deletePage();
void currentPageChanged( KPageWidgetItem*, KPageWidgetItem* );
void pageToggled( KPageWidgetItem*, bool );
private:
KPageWidget *mWidget;
};
#endif

View file

@ -1,88 +0,0 @@
#include "kpassivepopuptest.h"
#include "moc_kpassivepopuptest.cpp"
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kpassivepopup.h>
#include <QtGui/QPushButton>
#include <ksystemtrayicon.h>
QPushButton *pb;
QPushButton *pb2;
QPushButton *pb3;
QPushButton *pb4;
QPushButton *pb5;
KSystemTrayIcon *icon;
void Test::showIt()
{
KPassivePopup::message( "Hello World", pb );
}
void Test::showIt2()
{
KPassivePopup::message( "The caption is...", "Hello World", pb2 );
}
void Test::showIt3()
{
KPassivePopup *pop = new KPassivePopup( pb3->winId() );
pop->setView( "Caption", "test" );
pop->show();
}
void Test::showIt4()
{
KPassivePopup::message( KPassivePopup::Boxed, "The caption is...", "Hello World", pb4 );
}
void Test::showIt5()
{
KPassivePopup::message( KPassivePopup::Balloon, "The caption is...", "Hello World", pb5 );
}
void Test::showIt6(QSystemTrayIcon::ActivationReason reason)
{
if (reason == QSystemTrayIcon::Trigger)
KPassivePopup::message( "QSystemTrayIcon test", "Hello World", icon);
}
int main( int argc, char **argv )
{
KCmdLineArgs::init( argc, argv, "test", 0, ki18n("Test"), "1.0", ki18n("test app"));
KApplication app;
Test *t = new Test();
pb = new QPushButton();
pb->setText( "By taskbar entry" );
pb->connect( pb, SIGNAL(clicked()), t, SLOT(showIt()) );
pb->show();
pb2 = new QPushButton();
pb2->setText( "By taskbar entry (with caption)" );
pb2->connect( pb2, SIGNAL(clicked()), t, SLOT(showIt2()) );
pb2->show();
pb3 = new QPushButton();
pb3->setText( "By WinId" );
pb3->connect( pb3, SIGNAL(clicked()), t, SLOT(showIt3()) );
pb3->show();
pb4 = new QPushButton();
pb4->setText( "Boxed taskbar entry" );
pb4->connect( pb4, SIGNAL(clicked()), t, SLOT(showIt4()) );
pb4->show();
pb5 = new QPushButton();
pb5->setText( "Balloon taskbar entry" );
pb5->connect( pb5, SIGNAL(clicked()), t, SLOT(showIt5()) );
pb5->show();
icon = new KSystemTrayIcon();
icon->setIcon(icon->loadIcon("xorg"));
icon->connect( icon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), t, SLOT(showIt6(QSystemTrayIcon::ActivationReason)) );
icon->show();
return app.exec();
}

View file

@ -1,27 +0,0 @@
#ifndef KPASSIVEPOPUPTEST_H
#define KPASSIVEPOPUPTEST_H
#include <QtCore/QObject>
#include <QtGui/QSystemTrayIcon>
class Test : public QObject
{
Q_OBJECT
public:
Test() : QObject() {}
~Test() {}
public Q_SLOTS:
void showIt();
void showIt2();
void showIt3();
void showIt4();
void showIt5();
void showIt6(QSystemTrayIcon::ActivationReason);
};
#endif // KPASSIVEPOPUPTEST_H

View file

@ -1,98 +0,0 @@
/* This file is part of the KDE libraries
Copyright (C) 2007 Olivier Goffart <ogoffart at kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kapplication.h>
#include <kpassworddialog.h>
#include <klocale.h>
#include <iostream>
int main( int argc, char *argv[] )
{
KAboutData about("KNewPasswordDialogTest", 0, ki18n("KNewPasswordDialogTest"), "1");
KCmdLineArgs::init(argc, argv, &about);
KApplication a;
//step 1 simple password
{
KPasswordDialog dlg(0, KPasswordDialog::ShowKeepPassword);
dlg.setPrompt(i18n("This is a long prompt line. It is important it to be long so we can test the dialog does not get broken because of multiline labels. Please enter a password:"));
dlg.addCommentLine(i18n("This is a rather large left comment line") , i18n("Right part of the comment line has to be long too so be test the layouting works really ok. Please visit http://www.kde.org"));
if( dlg.exec() )
{
std::cout << "Entered password: " << (const char*)dlg.password().toLatin1() << std::endl;
}
else
{
std::cout << "No password" << std::endl;
return -1;
}
}
//step 2 readonly username
{
KPasswordDialog dlg(0, KPasswordDialog::ShowUsernameLine | KPasswordDialog::UsernameReadOnly);
dlg.setPrompt(i18n("Enter a password for the test"));
dlg.setUsername("konqui");
dlg.addCommentLine( i18n("Site") , i18n("http://www.kde.org") );
if( dlg.exec() )
{
std::cout << "Entered password: " << (const char*)dlg.password().toLatin1() << std::endl;
}
else
{
std::cout << "No password" << std::endl;
return -1;
}
}
//step 3 with some username preset
{
KPasswordDialog dlg(0, KPasswordDialog::ShowUsernameLine);
dlg.setPrompt(i18n("Enter a password for the test"));
QMap<QString,QString> logins;
logins.insert("konqui" , "foo");
logins.insert("watson" , "bar");
logins.insert("ogoffart" , "");
dlg.setKnownLogins(logins);
if( dlg.exec() )
{
std::cout << "Entered password: " << (const char*)dlg.password().toLatin1() << " for username " << (const char*)dlg.username().toAscii() <<std::endl;
}
else
{
std::cout << "No password" << std::endl;
return -1;
}
}
return 0;
}

View file

@ -1,30 +0,0 @@
#include "kpixmapregionselectordialog.h"
#include <QtGui/QPixmap>
#include <QtGui/QImage>
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <iostream>
int main(int argc, char**argv)
{
KCmdLineOptions options;
options.add("+file", ki18n("The image file to open"));
KCmdLineArgs::init(argc, argv, "test", 0, ki18n("test"), "1.0", ki18n("test"));
KCmdLineArgs::addCmdLineOptions( options );
KApplication app;
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if (args->count()!=1)
{
std::cout << "Usage: kpixmapregionselectordialogtest <imageFile>" << std::endl;
return 1;
}
QImage image=
KPixmapRegionSelectorDialog::getSelectedImage(QPixmap(args->arg(0)),100,100);
image.save("output.png", "PNG");
return 0;
}

View file

@ -1,105 +0,0 @@
#include "kpixmapsequenceoverlaypaintertest.h"
#include "kpixmapsequenceoverlaypainter.h"
#include <QGridLayout>
#include <QComboBox>
#include <QSpinBox>
#include <QVariant>
#include <QEvent>
#include <klocale.h>
#include <kapplication.h>
#include <kcmdlineargs.h>
Q_DECLARE_METATYPE(Qt::Alignment)
TestWidget::TestWidget()
: QWidget()
{
m_draggingLeft = false;
m_draggingRight = false;
m_draggingTop = false;
m_draggingBottom = false;
QGridLayout* layout = new QGridLayout(this);
m_widget = new QWidget(this);
m_alignment = new QComboBox(this);
m_offsetX = new QSpinBox(this);
m_offsetY = new QSpinBox(this);
layout->addWidget(m_widget, 0, 0, 1, 2);
layout->addWidget(m_alignment, 1, 0, 1, 2);
layout->addWidget(m_offsetX, 2, 0, 1, 1);
layout->addWidget(m_offsetY, 2, 1, 1, 1);
m_alignment->addItem("Center", QVariant::fromValue(Qt::Alignment(Qt::AlignCenter)));
m_alignment->addItem("Top-left", QVariant::fromValue(Qt::Alignment(Qt::AlignTop|Qt::AlignLeft)));
m_alignment->addItem("Top", QVariant::fromValue(Qt::Alignment(Qt::AlignTop|Qt::AlignHCenter)));
m_alignment->addItem("Top-right", QVariant::fromValue(Qt::Alignment(Qt::AlignTop|Qt::AlignRight)));
m_alignment->addItem("Right", QVariant::fromValue(Qt::Alignment(Qt::AlignRight|Qt::AlignVCenter)));
m_alignment->addItem("Bottom-right", QVariant::fromValue(Qt::Alignment(Qt::AlignRight|Qt::AlignBottom)));
m_alignment->addItem("Bottom", QVariant::fromValue(Qt::Alignment(Qt::AlignHCenter|Qt::AlignBottom)));
m_alignment->addItem("Bottom-left", QVariant::fromValue(Qt::Alignment(Qt::AlignLeft|Qt::AlignBottom)));
m_alignment->addItem("Left", QVariant::fromValue(Qt::Alignment(Qt::AlignLeft|Qt::AlignVCenter)));
connect(m_alignment, SIGNAL(activated(int)), this, SLOT(alignementChanged(int)));
connect(m_offsetX, SIGNAL(valueChanged(int)), this, SLOT(offsetChanged()));
connect(m_offsetY, SIGNAL(valueChanged(int)), this, SLOT(offsetChanged()));
m_painter = new KPixmapSequenceOverlayPainter(this);
m_painter->setWidget(m_widget);
m_painter->start();
}
TestWidget::~TestWidget()
{
}
void TestWidget::alignementChanged(int i)
{
m_painter->setAlignment(m_alignment->itemData(i).value<Qt::Alignment>());
}
void TestWidget::offsetChanged()
{
m_painter->setOffset(QPoint(m_offsetX->value(), m_offsetY->value()));
}
bool TestWidget::eventFilter(QObject* o, QEvent* e)
{
if(o == m_widget) {
if(e->type() == QEvent::Paint) {
}
else if(e->type() == QEvent::MouseButtonPress) {
}
else if(e->type() == QEvent::MouseButtonRelease) {
}
else if(e->type() == QEvent::MouseMove) {
}
}
return QWidget::eventFilter(o, e);
}
/* --- MAIN -----------------------*/
int main(int argc, char **argv)
{
KCmdLineArgs::init( argc, argv, "test", 0, ki18n("Test"), "1.0", ki18n("test app"));
TestWidget *window;
KApplication testapp;
window = new TestWidget();
window->show();
return testapp.exec();
}
#include "moc_kpixmapsequenceoverlaypaintertest.cpp"

View file

@ -1,39 +0,0 @@
#ifndef _K_PIXMAPSEQUENCE_OVERLAY_PAINTER_TEST_H_
#define _K_PIXMAPSEQUENCE_OVERLAY_PAINTER_TEST_H_
#include <QWidget>
class KPixmapSequenceOverlayPainter;
#include <QComboBox>
#include <QSpinBox>
#include <QEvent>
class TestWidget : public QWidget
{
Q_OBJECT
public:
TestWidget();
~TestWidget();
bool eventFilter(QObject*, QEvent*);
private Q_SLOTS:
void alignementChanged(int);
void offsetChanged();
private:
KPixmapSequenceOverlayPainter* m_painter;
QWidget* m_widget;
QComboBox* m_alignment;
QSpinBox* m_offsetX;
QSpinBox* m_offsetY;
bool m_draggingLeft;
bool m_draggingRight;
bool m_draggingTop;
bool m_draggingBottom;
};
#endif

View file

@ -1,46 +0,0 @@
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <QtGui/QWidget>
#include <QtGui/QCursor>
#include <QtGui/qevent.h>
#include <QtGui/QPainter>
#include "kmenu.h"
class DemoWidget : public QWidget {
private:
KMenu *menu;
void mousePressEvent(QMouseEvent *)
{
menu->popup(QCursor::pos());
}
void paintEvent(QPaintEvent *)
{
QPainter paint(this);
paint.drawText(32, 32, "Press a Mouse Button!");
}
public:
DemoWidget() : QWidget()
{
menu = new KMenu("Popup Menu:");
menu->addAction( "Item1" );
menu->addAction( "Item2" );
menu->addSeparator();
QAction *a = new QAction( "Quit", this );
menu->addAction( a );
connect( a, SIGNAL(triggered()), qApp, SLOT(quit()));
}
};
int main(int argc, char **argv)
{
KCmdLineArgs::init( argc, argv, "test", 0, ki18n("Test"), "1.0", ki18n("test app"));
KApplication app;
DemoWidget w;
w.setFont(QFont("helvetica", 12, QFont::Bold));
w.show();
return app.exec();
}

View file

@ -1,53 +0,0 @@
#include <QtGui/QWidget>
#include <QtCore/QEvent>
#include <QtGui/QCheckBox>
#include <kapplication.h>
#include <kcmdlineargs.h>
#include "kprogressdialog.h"
class MyWidget : public QWidget {
public:
MyWidget() : QWidget()
{
setFixedSize(200, 80);
Cancelled = new QCheckBox("Cancelled", this);
Progress = new KProgressDialog(this);
startTimer(50);
Progress->setLabelText("label text");
Progress->setAllowCancel(false);
Progress->showCancelButton(true);
Progress->setButtonText("button text");
Progress->setAutoClose(false);
steps = 300;
Progress->progressBar()->setRange(0, steps);
}
private:
KProgressDialog *Progress;
QCheckBox *Cancelled;
int steps;
void timerEvent(QTimerEvent *);
};
void MyWidget::timerEvent(QTimerEvent *)
{
Progress->progressBar()->setValue(Progress->progressBar()->value()+1);
Cancelled->setCheckState(Progress->wasCancelled() ? Qt::Checked : Qt::Unchecked);
}
int main(int argc, char *argv[])
{
KCmdLineArgs::init( argc, argv, "test", 0, ki18n("Test"), "1.0", ki18n("test app"));
KApplication app;
MyWidget w;
w.show();
int ret = app.exec();
return ret;
}

View file

@ -1,391 +0,0 @@
#include <kcmdlineargs.h>
#include "krulertest.h"
#include "kruler.h"
#include <QtGui/QLayout>
#include <QtGui/QLabel>
#include <QtGui/qevent.h>
#include <QtGui/QGroupBox>
#include <QtGui/QButtonGroup>
/*
void
MyCheckBox::mouseReleaseEvent(QMouseEvent *e )
{
QButton::mouseReleaseEvent(e);
if ();
}
*/
MouseWidget::MouseWidget( QWidget *parent )
: QFrame(parent)
{
}
void
MouseWidget::mousePressEvent( QMouseEvent *e )
{
mouseButtonDown = true;
emit newXPos(e->x());
emit newYPos(e->y());
}
void
MouseWidget::mouseReleaseEvent( QMouseEvent * )
{ mouseButtonDown = false; }
void
MouseWidget::mouseMoveEvent( QMouseEvent *e )
{
if (mouseButtonDown) {
emit newXPos(e->x());
emit newYPos(e->y());
}
}
void
MouseWidget::resizeEvent( QResizeEvent *r )
{
emit newWidth(r->size().width());
emit newHeight(r->size().height());
}
KRulerTest::KRulerTest()
: KMainWindow(0)
{
mainframe = new QFrame(this);
layout = new QGridLayout(mainframe);
miniwidget = new QFrame(mainframe);
miniwidget->setFrameStyle(QFrame::WinPanel | QFrame::Raised);
bigwidget = new MouseWidget(mainframe);
bigwidget->setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
// QRect bwrect = bigwidget->frameRect();
// qDebug("big rect: top%i left%i bottom%i right%i",
// bwrect.top(), bwrect.left(), bwrect.bottom(), bwrect.right());
hruler = new KRuler(Qt::Horizontal, mainframe);
// hruler->setRange( bwrect.left(), bwrect.right() );
hruler->setRange( 0, 1000 );
// hruler->setOffset( bwrect.left() - bigwidget->frameRect().left() );
hruler->setOffset( 0 );
vruler = new KRuler(Qt::Vertical, mainframe);
vruler->setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
vruler->setOffset( 0 );
vruler->setRange( 0, 1000 );
connect( bigwidget, SIGNAL(newXPos(int)),
hruler, SLOT(slotNewValue(int)) );
connect( bigwidget, SIGNAL(newYPos(int)),
vruler, SLOT(slotNewValue(int)) );
connect( bigwidget, SIGNAL(newWidth(int)),
SLOT(slotNewWidth(int)) );
connect( bigwidget, SIGNAL(newHeight(int)),
SLOT(slotNewHeight(int)) );
layout->addWidget(miniwidget, 0, 0);
layout->addWidget(hruler, 0, 1);
layout->addWidget(vruler, 1, 0);
layout->addWidget(bigwidget, 1, 1);
mouse_message = new QLabel("Press and hold mouse button\nfor pointer movement", bigwidget);
mouse_message->adjustSize();
mouse_message->move(4,4);
showMarks = new QGroupBox("Show which marks ?", bigwidget);
showMarks->setFixedSize(140, 160);
showMarks->move(330,4);
showTM = new QCheckBox("show tiny marks", showMarks);
showTM->adjustSize();
showTM->move(5,15);
showTM->setChecked(true);
connect(showTM, SIGNAL(toggled(bool)), SLOT(slotSetTinyMarks(bool)) );
showLM = new QCheckBox("show little marks", showMarks);
showLM->adjustSize();
showLM->move(5,35);
showLM->setChecked(true);
connect(showLM, SIGNAL(toggled(bool)), SLOT(slotSetLittleMarks(bool)) );
showMM = new QCheckBox("show medium marks", showMarks);
showMM->adjustSize();
showMM->move(5,55);
showMM->setChecked(true);
connect(showMM, SIGNAL(toggled(bool)), SLOT(slotSetMediumMarks(bool)) );
showBM = new QCheckBox("show big marks", showMarks);
showBM->adjustSize();
showBM->move(5,75);
showBM->setChecked(true);
connect(showBM, SIGNAL(toggled(bool)), SLOT(slotSetBigMarks(bool)) );
showEM = new QCheckBox("show end marks", showMarks);
showEM->adjustSize();
showEM->move(5,95);
showEM->setChecked(true);
connect(showEM, SIGNAL(toggled(bool)), SLOT(slotSetEndMarks(bool)) );
showPT = new QCheckBox("show ruler pointer", showMarks);
showPT->adjustSize();
showPT->move(5,115);
showPT->setChecked(true);
connect(showPT, SIGNAL(toggled(bool)), SLOT(slotSetRulerPointer(bool)) );
fixLen = new QCheckBox("fix ruler length", showMarks);
fixLen->adjustSize();
fixLen->move(5,135);
fixLen->setChecked(true);
connect(fixLen, SIGNAL(toggled(bool)), SLOT(slotFixRulerLength(bool)) );
connect(fixLen, SIGNAL(toggled(bool)), SLOT(slotCheckLength(bool)) );
lineEdit = new QGroupBox("Value of begin/end", bigwidget);
lineEdit->setFixedSize(140, 80);
lineEdit->move(330,4+160);
beginMark = new KIntNumInput(0, lineEdit);
beginMark->setRange(-1000, 1000);
beginMark->setSliderEnabled(false);
beginMark->move(5, 15);
beginMark->setFixedSize(beginMark->sizeHint());
connect(beginMark, SIGNAL(valueChanged(int)),
hruler, SLOT(slotNewOffset(int)) );
connect(beginMark, SIGNAL(valueChanged(int)),
vruler, SLOT(slotNewOffset(int)) );
endMark = new KIntNumInput(0, lineEdit);
endMark->setRange(-1000, 1000);
endMark->setSliderEnabled(false);
endMark->move(5, 35);
endMark->setFixedSize(endMark->sizeHint());
connect(endMark, SIGNAL(valueChanged(int)),
hruler, SLOT(slotEndOffset(int)) );
connect(endMark, SIGNAL(valueChanged(int)),
vruler, SLOT(slotEndOffset(int)) );
lengthInput = new KIntNumInput(0, lineEdit);
lengthInput->setRange(-1000, 1000);
lengthInput->setSliderEnabled(false);
lengthInput->move(5, 55);
lengthInput->setFixedSize(lengthInput->sizeHint());
connect(lengthInput, SIGNAL(valueChanged(int)),
hruler, SLOT(slotEndOffset(int)) );
connect(lengthInput, SIGNAL(valueChanged(int)),
vruler, SLOT(slotEndOffset(int)) );
vertrot = new QGroupBox("Value of rotate translate for Vert.", bigwidget);
vertrot->setFixedSize(140, 80);
vertrot->move(330,4+160+80+4);
transX = new KDoubleNumInput(vertrot);
transX->setValue(0.0);
transX->setRange(-1000, 1000, 1, false);
transX->move(5, 15);
transX->setFixedSize(transX->sizeHint());
//transX->setLabel("transx", AlignLeft);
connect(transX, SIGNAL(valueChanged(double)),
SLOT(slotSetXTrans(double)) );
transY = new KDoubleNumInput(vertrot);
transY->setValue(-12.0);
transY->setRange(-1000, 1000, 1, false);
transY->move(5, 35);
transY->setFixedSize(transY->sizeHint());
//transY->setLabel("transy", AlignLeft);
connect(transY, SIGNAL(valueChanged(double)),
SLOT(slotSetYTrans(double)) );
rotV = new KDoubleNumInput(vertrot);
rotV->setValue(90.0);
rotV->setRange(-1000, 1000, 1, false);
rotV->move(5, 55);
rotV->setFixedSize(rotV->sizeHint());
//rotV->setLabel("rot", AlignLeft);
connect(rotV, SIGNAL(valueChanged(double)),
SLOT(slotSetRotate(double)) );
metricstyle = new QGroupBox("metric styles", bigwidget);
QButtonGroup* metricstyleButtons = new QButtonGroup(bigwidget);
metricstyle->setFixedSize(100, 120);
metricstyle->move(330-110,4);
pixelmetric = new QRadioButton("pixel", metricstyle);
pixelmetric->adjustSize();
pixelmetric->move(5,15);
metricstyleButtons->addButton(pixelmetric, (int)KRuler::Pixel);
inchmetric = new QRadioButton("inch", metricstyle);
inchmetric->adjustSize();
inchmetric->move(5,35);
metricstyleButtons->addButton(inchmetric, (int)KRuler::Inch);
mmmetric = new QRadioButton("millimeter", metricstyle);
mmmetric->adjustSize();
mmmetric->move(5,55);
metricstyleButtons->addButton(mmmetric, (int)KRuler::Millimetres);
cmmetric = new QRadioButton("centimeter", metricstyle);
cmmetric->adjustSize();
cmmetric->move(5,75);
metricstyleButtons->addButton(cmmetric, (int)KRuler::Centimetres);
mmetric = new QRadioButton("meter", metricstyle);
mmetric->adjustSize();
mmetric->move(5,95);
metricstyleButtons->addButton(mmetric, (int)KRuler::Metres);
connect ( metricstyleButtons, SIGNAL(buttonClicked(int)), SLOT(slotSetMStyle(int)) );
setCentralWidget(mainframe);
slotUpdateShowMarks();
}
KRulerTest::~KRulerTest()
{
delete layout;
delete hruler;
delete vruler;
delete miniwidget;
delete bigwidget;
delete mainframe;
}
void
KRulerTest::slotNewWidth(int width)
{
hruler->setMaximum(width);
}
void
KRulerTest::slotNewHeight(int height)
{
vruler->setMaximum(height);
}
void
KRulerTest::slotSetTinyMarks(bool set)
{
hruler->setShowTinyMarks(set);
vruler->setShowTinyMarks(set);
}
void
KRulerTest::slotSetLittleMarks(bool set)
{
hruler->setShowLittleMarks(set);
vruler->setShowLittleMarks(set);
}
void
KRulerTest::slotSetMediumMarks(bool set)
{
hruler->setShowMediumMarks(set);
vruler->setShowMediumMarks(set);
}
void
KRulerTest::slotSetBigMarks(bool set)
{
hruler->setShowBigMarks(set);
vruler->setShowBigMarks(set);
}
void
KRulerTest::slotSetEndMarks(bool set)
{
hruler->setShowEndMarks(set);
vruler->setShowEndMarks(set);
}
void
KRulerTest::slotSetRulerPointer(bool set)
{
hruler->setShowPointer(set);
vruler->setShowPointer(set);
}
void
KRulerTest::slotSetRulerLength(int len)
{
hruler->setLength(len);
vruler->setLength(len);
}
void
KRulerTest::slotFixRulerLength(bool fix)
{
hruler->setLengthFixed(fix);
vruler->setLengthFixed(fix);
}
void
KRulerTest::slotSetMStyle(int style)
{
hruler->setRulerMetricStyle((KRuler::MetricStyle)style);
vruler->setRulerMetricStyle((KRuler::MetricStyle)style);
slotUpdateShowMarks();
}
void
KRulerTest::slotUpdateShowMarks()
{
showTM->setChecked(hruler->showTinyMarks());
showLM->setChecked(hruler->showLittleMarks());
showMM->setChecked(hruler->showMediumMarks());
showBM->setChecked(hruler->showBigMarks());
showEM->setChecked(hruler->showEndMarks());
}
void
KRulerTest::slotCheckLength(bool fixlen)
{
Q_UNUSED(fixlen);
beginMark->setValue(hruler->offset());
endMark->setValue(hruler->endOffset());
lengthInput->setValue(hruler->length());
}
void
KRulerTest::slotSetRotate(double d)
{
Q_UNUSED(d);
#ifdef KRULER_ROTATE_TEST
vruler->rotate = d;
vruler->update();
//debug("rotate %.1f", d);
#endif
}
void
KRulerTest::slotSetXTrans(double d)
{
Q_UNUSED(d);
#ifdef KRULER_ROTATE_TEST
vruler->xtrans = d;
vruler->update();
//debug("trans x %.1f", d);
#endif
}
void
KRulerTest::slotSetYTrans(double d)
{
Q_UNUSED(d);
#ifdef KRULER_ROTATE_TEST
vruler->ytrans = d;
vruler->update();
//debug("trans y %.1f", d);
#endif
}
/* --- MAIN -----------------------*/
int main(int argc, char **argv)
{
KCmdLineArgs::init( argc, argv, "test", 0, ki18n("Test"), "1.0", ki18n("test app"));
KApplication *testapp;
KRulerTest *window;
testapp = new KApplication;
testapp->setFont(QFont("Helvetica",12));
window = new KRulerTest();
window->setCaption("KRulerTest");
window->show();
return testapp->exec();
}
#include "moc_krulertest.cpp"

View file

@ -1,88 +0,0 @@
/* -*- c++ -*- */
#ifndef KRULERTEST_H
#define KRULERTEST_H
#include <QtGui/QCheckBox>
#include <QtGui/QRadioButton>
#include <QtGui/QFrame>
#include <kapplication.h>
#include <kmainwindow.h>
#include <knuminput.h>
class KRuler;
#include <QWidget>
#include <QGridLayout>
#include <QCheckBox>
#include <QGroupBox>
#include <QLabel>
class MouseWidget : public QFrame
{
Q_OBJECT
public:
MouseWidget( QWidget *parent=0 );
Q_SIGNALS:
void newXPos(int);
void newYPos(int);
void newWidth(int);
void newHeight(int);
protected:
virtual void mousePressEvent ( QMouseEvent * );
virtual void mouseReleaseEvent ( QMouseEvent * );
virtual void mouseMoveEvent ( QMouseEvent * );
virtual void resizeEvent ( QResizeEvent * );
private:
bool mouseButtonDown;
};
class KRulerTest : public KMainWindow
{
Q_OBJECT
public:
KRulerTest();
~KRulerTest();
private Q_SLOTS:
void slotNewWidth(int);
void slotNewHeight(int);
void slotSetTinyMarks(bool);
void slotSetLittleMarks(bool);
void slotSetMediumMarks(bool);
void slotSetBigMarks(bool);
void slotSetEndMarks(bool);
void slotSetRulerPointer(bool);
void slotSetRulerLength(int);
void slotFixRulerLength(bool);
void slotSetMStyle(int);
void slotUpdateShowMarks();
void slotCheckLength(bool);
void slotSetRotate(double);
void slotSetXTrans(double);
void slotSetYTrans(double);
private:
KRuler *hruler, *vruler;
QGridLayout *layout;
QFrame *miniwidget, *bigwidget, *mainframe;
QLabel *mouse_message;
QGroupBox *showMarks, *lineEdit, *vertrot;
QCheckBox *showTM, *showLM, *showMM, *showBM, *showEM, *showPT, *fixLen;
KIntNumInput *beginMark, *endMark, *lengthInput;
KDoubleNumInput *transX, *transY, *rotV;
QGroupBox *metricstyle;
QRadioButton *pixelmetric, *inchmetric, *mmmetric, *cmmetric, *mmetric;
};
#endif

View file

@ -1,118 +0,0 @@
/*
Copyright 2006 Hamish Rodda <rodda@kde.org>
Copyright 2006 Simon Hausmann <hausmann@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <QtGui/QToolBar>
#include <QtGui/QMenuBar>
#include <kcmdlineargs.h>
#include <kapplication.h>
#include <kdebug.h>
#include "kselectactiontest.h"
#include <kselectaction.h>
#include <kactioncollection.h>
int main( int argc, char **argv )
{
KCmdLineArgs::init( argc, argv, "kselectactiontest", 0, ki18n("KSelectActionTest"), "1.0", ki18n("kselectaction test app"));
KApplication app;
SelectActionTest* test = new SelectActionTest;
test->show();
return app.exec();
}
SelectActionTest::SelectActionTest(QWidget *parent)
: KXmlGuiWindow(parent)
, m_comboSelect(new KSelectAction("Combo Selection", this))
, m_buttonSelect(new KSelectAction("Button Selection", this))
{
actionCollection()->addAction("combo", m_comboSelect);
actionCollection()->addAction("button", m_buttonSelect);
for (int i = 0; i < 7; ++i) {
QAction* action = m_comboSelect->addAction(QString ("Combo Action %1").arg(i));
connect(action, SIGNAL(triggered(bool)), SLOT(slotActionTriggered(bool)));
action = m_buttonSelect->addAction(QString ("Action %1").arg(i));
connect(action, SIGNAL(triggered(bool)), SLOT(slotActionTriggered(bool)));
}
m_comboSelect->setToolBarMode(KSelectAction::ComboBoxMode);
m_comboSelect->setWhatsThis("What's this?");
connect(m_comboSelect, SIGNAL(triggered(QAction*)), SLOT(triggered(QAction*)));
connect(m_comboSelect, SIGNAL(triggered(int)), SLOT(triggered(int)));
connect(m_comboSelect, SIGNAL(triggered(QString)), SLOT(triggered(QString)));
m_buttonSelect->setToolBarMode(KSelectAction::MenuMode);
m_buttonSelect->setWhatsThis("What's this?");
connect(m_buttonSelect, SIGNAL(triggered(QAction*)), SLOT(triggered(QAction*)));
connect(m_buttonSelect, SIGNAL(triggered(int)), SLOT(triggered(int)));
connect(m_buttonSelect, SIGNAL(triggered(QString)), SLOT(triggered(QString)));
menuBar()->addAction(m_comboSelect);
menuBar()->addAction(m_buttonSelect);
menuBar()->addAction("Add an action", this, SLOT(addAction()));
menuBar()->addAction("Remove an action", this, SLOT(removeAction()));
QToolBar* toolBar = addToolBar("Test");
toolBar->addAction(m_comboSelect);
toolBar->addAction(m_buttonSelect);
}
void SelectActionTest::triggered(QAction* action)
{
kDebug() << action;
}
void SelectActionTest::triggered(int index)
{
kDebug() << index;
}
void SelectActionTest::triggered(const QString& text)
{
kDebug() << '"' << text << '"';
}
void SelectActionTest::addAction()
{
QAction* action = m_comboSelect->addAction(QString ("Combo Action %1").arg(m_comboSelect->actions().count()));
connect(action, SIGNAL(triggered(bool)), SLOT(slotActionTriggered(bool)));
action = m_buttonSelect->addAction(QString ("Action %1").arg(m_buttonSelect->actions().count()));
connect(action, SIGNAL(triggered(bool)), SLOT(slotActionTriggered(bool)));
}
void SelectActionTest::removeAction()
{
if (!m_comboSelect->actions().isEmpty())
m_comboSelect->removeAction(m_comboSelect->actions().last());
if (!m_buttonSelect->actions().isEmpty())
m_buttonSelect->removeAction(m_buttonSelect->actions().last());
}
void SelectActionTest::slotActionTriggered(bool state)
{
kDebug() << sender() << " state " << state;
}
#include "moc_kselectactiontest.cpp"

View file

@ -1,49 +0,0 @@
/*
Copyright 2006 Hamish Rodda <rodda@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KSELECTACTION_TEST_H
#define KSELECTACTION_TEST_H
#include <kxmlguiwindow.h>
class KSelectAction;
class SelectActionTest : public KXmlGuiWindow
{
Q_OBJECT
public:
SelectActionTest(QWidget* parent = 0);
public Q_SLOTS:
void triggered(QAction* action);
void triggered(int index);
void triggered(const QString& text);
void slotActionTriggered(bool state);
void addAction();
void removeAction();
private:
KSelectAction* m_comboSelect;
KSelectAction* m_buttonSelect;
};
#endif

View file

@ -1,50 +0,0 @@
/*
* Copyright (C) 1997 Michael Roth <mroth@wirlweb.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include <QtGui/QApplication>
#include <QtGui/QLayout>
#include <QtGui/QWidget>
#include <QtGui/QBoxLayout>
#include "kseparator.h"
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QWidget toplevel;
QBoxLayout *mainbox = new QBoxLayout(QBoxLayout::TopToBottom,&toplevel);
mainbox->setMargin(10);
KSeparator *sep1 = new KSeparator( Qt::Vertical, &toplevel );
mainbox->addWidget(sep1);
KSeparator *sep2 = new KSeparator( Qt::Horizontal, &toplevel );
mainbox->addWidget(sep2);
mainbox->activate();
toplevel.show();
return app.exec();
}

View file

@ -1,27 +0,0 @@
#include "ksqueezedtextlabel.h"
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kvbox.h>
int main( int argc, char **argv )
{
KCmdLineArgs::init(argc, argv, "test", 0, ki18n("Test"), "1.0", ki18n("test app"));
KApplication app;
KVBox* box = new KVBox();
KSqueezedTextLabel *l = new KSqueezedTextLabel( "This is a rather long string", box);
Q_UNUSED(*l);
l = new KSqueezedTextLabel( "This is another long string, selectable by mouse", box );
l->setTextElideMode( Qt::ElideRight );
l->setTextInteractionFlags(Qt::TextSelectableByMouse);
KSqueezedTextLabel* urlLabel = new KSqueezedTextLabel("http://www.example.com/this/url/is/selectable/by/mouse", box);
urlLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
new QLabel("This is a normal QLabel", box);
QLabel* selectableLabel = new QLabel("This is a normal QLabel, selectable by mouse", box);
selectableLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
box->show();
return app.exec();
}

View file

@ -1,121 +0,0 @@
#include <QtGui/QWidget>
#include <QtGui/QMessageBox>
#include <QtGui/QTextEdit>
#include <QtGui/QPixmap>
#include <QtGui/QCursor>
#include <stdlib.h>
#include "kstatusbar.h"
#include <kcmdlineargs.h>
#include <kapplication.h>
#include <kmainwindow.h>
#include "kstatusbartest.h"
testWindow::testWindow (QWidget *)
: KXmlGuiWindow (0)
{
// Setup Menus
menuBar = new QMenuBar (this);
fileMenu = new QMenu;
menuBar->addAction ( "&File" );
QAction *action = fileMenu->addAction("&Exit");
action->setShortcut( Qt::ALT + Qt::Key_Q );
connect( action, SIGNAL(triggered()), KApplication::kApplication(), SLOT(quit()) );
statusbar = new KStatusBar (this);
statusbar->insertItem("Zoom: XXXX", 0);
statusbar->insertItem("XXX", 1);
statusbar->insertItem("Line: XXXXX", 2);
statusbar->changeItem("Zoom: 100%", 0);
statusbar->changeItem("INS", 1);
insert = true;
statusbar->changeItem("Line: 13567", 2);
connect (statusbar, SIGNAL(pressed(int)), this, SLOT(slotPress(int)));
connect (statusbar, SIGNAL(released(int)), this, SLOT(slotClick(int)));
widget = new QTextEdit (this);
setCentralWidget(widget);
setCaption( KGlobal::caption() );
smenu = new QMenu;
smenu->addAction("50%");
smenu->addAction("75%");
smenu->addAction("100%");
smenu->addAction("150%");
smenu->addAction("200%");
smenu->addAction("400%");
smenu->addAction("oo%");
connect (smenu, SIGNAL(triggered(QAction*)), this, SLOT(slotMenu(QAction*)));
}
void testWindow::slotClick(int id)
{
switch (id)
{
case 0:
break;
case 1:
if (insert == true)
{
insert = false;
statusbar->changeItem("OVR", 1);
}
else
{
insert = true;
statusbar->changeItem("INS", 1);
}
break;
case 2:
QMessageBox::information(0, "Go to line", "Enter line number:");
statusbar->changeItem("16543", 2);
break;
}
}
void testWindow::slotPress(int id)
{
if (id == 0)
smenu->popup(QCursor::pos()); // This popup should understand keys up and down
}
void testWindow::slotMenu(QAction *action)
{
QString s = "Zoom: ";
s.append (action->text());
statusbar->changeItem(s,0);
}
testWindow::~testWindow ()
{
// I would delete toolbars here, but there are none
delete statusbar;
}
int main( int argc, char *argv[] )
{
KCmdLineArgs::init( argc, argv, "test", 0, ki18n("Test"), "1.0", ki18n("test app"));
KApplication *myApp = new KApplication;
testWindow *test = new testWindow;
test->show();
test->resize(test->width(), test->height()); // I really really really dunno why it doesn't show
int ret = myApp->exec();
delete test;
return ret;
}
#include "moc_kstatusbartest.cpp"

View file

@ -1,31 +0,0 @@
#ifndef TEST_KSTATUSBAR_H
#define TEST_KSTATUSBAR_H
#include <kstatusbar.h>
#include <kxmlguiwindow.h>
#include <QMenuBar>
#include <QTextEdit>
class testWindow : public KXmlGuiWindow
{
Q_OBJECT
public:
testWindow (QWidget *parent=0);
~testWindow ();
public Q_SLOTS:
void slotPress(int i);
void slotClick(int i);
void slotMenu(QAction*);
protected:
QMenu *fileMenu;
QMenu *smenu;
QMenuBar *menuBar;
KStatusBar *statusbar;
bool insert;
QTextEdit *widget;
};
#endif

View file

@ -1,112 +0,0 @@
/* This file is part of the KDE libraries
Copyright 2009 by Marco Martin <notmart@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License (LGPL) as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later
version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "kstatusnotifieritemtest.h"
#include "notifications/kstatusnotifieritem.h"
#include <QDateTime>
#include <QLabel>
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kiconloader.h>
#include <kdebug.h>
#include <kaboutdata.h>
#include <kmenu.h>
#include <kicon.h>
KStatusNotifierItemTest::KStatusNotifierItemTest(QObject *parent, KStatusNotifierItem *tray)
: QObject(parent)
{
KMenu *menu = tray->contextMenu();
m_tray = tray;
QAction *needsAttention = new QAction("Set needs attention", menu);
QAction *active = new QAction("Set active", menu);
QAction *passive = new QAction("Set passive", menu);
menu->addAction(needsAttention);
menu->addAction(active);
menu->addAction(passive);
connect(needsAttention, SIGNAL(triggered()), this, SLOT(setNeedsAttention()));
connect(active, SIGNAL(triggered()), this, SLOT(setActive()));
connect(passive, SIGNAL(triggered()), this, SLOT(setPassive()));
}
void KStatusNotifierItemTest::setNeedsAttention()
{
kDebug()<<"Asking for attention";
m_tray->showMessage("message test", "Test of the new systemtray notifications wrapper", "konqueror", 3000);
m_tray->setStatus(KStatusNotifierItem::NeedsAttention);
}
void KStatusNotifierItemTest::setActive()
{
kDebug()<<"Systray icon in active state";
m_tray->setStatus(KStatusNotifierItem::Active);
}
void KStatusNotifierItemTest::setPassive()
{
kDebug()<<"Systray icon in passive state";
m_tray->setStatus(KStatusNotifierItem::Passive);
}
int main(int argc, char **argv)
{
KAboutData aboutData( "kstatusnotifieritemtest", 0 , ki18n("KStatusNotifierItemtest"), "1.0" );
KCmdLineArgs::init(argc, argv, &aboutData);
KCmdLineOptions options;
options.add("active-icon <name>", ki18n("Name of active icon"), "konqueror");
options.add("ksni-count <count>", ki18n("How many instances of KStatusNotifierItem to create"), "1");
KCmdLineArgs::addCmdLineOptions(options);
KApplication app;
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
QLabel *l = new QLabel("System Tray Main Window", 0L);
int ksniCount = args->getOption("ksni-count").toInt();
for (int x=0; x < ksniCount; ++x) {
KStatusNotifierItem *tray = new KStatusNotifierItem(l);
new KStatusNotifierItemTest(0, tray);
tray->setTitle("DBus System tray test");
tray->setIconByName(args->getOption("active-icon"));
//tray->setImage(KIcon("konqueror"));
//tray->setAttentionIconByName("kmail");
tray->setOverlayIconByName("emblem-important");
tray->setToolTipIconByName("konqueror");
tray->setToolTipTitle("DBus System tray test");
tray->setToolTipSubTitle("This is a test of the new systemtray specification");
tray->setToolTip("konqueror", QString("DBus System tray test #%1").arg(x + 1), "This is a test of the new systemtray specification");
tray->showMessage("message test", "Test of the new systemtray notifications wrapper", "konqueror", 3000);
//tray->setStandardActionsEnabled(false);
}
return app.exec();
}
#include "moc_kstatusnotifieritemtest.cpp"

View file

@ -1,44 +0,0 @@
/* This file is part of the KDE libraries
Copyright 2009 by Marco Martin <notmart@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License (LGPL) as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later
version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KSTATUSNOTIFIERITEMTEST_H
#define KSTATUSNOTIFIERITEMTEST_H
#include <QObject>
class KStatusNotifierItem;
class KStatusNotifierItemTest : public QObject
{
Q_OBJECT
public:
KStatusNotifierItemTest(QObject *parent, KStatusNotifierItem *tray);
//~KStatusNotifierItemTest();
public Q_SLOTS:
void setNeedsAttention();
void setActive();
void setPassive();
private:
KStatusNotifierItem *m_tray;
};
#endif

View file

@ -1,18 +0,0 @@
#include <ksystemtrayicon.h>
#include <kapplication.h>
#include <QtGui/QLabel>
#include <kcmdlineargs.h>
#include <kaboutdata.h>
int main(int argc, char **argv)
{
KAboutData aboutData( "ksystemtraytest", 0 , ki18n("ksystemtraytest"), "1.0" );
KCmdLineArgs::init(argc, argv, &aboutData);
KApplication app;
QLabel *l = new QLabel("System Tray Main Window", 0L);
KSystemTrayIcon *tray = new KSystemTrayIcon( "test", l );
l->show();
tray->show();
return app.exec();
}

View file

@ -1,395 +0,0 @@
#include <QtGui/QLayout>
#include <QtGui/qevent.h>
#include <QtGui/QMenu>
#include <QtCore/QMimeData>
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kinputdialog.h>
#include <kdebug.h>
#include "ktabwidgettest.h"
Test::Test( QWidget* parent )
:KVBox( parent ), mLeftWidget(0), mRightWidget(0),
mLeftPopup(0), mRightPopup(0), mTabbarContextPopup(0), mContextPopup(0)
{
resize( 600,300 );
mWidget = new KTabWidget( this );
mWidget->addTab( new QLabel( "Testlabel 1", 0 ), "&One" );
mWidget->addTab( new QLabel( "Testlabel 2", 0 ), "Two" );
mWidget->addTab( new QWidget(), SmallIcon( "konsole" ), "Three" );
mWidget->addTab( new QWidget(), "Four" );
mWidget->setTabTextColor( 0, Qt::red );
mWidget->setTabTextColor( 1, Qt::blue );
mWidget->setUsesScrollButtons( false ); // corresponding checkbox is unchecked by default
connect( mWidget, SIGNAL(currentChanged(QWidget*)), SLOT(currentChanged(QWidget*)) );
connect( mWidget, SIGNAL(contextMenu(QWidget*,QPoint)), SLOT(contextMenu(QWidget*,QPoint)));
connect( mWidget, SIGNAL(contextMenu(QPoint)), SLOT(tabbarContextMenu(QPoint)));
connect( mWidget, SIGNAL(mouseDoubleClick(QWidget*)), SLOT(mouseDoubleClick(QWidget*)));
connect( mWidget, SIGNAL(mouseMiddleClick()), SLOT(addTab()));
connect( mWidget, SIGNAL(mouseMiddleClick(QWidget*)), SLOT(mouseMiddleClick(QWidget*)));
connect( mWidget, SIGNAL(closeRequest(QWidget*)), SLOT(mouseMiddleClick(QWidget*)));
connect( mWidget, SIGNAL(testCanDecode(const QDragMoveEvent*,bool&)), SLOT(testCanDecode(const QDragMoveEvent*,bool&)));
connect( mWidget, SIGNAL(receivedDropEvent(QDropEvent*)), SLOT(receivedDropEvent(QDropEvent*)));
connect( mWidget, SIGNAL(receivedDropEvent(QWidget*,QDropEvent*)), SLOT(receivedDropEvent(QWidget*,QDropEvent*)));
connect( mWidget, SIGNAL(initiateDrag(QWidget*)), SLOT(initiateDrag(QWidget*)));
connect( mWidget, SIGNAL(movedTab(int,int)), SLOT(movedTab(int,int)));
mWidget->setMovable( true );
QWidget * grid = new QWidget(this);
QGridLayout * gridlayout = new QGridLayout( grid );
QPushButton * addTab = new QPushButton( "Add Tab", grid );
gridlayout->addWidget( addTab, 0, 0 );
connect( addTab, SIGNAL(clicked()), SLOT(addTab()) );
QPushButton * removeTab = new QPushButton( "Remove Current Tab", grid );
gridlayout->addWidget( removeTab, 0, 1 );
connect( removeTab, SIGNAL(clicked()), SLOT(removeCurrentTab()) );
mLeftButton = new QCheckBox( "Show left button", grid );
gridlayout->addWidget( mLeftButton, 1, 0 );
connect( mLeftButton, SIGNAL(toggled(bool)), SLOT(toggleLeftButton(bool)) );
mLeftButton->setChecked(true);
QCheckBox * leftPopup = new QCheckBox( "Enable left popup", grid );
gridlayout->addWidget( leftPopup, 2, 0 );
connect( leftPopup, SIGNAL(toggled(bool)), SLOT(toggleLeftPopup(bool)) );
leftPopup->setChecked(true);
mRightButton = new QCheckBox( "Show right button", grid );
gridlayout->addWidget( mRightButton, 1, 1 );
connect( mRightButton, SIGNAL(toggled(bool)), SLOT(toggleRightButton(bool)) );
mRightButton->setChecked(true);
QCheckBox * rightPopup = new QCheckBox( "Enable right popup", grid );
gridlayout->addWidget( rightPopup, 2, 1 );
connect( rightPopup, SIGNAL(toggled(bool)), SLOT(toggleRightPopup(bool)) );
rightPopup->setChecked(true);
mTabsBottom = new QCheckBox( "Show tabs at bottom", grid );
gridlayout->addWidget( mTabsBottom, 3, 0 );
connect( mTabsBottom, SIGNAL(toggled(bool)), SLOT(toggleTabPosition(bool)) );
QCheckBox * tabshape = new QCheckBox( "Triangular tab shape", grid );
gridlayout->addWidget( tabshape, 3, 1 );
connect( tabshape, SIGNAL(toggled(bool)), SLOT(toggleTabShape(bool)) );
QCheckBox *tabClose = new QCheckBox( "Close button on icon hover", grid );
gridlayout->addWidget( tabClose, 4, 0 );
connect( tabClose, SIGNAL(toggled(bool)), SLOT(toggleCloseButtons(bool)) );
tabClose->setChecked(true);
QCheckBox * showlabels = new QCheckBox( "Show labels", grid );
gridlayout->addWidget( showlabels, 4, 1 );
connect( showlabels, SIGNAL(toggled(bool)), this, SLOT(toggleLabels(bool)) );
QCheckBox * elideText = new QCheckBox( "Elide text", grid );
gridlayout->addWidget( elideText, 5, 0 );
connect( elideText, SIGNAL(toggled(bool)), this, SLOT(toggleEliding(bool)) );
QCheckBox * scrollButtons = new QCheckBox( "Enable scroll buttons", grid );
gridlayout->addWidget( scrollButtons, 5, 1 );
connect( scrollButtons, SIGNAL(toggled(bool)), this, SLOT(toggleScrollButtons(bool)) );
}
void Test::currentChanged(QWidget* w)
{
mWidget->setTabTextColor( mWidget->indexOf(w), Qt::black );
}
void Test::addTab()
{
mWidget->addTab( new QWidget(), SmallIcon( "konsole" ), QString("This is tab %1").arg( mWidget->count()+1 ) );
}
void Test::testCanDecode(const QDragMoveEvent *e, bool &accept /* result */)
{
if ( e->mimeData()->hasText() ) // don't accept=false if it cannot be decoded!
accept = true;
}
void Test::receivedDropEvent( QDropEvent *e )
{
if (e->mimeData()->hasText()) {
mWidget->addTab( new QWidget(), e->mimeData()->text() );
}
}
void Test::receivedDropEvent( QWidget *w, QDropEvent *e )
{
if (e->mimeData()->hasText()) {
mWidget->setTabText( mWidget->indexOf( w ), e->mimeData()->text() );
}
}
void Test::initiateDrag( QWidget *w )
{
QDrag *drag = new QDrag( this );
QMimeData *mimeData = new QMimeData;
mimeData->setText(mWidget->tabText( mWidget->indexOf(w)));
drag->setMimeData(mimeData);
drag->start(); // do NOT delete d.
}
void Test::removeCurrentTab()
{
if ( mWidget->count()==1 ) return;
mWidget->removeTab( mWidget->currentIndex() );
}
void Test::toggleLeftButton(bool state)
{
if (state) {
if (!mLeftWidget) {
mLeftWidget = new QToolButton( mWidget );
connect( mLeftWidget, SIGNAL(clicked()), SLOT(addTab()) );
mLeftWidget->setIcon( SmallIcon( "tab-new" ) );
mLeftWidget->setText("New");
mLeftWidget->setToolTip("New");
mLeftWidget->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
mLeftWidget->adjustSize();
//mLeftWidget->setGeometry( 0, 0, h, h );
mLeftWidget->setMenu(mLeftPopup);
mWidget->setCornerWidget( mLeftWidget, Qt::TopLeftCorner );
}
mLeftWidget->show();
}
else
mLeftWidget->hide();
}
void Test::toggleLeftPopup(bool state)
{
if (state) {
if (!mLeftPopup) {
mLeftPopup = new QMenu(this);
mLeftPopup->addAction(SmallIcon( "tab-new" ), "Empty Tab");
mLeftPopup->addAction(SmallIcon( "tab-new" ), "Empty Tab After First");
mLeftPopup->addSeparator();
mLeftPopup->addAction(SmallIcon( "tab-new" ), "Button Tab");
mLeftPopup->addAction(SmallIcon( "tab-new" ), "Label Tab");
connect(mLeftPopup, SIGNAL(triggered(QAction*)), SLOT(leftPopupActivated(QAction*)));
}
mLeftWidget->setMenu(mLeftPopup);
}
else
mLeftWidget->setMenu(0);
}
void Test::leftPopupActivated(QAction *action)
{
switch (mLeftPopup->actions().indexOf(action)){
case 0: mWidget->addTab( new QWidget(), QString("Tab %1").arg( mWidget->count()+1 ) );
break;
case 1: mWidget->insertTab( 1, new QWidget(), QString("Tab %1").arg( mWidget->count()+1 ) );
break;
case 3: mWidget->addTab( new QPushButton( "Testbutton" ), QString("Tab %1").arg( mWidget->count()+1 ) );
break;
case 4: mWidget->addTab( new QLabel( "Testlabel" ), QString("Tab %1").arg( mWidget->count()+1 ) );
break;
}
}
void Test::toggleRightButton(bool state)
{
if (state) {
if ( !mRightWidget) {
mRightWidget = new QToolButton( mWidget );
QObject::connect( mRightWidget, SIGNAL(clicked()), SLOT(removeCurrentTab()) );
mRightWidget->setIcon( SmallIcon( "tab-close" ) );
mRightWidget->setText("Close");
mRightWidget->setToolTip("Close");
mRightWidget->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
mRightWidget->adjustSize();
//mRightButton->setGeometry( 0, 0, h, h );
mRightWidget->setMenu(mRightPopup);
mWidget->setCornerWidget( mRightWidget, Qt::TopRightCorner );
}
mRightWidget->show();
}
else
mRightWidget->hide();
}
void Test::toggleRightPopup(bool state)
{
if (state) {
if (!mRightPopup) {
mRightPopup = new QMenu(this);
mRightPopup->addAction(SmallIcon( "tab-close" ), "Current Tab");
mRightPopup->addSeparator();
mRightPopup->addAction(SmallIcon( "tab-close" ), "Most Left Tab");
mRightPopup->addAction(SmallIcon( "tab-close" ), "Most Right Tab");
connect(mRightPopup, SIGNAL(triggered(QAction*)), SLOT(rightPopupActivated(QAction*)));
}
mRightWidget->setMenu(mRightPopup);
}
else
mRightWidget->setMenu(0);
}
void Test::rightPopupActivated(QAction *action)
{
switch (mRightPopup->actions().indexOf(action)) {
case 0: removeCurrentTab();
break;
case 2: if ( mWidget->count() >1) {
mWidget->removeTab( 0 );
}
break;
case 3: int count = mWidget->count();
if (count>1) {
mWidget->removeTab( count-1 );
}
break;
}
}
void Test::toggleTabPosition(bool state)
{
mWidget->setTabPosition(state ? QTabWidget::South : QTabWidget::North );
}
void Test::toggleTabShape(bool state)
{
mWidget->setTabShape(state ? QTabWidget::Triangular : QTabWidget::Rounded);
}
void Test::toggleCloseButtons(bool state)
{
mWidget->setTabsClosable( state );
}
void Test::contextMenu(QWidget *w, const QPoint &p)
{
delete mContextPopup;
int idx = mWidget->indexOf( w );
mContextPopup = new QMenu(this);
mContextPopup->addAction( "Activate Tab");
mContextPopup->addSeparator();
mContextPopup->addAction(SmallIcon( "konsole" ), "Set This Icon");
mContextPopup->addAction(SmallIcon( "konqueror" ), "Set This Icon");
mContextPopup->addSeparator();
mContextPopup->addAction( mWidget->isTabEnabled(idx) ? "Disable Tab" : "Enable Tab");
mContextPopup->addAction( mWidget->tabToolTip(idx).isEmpty() ? "Set Tooltip" : "Remove Tooltip");
connect(mContextPopup, SIGNAL(triggered(QAction*)), SLOT(contextMenuActivated(QAction*)));
mContextWidgetIndex = mWidget->indexOf( w );
mContextPopup->popup(p);
}
void Test::contextMenuActivated(QAction *action)
{
switch (mContextPopup->actions().indexOf(action)) {
case 0:
mWidget->setCurrentIndex( mContextWidgetIndex );
break;
case 2:
mWidget->setTabIcon( mContextWidgetIndex, SmallIcon( "konsole" ) );
break;
case 3:
mWidget->setTabIcon( mContextWidgetIndex, SmallIcon( "konqueror" ) );
break;
case 4:
mWidget->setTabEnabled( mContextWidgetIndex, !(mWidget->isTabEnabled(mContextWidgetIndex)) );
break;
case 5:
if ( mWidget->tabToolTip(mContextWidgetIndex).isEmpty() )
mWidget->setTabToolTip( mContextWidgetIndex, "This is a tool tip.");
else
mWidget->setTabToolTip( mContextWidgetIndex, QString() );
break;
}
}
void Test::tabbarContextMenu(const QPoint &p)
{
delete mTabbarContextPopup;
mTabbarContextPopup = new QMenu(this);
mTabbarContextPopup->addAction(SmallIcon( "tab-new" ), mLeftWidget->isVisible() ? "Hide \"Add\" Button" : "Show \"Add\" Button");
mTabbarContextPopup->addAction(SmallIcon( "tab-close" ), mRightWidget->isVisible() ? "Hide \"Remove\" Button" : "Show \"Remove\" Button");
mTabbarContextPopup->addSeparator();
mTabbarContextPopup->addAction(mWidget->tabPosition()==QTabWidget::North ? "Put Tabbar to Bottom" : "Put Tabbar to Top");
connect(mTabbarContextPopup, SIGNAL(triggered(QAction*)), SLOT(tabbarContextMenuActivated(QAction*)));
mTabbarContextPopup->popup(p);
}
void Test::tabbarContextMenuActivated(QAction *action)
{
switch (mTabbarContextPopup->actions().indexOf(action)) {
case 0: mLeftButton->toggle();
break;
case 1: mRightButton->toggle();
break;
case 3: mTabsBottom->toggle();
break;
}
}
void Test::mouseDoubleClick(QWidget *w)
{
int index = mWidget->indexOf( w );
bool ok;
QString text = KInputDialog::getText(
"Rename Tab", "Enter new name:",
mWidget->tabText( index ), &ok, this );
if ( ok && !text.isEmpty() ) {
mWidget->setTabText( index, text );
mWidget->setTabTextColor( index, Qt::green );
}
}
void Test::mouseMiddleClick(QWidget *w)
{
if ( mWidget->count()==1 ) return;
mWidget->removeTab( mWidget->indexOf( w ) );
}
void Test::movedTab(int from, int to)
{
kDebug() << "Moved tab from index " << from << " to " << to;
}
void Test::toggleLabels(bool state)
{
mLeftWidget->setToolButtonStyle(state?Qt::ToolButtonTextUnderIcon:Qt::ToolButtonIconOnly);
mLeftWidget->adjustSize();
mRightWidget->setToolButtonStyle(state?Qt::ToolButtonTextUnderIcon:Qt::ToolButtonIconOnly);
mRightWidget->adjustSize();
mWidget->hide(); // trigger update
mWidget->show();
}
void Test::toggleScrollButtons(bool state)
{
mWidget->setUsesScrollButtons(state);
}
void Test::toggleEliding(bool state)
{
mWidget->setAutomaticResizeTabs(state);
//mWidget->setElideMode(state ? Qt::ElideRight : Qt::ElideNone);
}
int main(int argc, char** argv )
{
KCmdLineArgs::init(argc, argv, "ktabwidgettest", 0, ki18n("KTabWidgetTest"), "1.0", ki18n("ktabwidget test app"));
//KApplication::disableAutoDcopRegistration();
KApplication app;
Test *t = new Test();
t->show();
app.exec();
}
#include "moc_ktabwidgettest.cpp"

View file

@ -1,69 +0,0 @@
#ifndef KTABWIDGETTEST_H
#define KTABWIDGETTEST_H
#include <kiconloader.h>
#include <QtGui/QWidget>
#include <ktabwidget.h>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
#include <stdlib.h>
#include <kvbox.h>
#include <time.h>
#include <QtGui/QCheckBox>
#include <QtGui/QToolButton>
class Test : public KVBox
{
Q_OBJECT
public:
Test( QWidget* parent=0 );
private Q_SLOTS:
void addTab();
void removeCurrentTab();
void toggleLeftButton(bool);
void toggleRightButton(bool);
void toggleLeftPopup(bool);
void toggleRightPopup(bool);
void toggleTabPosition(bool);
void toggleTabShape(bool);
void toggleCloseButtons(bool);
void toggleLabels(bool);
void toggleScrollButtons(bool);
void toggleEliding(bool);
void currentChanged(QWidget*);
void contextMenu(QWidget*, const QPoint&);
void tabbarContextMenu(const QPoint&);
void testCanDecode(const QDragMoveEvent *, bool & /* result */);
void receivedDropEvent( QDropEvent* );
void initiateDrag( QWidget * );
void receivedDropEvent( QWidget *, QDropEvent * );
void mouseDoubleClick(QWidget*);
void mouseMiddleClick(QWidget*);
void movedTab( int, int );
void leftPopupActivated(QAction*);
void rightPopupActivated(QAction*);
void contextMenuActivated(QAction*);
void tabbarContextMenuActivated(QAction*);
private:
KTabWidget* mWidget;
QCheckBox * mLeftButton;
QCheckBox * mRightButton;
QCheckBox * mTabsBottom;
QToolButton* mLeftWidget;
QToolButton* mRightWidget;
QMenu* mLeftPopup;
QMenu* mRightPopup;
QMenu* mTabbarContextPopup;
QMenu* mContextPopup;
int mContextWidgetIndex;
};
#endif

View file

@ -1,48 +0,0 @@
/* This file is part of the KDE libraries
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <ktextedit.h>
#include <QFile>
#include <QAction>
int main( int argc, char **argv )
{
KCmdLineArgs::init( argc, argv, "ktextedittest", 0, ki18n("KTextEditTest"), "1.0", ki18n("ktextedit test app"));
KApplication app;
KTextEdit *edit = new KTextEdit();
//QAction* action = new QAction("Select All", edit);
//action->setShortcut( Qt::CTRL | Qt::Key_Underscore );
//edit->addAction(action);
//QObject::connect(action, SIGNAL(triggered()), edit, SLOT(selectAll()));
QFile file(KDESRCDIR "/ktextedittest.cpp");
if ( file.open( QIODevice::ReadOnly ) )
{
edit->setPlainText( file.readAll() );
file.close();
}
edit->resize( 600, 600 );
edit->show();
return app.exec();
}

View file

@ -1,79 +0,0 @@
/* This file is part of the KDE libraries
Copyright (C) 2007 Urs Wolfer <uwolfer @ kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kicon.h>
#include <ktitlewidget.h>
#include <QCheckBox>
#include <QLabel>
#include <QVBoxLayout>
#include <QWidget>
class KTitleWidgetTestWidget : public QWidget
{
public:
KTitleWidgetTestWidget(QWidget *parent = 0)
: QWidget(parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
KTitleWidget *titleWidget = new KTitleWidget(this);
titleWidget->setText("Title");
titleWidget->setPixmap(KIcon("screen").pixmap(22, 22), KTitleWidget::ImageLeft);
mainLayout->addWidget(titleWidget);
KTitleWidget *errorTitle = new KTitleWidget(this);
errorTitle->setText("Title");
errorTitle->setComment("Error Comment", KTitleWidget::ErrorMessage);
mainLayout->addWidget(errorTitle);
KTitleWidget *checkboxTitleWidget = new KTitleWidget(this);
QWidget *checkBoxTitleMainWidget = new QWidget(this);
QVBoxLayout *titleLayout = new QVBoxLayout(checkBoxTitleMainWidget);
titleLayout->setMargin(6);
QCheckBox *checkBox = new QCheckBox("Text Checkbox", checkBoxTitleMainWidget);
titleLayout->addWidget(checkBox);
checkboxTitleWidget->setWidget(checkBoxTitleMainWidget);
mainLayout->addWidget(checkboxTitleWidget);
QLabel *otherLabel = new QLabel("Some text...", this);
mainLayout->addWidget(otherLabel);
mainLayout->addStretch();
}
};
int main(int argc, char **argv)
{
KCmdLineArgs::init(argc, argv, "ktitlewidgettest", 0, ki18n("KTitleWidgetTest"), "version", ki18n("description"));
KApplication app;
KTitleWidgetTestWidget *mainWidget = new KTitleWidgetTestWidget;
mainWidget->show();
return app.exec();
}

View file

@ -1,101 +0,0 @@
/* This file is part of the KDE libraries
Copyright (C) 2004 Felix Berger <felixberger@beldesign.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <kcmdlineargs.h>
#include <kapplication.h>
#include <kxmlguiwindow.h>
#include <klineedit.h>
#include <kstandarddirs.h>
#include <ktoolbarlabelaction.h>
#include <ksqueezedtextlabel.h>
#include <kvbox.h>
#include <kactioncollection.h>
#include <assert.h>
class MainWindow : public KXmlGuiWindow
{
public:
MainWindow()
{
// KXMLGUIClient looks in the "data" resource for the .rc files
// This line is for test programs only!
KGlobal::dirs()->addResourceDir( "data", KDESRCDIR );
KVBox* main = new KVBox( this );
setCentralWidget( main );
KSqueezedTextLabel* accel = new KSqueezedTextLabel( "&Really long, long, long and boring text goes here", main );
mainLabel = new KSqueezedTextLabel( "Click me to change Label 1 text", main );
mainLabel->installEventFilter(this);
// first constructor
label1 = new KToolBarLabelAction( "&Label 1", this );
actionCollection()->addAction("label1", label1);
KLineEdit* lineEdit = new KLineEdit( this );
KAction* lineEditAction = new KAction( "Line Edit", this );
actionCollection()->addAction( "lineEdit", lineEditAction );
lineEditAction->setDefaultWidget(lineEdit);
// second constructor
KToolBarLabelAction *label2 = new KToolBarLabelAction( lineEditAction, "This is the &second label", this );
actionCollection()->addAction( "label2", label2 );
// set buddy for label1
label1->setBuddy( lineEditAction );
// set buddy for accel
accel->setBuddy( lineEdit );
// another widget so lineEdit can loose focus and check budyness works
new KLineEdit( main );
setupGUI( Default, "ktoolbarlabelactiontestui.rc" );
}
bool eventFilter(QObject * watched, QEvent * event )
{
if (watched == mainLabel && event->type() == QEvent::MouseButtonPress)
{
label1->setText("&You clicked to make me change!");
}
return KXmlGuiWindow::eventFilter(watched, event);
}
KToolBarLabelAction* label1;
KSqueezedTextLabel *mainLabel;
};
int main( int argc, char **argv )
{
KCmdLineArgs::init( argc, argv, "test", 0, ki18n("Test"), "1.0", ki18n("test app"));
KApplication app;
KGlobal::mainComponent().dirs()->addResourceDir( "data", "." );
MainWindow* mw = new MainWindow;
mw->show();
return app.exec();
}

View file

@ -1,8 +0,0 @@
<!DOCTYPE kpartgui>
<kpartgui name="ktoolbarlabelactiontest" version="0.1">
<ToolBar name="mytoolbar">
<Action name="label1"/>
<Action name="lineEdit"/>
<Action name="label2"/>
</ToolBar>
</kpartgui>

View file

@ -1,63 +0,0 @@
#include <kapplication.h>
#include <kaction.h>
#include <kactioncollection.h>
#include <QtGui/QMainWindow>
#include <ktoolbar.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
// This is a test for "Automatically hide extra toolbar separators"
// If several separators are next to each other, only one should show up.
int main( int argc, char **argv )
{
KAboutData aboutData( "kactiontest", 0, ki18n("kactiontest"), "1.0" );
KCmdLineArgs::init(argc, argv, &aboutData);
KApplication app;
KActionCollection coll( static_cast<QObject *>( 0 ) );
QAction* action1 = coll.addAction("test1");
action1->setText("test1");
QAction* action2 = coll.addAction("test2");
action2->setText("test2");
QAction* action3 = coll.addAction("test3");
action3->setText("test3");
QAction* action4 = coll.addAction("test4");
action4->setText("test4");
QAction* action5 = coll.addAction("test5");
action5->setText("test5");
QAction* action6 = coll.addAction("test6");
action6->setText("test6");
QAction* action7 = coll.addAction("test7");
action7->setText("test7");
QMainWindow* mw = new QMainWindow();
KToolBar* tb = new KToolBar(mw);
mw->addToolBar(tb);
action2->setSeparator(true);
action3->setSeparator(true);
action7->setSeparator(true);
coll.addAssociatedWidget(tb);
mw->show();
app.exec();
mw->show();
action2->setVisible(false);
app.exec();
mw->show();
action1->setVisible(false);
return app.exec();
}
/* vim: et sw=4 ts=4
*/

View file

@ -1,118 +0,0 @@
#include "ktreewidgetsearchlinetest.h"
#include <QtGui/QTreeWidget>
#include <QtGui/QBoxLayout>
#include <QtGui/QPushButton>
#include <QtGui/QHeaderView>
#include <ktreewidgetsearchline.h>
#include <kapplication.h>
#include <kcmdlineargs.h>
KTreeWidgetSearchLineTest::KTreeWidgetSearchLineTest()
: KDialog()
{
QWidget* container = mainWidget();
// to test KWhatsThisManager too:
container->setWhatsThis("This is a test dialog for KTreeWidgetSearchLineTest");
tw = new QTreeWidget(container);
tw->setColumnCount(4);
tw->setHeaderLabels(QStringList() << "Item" << "Price" << "HIDDEN COLUMN" << "Source");
tw->hideColumn(2);
KTreeWidgetSearchLineWidget* searchWidget = new KTreeWidgetSearchLineWidget(container,tw);
m_searchLine = searchWidget->searchLine();
QTreeWidgetItem* red = new QTreeWidgetItem( tw, QStringList() << "Red");
red->setWhatsThis( 0, "This item is red" );
red->setWhatsThis( 1, "This item is pricy" );
tw->expandItem(red);
QTreeWidgetItem* blue = new QTreeWidgetItem( tw, QStringList() << "Blue");
tw->expandItem(blue);
QTreeWidgetItem* green = new QTreeWidgetItem( tw, QStringList() << "Green");
tw->expandItem(green);
QTreeWidgetItem* yellow = new QTreeWidgetItem( tw, QStringList() << "Yellow");
tw->expandItem(yellow);
create2ndLevel(red);
create2ndLevel(blue);
create2ndLevel(green);
create2ndLevel(yellow);
QVBoxLayout* layout = new QVBoxLayout(container);
layout->setMargin(0);
QHBoxLayout* hbox = new QHBoxLayout();
QPushButton* caseSensitive = new QPushButton("&Case Sensitive", container);
hbox->addWidget(caseSensitive);
caseSensitive->setCheckable(true);
connect(caseSensitive, SIGNAL(toggled(bool)), SLOT(switchCaseSensitivity(bool)));
QPushButton* keepParentsVisible = new QPushButton("Keep &Parents Visible", container);
hbox->addWidget(keepParentsVisible);
keepParentsVisible->setCheckable(true);
keepParentsVisible->setChecked(true);
connect(keepParentsVisible, SIGNAL(toggled(bool)), m_searchLine, SLOT(setKeepParentsVisible(bool)));
layout->addWidget(searchWidget);
layout->addWidget(tw);
layout->addLayout(hbox);
m_searchLine->setFocus();
resize(350, 600);
}
void KTreeWidgetSearchLineTest::create3rdLevel( QTreeWidgetItem * item )
{
new QTreeWidgetItem( item, QStringList() << "Growing" << "$2.00" << "" << "Farmer" );
new QTreeWidgetItem( item, QStringList() << "Ripe" << "$8.00" << "" << "Market" );
new QTreeWidgetItem( item, QStringList() << "Decaying" << "$0.50" << "" << "Ground" );
new QTreeWidgetItem( item, QStringList() << "Pickled" << "$4.00" << "" << "Shop" );
}
void KTreeWidgetSearchLineTest::create2ndLevel( QTreeWidgetItem * item )
{
QTreeWidgetItem* beans = new QTreeWidgetItem(item, QStringList() << "Beans");
tw->expandItem(beans);
create3rdLevel(beans);
QTreeWidgetItem* grapes = new QTreeWidgetItem(item, QStringList() << "Grapes");
tw->expandItem(grapes);
create3rdLevel(grapes);
QTreeWidgetItem* plums = new QTreeWidgetItem(item, QStringList() << "Plums");
tw->expandItem(plums);
create3rdLevel(plums);
QTreeWidgetItem* bananas = new QTreeWidgetItem(item, QStringList() << "Bananas");
tw->expandItem(bananas);
create3rdLevel(bananas);
}
void KTreeWidgetSearchLineTest::switchCaseSensitivity(bool cs)
{
m_searchLine->setCaseSensitivity(cs ? Qt::CaseSensitive : Qt::CaseInsensitive);
}
void KTreeWidgetSearchLineTest::showEvent( QShowEvent * event )
{
KDialog::showEvent(event);
for (int i = 0; i < tw->header()->count(); ++i)
if (!tw->header()->isSectionHidden(i))
tw->resizeColumnToContents(i);
}
int main( int argc, char **argv )
{
KCmdLineArgs::init( argc, argv, "KTreeWidgetSearchLineTest", 0, ki18n("KTreeWidgetSearchLineTest"), "1.0", ki18n("KTreeWidgetSearchLine test app"));
KApplication app;
KTreeWidgetSearchLineTest dialog;
dialog.exec();
return 0;
}
#include "moc_ktreewidgetsearchlinetest.cpp"

View file

@ -1,28 +0,0 @@
#ifndef KTREEWIDGETSEARCHLINETEST_H
#define KTREEWIDGETSEARCHLINETEST_H
#include <kdialog.h>
#include <QTreeWidget>
class KTreeWidgetSearchLineTest : public KDialog
{
Q_OBJECT
public:
KTreeWidgetSearchLineTest();
void create2ndLevel(class QTreeWidgetItem* item);
void create3rdLevel(QTreeWidgetItem* item);
public Q_SLOTS:
void switchCaseSensitivity(bool cs);
protected:
virtual void showEvent(QShowEvent* event);
private:
class KTreeWidgetSearchLine* m_searchLine;
QTreeWidget* tw;
};
#endif

View file

@ -1,335 +0,0 @@
/**
* This file is part of the KDE project
* Copyright (C) 2007-2008 Rafael Fernández López <ereslibre@kde.org>
* Copyright (C) 2008 Kevin Ottens <ervin@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <QtGui/QApplication>
#include <QtGui/QAbstractItemView>
#include <QtGui/QListView>
#include <QtGui/QStringListModel>
#include <QtGui/QMainWindow>
#include <QtGui/QPainter>
#include <QtGui/QRadialGradient>
#include <QtGui/qevent.h>
#include <QtCore/QDebug>
#include <QtGui/QToolButton>
#include <QtGui/QMenu>
#include <kapplication.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kmessagebox.h>
#include <kpushbutton.h>
#include <klineedit.h>
#include <kicon.h>
#include <kwidgetitemdelegate.h>
#define HARDCODED_BORDER 10
#define EQUALLY_SIZED_TOOLBUTTONS 1
#if EQUALLY_SIZED_TOOLBUTTONS
#include <QtGui/qstyleoption.h>
#endif
class TestWidget
: public QWidget
{
Q_OBJECT
public:
TestWidget(QWidget *parent = 0)
: QWidget(parent)
{
setMouseTracking(true);
setAttribute(Qt::WA_Hover);
}
~TestWidget()
{
}
QSize sizeHint() const
{
return QSize(30, 30);
}
protected:
void paintEvent (QPaintEvent *event)
{
QPainter p(this);
QRadialGradient radialGrad(QPointF(event->rect().width() / 2,
event->rect().height() / 2),
qMin(event->rect().width() / 2,
event->rect().height() / 2));
if (underMouse())
radialGrad.setColorAt(0, Qt::green);
else
radialGrad.setColorAt(0, Qt::red);
radialGrad.setColorAt(1, Qt::transparent);
p.fillRect(event->rect(), radialGrad);
p.setPen(Qt::black);
p.drawLine(0, 15, 30, 15);
p.drawLine(15, 0, 15, 30);
p.end();
}
bool event(QEvent *event)
{
if (event->type() == QEvent::MouseButtonPress) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
if (mouseEvent->pos().x() > 15 &&
mouseEvent->pos().y() < 15)
qDebug() << "First quarter";
else if (mouseEvent->pos().x() < 15 &&
mouseEvent->pos().y() < 15)
qDebug() << "Second quarter";
else if (mouseEvent->pos().x() < 15 &&
mouseEvent->pos().y() > 15)
qDebug() << "Third quarter";
else
qDebug() << "Forth quarter";
}
return QWidget::event(event);
}
};
class MyDelegate
: public KWidgetItemDelegate
{
Q_OBJECT
public:
MyDelegate(QAbstractItemView *itemView, QObject *parent = 0)
: KWidgetItemDelegate(itemView, parent)
{
for (int i = 0; i < 100; i++)
{
installed[i] = i % 5;
}
}
~MyDelegate()
{
}
QSize sizeHint(const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
Q_UNUSED(option);
Q_UNUSED(index);
return sizeHint();
}
QSize sizeHint() const
{
return QSize(600, 60);
}
void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
painter->save();
itemView()->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter, 0);
if (option.state & QStyle::State_Selected)
{
painter->setPen(option.palette.highlightedText().color());
}
painter->restore();
}
QList<QWidget*> createItemWidgets() const
{
KPushButton *button = new KPushButton();
QToolButton *toolButton = new QToolButton();
setBlockedEventTypes(button, QList<QEvent::Type>() << QEvent::MouseButtonPress
<< QEvent::MouseButtonRelease << QEvent::MouseButtonDblClick);
setBlockedEventTypes(toolButton, QList<QEvent::Type>() << QEvent::MouseButtonPress
<< QEvent::MouseButtonRelease << QEvent::MouseButtonDblClick);
connect(button, SIGNAL(clicked(bool)), this, SLOT(mySlot()));
connect(toolButton, SIGNAL(triggered(QAction*)), this, SLOT(mySlot2()));
connect(toolButton, SIGNAL(clicked(bool)), this, SLOT(mySlot3()));
return QList<QWidget*>()
<< button
<< new TestWidget()
<< new KLineEdit()
<< toolButton;
}
void updateItemWidgets(const QList<QWidget*> widgets,
const QStyleOptionViewItem &option,
const QPersistentModelIndex &index) const
{
QPushButton *button = static_cast<QPushButton*>(widgets[0]);
button->setText("Test me");
button->setIcon(KIcon("kde"));
button->resize(button->sizeHint());
button->move(HARDCODED_BORDER, sizeHint().height() / 2 - button->height() / 2);
TestWidget *testWidget = static_cast<TestWidget*>(widgets[1]);
testWidget->resize(testWidget->sizeHint());
testWidget->move(2 * HARDCODED_BORDER + button->sizeHint().width(),
sizeHint().height() / 2 - testWidget->size().height() / 2);
// Hide the test widget when row can be divided by three
testWidget->setVisible( (index.row() % 3) != 0 );
KLineEdit *lineEdit = static_cast<KLineEdit*>(widgets[2]);
lineEdit->setClearButtonShown(true);
lineEdit->resize(lineEdit->sizeHint());
lineEdit->move(3 * HARDCODED_BORDER
+ button->sizeHint().width()
+ testWidget->sizeHint().width(),
sizeHint().height() / 2 - lineEdit->size().height() / 2);
QToolButton *toolButton = static_cast<QToolButton*>(widgets[3]);
if (!toolButton->menu())
{
QMenu *myMenu = new QMenu(toolButton);
myMenu->addAction("Save");
myMenu->addAction("Load");
myMenu->addSeparator();
myMenu->addAction("Close");
toolButton->setMenu(myMenu);
}
toolButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
toolButton->setPopupMode(QToolButton::MenuButtonPopup);
if (installed[index.row()])
{
toolButton->setText("Uninstall");
}
else
{
toolButton->setText("Install");
}
toolButton->resize(toolButton->sizeHint());
#if EQUALLY_SIZED_TOOLBUTTONS
QStyleOptionToolButton toolButtonOpt;
toolButtonOpt.initFrom(toolButton);
toolButtonOpt.features = QStyleOptionToolButton::MenuButtonPopup;
toolButtonOpt.arrowType = Qt::DownArrow;
toolButtonOpt.toolButtonStyle = Qt::ToolButtonTextBesideIcon;
toolButtonOpt.text = "Install";
int widthInstall = QApplication::style()->sizeFromContents(QStyle::CT_ToolButton, &toolButtonOpt, QSize(option.fontMetrics.width("Install") + HARDCODED_BORDER * 3, option.fontMetrics.height()), toolButton).width();
toolButtonOpt.text = "Uninstall";
int widthUninstall = QApplication::style()->sizeFromContents(QStyle::CT_ToolButton, &toolButtonOpt, QSize(option.fontMetrics.width("Uninstall") + HARDCODED_BORDER * 3, option.fontMetrics.height()), toolButton).width();
QSize size = toolButton->sizeHint();
size.setWidth(qMax(widthInstall, widthUninstall));
toolButton->resize(size);
#endif
toolButton->move(option.rect.width() - toolButton->size().width() - HARDCODED_BORDER,
sizeHint().height() / 2 - toolButton->size().height() / 2);
// Eat more space
lineEdit->resize(option.rect.width()
- toolButton->width()
- testWidget->width()
- button->width()
- 5 * HARDCODED_BORDER,
lineEdit->height());
}
private Q_SLOTS:
void mySlot()
{
KMessageBox::information(0, QString("The button in row %1 was clicked").arg(focusedIndex().row()), "Button clicked");
}
void mySlot2()
{
KMessageBox::information(0, QString("A menu item was triggered in row %1").arg(focusedIndex().row()), "Toolbutton menu item clicked");
}
void mySlot3()
{
bool isInstalled = installed[focusedIndex().row()];
installed[focusedIndex().row()] = !isInstalled;
const_cast<QAbstractItemModel*>(focusedIndex().model())->setData(focusedIndex(), QString("makemodelbeupdated"));
}
private:
bool installed[100];
};
int main(int argc, char **argv)
{
KAboutData aboutData("goyaTest",
0,
ki18n("Goya Test"),
"1.0",
ki18n("Goya Test"),
KAboutData::License_LGPL_V3,
ki18n("(c) 2008 Rafael Fernández López and Kevin Ottens "),
ki18n("Goya Test"),
"http://www.kde.org");
KCmdLineArgs::init( argc, argv, &aboutData );
KApplication app;
QMainWindow *mainWindow = new QMainWindow();
mainWindow->setMinimumSize(640, 480);
QListView *listView = new QListView();
QStringListModel *model = new QStringListModel();
model->insertRows(0, 100);
for (int i = 0; i < 100; ++i)
{
model->setData(model->index(i, 0), QString("Test " + QString::number(i)), Qt::DisplayRole);
}
listView->setModel(model);
MyDelegate *myDelegate = new MyDelegate(listView);
listView->setItemDelegate(myDelegate);
listView->setVerticalScrollMode(QListView::ScrollPerPixel);
mainWindow->setCentralWidget(listView);
mainWindow->show();
model->removeRows(0, 95);
return app.exec();
}
#include "kwidgetitemdelegatetest.moc"

View file

@ -1,71 +0,0 @@
/*
Copyright (c) 2003 Lubos Lunak <l.lunak@kde.org>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <QtGui/QWidget>
#include <X11/Xlib.h>
#include <iostream>
using namespace std;
#include <kxerrorhandler.h>
int handler1( Display*, XErrorEvent* e )
{
cout << "ERR1:" << e->resourceid << ":" << (int)e->error_code << ":" << (int)e->request_code << ":" << e->serial << endl;
return 1;
}
bool handler3( int request, int error_code, unsigned long resourceid )
{
cout << "ERR3:" << resourceid << ":" << error_code << ":" << request << endl;
return true;
}
int main()
{
Display* dpy = XOpenDisplay( NULL );
XSetWindowAttributes attrs;
Window w = XCreateWindow( dpy, DefaultRootWindow( dpy ), 0, 0, 100, 100, 0, CopyFromParent, CopyFromParent,
CopyFromParent, 0, &attrs );
cout << w << ":" << XNextRequest( dpy ) << endl;
XMapWindow( dpy, w );
++w;
// XSetInputFocus( dpy, w, RevertToParent, CurrentTime );
{
KXErrorHandler handle1( handler1, dpy );
cout << w << ":" << XNextRequest( dpy ) << endl;
XMapWindow( dpy, w );
XWindowAttributes attr;
{
KXErrorHandler handle2( dpy );
XGetWindowAttributes(dpy, w, &attr);
cout << "WAS2:" << handle2.error( false ) << endl;
}
// XSync( dpy, False );
cout << "WAS1:" << handle1.error( false ) << endl;
}
for(;;) {
XEvent ev;
XNextEvent( dpy, &ev );
}
XCloseDisplay( dpy );
}

View file

@ -1,74 +0,0 @@
#include "kxmlguitest.h"
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kmainwindow.h>
#include <kxmlguifactory.h>
#include <kxmlguiclient.h>
#include <kxmlguibuilder.h>
#include <kaction.h>
#include <kactioncollection.h>
#include <kdebug.h>
#include <kicon.h>
#include <kstandardaction.h>
#include <kstandarddirs.h>
#include <QtGui/QLineEdit>
#include <QtCore/QDir>
void Client::slotSec()
{
kDebug() << "Client::slotSec()";
}
int main( int argc, char **argv )
{
KCmdLineArgs::init( argc, argv, "test", 0, ki18n("Test"), "1.0", ki18n("test app"));
KApplication app;
KAction *a;
// KXMLGUIClient looks in the "data" resource for the .rc files
// Let's add the source dir to it
KGlobal::dirs()->addResourceDir( "data", KDESRCDIR );
KMainWindow *mainwindow = new KMainWindow;
QLineEdit* line = new QLineEdit( mainwindow );
mainwindow->setCentralWidget( line );
mainwindow->show();
KXMLGUIBuilder *builder = new KXMLGUIBuilder( mainwindow );
KXMLGUIFactory *factory = new KXMLGUIFactory( builder );
Client *shell = new Client;
shell->setComponentData(KComponentData("konqueror"));
shell->componentData().dirs()->addResourceDir( "data", QDir::currentPath() );
a = new KAction( KIcon( "view-split-left-right" ), "Split", shell );
shell->actionCollection()->addAction( "splitviewh", a );
shell->setXMLFile( KDESRCDIR "/kxmlguitest_shell.rc" );
factory->addClient( shell );
Client *part = new Client;
a = new KAction( KIcon( "zoom-out" ), "decfont", part );
part->actionCollection()->addAction( "decFontSizes", a );
a = new KAction( KIcon( "security-low" ), "sec", part );
part->actionCollection()->addAction( "security", a );
a->setShortcut( KShortcut(Qt::ALT + Qt::Key_1), KAction::DefaultShortcut );
a->connect( a, SIGNAL(triggered(bool)), part, SLOT(slotSec()) );
part->setXMLFile( KDESRCDIR "/kxmlguitest_part.rc" );
factory->addClient( part );
for ( int i = 0; i < 10; ++i )
{
factory->removeClient( part );
factory->addClient( part );
}
return app.exec();
}
#include "moc_kxmlguitest.cpp"

View file

@ -1,19 +0,0 @@
#ifndef KXMLGUITEST_H
#define KXMLGUITEST_H
#include <kxmlguiclient.h>
#include <QtCore/QObject>
class Client : public QObject, public KXMLGUIClient
{
Q_OBJECT
public:
Client() {}
void setXMLFile( const QString &f, bool merge = true, bool setXMLDoc = true ) { KXMLGUIClient::setXMLFile( f, merge, setXMLDoc ); }
void setComponentData(const KComponentData &inst) { KXMLGUIClient::setComponentData(inst); }
public Q_SLOTS:
void slotSec();
};
#endif

View file

@ -1,8 +0,0 @@
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="khtmlpart" version="7">
<ToolBar name="mainToolBar"><text>Main Toolbar</text>
<Action name="decFontSizes" />
<Separator />
<Action name="security" />
</ToolBar>
</kpartgui>

View file

@ -1,7 +0,0 @@
<!DOCTYPE kpartgui ><kpartgui version="31" name="Konqueror" >
<ToolBar newline="true" name="mainToolBar">
<text>Main Toolbar</text>
<Merge/>
<Action name="splitviewh" />
</ToolBar>
</kpartgui>

View file

@ -1,129 +0,0 @@
/* This file is part of the KDE libraries
Copyright (C) 2008 Rafael Fernández López <ereslibre@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <QTextEdit>
#include <QTimer>
#include <kapplication.h>
#include <kxmlguiwindow.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kactioncollection.h>
#include <kstandarddirs.h>
#include <kmessagebox.h>
#include <kaction.h>
#include <kdebug.h>
#include <kconfiggroup.h>
// BUG: if this symbol is defined the problem consists on:
// - main window is created.
// - settings are saved (and applied), but in this case no toolbars exist yet, so they don't
// apply to any toolbar.
// - after 1 second the GUI is created.
//
// How to reproduce ?
// - Move one toolbar to other place (bottom, left, right, or deattach it).
// - Close the test (so settings are saved).
// - Reopen the test. The toolbar you moved is not keeping the place you specified.
#define REPRODUCE_TOOLBAR_BUG
class MainWindow
: public KXmlGuiWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
public Q_SLOTS:
void slotTest();
void slotCreate();
private:
void setupActions();
};
void MainWindow::slotTest()
{
KMessageBox::information(0, "Test", "Test");
}
void MainWindow::slotCreate()
{
setupGUI(ToolBar);
createGUI(xmlFile());
if (autoSaveConfigGroup().isValid()) {
applyMainWindowSettings(autoSaveConfigGroup());
}
}
void MainWindow::setupActions()
{
KAction *testAction = new KAction(this);
testAction->setText("Test");
testAction->setIcon(KIcon("kde"));
actionCollection()->addAction("test", testAction);
connect(testAction, SIGNAL(triggered(bool)), this, SLOT(slotTest()));
KStandardAction::quit(kapp, SLOT(quit()), actionCollection());
setAutoSaveSettings();
// BUG: if the GUI is created after an amount of time (so settings have been saved), then toolbars
// are shown misplaced. KMainWindow uses a 500 ms timer to save window settings.
#ifdef REPRODUCE_TOOLBAR_BUG
QTimer::singleShot(1000, this, SLOT(slotCreate())); // more than 500 ms so the main window has saved settings.
// We can think of this case on natural applications when they
// load plugins and change parts. It can take 1 second perfectly.
#else
QTimer::singleShot(0, this, SLOT(slotCreate()));
#endif
}
MainWindow::MainWindow(QWidget *parent)
: KXmlGuiWindow(parent)
{
setXMLFile(KDESRCDIR "/kxmlguiwindowtestui.rc", true);
// Because we use a full path in setXMLFile, we need to call setLocalXMLFile too.
// In your apps, just pass a relative filename to setXMLFile instead.
setLocalXMLFile(KStandardDirs::locateLocal("data", "kxmlguiwindowtest/kxmlguiwindowtestui.rc"));
setCentralWidget(new QTextEdit(this));
setupActions();
}
int main(int argc, char **argv)
{
KAboutData aboutData("kxmlguiwindowtest", 0,
ki18n("kxmlguiwindowtest"), "0.1",
ki18n("kxmlguiwindowtest"),
KAboutData::License_LGPL,
ki18n("Copyright (c) 2008 Rafael Fernandez Lopez"));
KCmdLineArgs::init(argc, argv, &aboutData);
KApplication app;
KGlobal::dirs()->addResourceDir("data", KDESRCDIR);
MainWindow *mainWindow = new MainWindow;
mainWindow->show();
return app.exec();
}
#include "kxmlguiwindowtest.moc"

Some files were not shown because too many files have changed in this diff Show more