text = text.trimmed();
text.insert(0, "http://www.");
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
QNetworkReply
*reply
= manager
->head
(QNetworkRequest
(QUrl(text
)));
//QMessageBox::information(this,"asd","asdasd");
QVariant variant
= reply
->header
(QNetworkRequest
::LocationHeader);
if(!variant.isNull())
{
if (text.length() > 18)
{
truncatedURL.truncate(15);
truncatedURL += "...";
}
//open selected text url in a new tab
a = new KAction(KIcon("tab-new"), i18n("Open '%1' in New Tab", truncatedURL), this);
connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInNewTab()));
menu.addAction(a);
//open selected text url in a new window
a = new KAction(KIcon("window-new"), i18n("Open '%1' in New Window", truncatedURL), this);
connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInNewWindow()));
menu.addAction(a);
menu.addSeparator();
}
QString text = selectedText();
text = text.trimmed();
text.insert(0, "http://www.");
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
QNetworkReply *reply = manager->head(QNetworkRequest(QUrl(text)));
//QMessageBox::information(this,"asd","asdasd");
QVariant variant = reply->header(QNetworkRequest::LocationHeader);
if(!variant.isNull())
{
QString truncatedURL = text;
if (text.length() > 18)
{
truncatedURL.truncate(15);
truncatedURL += "...";
}
//open selected text url in a new tab
a = new KAction(KIcon("tab-new"), i18n("Open '%1' in New Tab", truncatedURL), this);
a->setData(QUrl(text));
connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInNewTab()));
menu.addAction(a);
//open selected text url in a new window
a = new KAction(KIcon("window-new"), i18n("Open '%1' in New Window", truncatedURL), this);
a->setData(QUrl(text));
connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInNewWindow()));
menu.addAction(a);
menu.addSeparator();
}
To copy to clipboard, switch view to plain text mode
//QMessageBox::information(this,"asd","asdasd");
//QMessageBox::information(this,"asd","asdasd");
To copy to clipboard, switch view to plain text mode
it works fine. But when I comment that line it doesn't! I think the application can have enough time to compute the QNetworkReply result. I don't know how to solve the problem, please help me!
Bookmarks