760 void HWChatWidget::dragEnterEvent(QDragEnterEvent * event) |
760 void HWChatWidget::dragEnterEvent(QDragEnterEvent * event) |
761 { |
761 { |
762 if (event->mimeData()->hasUrls()) |
762 if (event->mimeData()->hasUrls()) |
763 { |
763 { |
764 QList<QUrl> urls = event->mimeData()->urls(); |
764 QList<QUrl> urls = event->mimeData()->urls(); |
765 QString url = urls[0].toString(); |
|
766 if (urls.count() == 1) |
765 if (urls.count() == 1) |
767 if (url.contains(QRegExp("^file://.*\\.css$"))) |
766 { |
|
767 QUrl url = urls[0]; |
|
768 |
|
769 static QRegExp localFileRegExp("file://.*\\.css$"); |
|
770 localFileRegExp.setCaseSensitivity(Qt::CaseInsensitive); |
|
771 |
|
772 if (url.toString().contains(localFileRegExp)) |
768 event->acceptProposedAction(); |
773 event->acceptProposedAction(); |
|
774 } |
769 } |
775 } |
770 } |
776 } |
771 |
777 |
772 void HWChatWidget::dropEvent(QDropEvent * event) |
778 void HWChatWidget::dropEvent(QDropEvent * event) |
773 { |
779 { |
774 const QString path(event->mimeData()->urls()[0].toString()); |
780 const QString path(event->mimeData()->urls()[0].toString()); |
775 QFile file(QString(path).remove(QRegExp("^file://"))); |
781 |
|
782 QFile file(event->mimeData()->urls()[0].toLocalFile()); |
776 |
783 |
777 if (file.exists() && (file.open(QIODevice::ReadOnly | QIODevice::Text))) |
784 if (file.exists() && (file.open(QIODevice::ReadOnly | QIODevice::Text))) |
778 { |
785 { |
779 QString style; |
786 QString style; |
780 QTextStream in(&file); |
787 QTextStream in(&file); |
781 while (!in.atEnd()) |
788 while (!in.atEnd()) |
782 { |
789 { |
783 QString line = in.readLine(); |
790 QString line = in.readLine(); |
784 if(!line.isEmpty()) |
791 style.append(line + "\n"); |
785 style.append(line); |
|
786 } |
792 } |
787 |
793 |
788 setStyleSheet(style); |
794 setStyleSheet(style); |
789 chatText->document()->setDefaultStyleSheet(*s_styleSheet); |
795 chatText->document()->setDefaultStyleSheet(*s_styleSheet); |
790 displayNotice(tr("Stylesheet imported from %1").arg(path)); |
796 displayNotice(tr("Stylesheet imported from %1").arg(path)); |