Example #1
0
void RunCommandRequester::slotSelCommand()
{
	KOpenWithDialog *dlg =  new KOpenWithDialog(KUrl::List(), m_message, m_runCommand->text(), this);
	dlg->exec();
	if ( ! dlg->text().isEmpty() )
		m_runCommand->setText(dlg->text());
}
Example #2
0
int main(int argc, char **argv)
{
    KCmdLineArgs::init(argc, argv, "kopenwithdialogtest", 0, ki18n("kopenwithdialogtest"), "0.1", ki18n("kopenwithdialogtest"));
    KApplication app;
    KUrl::List list;

    list += KUrl("file:///tmp/testfile.txt");

    // Test with one URL
    KOpenWithDialog* dlg = new KOpenWithDialog(list, "OpenWith_Text", "OpenWith_Value", 0);
    if(dlg->exec()) {
        kDebug() << "Dialog ended successfully\ntext: " << dlg->text();
    }
    else
        kDebug() << "Dialog was canceled.";
    delete dlg;

    // Test with two URLs
    list += KUrl("http://www.kde.org/index.html");
    dlg = new KOpenWithDialog(list, "OpenWith_Text", "OpenWith_Value", 0);
    if(dlg->exec()) {
        kDebug() << "Dialog ended successfully\ntext: " << dlg->text();
    }
    else
        kDebug() << "Dialog was canceled.";
    delete dlg;

    // Test with a mimetype
    QString mimetype = "text/plain";
    dlg = new KOpenWithDialog( mimetype, "kedit", 0);
    if(dlg->exec()) {
        kDebug() << "Dialog ended successfully\ntext: " << dlg->text();
    }
    else
        kDebug() << "Dialog was canceled.";
    delete dlg;

    return 0;
}