From ec3b722443fac104d4694563da86147474508f29 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 27 May 2012 22:41:09 +0200 Subject: Runtime Nepomuk tagging check --- src/urlbar/bookmarkwidget.cpp | 111 +++++++++++++++++++++++++----------------- 1 file changed, 67 insertions(+), 44 deletions(-) (limited to 'src/urlbar/bookmarkwidget.cpp') diff --git a/src/urlbar/bookmarkwidget.cpp b/src/urlbar/bookmarkwidget.cpp index f73e5eb4..d3bcd41b 100644 --- a/src/urlbar/bookmarkwidget.cpp +++ b/src/urlbar/bookmarkwidget.cpp @@ -42,12 +42,14 @@ #include // Qt Includes -#include -#include -#include -#include +#include +#include +#include +#include #include #include +#include +#include // Nepomuk config include #include "../config-nepomuk.h" @@ -71,6 +73,8 @@ BookmarkWidget::BookmarkWidget(const KBookmark &bookmark, QWidget *parent) #ifdef HAVE_NEPOMUK m_nfoResource = (QUrl)m_bookmark->url(); + m_isNepomukEnabled = QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.NepomukServer"); + kDebug() << "IS NEPOMUK ACTUALLY RUNNING? " << m_isNepomukEnabled; #endif QFormLayout *layout = new QFormLayout(this); @@ -118,50 +122,66 @@ BookmarkWidget::BookmarkWidget(const KBookmark &bookmark, QWidget *parent) layout->addRow(nameLabel, m_name); #ifdef HAVE_NEPOMUK - QLabel* rateLabel = new QLabel(this); - rateLabel->setText( i18n( "Rate:" ) ); - KRatingWidget *ratingWidget = new KRatingWidget( this ); - if( m_nfoResource.rating() != NULL ) { - ratingWidget->setRating( m_nfoResource.rating() ); - } - connect( ratingWidget, SIGNAL( ratingChanged( int ) ), this, SLOT( setRatingSlot( int ) ) ); - ratingWidget->setToolTip( i18n( "Rate this page" ) ); - layout->addRow( rateLabel,ratingWidget ); - - //Add comments - QLabel *commentLabel = new QLabel( this ); - commentLabel->setText( i18n( "Describe:" ) ); - commentLabel->setAlignment( Qt::AlignCenter ); - m_commentEdit = new QPlainTextEdit( this ); - if( !m_nfoResource.description().isEmpty() ) { - m_commentEdit->setPlainText( m_nfoResource.description() ); - } - connect( m_commentEdit, SIGNAL(textChanged()), this, SLOT(addCommentSlot()) ); - layout->addRow( commentLabel, m_commentEdit ); - // Create tags - QLabel *tagLabel = new QLabel( this ); - tagLabel->setText( i18n( "Tags:" ) ); - tagLabel->setAlignment( Qt::AlignLeft ); - m_tagLine = new KLineEdit( this ); - m_tagLine->setPlaceholderText( i18n( "add tags(comma separated)" ) ); + if (m_isNepomukEnabled) + { + QLabel* rateLabel = new QLabel(this); + rateLabel->setText( i18n( "Rate:" ) ); + KRatingWidget *ratingWidget = new KRatingWidget( this ); + if ( m_nfoResource.rating() != NULL ) + { + ratingWidget->setRating( m_nfoResource.rating() ); + } + connect( ratingWidget, SIGNAL( ratingChanged( int ) ), this, SLOT( setRatingSlot( int ) ) ); + ratingWidget->setToolTip( i18n( "Rate this page" ) ); + layout->addRow( rateLabel,ratingWidget ); + + //Add comments + QLabel *commentLabel = new QLabel( this ); + commentLabel->setText( i18n( "Describe:" ) ); + commentLabel->setAlignment( Qt::AlignCenter ); + m_commentEdit = new QPlainTextEdit( this ); + if ( !m_nfoResource.description().isEmpty() ) + { + m_commentEdit->setPlainText( m_nfoResource.description() ); + } + connect( m_commentEdit, SIGNAL(textChanged()), this, SLOT(addCommentSlot()) ); + layout->addRow( commentLabel, m_commentEdit ); + // Create tags + QLabel *tagLabel = new QLabel( this ); + tagLabel->setText( i18n( "Tags:" ) ); + tagLabel->setAlignment( Qt::AlignLeft ); + m_tagLine = new KLineEdit( this ); + m_tagLine->setPlaceholderText( i18n( "add tags(comma separated)" ) ); - QList tagList = Nepomuk::Tag::allTags(); - Q_FOREACH(Nepomuk::Tag t,tagList) { - m_tList.append(t.label()); - } - QCompleter *completeTag = new QCompleter( m_tList ); - completeTag->setCompletionMode(QCompleter::PopupCompletion); - m_tagLine->setCompleter(completeTag); - loadTags(); - layout->addRow(tagLabel,m_tagLine); + QList tagList = Nepomuk::Tag::allTags(); + Q_FOREACH(Nepomuk::Tag t,tagList) + { + m_tList.append(t.label()); + } + QCompleter *completeTag = new QCompleter( m_tList ); + completeTag->setCompletionMode(QCompleter::PopupCompletion); + m_tagLine->setCompleter(completeTag); + loadTags(); + + layout->addRow(tagLabel,m_tagLine); - QPushButton *linkToResource = new QPushButton( this ); - linkToResource->setText( i18n( "Link Resources" ) ); - connect(linkToResource, SIGNAL(clicked()), this, SLOT( linkToResourceSlot() ) ); - layout->addWidget(linkToResource); + QPushButton *linkToResource = new QPushButton( this ); + linkToResource->setText( i18n( "Link Resources" ) ); + connect(linkToResource, SIGNAL(clicked()), this, SLOT( linkToResourceSlot() ) ); + layout->addWidget(linkToResource); + } + else + { + QLabel *nepomukLabel = new QLabel(this); + QPalette p = nepomukLabel->palette(); + p.setColor(QPalette::WindowText, Qt::red); + nepomukLabel->setPalette(p); + nepomukLabel->setText(i18n("Nepomuk is actually disabled.")); + layout->addWidget(nepomukLabel); + } #endif // Ok & Cancel buttons @@ -204,7 +224,10 @@ void BookmarkWidget::accept() rApp->bookmarkManager()->manager()->emitChanged(a); #ifdef HAVE_NEPOMUK - parseTags(); + if (m_isNepomukEnabled) + { + parseTags(); + } #endif close(); -- cgit v1.2.1