summaryrefslogtreecommitdiffstats
path: root/kdeui/tests/kmessageboxtest.cpp
blob: 1b926739f4473bb463b429e3381dca6569ddcdd3 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
#include "kmessagebox.h"

#include <tqdialog.h>
#include <tqlayout.h>

#include <stdlib.h>

#include <stdio.h>

#include <kstatusbar.h>
#include <kapplication.h>

#include <kglobal.h>

class ExampleWidget : public QLabel
{
public:
    ExampleWidget( TQWidget *parent = 0, const char *name = 0 );
};

ExampleWidget::ExampleWidget( TQWidget *parent, const char *name )
    : TQLabel(parent, name )
{
    // Make the top-level layout; a vertical box to contain all widgets
    // and sub-layouts.
    TQSize 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() : TQDialog(0, "foo", true) { resize(200,200); new TQLabel("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;
    new KApplication( argc, argv, "MyApplication" );

    ExampleWidget *w = new ExampleWidget();
    w->show();    
    w->deleteLater();

    TQStringList 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", TQString::fromLatin1("&Print"), "dontask", false);
  i = KMessageBox::warningContinueCancel(0, 
                "You are about to <Print>.\n"
		"Are you sure?",
                "Print", TQString::fromLatin1("&Print"), "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>",
  	TQString("Bla"), TQString("Yes"), TQString("No"), "bla", KMessageBox::AllowLink);
  break;

case 2:
  i = KMessageBox::questionYesNo(0, "Do you have a printer?",
				 TQString("Printer setup"), TQString::null);
  break;

case 3:
  i = KMessageBox::questionYesNo(0,
                "Does your printer support color or only black and white?",
                "Printer setup", TQString::fromLatin1("&Color"), TQString::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", TQString::fromLatin1("&Print"));
  break;
case 7:
  i = KMessageBox::warningContinueCancel(0, 
                "You are about to <Print>.\n"
		"Are you sure?",
                "Print", TQString::fromLatin1("&Print"), "dontask", false);
  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",
                TQString::fromLatin1("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", TQString::fromLatin1("&Save"), TQString::fromLatin1("&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.", TQString::null, "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.", TQString::null, "Enable_Menubar");
  break;
case 20:
  {
  TQStringList 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:
  {
  TQStringList strlist;
  printf("Filling StringList...\n");  
  for (int j=1;j<=6000;j++) strlist.append(TQString("/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, TQString::null, "Search_Words");
  break;

default:
  return 0;
         } // Switch

         showResult(test, i);
    } // Test
}