summaryrefslogtreecommitdiffstats
path: root/tdeui/tests/kpanelmenutest.cpp
blob: e081e467ff403eeeaf889dc0c9f9eb34dbbb28c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "kpanelmenutest.h"
#include <kapplication.h>
#include <kstandarddirs.h>
#include <dcopclient.h>

TestWidget::TestWidget(TQWidget *parent, const char *name)
    : TQLabel(parent, name)
{
    testMenu = new KPanelAppMenu(locate("mini", "x.png"), "Client Test", this,
                              "menu1");

    subMenu = testMenu->insertMenu(locate("mini", "x.png"), "Submenu Test");
    subMenu->insertItem(locate("mini", "bx2.png"), "First Entry", 100);
    subMenu->insertItem(locate("mini", "bx2.png"), "Second Entry", 101);

    KPanelAppMenu *ssub = subMenu->insertMenu(locate("mini", "x.png"), "One more");
   
    connect(testMenu, TQT_SIGNAL(activated(int)), TQT_SLOT(slotMenuCalled(int)));
    connect(subMenu, TQT_SIGNAL(activated(int)), TQT_SLOT(slotSubMenuCalled(int)));
    init();
    
    setText("We added \"Client Test\" to kicker. Click the K Menu to check.");
    resize(tqsizeHint());
}

void TestWidget::init()
{
    testMenu->insertItem(locate("mini", "bx2.png"),
                                "Add another entry!", 1);
    testMenu->insertItem("Attention, this will clear the menu", 2);
}

void TestWidget::slotMenuCalled(int id)
{
    switch ( id ) {
    case 1:
	setText("Selected \"Add another entry!\" ");
	testMenu->insertItem("Another entry");
    break;
    case 2:
	setText("Selected \"Attention, this will clear the menu\"");
	testMenu->clear();
	init();
    break;
    default:
	setText("Selected \"Another entry...\"");
    }
}


void TestWidget::slotSubMenuCalled(int id)
{
  TQString msg("Called with id=%1");
  setText(msg.arg(id));
}


int main(int argc, char **argv)
{
    KApplication *app = new KApplication(argc, argv, "menutest");
    
    TestWidget w;
    app->setMainWidget(&w);
    w.show();
    
    app->exec();
}

#include "kpanelmenutest.moc"