You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
243 lines
7.1 KiB
243 lines
7.1 KiB
15 years ago
|
#include "kmessagebox.h"
|
||
|
|
||
15 years ago
|
#include <tqdialog.h>
|
||
|
#include <tqlayout.h>
|
||
15 years ago
|
|
||
|
#include <stdlib.h>
|
||
|
|
||
|
#include <stdio.h>
|
||
|
|
||
|
#include <kstatusbar.h>
|
||
|
#include <kapplication.h>
|
||
|
|
||
|
#include <kglobal.h>
|
||
|
|
||
|
class ExampleWidget : public QLabel
|
||
|
{
|
||
|
public:
|
||
15 years ago
|
ExampleWidget( TQWidget *parent = 0, const char *name = 0 );
|
||
15 years ago
|
};
|
||
|
|
||
15 years ago
|
ExampleWidget::ExampleWidget( TQWidget *parent, const char *name )
|
||
|
: TQLabel(parent, name )
|
||
15 years ago
|
{
|
||
14 years ago
|
// Make the top-level layout; a vertical box to contain all widgets
|
||
|
// and sub-layouts.
|
||
15 years ago
|
TQSize sh;
|
||
15 years ago
|
setText("<p>Hello.</p>");
|
||
14 years ago
|
sh = tqsizeHint();
|
||
15 years ago
|
qWarning("SizeHint = %d x %d", sh.width(), sh.height());
|
||
|
setText("Hello.");
|
||
14 years ago
|
sh = tqsizeHint();
|
||
15 years ago
|
qWarning("SizeHint = %d x %d", sh.width(), sh.height());
|
||
|
setText("<p>Hello<br>World</p>");
|
||
14 years ago
|
sh = tqsizeHint();
|
||
15 years ago
|
qWarning("SizeHint = %d x %d", sh.width(), sh.height());
|
||
|
// setText("Hello\nWorld");
|
||
14 years ago
|
sh = tqsizeHint();
|
||
15 years ago
|
qWarning("SizeHint = %d x %d", sh.width(), sh.height());
|
||
14 years ago
|
setMinimumSize(tqsizeHint());
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
|
class Foo: public QDialog
|
||
|
{
|
||
|
public:
|
||
15 years ago
|
Foo() : TQDialog(0, "foo", true) { resize(200,200); new TQLabel("Hello World", this); show(); }
|
||
15 years ago
|
};
|
||
|
|
||
|
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();
|
||
|
|
||
15 years ago
|
TQStringList list; list.append("Hello"); list.append("World");
|
||
15 years ago
|
|
||
|
for( test = 1; true; test++)
|
||
|
{
|
||
|
switch(test)
|
||
|
{
|
||
|
case 1:
|
||
|
i = KMessageBox::warningContinueCancel(w,
|
||
|
"You are about to <Print>.\n"
|
||
|
"Are you sure?",
|
||
14 years ago
|
"Print", TQString::tqfromLatin1("&Print"), "dontask", false);
|
||
15 years ago
|
i = KMessageBox::warningContinueCancel(0,
|
||
|
"You are about to <Print>.\n"
|
||
|
"Are you sure?",
|
||
14 years ago
|
"Print", TQString::tqfromLatin1("&Print"), "dontask", KMessageBox::AllowLink);
|
||
15 years ago
|
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>",
|
||
15 years ago
|
TQString("Bla"), TQString("Yes"), TQString("No"), "bla", KMessageBox::AllowLink);
|
||
15 years ago
|
break;
|
||
|
|
||
|
case 2:
|
||
|
i = KMessageBox::questionYesNo(0, "Do you have a printer?",
|
||
15 years ago
|
TQString("Printer setup"), TQString::null);
|
||
15 years ago
|
break;
|
||
|
|
||
|
case 3:
|
||
|
i = KMessageBox::questionYesNo(0,
|
||
|
"Does your printer support color or only black and white?",
|
||
14 years ago
|
"Printer setup", TQString::tqfromLatin1("&Color"), TQString::tqfromLatin1("&Black & White"));
|
||
15 years ago
|
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?",
|
||
14 years ago
|
"Print", TQString::tqfromLatin1("&Print"));
|
||
15 years ago
|
break;
|
||
|
case 7:
|
||
|
i = KMessageBox::warningContinueCancel(0,
|
||
|
"You are about to <Print>.\n"
|
||
|
"Are you sure?",
|
||
14 years ago
|
"Print", TQString::tqfromLatin1("&Print"), "dontask", false);
|
||
15 years ago
|
break;
|
||
|
|
||
|
case 8:
|
||
|
i = KMessageBox::warningYesNoCancel(0,
|
||
14 years ago
|
"Your document contains unsaved changes.\n"
|
||
15 years ago
|
"Do you want to save your changes?\n");
|
||
|
break;
|
||
|
|
||
|
case 9:
|
||
|
i = KMessageBox::warningYesNoCancel(0,
|
||
14 years ago
|
"Your document contains unsaved changes.\n"
|
||
15 years ago
|
"Do you want to save your changes?\n",
|
||
14 years ago
|
TQString::tqfromLatin1("Close"));
|
||
15 years ago
|
break;
|
||
|
|
||
|
case 10:
|
||
|
i = KMessageBox::warningYesNoCancel(0,
|
||
14 years ago
|
"Your document contains unsaved changes.\n"
|
||
15 years ago
|
"Do you want to save or discard your changes?\n",
|
||
14 years ago
|
"Close", TQString::tqfromLatin1("&Save"), TQString::tqfromLatin1("&Discard") );
|
||
15 years ago
|
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;
|
||
15 years ago
|
KMessageBox::information(0, "You can enable the menubar again\nwith the right mouse button menu.", TQString::null, "Enable_Menubar");
|
||
15 years ago
|
break;
|
||
|
|
||
|
case 18:
|
||
|
i = KMessageBox::Ok;
|
||
|
KMessageBox::enableAllMessages();
|
||
|
break;
|
||
|
|
||
|
case 19:
|
||
|
i = KMessageBox::Ok;
|
||
15 years ago
|
KMessageBox::information(0, "Return of the annoying popup message.", TQString::null, "Enable_Menubar");
|
||
15 years ago
|
break;
|
||
|
case 20:
|
||
|
{
|
||
15 years ago
|
TQStringList strlist;
|
||
15 years ago
|
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:
|
||
|
{
|
||
15 years ago
|
TQStringList strlist;
|
||
15 years ago
|
printf("Filling StringList...\n");
|
||
15 years ago
|
for (int j=1;j<=6000;j++) strlist.append(TQString("/tmp/tmp.%1").arg(j));
|
||
15 years ago
|
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;
|
||
15 years ago
|
KMessageBox::informationList(0, "The follwoing words have been found:", list, TQString::null, "Search_Words");
|
||
15 years ago
|
break;
|
||
|
|
||
|
default:
|
||
|
return 0;
|
||
|
} // Switch
|
||
|
|
||
|
showResult(test, i);
|
||
|
} // Test
|
||
|
}
|
||
|
|