void QDeclarativeWebView::init() { d = new QDeclarativeWebViewPrivate(this); if (QWebSettings::iconDatabasePath().isNull() && QWebSettings::globalSettings()->localStoragePath().isNull() && QWebSettings::offlineStoragePath().isNull() && QWebSettings::offlineWebApplicationCachePath().isNull()) QWebSettings::enablePersistentStorage(); setAcceptedMouseButtons(Qt::LeftButton); setFlag(QGraphicsItem::ItemHasNoContents, true); setFlag(QGraphicsItem::ItemIsFocusScope, true); setClip(true); d->view = new GraphicsWebView(this); d->view->setResizesToContents(true); d->view->setFocus(); QWebPage* wp = new QDeclarativeWebPage(this); setPage(wp); if (!preferredWidth()) setPreferredWidth(d->view->preferredWidth()); if (!preferredHeight()) setPreferredHeight(d->view->preferredHeight()); connect(d->view, SIGNAL(geometryChanged()), this, SLOT(updateDeclarativeWebViewSize())); connect(d->view, SIGNAL(doubleClick(int,int)), this, SIGNAL(doubleClick(int,int))); connect(d->view, SIGNAL(scaleChanged()), this, SIGNAL(contentsScaleChanged())); }
void PhotosApplet::init() { DEBUG_BLOCK // Call the base implementation. Context::Applet::init(); // Create label enableHeader( true ); setHeaderText( i18n( "Photos" ) ); // Set the collapse size setCollapseHeight( m_header->height() ); setCollapseOffHeight( 220 ); setMaximumHeight( 220 ); setMinimumHeight( collapseHeight() ); setPreferredHeight( collapseHeight() ); // Icon QAction* settingsAction = new QAction( this ); settingsAction->setIcon( KIcon( "preferences-system" ) ); settingsAction->setVisible( true ); settingsAction->setEnabled( true ); settingsAction->setText( i18n( "Settings" ) ); m_settingsIcon = addRightHeaderAction( settingsAction ); connect( m_settingsIcon, SIGNAL( clicked() ), this, SLOT( showConfigurationInterface() ) ); m_widget = new PhotosScrollWidget( this ); m_widget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); m_widget->setContentsMargins( 0, 0, 0, 0 ); connect( m_widget, SIGNAL(photoAdded()), SLOT(photoAdded()) ); QGraphicsLinearLayout *layout = new QGraphicsLinearLayout( Qt::Vertical, this ); layout->addItem( m_header ); layout->addItem( m_widget ); // Read config and inform the engine. KConfigGroup config = Amarok::config("Photos Applet"); m_nbPhotos = config.readEntry( "NbPhotos", "10" ).toInt(); m_Animation = config.readEntry( "Animation", "Fading" ); m_KeyWords = config.readEntry( "KeyWords", QStringList() ); if( m_Animation == i18nc( "animation type", "Automatic" ) ) m_widget->setMode( 0 ); else if( m_Animation == i18n( "Interactive" ) ) m_widget->setMode( 1 ); else // fading m_widget->setMode( 2 ); Plasma::DataEngine *engine = dataEngine( "amarok-photos" ); engine->setProperty( "fetchSize", m_nbPhotos ); engine->setProperty( "keywords", m_KeyWords ); engine->connectSource( "photos", this ); }
/** * \brief Initialization * * Initializes the TabsApplet with default parameters */ void TabsApplet::init() { // applet base initialization Context::Applet::init(); // create the header label enableHeader( true ); setHeaderText( i18nc( "Guitar tablature", "Tabs" ) ); // creates the tab view m_tabsView = new TabsView( this ); // Set the collapse size setCollapseOffHeight( -1 ); setCollapseHeight( m_header->height() ); setMinimumHeight( collapseHeight() ); setPreferredHeight( collapseHeight() ); // create the reload icon QAction* reloadAction = new QAction( this ); reloadAction->setIcon( KIcon( "view-refresh" ) ); reloadAction->setVisible( true ); reloadAction->setEnabled( true ); reloadAction->setText( i18nc( "Guitar tablature", "Reload tabs" ) ); m_reloadIcon = addLeftHeaderAction( reloadAction ); m_reloadIcon.data()->setEnabled( false ); connect( m_reloadIcon.data(), SIGNAL(clicked()), this, SLOT(reloadTabs()) ); // create the settings icon QAction* settingsAction = new QAction( this ); settingsAction->setIcon( KIcon( "preferences-system" ) ); settingsAction->setEnabled( true ); settingsAction->setText( i18n( "Settings" ) ); QWeakPointer<Plasma::IconWidget> settingsIcon = addRightHeaderAction( settingsAction ); connect( settingsIcon.data(), SIGNAL(clicked()), this, SLOT(showConfigurationInterface()) ); m_layout = new QGraphicsLinearLayout( Qt::Vertical ); m_layout->addItem( m_header ); m_layout->addItem( m_tabsView ); setLayout( m_layout ); // read configuration data and update the engine. KConfigGroup config = Amarok::config("Tabs Applet"); m_fetchGuitar = config.readEntry( "FetchGuitar", true ); m_fetchBass = config.readEntry( "FetchBass", true ); Plasma::DataEngine *engine = dataEngine( "amarok-tabs" ); engine->setProperty( "fetchGuitarTabs", m_fetchGuitar ); engine->setProperty( "fetchBassTabs", m_fetchBass ); engine->connectSource( "tabs", this ); updateInterface( InitState ); }
void QDeclarativeMozView::init() { setAcceptedMouseButtons(Qt::LeftButton); setFlag(QGraphicsItem::ItemHasNoContents, true); setFlag(QGraphicsItem::ItemIsFocusScope, true); setClip(true); d->view = new GraphicsMozView(this); d->view->setFocus(); if (!preferredWidth()) setPreferredWidth(d->view->preferredWidth()); if (!preferredHeight()) setPreferredHeight(d->view->preferredHeight()); }
void Context::Applet::collapse( bool on ) { qreal finalHeight = ( on ) ? m_heightCollapseOn : m_heightCollapseOff; const qreal maxHeight = containment()->size().height(); if( (finalHeight > maxHeight) || (finalHeight < 0) ) finalHeight = maxHeight; prepareGeometryChange(); // warning: view() currently can return pointer to ToolbarView, not the ContextView ContextView *v = ContextView::self(); // may return null // Plasma::Applet::view() might return 0, if the widget is not yet constructed, etc. // \sa https://bugs.kde.org/show_bug.cgi?id=258741. If view is not available // yet, regardless of the animation setting the preferred size is set // straight away. if( !v || !AmarokConfig::animateAppletCollapse() ) { setPreferredHeight( finalHeight ); emit sizeHintChanged( Qt::PreferredSize ); updateGeometry(); return; } if( finalHeight == size().height() ) return; // debug() << pluginName() << (on ? "collapsing to" : "uncollapsing to") << finalHeight; QPropertyAnimation *pan = m_animation.data(); if( !pan ) pan = new QPropertyAnimation( this, "preferredSize" ); if( pan->state() == QAbstractAnimation::Running ) pan->stop(); pan->setDuration( 600 ); pan->setEasingCurve( QEasingCurve::InQuad ); pan->setStartValue( size() ); pan->setEndValue( QSizeF(size().width(), finalHeight) ); connect( pan, SIGNAL(finished()), SLOT(collapseAnimationFinished()) ); m_animation = pan; pan->setDirection( QAbstractAnimation::Forward ); v->addCollapseAnimation( pan ); }
Options::Options(QGraphicsWidget *parent) : QGraphicsWidget(parent), // m_volume(new Plasma::IconWidget(this)), //m_meter(new KcdMeter(this)), //m_tracklist(new Plasma::IconWidget(this)), m_albumText(new Plasma::Label(this)), m_random(new Plasma::IconWidget(this)), m_loop(new Plasma::IconWidget(this)) { //m_volume->setIcon("audio-volume-high"); //connect (m_volume, SIGNAL(clicked()), this, SLOT(handleVolume())); //m_volume->setMinimumSize(m_random->sizeFromIconSize(10)); //m_meter->setMinimum(0); //m_meter->setMaximum(10); //m_meter->setMeterType(Plasma::Meter::BarMeterHorizontal); //connect (m_meter, SIGNAL(valueChanged(int)), this, SIGNAL(volumeChanged(int))); //m_tracklist->setIcon("format-list-unordered"); //m_tracklist->setMinimumSize(m_random->sizeFromIconSize(10)); //connect(m_tracklist, SIGNAL(clicked()), this, SIGNAL(showTrackList())); Plasma::ToolTipContent data; //data.setMainText(i18n("Tracklist")); //data.setSubText(i18n("View the tracklist")); //data.setImage(KIcon("format-list-unordered").pixmap(IconSize(KIconLoader::Desktop))); //Plasma::ToolTipManager::self()->setContent(m_tracklist, data); m_random->setIcon("roll"); connect(m_random, SIGNAL(clicked()), this, SLOT(randomTrack())); data.setMainText(i18n("Random - off")); data.setSubText(i18n("Play random track")); data.setImage(KIcon("roll").pixmap(IconSize(KIconLoader::Desktop))); Plasma::ToolTipManager::self()->setContent(m_random, data); m_loop->setIcon("object-rotate-right"); connect(m_loop, SIGNAL(clicked()), this, SLOT(loopList())); data.setMainText(i18n("Repeat - off")); data.setSubText(i18n("Play again the tracklist")); data.setImage(KIcon("object-rotate-right").pixmap(IconSize(KIconLoader::Desktop))); Plasma::ToolTipManager::self()->setContent(m_loop, data); QGraphicsLinearLayout *layout = new QGraphicsLinearLayout; layout->setOrientation(Qt::Horizontal); //layout->addItem(m_volume); //layout->addItem(m_meter); layout->addItem(m_albumText); layout->addItem(m_random); layout->addItem(m_loop); layout->setAlignment(m_albumText, Qt::AlignLeft); layout->setAlignment(m_random, Qt::AlignRight); layout->setAlignment(m_loop, Qt::AlignRight); layout->setStretchFactor(m_random, 0); layout->setStretchFactor(m_loop, 0); setPreferredHeight(35); //layout->setItemSpacing(0, 50); //layout->addItem(m_tracklist); //layout->setStretchFactor(m_meter, 20); //layout->setSpacing(0); //layout->setAlignment(m_random, Qt::AlignRight); //layout->setAlignment(m_loop, Qt::AlignRight); //layout->setAlignment(m_tracklist, Qt::AlignRight); //layout->setItemSpacing(1, 10); setLayout(layout); randomFlag = false; loopFlag = false; //volumeFlag = true; }
void SimilarArtistsApplet::init() { DEBUG_BLOCK // Call the base implementation. Context::Applet::init(); enableHeader( true ); setHeaderText( i18n( "Similar Artists" ) ); QAction* backwardAction = new QAction( this ); backwardAction->setIcon( KIcon( "go-previous" ) ); backwardAction->setEnabled( false ); backwardAction->setText( i18n( "Back" ) ); m_backwardIcon = addLeftHeaderAction( backwardAction ); connect( m_backwardIcon, SIGNAL(clicked()), this, SLOT(goBackward()) ); QAction* forwardAction = new QAction( this ); forwardAction->setIcon( KIcon( "go-next" ) ); forwardAction->setEnabled( false ); forwardAction->setText( i18n( "Forward" ) ); m_forwardIcon = addLeftHeaderAction( forwardAction ); connect( m_forwardIcon, SIGNAL(clicked()), this, SLOT(goForward()) ); QAction *currentAction = new QAction( this ); currentAction->setIcon( KIcon( "filename-artist-amarok" ) ); currentAction->setEnabled( true ); currentAction->setText( i18n( "Show Similar Artists for Currently Playing Track" ) ); m_currentArtistIcon = addRightHeaderAction( currentAction ); connect( m_currentArtistIcon, SIGNAL(clicked()), this, SLOT(queryForCurrentTrack()) ); QAction* settingsAction = new QAction( this ); settingsAction->setIcon( KIcon( "preferences-system" ) ); settingsAction->setEnabled( true ); settingsAction->setText( i18n( "Settings" ) ); m_settingsIcon = addRightHeaderAction( settingsAction ); connect( m_settingsIcon, SIGNAL(clicked()), this, SLOT(configure()) ); setCollapseOffHeight( -1 ); setCollapseHeight( m_header->height() ); setMinimumHeight( collapseHeight() ); setPreferredHeight( collapseHeight() ); // create a scrollarea m_scroll = new ArtistsListWidget( this ); m_scroll->hide(); connect( m_scroll, SIGNAL(showSimilarArtists(QString)), SLOT(showSimilarArtists(QString)) ); connect( m_scroll, SIGNAL(showBio(QString)), SLOT(showArtistBio(QString)) ); m_layout = new QGraphicsLinearLayout( Qt::Vertical, this ); m_layout->addItem( m_header ); m_layout->addItem( m_scroll ); setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); // Read config and inform the engine. KConfigGroup config = Amarok::config( "SimilarArtists Applet" ); m_maxArtists = config.readEntry( "maxArtists", "5" ).toInt(); Plasma::DataEngine *engine = dataEngine( "amarok-similarArtists" ); connect( engine, SIGNAL(sourceAdded(QString)), SLOT(connectSource(QString)) ); engine->setProperty( "maximumArtists", m_maxArtists ); engine->query( "similarArtists" ); }
void KWidget::setFixHeight( qreal h ) { setMinimumHeight(h); setPreferredHeight(h); setMaximumHeight(h); }
void KWidget::setHeightToChild(bool on) { setPreferredHeight(-1); setMaximumHeight(-1); setMinimumHeight(-1); }