ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget* parent ) : QWidget( parent ) , TomahawkUtils::DpiScaler( this ) , ui( new Ui::ArtistInfoWidget ) , m_artist( artist ) { m_widget = new QWidget; m_headerWidget = new BasicHeader; ui->setupUi( m_widget ); { ui->relatedArtists->setAutoResize( true ); ui->relatedArtists->setAutoFitItems( true ); ui->relatedArtists->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); ui->relatedArtists->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); ui->relatedArtists->setItemWidth( scaledX( 170 ) ); m_relatedModel = new PlayableModel( ui->relatedArtists ); ui->relatedArtists->setPlayableModel( m_relatedModel ); ui->relatedArtists->proxyModel()->sort( -1 ); ui->relatedArtists->setEmptyTip( tr( "Sorry, we could not find any related artists!" ) ); TomahawkStyle::stylePageFrame( ui->relatedArtists ); TomahawkStyle::stylePageFrame( ui->artistFrame ); TomahawkStyle::styleScrollBar( ui->relatedArtists->verticalScrollBar() ); } { ui->albums->setAutoResize( true ); ui->albums->setAutoFitItems( false ); ui->albums->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); ui->albums->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); ui->albums->setWrapping( false ); ui->albums->setItemWidth( scaledX( 190 ) ); ui->albums->proxyModel()->setHideDupeItems( true ); ui->albums->delegate()->setWordWrapping( true ); ui->albums->setFixedHeight( ui->albums->itemSize().height() + ui->albums->spacing() * 2 ); m_albumsModel = new PlayableModel( ui->albums ); ui->albums->setPlayableModel( m_albumsModel ); ui->albums->proxyModel()->sort( -1 ); ui->albums->setEmptyTip( tr( "Sorry, we could not find any albums for this artist!" ) ); TomahawkStyle::stylePageFrame( ui->albumFrame ); TomahawkStyle::styleScrollBar( ui->albums->verticalScrollBar() ); TomahawkStyle::styleScrollBar( ui->albums->horizontalScrollBar() ); } { ui->topHits->setAutoResize( true ); ui->topHits->setAutoFitItems( false ); ui->topHits->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); ui->topHits->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); ui->topHits->setWrapping( false ); ui->topHits->setItemWidth( scaledX( 140 ) ); ui->topHits->proxyModel()->setHideDupeItems( true ); ui->topHits->delegate()->setWordWrapping( true ); ui->topHits->delegate()->setShowBuyButtons( true ); ui->topHits->setFixedHeight( ui->topHits->itemSize().height() + ui->topHits->spacing() * 2 ); m_topHitsModel = new PlayableModel( ui->topHits ); ui->topHits->setPlayableModel( m_topHitsModel ); ui->topHits->proxyModel()->sort( -1 ); ui->topHits->setEmptyTip( tr( "Sorry, we could not find any top hits for this artist!" ) ); TomahawkStyle::stylePageFrame( ui->trackFrame ); } { ui->biography->setObjectName( "biography" ); ui->biography->setContentsMargins( 0, 0, 0, 0 ); ui->biography->page()->mainFrame()->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff ); ui->biography->page()->mainFrame()->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAsNeeded ); ui->biography->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks ); ui->biography->installEventFilter( this ); TomahawkStyle::stylePageWidget( ui->biography ); TomahawkStyle::stylePageFrame( ui->bioFrame ); connect( ui->biography, SIGNAL( linkClicked( QUrl ) ), SLOT( onBiographyLinkClicked( QUrl ) ) ); QFont f = ui->topHitsMoreLabel->font(); f.setWeight( QFont::Light ); f.setPointSize( TomahawkUtils::defaultFontSize() + 1 ); ui->topHitsMoreLabel->setFont( f ); ui->albumsMoreLabel->setFont( f ); connect( ui->albumsMoreLabel, SIGNAL( clicked() ), SLOT( onAlbumsMoreClicked() ) ); connect( ui->topHitsMoreLabel, SIGNAL( clicked() ), SLOT( onTopHitsMoreClicked() ) ); ui->cover->setFixedSize( scaled( QSize( 384, 384 ) ) ); } { m_headerWidget->ui->anchor1Label->setText( tr( "Music" ) ); m_headerWidget->ui->anchor2Label->setText( tr( "Biography" ) ); m_headerWidget->ui->anchor3Label->setText( tr( "Related Artists" ) ); m_headerWidget->ui->anchor1Label->show(); m_headerWidget->ui->anchor2Label->show(); m_headerWidget->ui->anchor3Label->show(); QFontMetrics fm( m_headerWidget->ui->anchor1Label->font() ); m_headerWidget->ui->anchor1Label->setFixedWidth( fm.width( m_headerWidget->ui->anchor1Label->text() ) + 16 ); m_headerWidget->ui->anchor2Label->setFixedWidth( fm.width( m_headerWidget->ui->anchor2Label->text() ) + 16 ); m_headerWidget->ui->anchor3Label->setFixedWidth( fm.width( m_headerWidget->ui->anchor3Label->text() ) + 16 ); connect( m_headerWidget->ui->anchor1Label, SIGNAL( clicked() ), SLOT( onMusicAnchorClicked() ) ); connect( m_headerWidget->ui->anchor2Label, SIGNAL( clicked() ), SLOT( onBioAnchorClicked() ) ); connect( m_headerWidget->ui->anchor3Label, SIGNAL( clicked() ), SLOT( onRelatedArtistsAnchorClicked() ) ); } m_stackedWidget = new QStackedWidget(); { m_area = new QScrollArea(); m_area->setWidgetResizable( true ); m_area->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); m_area->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); m_area->setWidget( m_widget ); QPalette pal = palette(); pal.setBrush( backgroundRole(), TomahawkStyle::PAGE_BACKGROUND ); m_area->setPalette( pal ); m_area->setAutoFillBackground( true ); m_area->setFrameShape( QFrame::NoFrame ); m_area->setAttribute( Qt::WA_MacShowFocusRect, 0 ); m_stackedWidget->addWidget( m_area ); connect( m_area->verticalScrollBar(), SIGNAL( valueChanged(int ) ), SLOT( onSliderValueChanged( int ) ) ); } { ContextView* topHitsFullView = new ContextView( m_stackedWidget ); topHitsFullView->setCaption( tr( "Songs" ) ); topHitsFullView->setShowCloseButton( true ); topHitsFullView->trackView()->setPlayableModel( m_topHitsModel ); m_stackedWidget->addWidget( topHitsFullView ); connect( topHitsFullView, SIGNAL( closeClicked() ), SLOT( onPageClosed() ) ); } { GridView* albumsFullView = new GridView( m_stackedWidget ); albumsFullView->delegate()->setWordWrapping( true ); // albumsFullView->setCaption( tr( "Albums" ) ); // albumsFullView->setShowCloseButton( true ); albumsFullView->setPlayableModel( m_albumsModel ); albumsFullView->proxyModel()->setHideDupeItems( true ); CaptionLabel* captionLabel = new CaptionLabel( this ); captionLabel->setText( tr( "Albums" ) ); captionLabel->setShowCloseButton( true ); QWidget* vbox = new QWidget; QPalette pal = vbox->palette(); pal.setBrush( vbox->backgroundRole(), TomahawkStyle::PAGE_BACKGROUND ); vbox->setPalette( pal ); vbox->setAutoFillBackground( true ); QVBoxLayout* vboxl = new QVBoxLayout; TomahawkUtils::unmarginLayout( vboxl ); vboxl->setContentsMargins( 32, 32, 32, 32 ); vboxl->setSpacing( scaledY( 8 ) ); vbox->setLayout( vboxl ); vboxl->addWidget( captionLabel ); vboxl->addWidget( albumsFullView ); vboxl->addStretch(); vboxl->setStretchFactor( albumsFullView, 1 ); m_stackedWidget->addWidget( vbox ); connect( captionLabel, SIGNAL( clicked() ), SLOT( onPageClosed() ) ); } { QVBoxLayout* layout = new QVBoxLayout(); layout->addWidget( m_headerWidget ); layout->addWidget( m_stackedWidget ); setLayout( layout ); TomahawkUtils::unmarginLayout( layout ); } MetaPlaylistInterface* mpl = new MetaPlaylistInterface(); mpl->addChildInterface( ui->relatedArtists->playlistInterface() ); mpl->addChildInterface( ui->topHits->playlistInterface() ); mpl->addChildInterface( ui->albums->playlistInterface() ); m_plInterface = playlistinterface_ptr( mpl ); onSliderValueChanged( 0 ); TomahawkUtils::fixMargins( this ); m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultArtistImage, TomahawkUtils::Original, scaled( QSize( 48, 48 ) ) ); load( artist ); }
KAstTopLevel::KAstTopLevel( QWidget *parent, const char *name ) : Q3MainWindow( parent, name, 0 ) { QWidget *border = new QWidget( this ); border->setBackgroundColor( Qt::black ); setCentralWidget( border ); Q3VBoxLayout *borderLayout = new Q3VBoxLayout( border ); borderLayout->addStretch( 1 ); QWidget *mainWin = new QWidget( border ); mainWin->setFixedSize(640, 480); borderLayout->addWidget( mainWin, 0, Qt::AlignHCenter ); borderLayout->addStretch( 1 ); view = new KAsteroidsView( mainWin ); view->setFocusPolicy( Qt::StrongFocus ); connect( view, SIGNAL( shipKilled() ), SLOT( slotShipKilled() ) ); connect( view, SIGNAL( rockHit(int) ), SLOT( slotRockHit(int) ) ); connect( view, SIGNAL( rocksRemoved() ), SLOT( slotRocksRemoved() ) ); connect( view, SIGNAL( updateVitals() ), SLOT( slotUpdateVitals() ) ); Q3VBoxLayout *vb = new Q3VBoxLayout( mainWin ); Q3HBoxLayout *hb = new Q3HBoxLayout; Q3HBoxLayout *hbd = new Q3HBoxLayout; vb->addLayout( hb ); QFont labelFont( "helvetica", 24 ); QColorGroup grp( Qt::darkGreen, Qt::black, QColor( 128, 128, 128 ), QColor( 64, 64, 64 ), Qt::black, Qt::darkGreen, Qt::black ); QPalette pal( grp, grp, grp ); mainWin->setPalette( pal ); hb->addSpacing( 10 ); QLabel *label; label = new QLabel( tr("Score"), mainWin ); label->setFont( labelFont ); label->setPalette( pal ); label->setFixedWidth( label->sizeHint().width() ); hb->addWidget( label ); scoreLCD = new QLCDNumber( 6, mainWin ); scoreLCD->setFrameStyle( Q3Frame::NoFrame ); scoreLCD->setSegmentStyle( QLCDNumber::Flat ); scoreLCD->setFixedWidth( 150 ); scoreLCD->setPalette( pal ); hb->addWidget( scoreLCD ); hb->addStretch( 10 ); label = new QLabel( tr("Level"), mainWin ); label->setFont( labelFont ); label->setPalette( pal ); label->setFixedWidth( label->sizeHint().width() ); hb->addWidget( label ); levelLCD = new QLCDNumber( 2, mainWin ); levelLCD->setFrameStyle( Q3Frame::NoFrame ); levelLCD->setSegmentStyle( QLCDNumber::Flat ); levelLCD->setFixedWidth( 70 ); levelLCD->setPalette( pal ); hb->addWidget( levelLCD ); hb->addStretch( 10 ); label = new QLabel( tr("Ships"), mainWin ); label->setFont( labelFont ); label->setFixedWidth( label->sizeHint().width() ); label->setPalette( pal ); hb->addWidget( label ); shipsLCD = new QLCDNumber( 1, mainWin ); shipsLCD->setFrameStyle( Q3Frame::NoFrame ); shipsLCD->setSegmentStyle( QLCDNumber::Flat ); shipsLCD->setFixedWidth( 40 ); shipsLCD->setPalette( pal ); hb->addWidget( shipsLCD ); hb->addStrut( 30 ); vb->addWidget( view, 10 ); // -- bottom layout: vb->addLayout( hbd ); QFont smallFont( "helvetica", 14 ); hbd->addSpacing( 10 ); QString sprites_prefix = ":/trolltech/examples/graphicsview/portedasteroids/sprites/"; /* label = new QLabel( tr( "T" ), mainWin ); label->setFont( smallFont ); label->setFixedWidth( label->sizeHint().width() ); label->setPalette( pal ); hbd->addWidget( label ); teleportsLCD = new QLCDNumber( 1, mainWin ); teleportsLCD->setFrameStyle( QFrame::NoFrame ); teleportsLCD->setSegmentStyle( QLCDNumber::Flat ); teleportsLCD->setPalette( pal ); teleportsLCD->setFixedHeight( 20 ); hbd->addWidget( teleportsLCD ); hbd->addSpacing( 10 ); */ QPixmap pm( sprites_prefix + "powerups/brake.png" ); label = new QLabel( mainWin ); label->setPixmap( pm ); label->setFixedWidth( label->sizeHint().width() ); label->setPalette( pal ); hbd->addWidget( label ); brakesLCD = new QLCDNumber( 1, mainWin ); brakesLCD->setFrameStyle( Q3Frame::NoFrame ); brakesLCD->setSegmentStyle( QLCDNumber::Flat ); brakesLCD->setPalette( pal ); brakesLCD->setFixedHeight( 20 ); hbd->addWidget( brakesLCD ); hbd->addSpacing( 10 ); pm.load( sprites_prefix + "powerups/shield.png" ); label = new QLabel( mainWin ); label->setPixmap( pm ); label->setFixedWidth( label->sizeHint().width() ); label->setPalette( pal ); hbd->addWidget( label ); shieldLCD = new QLCDNumber( 1, mainWin ); shieldLCD->setFrameStyle( Q3Frame::NoFrame ); shieldLCD->setSegmentStyle( QLCDNumber::Flat ); shieldLCD->setPalette( pal ); shieldLCD->setFixedHeight( 20 ); hbd->addWidget( shieldLCD ); hbd->addSpacing( 10 ); pm.load( sprites_prefix + "powerups/shoot.png" ); label = new QLabel( mainWin ); label->setPixmap( pm ); label->setFixedWidth( label->sizeHint().width() ); label->setPalette( pal ); hbd->addWidget( label ); shootLCD = new QLCDNumber( 1, mainWin ); shootLCD->setFrameStyle( Q3Frame::NoFrame ); shootLCD->setSegmentStyle( QLCDNumber::Flat ); shootLCD->setPalette( pal ); shootLCD->setFixedHeight( 20 ); hbd->addWidget( shootLCD ); hbd->addStretch( 1 ); label = new QLabel( tr( "Fuel" ), mainWin ); label->setFont( smallFont ); label->setFixedWidth( label->sizeHint().width() + 10 ); label->setPalette( pal ); hbd->addWidget( label ); powerMeter = new KALedMeter( mainWin ); powerMeter->setFrameStyle( Q3Frame::Box | Q3Frame::Plain ); powerMeter->setRange( MAX_POWER_LEVEL ); powerMeter->addColorRange( 10, Qt::darkRed ); powerMeter->addColorRange( 20, QColor(160, 96, 0) ); powerMeter->addColorRange( 70, Qt::darkGreen ); powerMeter->setCount( 40 ); powerMeter->setPalette( pal ); powerMeter->setFixedSize( 200, 12 ); hbd->addWidget( powerMeter ); shipsRemain = 3; showHiscores = FALSE; actions.insert( Qt::Key_Up, Thrust ); actions.insert( Qt::Key_Left, RotateLeft ); actions.insert( Qt::Key_Right, RotateRight ); actions.insert( Qt::Key_Space, Shoot ); actions.insert( Qt::Key_Z, Teleport ); actions.insert( Qt::Key_X, Brake ); actions.insert( Qt::Key_S, Shield ); actions.insert( Qt::Key_P, Pause ); actions.insert( Qt::Key_L, Launch ); actions.insert( Qt::Key_N, NewGame ); view->showText( tr( "Press N to start playing" ), Qt::yellow ); }
void RackWindow::createPluginHost(int position) { //layout settings widget: QWidget *settingsWidget = new QWidget; settingsWidget->setPalette(QPalette(QColor(0,0,0,160))); settingsWidget->setAutoFillBackground(true); RPushButton *leftButton = new RPushButton; leftButton->setObjectName("rackSettingsLeftArrowButton"); RPushButton *rightButton = new RPushButton; rightButton->setObjectName("rackSettingsRightArrowButton"); RPushButton *topButton = new RPushButton; topButton->setObjectName("rackSettingsTopArrowButton"); RPushButton *bottomButton = new RPushButton; bottomButton->setObjectName("rackSettingsBottomArrowButton"); RPushButton *closeButton = new RPushButton; closeButton->setObjectName("rackSettingsCloseButton"); //vertical toolbar for plugin buttons: QToolBar *pluginHostToolBar = new QToolBar; pluginHostToolBar->setObjectName("rackPluginHostToolBar"); pluginHostToolBar->setOrientation(Qt::Vertical); //actiongroup for exclusive handling of buttons: QActionGroup *ag = new QActionGroup(pluginHostToolBar); ag->setExclusive(true); RPushButton *addPluginWidgetButton = new RPushButton(tr("Add Widget ...")); addPluginWidgetButton->setObjectName("rackAddPluginWidgetButton"); QWidget *middleWidget = new QWidget; QVBoxLayout *middleLayout = new QVBoxLayout(middleWidget); middleLayout->setSpacing(0); middleLayout->setContentsMargins(0,0,0,0); middleLayout->addWidget(pluginHostToolBar, 0, Qt::AlignHCenter); middleLayout->addWidget(addPluginWidgetButton, 0, Qt::AlignHCenter); QGridLayout *settingsLayout = new QGridLayout(settingsWidget); settingsLayout->setSpacing(0); settingsLayout->setContentsMargins(0,0,0,0); settingsLayout->addWidget(topButton,0,1, Qt::AlignTop | Qt::AlignHCenter); settingsLayout->addWidget(closeButton,0,2, Qt::AlignTop | Qt::AlignRight); settingsLayout->addWidget(leftButton,1,0, Qt::AlignLeft); settingsLayout->addWidget(rightButton,1,2, Qt::AlignRight); settingsLayout->addWidget(bottomButton,2,1, Qt::AlignBottom| Qt::AlignHCenter); settingsLayout->addWidget(middleWidget,1,1); QStackedWidget *pluginStack = new QStackedWidget; pluginStack->setObjectName("rackPluginStack"); pluginStack->setAutoFillBackground(true); QWidget *pluginHost = new QWidget; pluginHost->setMinimumSize(200,80); QStackedLayout *overlayLayout = new QStackedLayout(pluginHost); overlayLayout->setStackingMode(QStackedLayout::StackAll); overlayLayout->addWidget(pluginStack); overlayLayout->addWidget(settingsWidget); overlayLayout->setCurrentIndex(1); //enter/leave settings signals: QSignalMapper *mapperShowSettingsMode = new QSignalMapper(pluginHost); QObject::connect(this, SIGNAL(enterSettingsMode()), mapperShowSettingsMode, SLOT(map())); mapperShowSettingsMode->setMapping(this, 1); QSignalMapper *mapperHideSettingsMode = new QSignalMapper(pluginHost); QObject::connect(this, SIGNAL(leaveSettingsMode()), mapperHideSettingsMode, SLOT(map())); mapperHideSettingsMode->setMapping(this, 0); QObject::connect(mapperShowSettingsMode, SIGNAL(mapped(int)), overlayLayout, SLOT(setCurrentIndex(int))); QObject::connect(mapperHideSettingsMode, SIGNAL(mapped(int)), overlayLayout, SLOT(setCurrentIndex(int))); //create plugin host widget signals: QSignalMapper *mapperCreatePluginHost = new QSignalMapper(pluginHost); QObject::connect(leftButton, SIGNAL(clicked()), mapperCreatePluginHost, SLOT(map())); QObject::connect(rightButton, SIGNAL(clicked()), mapperCreatePluginHost, SLOT(map())); QObject::connect(topButton, SIGNAL(clicked()), mapperCreatePluginHost, SLOT(map())); QObject::connect(bottomButton, SIGNAL(clicked()), mapperCreatePluginHost, SLOT(map())); mapperCreatePluginHost->setMapping(leftButton, NewSplitterLeft); mapperCreatePluginHost->setMapping(rightButton, NewSplitterRight); mapperCreatePluginHost->setMapping(topButton, NewSplitterTop); mapperCreatePluginHost->setMapping(bottomButton, NewSplitterBottom); QObject::connect(mapperCreatePluginHost, SIGNAL(mapped(int)), SLOT(createPluginHost(int))); //load plugin signal: QObject::connect(addPluginWidgetButton, SIGNAL(clicked()), m_mapperLoadNewPlugin, SLOT(map())); m_mapperLoadNewPlugin->setMapping(addPluginWidgetButton, pluginHost); //close plugin host signal: QObject::connect(closeButton, SIGNAL(clicked()), m_mapperClosePluginHost, SLOT(map())); m_mapperClosePluginHost->setMapping(closeButton, pluginHost); //create plugin switch signalmapper QSignalMapper *mapperSwitchPlugin = new QSignalMapper(pluginHost); mapperSwitchPlugin->setObjectName("rackPluginSwitchMapper"); QObject::connect(mapperSwitchPlugin, SIGNAL(mapped(QWidget *)), pluginStack, SLOT(setCurrentWidget(QWidget *))); ////test show/hide plugin widget ////QObject::connect(mapperSwitchPlugin, SIGNAL(mapped(QWidget *)), this, SLOT(showHidePluginWidget(QWidget*))); ////// //create plugin toolbar for mainwindow QToolBar *pluginToolBar = new QToolBar; pluginToolBar->setObjectName("rackPluginToolBar"); pluginToolBar->setMovable(false); pluginToolBar->hide(); addToolBar(Qt::BottomToolBarArea, pluginToolBar); //store the toolbar pointer as dynamic property to access later when creating plugin toolbar buttons pluginHost->setProperty("pluginToolBar", qVariantFromValue((QWidget *)pluginToolBar)); //plugin bar signals & slots: QObject::connect(this, SIGNAL(enterSettingsMode()), pluginToolBar, SLOT(hide())); QObject::connect(this, SIGNAL(leaveSettingsMode()), pluginToolBar, SLOT(show())); //insert new pluginhost widget in splitter, create new splitter if necessary if (position == 0) { m_mainSplitter->addWidget(pluginHost); return; } QSignalMapper *sm = qobject_cast<QSignalMapper *>(sender()); QWidget *senderPluginHost = qobject_cast<QWidget *>(sm->mapping(position)->parent()->parent()); RSplitter *parentSplitter = qobject_cast<RSplitter *>(senderPluginHost->parent()); QList<int> widgetsizes; int senderpos = parentSplitter->indexOf(senderPluginHost); int newposition; if ((position == NewSplitterLeft) or (position == NewSplitterTop)) newposition = senderpos; else newposition = senderpos + 1; switch (position + parentSplitter->orientation()) { //horizontal=1 vertical=2 case 0: //left horizontal / top vertical case 2: //right horizontal case 4: //bottom vertical widgetsizes = parentSplitter->sizes(); widgetsizes.replace(senderpos, int(widgetsizes.at(senderpos)/2)); widgetsizes.insert(senderpos + 1, widgetsizes.at(senderpos)); parentSplitter->insertWidget(newposition, pluginHost); parentSplitter->setSizes(widgetsizes); break; case 1: //left vertical case 3: //right vertical / bottom horizontal case -1: //top horizontal if (parentSplitter->count() == 1) { parentSplitter->setOrientation(Qt::Orientation(abs(position))); widgetsizes = parentSplitter->sizes(); widgetsizes.replace(0, int(widgetsizes.at(0)/2)); widgetsizes.append(widgetsizes.at(0)); parentSplitter->insertWidget(newposition, pluginHost); parentSplitter->setSizes(widgetsizes); } else if (parentSplitter->count() > 1) { RSplitter *newSplitter = new RSplitter(Qt::Orientation(abs(position))); QObject::connect(this, SIGNAL(enterSettingsMode()), newSplitter, SIGNAL(enterSettingsMode())); QObject::connect(this, SIGNAL(leaveSettingsMode()), newSplitter, SIGNAL(leaveSettingsMode())); widgetsizes = parentSplitter->sizes(); parentSplitter->insertWidget(parentSplitter->indexOf(senderPluginHost), newSplitter); newSplitter->addWidget(senderPluginHost); QList<int> newsizes = newSplitter->sizes(); newsizes.replace(0, int(newsizes.at(0)/2)); newsizes.append(newsizes.at(0)); if ((position == NewSplitterLeft) or (position == NewSplitterTop)) newSplitter->insertWidget(0, pluginHost); else newSplitter->addWidget(pluginHost); newSplitter->setSizes(newsizes); parentSplitter->setSizes(widgetsizes); } break; } }
AlbumInfoWidget::AlbumInfoWidget( const Tomahawk::album_ptr& album, QWidget* parent ) : QWidget( parent ) , ui( new Ui::AlbumInfoWidget ) { QWidget* widget = new QWidget; ui->setupUi( widget ); QPalette pal = palette(); pal.setColor( QPalette::Window, TomahawkStyle::PAGE_BACKGROUND ); widget->setPalette( pal ); widget->setAutoFillBackground( true ); m_albumsModel = new PlayableModel( ui->albums ); ui->albums->setPlayableModel( m_albumsModel ); ui->albums->setEmptyTip( tr( "Sorry, we could not find any other albums for this artist!" ) ); m_tracksModel = new TreeModel( ui->tracks ); m_tracksModel->setMode( Mixed ); ui->tracks->setRootIsDecorated( false ); ui->tracks->setEmptyTip( tr( "Sorry, we could not find any tracks for this album!" ) ); ui->tracks->proxyModel()->setStyle( PlayableProxyModel::Large ); ui->tracks->setAutoResize( true ); ui->tracks->setPlayableModel( m_tracksModel ); AlbumItemDelegate* del = new AlbumItemDelegate( ui->tracks, ui->tracks->proxyModel() ); ui->tracks->setPlaylistItemDelegate( del ); ui->albums->setAutoFitItems( false ); ui->albums->setWrapping( false ); ui->albums->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); ui->albums->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); ui->albums->delegate()->setItemSize( QSize( 170, 170 ) ); ui->albums->proxyModel()->setHideDupeItems( true ); ui->tracks->setFrameShape( QFrame::StyledPanel ); ui->tracks->setAttribute( Qt::WA_MacShowFocusRect, 0 ); m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultAlbumCover, TomahawkUtils::Original, QSize( 48, 48 ) ); ui->cover->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultAlbumCover, TomahawkUtils::Grid, ui->cover->size() ) ); ui->cover->setShowText( true ); ui->biography->setFrameShape( QFrame::NoFrame ); ui->biography->setAttribute( Qt::WA_MacShowFocusRect, 0 ); TomahawkUtils::styleScrollBar( ui->biography->verticalScrollBar() ); QPalette p = ui->biography->palette(); p.setColor( QPalette::Foreground, Qt::white ); p.setColor( QPalette::Text, Qt::white ); ui->biography->setPalette( p ); ui->label->setPalette( p ); ui->label_2->setPalette( p ); QScrollArea* area = new QScrollArea(); area->setWidgetResizable( true ); area->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); area->setWidget( widget ); area->setStyleSheet( "QScrollArea { background-color: #454e59; }" ); area->setFrameShape( QFrame::NoFrame ); area->setAttribute( Qt::WA_MacShowFocusRect, 0 ); QVBoxLayout* layout = new QVBoxLayout(); layout->addWidget( area ); setLayout( layout ); TomahawkUtils::unmarginLayout( layout ); TomahawkUtils::styleScrollBar( ui->tracks->horizontalScrollBar() ); TomahawkUtils::styleScrollBar( ui->albums->horizontalScrollBar() ); ui->biography->setStyleSheet( "QTextBrowser#biography { background-color: transparent; }" ); ui->albums->setStyleSheet( "QListView { background-color: transparent; }" ); ui->albumFrame->setStyleSheet( "QFrame#albumFrame { background-color: transparent; }" "QFrame#albumFrame { " "border-image: url(" RESPATH "images/widget-border.png) 3 3 3 3 stretch stretch;" "border-top: 3px transparent; border-bottom: 3px transparent; border-right: 3px transparent; border-left: 3px transparent; }" ); ui->trackFrame->setStyleSheet( "QFrame#trackFrame { background-color: transparent; }" "QFrame#trackFrame { " "border-image: url(" RESPATH "images/widget-border.png) 3 3 3 3 stretch stretch;" "border-top: 3px transparent; border-bottom: 3px transparent; border-right: 3px transparent; border-left: 3px transparent; }" ); MetaPlaylistInterface* mpl = new MetaPlaylistInterface(); mpl->addChildInterface( ui->tracks->playlistInterface() ); mpl->addChildInterface( ui->albums->playlistInterface() ); m_playlistInterface = playlistinterface_ptr( mpl ); load( album ); }
InformationPanelContent::InformationPanelContent(QWidget* parent) : QWidget(parent), m_item(), m_pendingPreview(false), m_outdatedPreviewTimer(0), m_preview(0), m_phononWidget(0), m_nameLabel(0), m_metaDataWidget(0), m_metaDataArea(0) { parent->installEventFilter(this); // Initialize timer for disabling an outdated preview with a small // delay. This prevents flickering if the new preview can be generated // within a very small timeframe. m_outdatedPreviewTimer = new QTimer(this); m_outdatedPreviewTimer->setInterval(300); m_outdatedPreviewTimer->setSingleShot(true); connect(m_outdatedPreviewTimer, SIGNAL(timeout()), this, SLOT(markOutdatedPreview())); QVBoxLayout* layout = new QVBoxLayout(this); layout->setSpacing(KDialog::spacingHint()); // preview const int minPreviewWidth = KIconLoader::SizeEnormous + KIconLoader::SizeMedium; m_preview = new PixmapViewer(parent); m_preview->setMinimumWidth(minPreviewWidth); m_preview->setMinimumHeight(KIconLoader::SizeEnormous); m_phononWidget = new PhononWidget(parent); m_phononWidget->hide(); m_phononWidget->setMinimumWidth(minPreviewWidth); connect(m_phononWidget, SIGNAL(playingStarted()), this, SLOT(slotPlayingStarted())); connect(m_phononWidget, SIGNAL(playingStopped()), this, SLOT(slotPlayingStopped())); // name m_nameLabel = new QLabel(parent); QFont font = m_nameLabel->font(); font.setBold(true); m_nameLabel->setFont(font); m_nameLabel->setAlignment(Qt::AlignHCenter); m_nameLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); const bool showPreview = InformationPanelSettings::showPreview(); m_preview->setVisible(showPreview); m_metaDataWidget = new KFileMetaDataWidget(parent); m_metaDataWidget->setFont(KGlobalSettings::smallestReadableFont()); m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); connect(m_metaDataWidget, SIGNAL(urlActivated(KUrl)), this, SIGNAL(urlActivated(KUrl))); // Encapsulate the MetaDataWidget inside a container that has a dummy widget // at the bottom. This prevents that the meta data widget gets vertically stretched // in the case where the height of m_metaDataArea > m_metaDataWidget. QWidget* metaDataWidgetContainer = new QWidget(parent); QVBoxLayout* containerLayout = new QVBoxLayout(metaDataWidgetContainer); containerLayout->setContentsMargins(0, 0, 0, 0); containerLayout->setSpacing(0); containerLayout->addWidget(m_metaDataWidget); containerLayout->addStretch(); m_metaDataArea = new QScrollArea(parent); m_metaDataArea->setWidget(metaDataWidgetContainer); m_metaDataArea->setWidgetResizable(true); m_metaDataArea->setFrameShape(QFrame::NoFrame); QWidget* viewport = m_metaDataArea->viewport(); viewport->installEventFilter(this); QPalette palette = viewport->palette(); palette.setColor(viewport->backgroundRole(), QColor(Qt::transparent)); viewport->setPalette(palette); layout->addWidget(m_preview); layout->addWidget(m_phononWidget); layout->addWidget(m_nameLabel); layout->addWidget(new KSeparator()); layout->addWidget(m_metaDataArea); }
pFileDialog::pFileDialog( QWidget* parent, const QString& caption, const QString& directory, const QString& filter, bool textCodecEnabled, bool openReadOnlyEnabled ) : QFileDialog( parent, caption, directory, filter ) { setFileMode( QFileDialog::AnyFile ); setOption( QFileDialog::DontUseNativeDialog ); // get grid layout glDialog = qobject_cast<QGridLayout*>( layout() ); // assert on gridlayout Q_ASSERT( glDialog ); // relook the dialog to be more friendly QLabel* lLookIn = findChild<QLabel*>( "lookInLabel" ); QComboBox* cbLookIn = findChild<QComboBox*>( "lookInCombo" ); QToolButton* tbNewFolder = findChild<QToolButton*>( "newFolderButton" ); QAbstractItemView* sidebar = findChild<QAbstractItemView*>( "sidebar" ); QFrame* fFrame = findChild<QFrame*>( "frame" ); QBoxLayout* hLayout = 0; // search layout containing tbNewFolder foreach ( QLayout* layout, findChildren<QLayout*>() ) { if ( layout->indexOf( tbNewFolder ) != -1 ) { hLayout = qobject_cast<QBoxLayout*>( layout ); break; } } if ( lLookIn ) { lLookIn->setVisible( false ); } if ( hLayout ) { hLayout->setSpacing( 3 ); hLayout->insertStretch( hLayout->indexOf( tbNewFolder ) ); } if ( cbLookIn && fFrame ) { QBoxLayout* vLayout = qobject_cast<QBoxLayout*>( fFrame->layout() ); if ( vLayout ) { vLayout->setSpacing( 3 ); vLayout->insertWidget( 0, cbLookIn ); if ( hLayout ) { glDialog->removeItem( hLayout ); hLayout->setParent( 0 ); vLayout->insertLayout( 0, hLayout ); } } } if ( sidebar ) { QWidget* viewport = sidebar->viewport(); QPalette pal = viewport->palette(); pal.setColor( viewport->backgroundRole(), QColor( Qt::transparent ) ); viewport->setPalette( pal ); sidebar->setFrameStyle( QFrame::NoFrame | QFrame::Plain ); sidebar->setIconSize( QSize( 16, 16 ) ); } // text codec mTextCodecEnabled = true; lCodec = new QLabel( tr( "Codec:" ), this ); cbCodec = new QComboBox( this ); cbCodec->addItems( pCoreUtils::textCodecs() ); setTextCodec( QTextCodec::codecForLocale()->name() ); glDialog->addWidget( lCodec, 4, 0 ); glDialog->addWidget( cbCodec, 4, 1 ); // read only mOpenReadOnlyEnabled = true; cbOpenReadOnly = new QCheckBox( tr( "Open in read only." ), this ); glDialog->addWidget( cbOpenReadOnly, 5, 1 ); // configuration setTextCodecEnabled( textCodecEnabled ); setOpenReadOnlyEnabled( openReadOnlyEnabled ); }
FlexibleView::FlexibleView( QWidget* parent, QWidget* extraHeader ) : QWidget( parent ) , m_header( new FilterHeader( this ) ) , m_trackView( new TrackView() ) , m_detailedView( new TrackView() ) , m_gridView( new GridView() ) , m_model( 0 ) , m_temporary( false ) { qRegisterMetaType< FlexibleViewMode >( "FlexibleViewMode" ); m_header->setBackground( ImageRegistry::instance()->pixmap( RESPATH "images/playlist_background.png", QSize( 0, 0 ) ) ); // m_trackView->setPlaylistInterface( m_playlistInterface ); m_detailedView->setPlaylistInterface( m_trackView->proxyModel()->playlistInterface() ); m_gridView->setPlaylistInterface( m_trackView->proxyModel()->playlistInterface() ); m_detailedView->setColumnHidden( PlayableModel::Age, true ); // Hide age column per default m_detailedView->setColumnHidden( PlayableModel::Filesize, true ); // Hide filesize column per default m_detailedView->setColumnHidden( PlayableModel::Composer, true ); // Hide composer column per default TrackItemDelegate* del = new TrackItemDelegate( TrackItemDelegate::LovedTracks, m_trackView, m_trackView->proxyModel() ); m_trackView->setPlaylistItemDelegate( del ); m_trackView->proxyModel()->setStyle( PlayableProxyModel::Large ); m_stack = new QStackedWidget(); setLayout( new QVBoxLayout() ); TomahawkUtils::unmarginLayout( layout() ); m_trackView->setStyleSheet( QString( "QTreeView { background-color: white; }" ) ); m_gridView->setStyleSheet( QString( "QListView { background-color: white; }" ) ); TomahawkStyle::styleScrollBar( m_trackView->verticalScrollBar() ); layout()->addWidget( m_header ); if ( extraHeader ) layout()->addWidget( extraHeader ); CaptionLabel* caption = new CaptionLabel( this ); caption->setText( tr( "Playlist Details" ) ); QWidget* vbox = new QWidget; QPalette pal = vbox->palette(); pal.setBrush( vbox->backgroundRole(), Qt::white ); vbox->setPalette( pal ); vbox->setAutoFillBackground( true ); QVBoxLayout* vboxl = new QVBoxLayout; TomahawkUtils::unmarginLayout( vboxl ); vboxl->setContentsMargins( 32, 32, 32, 32 ); vboxl->setSpacing( 32 ); vbox->setLayout( vboxl ); QWidget* hbox = new QWidget; QHBoxLayout* hboxl = new QHBoxLayout; TomahawkUtils::unmarginLayout( hboxl ); hboxl->setSpacing( 32 ); m_detailView = new TrackDetailView; m_detailView->setPlaylistInterface( playlistInterface() ); hboxl->addWidget( m_detailView ); hboxl->addWidget( m_stack ); hbox->setLayout( hboxl ); vboxl->addWidget( caption ); vboxl->addWidget( hbox ); layout()->addWidget( vbox ); m_stack->addWidget( m_trackView ); m_stack->addWidget( m_detailedView ); m_stack->addWidget( m_gridView ); setCurrentMode( Flat ); connect( m_trackView, SIGNAL( querySelected( Tomahawk::query_ptr ) ), m_detailView, SLOT( setQuery( Tomahawk::query_ptr ) ) ); connect( m_header, SIGNAL( filterTextChanged( QString ) ), SLOT( setFilter( QString ) ) ); TomahawkUtils::fixMargins( this ); }
AbstractConfig::AbstractConfig(AbstractContent * content, AbstractConfig_PARENT * parent) : AbstractConfig_TYPE(parent) , m_content(content) , m_commonUi(new Ui::AbstractConfig()) #if !defined(MOBILE_UI) , m_closeButton(0) , m_okButton(0) #endif , m_frame(FrameFactory::defaultPanelFrame()) { #if !defined(MOBILE_UI) // close button m_closeButton = new StyledButtonItem(tr(" x "), font(), this);//this, ":/data/button-close.png", ":/data/button-close-hovered.png", ":/data/button-close-pressed.png"); connect(m_closeButton, SIGNAL(clicked()), this, SIGNAL(requestClose())); // WIDGET setup (populate contents and set base palette (only) to transparent) QWidget * widget = new QWidget(); m_commonUi->setupUi(widget); QPalette pal; QColor oldColor = pal.window().color(); pal.setBrush(QPalette::Window, Qt::transparent); widget->setPalette(pal); pal.setBrush(QPalette::Window, oldColor); m_commonUi->tab->setPalette(pal); #else m_commonUi->setupUi(this); #endif populateFrameList(); // select the frame quint32 frameClass = m_content->frameClass(); if (frameClass != Frame::NoFrame) { for (int i = 0; i < m_commonUi->framesList->count(); ++i) { QListWidgetItem * item = m_commonUi->framesList->item(i); if (item->data(Qt::UserRole).toUInt() == frameClass) { item->setSelected(true); break; } } } // read other properties m_commonUi->reflection->setChecked(m_content->mirrored()); m_commonUi->contentLocked->setChecked(m_content->locked()); m_commonUi->fixedPosition->setChecked(m_content->fixedPosition()); m_commonUi->fixedRotation->setChecked(m_content->fixedRotation()); m_commonUi->fixedPerspective->setChecked(m_content->fixedPerspective()); connect(m_commonUi->front, SIGNAL(clicked()), m_content, SLOT(slotStackFront())); connect(m_commonUi->raise, SIGNAL(clicked()), m_content, SLOT(slotStackRaise())); connect(m_commonUi->lower, SIGNAL(clicked()), m_content, SLOT(slotStackLower())); connect(m_commonUi->back, SIGNAL(clicked()), m_content, SLOT(slotStackBack())); connect(m_commonUi->save, SIGNAL(clicked()), m_content, SLOT(slotSaveAs())); connect(m_commonUi->background, SIGNAL(clicked()), m_content, SIGNAL(requestBackgrounding())); connect(m_commonUi->del, SIGNAL(clicked()), m_content, SIGNAL(requestRemoval())); connect(m_commonUi->contentLocked, SIGNAL(stateChanged(int)), m_content, SLOT(slotSetLocked(int))); connect(m_commonUi->fixedPosition, SIGNAL(stateChanged(int)), m_content, SLOT(slotSetFixedPosition(int))); connect(m_commonUi->fixedRotation, SIGNAL(stateChanged(int)), m_content, SLOT(slotSetFixedRotation(int))); connect(m_commonUi->fixedPerspective, SIGNAL(stateChanged(int)), m_content, SLOT(slotSetFixedPerspective(int))); connect(m_commonUi->newFrame, SIGNAL(clicked()), this, SLOT(slotAddFrame())); connect(m_commonUi->removeFrame, SIGNAL(clicked()), this, SLOT(slotRemoveFrame())); connect(m_commonUi->lookApplyAll, SIGNAL(clicked()), this, SLOT(slotLookApplyAll())); connect(m_commonUi->framesList, SIGNAL(itemSelectionChanged()), this, SLOT(slotFrameSelectionChanged())); connect(m_commonUi->reflection, SIGNAL(toggled(bool)), this, SLOT(slotReflectionToggled(bool))); // ITEM setup #if !defined(MOBILE_UI) setFlag(QGraphicsItem::ItemIgnoresTransformations, true); setWidget(widget); static qreal s_propZBase = 99999; setZValue(s_propZBase++); #endif #if !defined(MOBILE_UI) && QT_VERSION >= 0x040600 // fade in animation QPropertyAnimation * ani = new QPropertyAnimation(this, "opacity"); ani->setEasingCurve(QEasingCurve::OutCubic); ani->setDuration(400); ani->setStartValue(0.0); ani->setEndValue(1.0); ani->start(QPropertyAnimation::DeleteWhenStopped); #endif }
void caStripPlot::setLegendAttribute(QColor c, QFont f, LegendAtttribute SW) { int i; #if QWT_VERSION < 0x060100 for(i=0; i < NumberOfCurves; i++) { switch (SW) { case TEXT: if(thisLegendshow) { QwtText text; text.setText(legendText(i)); qobject_cast<QwtLegendItem*>(this->legend()->find(curve[i]))->setText(text); } break; case FONT: if(getLegendEnabled()) { if(legend() != (QwtLegend*) 0) { QList<QWidget *> list = legend()->legendItems(); for (QList<QWidget*>::iterator it = list.begin(); it != list.end(); ++it ) { QWidget *w = *it; w->setFont(f); } } } break; case COLOR: if(legend() != (QwtLegend*) 0) { QList<QWidget *> list = legend()->legendItems(); for (QList<QWidget*>::iterator it = list.begin(); it != list.end(); ++it ) { QWidget *w = *it; QPalette palette = w->palette(); palette.setColor( QPalette::WindowText, c); // for ticks palette.setColor( QPalette::Text, c); // for ticks' labels w->setPalette (palette); w->setFont(f); } } break; } } #else i=0; foreach (QwtPlotItem *plt_item, itemList()) { if ( plt_item->rtti() == QwtPlotItem::Rtti_PlotCurve ) { QwtLegend *lgd = qobject_cast<QwtLegend *>(legend()); QList<QWidget *> legendWidgets = lgd->legendWidgets(itemToInfo(plt_item)); if ( legendWidgets.size() == 1 ) { QwtLegendLabel *b = qobject_cast<QwtLegendLabel *>(legendWidgets[0]); switch (SW) { case TEXT: if(thisLegendshow) { QwtText text; text.setText(legendText(i++)); //printf("%s %s\n", b->plainText().toAscii().constData(), legendText(i-1).toAscii().constData()); b->setText(text); b->update(); } break; case FONT: //printf("%s %s\n", b->plainText().toAscii().constData(), legendText(i-1).toAscii().constData()); b->setFont(f); b->update(); break; case COLOR: //printf("%s %s\n", b->plainText().toAscii().constData(), legendText(i-1).toAscii().constData()); QPalette palette = b->palette(); palette.setColor( QPalette::WindowText, c); // for ticks palette.setColor( QPalette::Text, c); // for ticks' labels b->setPalette(palette); b->update(); break; } } } } #endif }
InformationPanelContent::InformationPanelContent(QWidget* parent) : QWidget(parent), m_item(), m_previewJob(0), m_outdatedPreviewTimer(0), m_preview(0), m_phononWidget(0), m_nameLabel(0), m_metaDataWidget(0), m_metaDataArea(0), m_placesItemModel(0) { parent->installEventFilter(this); // Initialize timer for disabling an outdated preview with a small // delay. This prevents flickering if the new preview can be generated // within a very small timeframe. m_outdatedPreviewTimer = new QTimer(this); m_outdatedPreviewTimer->setInterval(300); m_outdatedPreviewTimer->setSingleShot(true); connect(m_outdatedPreviewTimer, &QTimer::timeout, this, &InformationPanelContent::markOutdatedPreview); QVBoxLayout* layout = new QVBoxLayout(this); // preview const int minPreviewWidth = KIconLoader::SizeEnormous + KIconLoader::SizeMedium; m_preview = new PixmapViewer(parent); m_preview->setMinimumWidth(minPreviewWidth); m_preview->setMinimumHeight(KIconLoader::SizeEnormous); m_phononWidget = new PhononWidget(parent); m_phononWidget->hide(); m_phononWidget->setMinimumWidth(minPreviewWidth); connect(m_phononWidget, &PhononWidget::hasVideoChanged, this, &InformationPanelContent::slotHasVideoChanged); // name m_nameLabel = new QLabel(parent); QFont font = m_nameLabel->font(); font.setBold(true); m_nameLabel->setFont(font); m_nameLabel->setTextFormat(Qt::PlainText); m_nameLabel->setAlignment(Qt::AlignHCenter); m_nameLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); const bool previewsShown = InformationPanelSettings::previewsShown(); m_preview->setVisible(previewsShown); #ifndef HAVE_BALOO m_metaDataWidget = new KFileMetaDataWidget(parent); connect(m_metaDataWidget, &KFileMetaDataWidget::urlActivated, this, &InformationPanelContent::urlActivated); #else m_metaDataWidget = new Baloo::FileMetaDataWidget(parent); connect(m_metaDataWidget, &Baloo::FileMetaDataWidget::urlActivated, this, &InformationPanelContent::urlActivated); #endif m_metaDataWidget->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); // Encapsulate the MetaDataWidget inside a container that has a dummy widget // at the bottom. This prevents that the meta data widget gets vertically stretched // in the case where the height of m_metaDataArea > m_metaDataWidget. QWidget* metaDataWidgetContainer = new QWidget(parent); QVBoxLayout* containerLayout = new QVBoxLayout(metaDataWidgetContainer); containerLayout->setContentsMargins(0, 0, 0, 0); containerLayout->setSpacing(0); containerLayout->addWidget(m_metaDataWidget); containerLayout->addStretch(); m_metaDataArea = new QScrollArea(parent); m_metaDataArea->setWidget(metaDataWidgetContainer); m_metaDataArea->setWidgetResizable(true); m_metaDataArea->setFrameShape(QFrame::NoFrame); QWidget* viewport = m_metaDataArea->viewport(); viewport->installEventFilter(this); QPalette palette = viewport->palette(); palette.setColor(viewport->backgroundRole(), QColor(Qt::transparent)); viewport->setPalette(palette); layout->addWidget(m_preview); layout->addWidget(m_phononWidget); layout->addWidget(m_nameLabel); layout->addWidget(new KSeparator()); layout->addWidget(m_metaDataArea); m_placesItemModel = new PlacesItemModel(this); }
TrackInfoWidget::TrackInfoWidget( const Tomahawk::query_ptr& query, QWidget* parent ) : QWidget( parent ) , ui( new Ui::TrackInfoWidget ) , m_scrollArea( 0 ) { QWidget* widget = new QWidget; ui->setupUi( widget ); QPalette pal = palette(); pal.setColor( QPalette::Window, TomahawkStyle::PAGE_BACKGROUND ); widget->setPalette( pal ); widget->setAutoFillBackground( true ); ui->statsLabel->setStyleSheet( "QLabel { background-image:url(); border: 2px solid #dddddd; background-color: #faf9f9; border-radius: 4px; padding: 12px; }" ); ui->lyricsView->setStyleSheet( "QTextBrowser#lyricsView { background-color: transparent; }" ); ui->lyricsView->setFrameShape( QFrame::NoFrame ); ui->lyricsView->setAttribute( Qt::WA_MacShowFocusRect, 0 ); ui->lyricsView->setVisible( false ); // FIXME eventually ui->similarTracksView->setAutoResize( true ); ui->similarTracksView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); // TomahawkUtils::styleScrollBar( ui->similarTracksView->verticalScrollBar() ); TomahawkUtils::styleScrollBar( ui->lyricsView->verticalScrollBar() ); // ui->similarTracksView->setStyleSheet( "QListView { background-color: transparent; } QListView::item { background-color: transparent; }" ); QFont f = ui->statsLabel->font(); f.setPointSize( TomahawkUtils::defaultFontSize() + 2 ); f.setBold( true ); ui->statsLabel->setFont( f ); QPalette p = ui->lyricsView->palette(); p.setColor( QPalette::Foreground, Qt::white ); p.setColor( QPalette::Text, Qt::white ); ui->lyricsView->setPalette( p ); ui->label->setPalette( p ); // ui->similarTracksLabel->setPalette( p ); m_relatedTracksModel = new PlayableModel( ui->similarTracksView ); ui->similarTracksView->setPlayableModel( m_relatedTracksModel ); ui->similarTracksView->proxyModel()->sort( -1 ); ui->similarTracksView->setEmptyTip( tr( "Sorry, but we could not find similar tracks for this song!" ) ); m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultTrackImage, TomahawkUtils::Original, QSize( 48, 48 ) ); ui->cover->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultTrackImage, TomahawkUtils::Grid, ui->cover->size() ) ); ui->cover->setShowText( true ); m_scrollArea = new QScrollArea(); m_scrollArea->setWidgetResizable( true ); m_scrollArea->setWidget( widget ); m_scrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); m_scrollArea->setStyleSheet( "QScrollArea { background-color: #454e59 }" ); m_scrollArea->setFrameShape( QFrame::NoFrame ); m_scrollArea->setAttribute( Qt::WA_MacShowFocusRect, 0 ); QVBoxLayout* layout = new QVBoxLayout(); layout->addWidget( m_scrollArea ); setLayout( layout ); TomahawkUtils::unmarginLayout( layout ); ui->similarTracksView->setStyleSheet( "QListView { background-color: transparent; }" ); ui->frame->setStyleSheet( "QFrame#frame { background-color: transparent; }" "QFrame#frame { " "border-image: url(" RESPATH "images/widget-border.png) 3 3 3 3 stretch stretch;" "border-top: 3px transparent; border-bottom: 3px transparent; border-right: 3px transparent; border-left: 3px transparent; }" ); load( query ); }
ContextView::ContextView( QWidget* parent, const QString& caption ) : QWidget( parent ) // , m_header( new FilterHeader( this ) ) , m_trackView( new TrackView() ) , m_model( 0 ) , m_temporary( false ) { // qRegisterMetaType< ContextViewMode >( "ContextViewMode" ); /* m_detailedView->setColumnHidden( PlayableModel::Age, true ); // Hide age column per default m_detailedView->setColumnHidden( PlayableModel::Filesize, true ); // Hide filesize column per default m_detailedView->setColumnHidden( PlayableModel::Composer, true ); // Hide composer column per default*/ TrackItemDelegate* del = new TrackItemDelegate( TrackItemDelegate::LovedTracks, m_trackView, m_trackView->proxyModel() ); m_trackView->setPlaylistItemDelegate( del ); m_trackView->proxyModel()->setStyle( PlayableProxyModel::Large ); TomahawkStyle::styleScrollBar( m_trackView->verticalScrollBar() ); setLayout( new QVBoxLayout() ); TomahawkUtils::unmarginLayout( layout() ); m_trackView->setStyleSheet( QString( "QTreeView { background-color: white; }" ) ); // m_gridView->setStyleSheet( QString( "QListView { background-color: white; }" ) ); m_captionLabel = new CaptionLabel( this ); setCaption( caption ); QWidget* vbox = new QWidget; QPalette pal = vbox->palette(); pal.setBrush( vbox->backgroundRole(), Qt::white ); vbox->setPalette( pal ); vbox->setAutoFillBackground( true ); QVBoxLayout* vboxl = new QVBoxLayout; TomahawkUtils::unmarginLayout( vboxl ); vboxl->setContentsMargins( 32, 32, 32, 32 ); vboxl->setSpacing( 32 ); vbox->setLayout( vboxl ); QWidget* hbox = new QWidget; QHBoxLayout* hboxl = new QHBoxLayout; TomahawkUtils::unmarginLayout( hboxl ); hboxl->setSpacing( 32 ); QVBoxLayout* vboxInner = new QVBoxLayout; TomahawkUtils::unmarginLayout( vboxInner ); vboxInner->addWidget( m_trackView ); vboxInner->addStretch(); vboxInner->setStretchFactor( m_trackView, 1 ); TrackDetailView* detailView = new TrackDetailView; detailView->setPlaylistInterface( playlistInterface() ); hboxl->addWidget( detailView ); hboxl->addLayout( vboxInner ); hbox->setLayout( hboxl ); vboxl->addWidget( m_captionLabel ); vboxl->addWidget( hbox ); layout()->addWidget( vbox ); connect( m_captionLabel, SIGNAL( clicked() ), SIGNAL( closeClicked() ) ); connect( m_trackView, SIGNAL( querySelected( Tomahawk::query_ptr ) ), SLOT( onQuerySelected( Tomahawk::query_ptr ) ) ); connect( m_trackView, SIGNAL( querySelected( Tomahawk::query_ptr ) ), detailView, SLOT( setQuery( Tomahawk::query_ptr ) ) ); // connect( m_header, SIGNAL( filterTextChanged( QString ) ), SLOT( setFilter( QString ) ) ); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); #ifdef Q_OS_WIN32 this->setAttribute(Qt::WA_TranslucentBackground); // WS_LAYERED this->setAttribute(Qt::WA_NoSystemBackground, false); #endif // Setup the recording subsystem m_recorder = new Recording::Coordinator(this); m_recorderThread = new QThread(this); m_recorder->moveToThread(m_recorderThread); QObject::connect(m_recorderThread, &QThread::finished, m_recorder, &QObject::deleteLater); // this is legal and even recommended by the docs for QThread::finished m_recorderThread->start(); QObject::connect(m_recorder, &Recording::Coordinator::statusUpdate, ui->recordStatus, &Recording::StatusView::handleStatusUpdate); QObject::connect(m_recorder, &Recording::Coordinator::error, ui->recordError, &Recording::ErrorWidget::displayError); Recording::ConfiguratorPane *recordpane = new Recording::ConfiguratorPane(this); recordpane->hookupCoordinator(m_recorder); QObject::connect(ui->recordBtn, &QAbstractButton::toggled, m_recorder, &Recording::Coordinator::setRecording); QObject::connect(ui->monitorBtn, &QAbstractButton::toggled, m_recorder, &Recording::Coordinator::setMonitorEnabled); QObject::connect(m_recorder, &Recording::Coordinator::recordingChanged, ui->recordBtn, &QAbstractButton::setChecked); QObject::connect(m_recorder, &Recording::Coordinator::monitorEnabledChanged, ui->monitorBtn, &QAbstractButton::setChecked); // HACK: We really don't want the left/right keys to trigger something else when the button // is not enabled. That's why we are creating a manual shortcut. QObject::connect(new QShortcut(QKeySequence(Qt::Key_Right), this), &QShortcut::activated, ui->nextBtn, &QAbstractButton::click); QObject::connect(new QShortcut(QKeySequence(Qt::Key_Down), this), &QShortcut::activated, ui->nextBtn, &QAbstractButton::click); QObject::connect(new QShortcut(QKeySequence(Qt::Key_Left), this), &QShortcut::activated, ui->prevBtn, &QAbstractButton::click); QObject::connect(new QShortcut(QKeySequence(Qt::Key_Up), this), &QShortcut::activated, ui->prevBtn, &QAbstractButton::click); m_presentation = new Presentation::PresentationTab(this); QObject::connect(ui->nextBtn, &QAbstractButton::clicked, m_presentation, &Presentation::PresentationTab::nextSlide); QObject::connect(ui->prevBtn, &QAbstractButton::clicked, m_presentation, &Presentation::PresentationTab::previousSlide); QObject::connect(ui->freezeBtn, &QAbstractButton::toggled, m_presentation, &Presentation::PresentationTab::freeze); QObject::connect(ui->blankBtn, &QAbstractButton::toggled, m_presentation, &Presentation::PresentationTab::blank); QObject::connect(m_presentation, &Presentation::PresentationTab::freezeChanged, ui->freezeBtn, &QAbstractButton::setChecked); QObject::connect(m_presentation, &Presentation::PresentationTab::blankChanged, ui->blankBtn, &QAbstractButton::setChecked); QObject::connect(m_presentation, &Presentation::PresentationTab::canNextSlideChanged, ui->nextBtn, &QAbstractButton::setEnabled); QObject::connect(m_presentation, &Presentation::PresentationTab::canPrevSlideChanged, ui->prevBtn, &QAbstractButton::setEnabled); ui->freezeBtn->setEnabled(true); ui->blankBtn->setEnabled(true); ui->tabWidget->addTab(recordpane, tr("Recording")); ui->tabWidget->addTab(m_presentation, tr("Presentation")); ui->tabWidget->addTab(new AboutPane(this), tr("About")); // == Main styling == QPalette pal = this->palette(); pal.setBrush(QPalette::Background, QColor(0x30, 0x30, 0x30)); pal.setBrush(QPalette::Foreground, QColor(0xFF, 0xFF, 0xFF)); pal.setBrush(QPalette::Light, QColor(0x40, 0x40, 0x40)); this->setPalette(pal); this->setAutoFillBackground(true); // == tab widget styling == // We use a normal QTabWidget, but style the tabs according // to our "custom theme" using CSS ui->tabWidget->setPalette(QGuiApplication::palette()); for (int i = 0; i < ui->tabWidget->count(); ++i) { QWidget *w = ui->tabWidget->widget(i); w->setAutoFillBackground(true); w->setPalette(w->palette()); w->setBackgroundRole(QPalette::Base); } ui->tabWidget->setStyleSheet(QString( "#tabWidget > QTabBar::tab {" " background-color: %1;" " color: %2;" " padding: 10px;" " border: 0;" " margin-left: 5px;" "}" "#tabWidget > QTabBar::tab:selected {" " background-color: %3;" " color: %4;" " margin-left: 0;" "}" "#tabWidget::pane {" " border: 0" "}" ).arg(this->palette().color(QPalette::Light).name()) .arg(this->palette().color(QPalette::Foreground).name()) .arg(ui->tabWidget->widget(0)->palette().color(ui->tabWidget->widget(0)->backgroundRole()).name()) .arg(ui->tabWidget->widget(0)->palette().color(QPalette::Text).name())); // == bottom button styling == // This can be easily done via style sheets, saving us from subclassing QPushButton ui->bottomButtonBox->setStyleSheet(QString( "QPushButton {" " background-color: %3;" " color: %2;" " border: 1px solid %3;" " outline: 0;" " padding: 2px 10px;" "}" "QPushButton:!enabled {" " background-color: %1;" "}" "QPushButton:pressed, QPushButton:checked {" " background-color: %2;" " color: %1;" " border-color: %2;" "}" "QPushButton:hover {" " border-color: %2;" "}" "QPushButton:checked:hover, QPushButton:pressed:hover {" " border-color: %3;" " background-color: %2;" "}" ).replace("%1", this->palette().color(QPalette::Window).name()) .replace("%2", this->palette().color(QPalette::Foreground).name()) .replace("%3", this->palette().color(QPalette::Light).name())); // VU meter style: Make overshoot red QPalette vupal = ui->recordStatus->palette(); vupal.setBrush(QPalette::Highlight, QColor(0xFF, 0, 0)); ui->recordStatus->setPalette(vupal); }
void tst_QWindowSurface::grabWidget() { QWidget parentWidget; QWidget childWidget(&parentWidget); QWidget babyWidget(&childWidget); parentWidget.resize(300, 300); childWidget.setGeometry(50, 50, 200, 200); childWidget.setAutoFillBackground(true); babyWidget.setGeometry(50, 50, 100, 100); babyWidget.setAutoFillBackground(true); QPalette pal = parentWidget.palette(); pal.setColor(QPalette::Window, QColor(Qt::blue)); parentWidget.setPalette(pal); pal = childWidget.palette(); pal.setColor(QPalette::Window, QColor(Qt::white)); childWidget.setPalette(pal); pal = babyWidget.palette(); pal.setColor(QPalette::Window, QColor(Qt::red)); babyWidget.setPalette(pal); // prevent custom styles from messing up the background parentWidget.setStyle(new QWindowsStyle); babyWidget.show(); childWidget.show(); parentWidget.show(); QTest::qWaitForWindowShown(&parentWidget); QPixmap parentPixmap; QTRY_COMPARE((parentPixmap = parentWidget.windowSurface()->grabWidget(&parentWidget)).size(), QSize(300,300)); QPixmap childPixmap = childWidget.windowSurface()->grabWidget(&childWidget); QPixmap babyPixmap = babyWidget.windowSurface()->grabWidget(&babyWidget); QPixmap parentSubPixmap = parentWidget.windowSurface()->grabWidget(&parentWidget, QRect(25, 25, 100, 100)); QPixmap childSubPixmap = childWidget.windowSurface()->grabWidget(&childWidget, QRect(55, 55, 50, 50)); QPixmap childInvalidSubPixmap = childWidget.windowSurface()->grabWidget(&childWidget, QRect(-50, -50, 150, 150)); QCOMPARE(parentPixmap.size(), QSize(300, 300)); QCOMPARE(childPixmap.size(), QSize(200, 200)); QCOMPARE(babyPixmap.size(), QSize(100, 100)); QCOMPARE(parentSubPixmap.size(), QSize(100, 100)); QCOMPARE(childSubPixmap.size(), QSize(50, 50)); QCOMPARE(childInvalidSubPixmap.size(), QSize(100, 100)); QImage parentImage = parentPixmap.toImage(); QImage childImage = childPixmap.toImage(); QImage babyImage = babyPixmap.toImage(); QImage parentSubImage = parentSubPixmap.toImage(); QImage childSubImage = childSubPixmap.toImage(); QImage childInvalidSubImage = childInvalidSubPixmap.toImage(); QVERIFY(QColor(parentImage.pixel(0, 0)) == QColor(Qt::blue)); QVERIFY(QColor(parentImage.pixel(75, 75)) == QColor(Qt::white)); QVERIFY(QColor(parentImage.pixel(149, 149)) == QColor(Qt::red)); QVERIFY(QColor(childImage.pixel(0, 0)) == QColor(Qt::white)); QVERIFY(QColor(childImage.pixel(99, 99)) == QColor(Qt::red)); QVERIFY(QColor(parentSubImage.pixel(0, 0)) == QColor(Qt::blue)); QVERIFY(QColor(parentSubImage.pixel(30, 30)) == QColor(Qt::white)); QVERIFY(QColor(parentSubImage.pixel(80, 80)) == QColor(Qt::red)); QVERIFY(QColor(childSubImage.pixel(0, 0)) == QColor(Qt::red)); QVERIFY(QColor(childInvalidSubImage.pixel(0, 0)) == QColor(Qt::white)); }
cal2::cal2(QWidget *parent) : QWidget(parent) { initBasicData(); //--------------------------顶层-------------------------------------------------------------- QFont font1; font1.setPixelSize(15); QPalette palette1; palette1.setColor(QPalette::WindowText,QColor(155,155,155,255)); today = new ClickedLabel; today->setFont(font1); today->setPalette(palette1); today->setText(tr("Today")); connect(today,SIGNAL(clicked(ClickedLabel*)),this,SLOT(todayOnClicked())); pre = new ClickedLabel; pre->setFont(font1); pre->setPalette(palette1); pre->setText(tr("PRE")); connect(pre,SIGNAL(clicked(ClickedLabel*)),this,SLOT(preOnClicked())); next = new ClickedLabel; next->setFont(font1); next->setPalette(palette1); next->setText(tr("NEXT")); connect(next,SIGNAL(clicked(ClickedLabel*)),this,SLOT(nextOnClicked())); month = new ClickedLabel; month->setFont(font1); month->setPalette(palette1); year = new ClickedLabel; year->setFont(font1); year->setPalette(palette1); QHBoxLayout *toplayout = new QHBoxLayout; toplayout->addWidget(today); toplayout->addStretch(); toplayout->addWidget(pre); toplayout->addSpacing(20); toplayout->addWidget(month); toplayout->addSpacing(5); toplayout->addWidget(year); toplayout->addSpacing(20); toplayout->addWidget(next); toplayout->addStretch(); //--------------------------顶层结束---------------------------------------------------------- //---------------------------星期--------------------------------------------------------------- QString weekstr[7]={"MON","TUE","WED","THU","FRI","SAT","SUN"}; QHBoxLayout* weeklayout = new QHBoxLayout; weeklayout->setSpacing(0); QFont font2; font2.setPixelSize(15); QPalette palette2; palette2.setColor(QPalette::WindowText,QColor(155,155,155,255)); for(int i=0;i<7;i++) { QLabel* label = new QLabel(tr("%1").arg(weekstr[i])); label->setFont(font2); label->setPalette(palette2); label->setAlignment(Qt::AlignBottom|Qt::AlignHCenter); label->setFixedHeight(20); weeklayout->addWidget(label); } QVBoxLayout *toplayout2 = new QVBoxLayout; toplayout2->addLayout(toplayout); toplayout2->addLayout(weeklayout); QWidget *topwidget = new QWidget; topwidget->setLayout(toplayout2); topwidget->setFixedHeight(70); topwidget->setAutoFillBackground(true); QPalette pet; pet.setColor(QPalette::Background,QColor(50,58,69)); topwidget->setPalette(pet); topwidget->setFixedHeight(100); //topwidget->setStyleSheet("background-color: rgb(50,58,69)"); //---------------------------星期结束--------------------------------------------------------------- //----------------------------月历---------------------------------------------------------------- QGridLayout* grid = new QGridLayout; grid->setSpacing(1); int row,col,num; for(row=0;row<6;row++) for(col=1;col<=7;col++) { num =row*7+col; labels[num] = new cal_label; QPalette lpa; lpa.setColor(QPalette::WindowText,QColor(200,200,200)); labels[num]->lunarday->setPalette(lpa); connect(labels[num],SIGNAL(clicked(cal_label*)),this,SLOT(changeday(cal_label*))); grid->addWidget(labels[num],row,col-1); } QVBoxLayout* mainlayout = new QVBoxLayout(); //mainlayout->setSpacing(0); mainlayout->addWidget(topwidget); mainlayout->addLayout(grid); QFont rtfont1; rtfont1.setPixelSize(30); righttop = new QLabel; righttop->setFont(rtfont1); righttop->setStyleSheet("color:white;background-color:rgb(20,185,214)"); righttop->setFixedSize(360,100); //righttop->setAlignment(Qt::AlignCenter); righttop->setIndent(20); righttop2 = new QLabel; rtfont1.setPixelSize(20); righttop2->setFont(rtfont1); righttop2->setFixedHeight(100); righttop2->setStyleSheet("color:white;background-color:grey"); righttop2->setAlignment(Qt::AlignCenter); //righttop2->setIndent(30); QVBoxLayout *rtlayout = new QVBoxLayout; rtlayout->addWidget(righttop); rtlayout->addWidget(righttop2); rtlayout->setSpacing(0); // QLabel *rtwidget = new QLabel; // rtwidget->setLayout(rtlayout); // rtwidget->setFixedHeight(200); // rtwidget->setStyleSheet("background-color:rgb(107,203,202)"); // //rtwidget->setPalette(pet); todaylist = new QListWidget; QFont f1; f1.setPixelSize(20); todaylist->setFont(f1); //todaylist->setStyleSheet("background-color:rgb(24,34,144)"); QVBoxLayout *right1 = new QVBoxLayout; right1->addLayout(rtlayout); right1->addWidget(todaylist); QHBoxLayout *lastlayout = new QHBoxLayout(this); lastlayout->setSpacing(1); lastlayout->addLayout(mainlayout); lastlayout->addLayout(right1); lastlayout->setMargin(0); newCal(); }
//******************************************************************************** // CALENDAR SIDEBAR (DiarySidebar) //******************************************************************************** DiarySidebar::DiarySidebar(Context *context) : context(context) { setContentsMargins(0,0,0,0); setAutoFillBackground(true); month = year = 0; _ride = NULL; QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->setContentsMargins(0,0,0,0); mainLayout->setSpacing(0); // Splitter - cal at top, summary at bottom splitter = new GcSplitter(Qt::Vertical); mainLayout->addWidget(splitter); // calendar calendarItem = new GcSplitterItem(tr("Calendar"), iconFromPNG(":images/sidebar/calendar.png"), this); summaryItem = new GcSplitterItem(tr("Summary"), iconFromPNG(":images/sidebar/dashboard.png"), this); QPalette pal; pal.setColor(QPalette::Window, Qt::white); setPalette(pal); // cal widget QWidget *cal = new QWidget(this); cal->setPalette(pal); cal->setContentsMargins(0,0,0,0); cal->setStyleSheet("QLabel { color: gray; }"); layout = new QVBoxLayout(cal); layout->setSpacing(0); layout->setContentsMargins(0,0,0,0); calendarItem->addWidget(cal); // summary widget QWidget *sum = new QWidget(this); sum->setPalette(pal); sum->setContentsMargins(0,0,0,0); QVBoxLayout *slayout = new QVBoxLayout(sum); slayout->setSpacing(0); summaryItem->addWidget(sum); splitter->addWidget(calendarItem); splitter->addWidget(summaryItem); splitter->prepare(context->athlete->cyclist, "diary"); black.setColor(QPalette::WindowText, Qt::gray); white.setColor(QPalette::WindowText, Qt::white); grey.setColor(QPalette::WindowText, Qt::gray); multiCalendar = new GcMultiCalendar(context); layout->addWidget(multiCalendar); // Summary level selector QHBoxLayout *h = new QHBoxLayout(); h->setSpacing(5); summarySelect = new QComboBox(this); summarySelect->setFixedWidth(150); // is it impossible to size constrain qcombos? summarySelect->addItem(tr("Day Summary")); summarySelect->addItem(tr("Weekly Summary")); summarySelect->addItem(tr("Monthly Summary")); summarySelect->setCurrentIndex(2); // default to monthly h->addStretch(); h->addWidget(summarySelect, Qt::AlignCenter); h->addStretch(); slayout->addLayout(h); summary = new QWebView(this); summary->setContentsMargins(0,0,0,0); summary->page()->view()->setContentsMargins(0,0,0,0); summary->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); summary->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); summary->setAcceptDrops(false); QFont defaultFont; // mainwindow sets up the defaults.. we need to apply summary->settings()->setFontSize(QWebSettings::DefaultFontSize, defaultFont.pointSize()); summary->settings()->setFontFamily(QWebSettings::StandardFont, defaultFont.family()); slayout->addWidget(summary); slayout->addStretch(); // summary mode changed connect(summarySelect, SIGNAL(currentIndexChanged(int)), this, SLOT(refresh())); // refresh on these events... connect(context, SIGNAL(rideAdded(RideItem*)), this, SLOT(refresh())); connect(context, SIGNAL(rideDeleted(RideItem*)), this, SLOT(refresh())); connect(context, SIGNAL(configChanged()), this, SLOT(refresh())); // set up for current selections refresh(); }
TrackInfoWidget::TrackInfoWidget( const Tomahawk::query_ptr& query, QWidget* parent ) : QWidget( parent ) , ui( new Ui::TrackInfoWidget ) { QWidget* widget = new QWidget; ui->setupUi( widget ); QPalette pal = palette(); pal.setColor( QPalette::Window, QColor( "#454e59" ) ); widget->setPalette( pal ); widget->setAutoFillBackground( true ); ui->rightBar->setPalette( pal ); ui->rightBar->setAutoFillBackground( true ); ui->statsLabel->setStyleSheet( "QLabel { background-image:url(); border: 2px solid #dddddd; background-color: #faf9f9; border-radius: 4px; padding: 12px; }" ); ui->lyricsView->setStyleSheet( "QTextBrowser#lyricsView { background-color: transparent; }" ); ui->lyricsView->setFrameShape( QFrame::NoFrame ); ui->lyricsView->setAttribute( Qt::WA_MacShowFocusRect, 0 ); ui->similarTracksView->setAutoResize( true ); ui->similarTracksView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); // TomahawkUtils::styleScrollBar( ui->similarTracksView->verticalScrollBar() ); TomahawkUtils::styleScrollBar( ui->lyricsView->verticalScrollBar() ); QFont f = font(); f.setBold( true ); f.setPixelSize( 18 ); ui->trackLabel->setFont( f ); // ui->similarTracksLabel->setFont( f ); f.setPixelSize( 14 ); ui->artistLabel->setFont( f ); ui->albumLabel->setFont( f ); f.setPixelSize( 12 ); ui->statsLabel->setFont( f ); // ui->similarTracksView->setStyleSheet( "QListView { background-color: transparent; } QListView::item { background-color: transparent; }" ); QPalette p = ui->trackLabel->palette(); p.setColor( QPalette::Foreground, Qt::white ); p.setColor( QPalette::Text, Qt::white ); ui->trackLabel->setPalette( p ); ui->artistLabel->setPalette( p ); ui->albumLabel->setPalette( p ); ui->lyricsView->setPalette( p ); ui->label->setPalette( p ); // ui->similarTracksLabel->setPalette( p ); ui->artistLabel->setType( QueryLabel::Artist ); ui->albumLabel->setType( QueryLabel::Album ); m_relatedTracksModel = new PlayableModel( ui->similarTracksView ); ui->similarTracksView->setPlayableModel( m_relatedTracksModel ); ui->similarTracksView->proxyModel()->sort( -1 ); ui->similarTracksView->setEmptyTip( tr( "Sorry, but we could not find similar tracks for this song!" ) ); m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultAlbumCover, TomahawkUtils::ScaledCover, QSize( 48, 48 ) ); ui->cover->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultTrackImage, TomahawkUtils::ScaledCover, QSize( ui->cover->sizeHint() ) ) ); QScrollArea* area = new QScrollArea(); area->setWidgetResizable( true ); area->setWidget( widget ); area->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); area->setStyleSheet( "QScrollArea { background-color: #454e59 }" ); area->setFrameShape( QFrame::NoFrame ); area->setAttribute( Qt::WA_MacShowFocusRect, 0 ); QVBoxLayout* layout = new QVBoxLayout(); layout->addWidget( area ); setLayout( layout ); TomahawkUtils::unmarginLayout( layout ); ui->similarTracksView->setStyleSheet( "QListView { background-color: transparent; }" ); ui->frame->setStyleSheet( "QFrame#frame { background-color: transparent; }" "QFrame#frame { " "border-image: url(" RESPATH "images/scrollbar-vertical-handle.png) 3 3 3 3 stretch stretch;" "border-top: 3px transparent; border-bottom: 3px transparent; border-right: 3px transparent; border-left: 3px transparent; }" ); load( query ); connect( ui->artistLabel, SIGNAL( clickedArtist() ), SLOT( onArtistClicked() ) ); connect( ui->albumLabel, SIGNAL( clickedAlbum() ), SLOT( onAlbumClicked() ) ); }
ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget* parent ) : QWidget( parent ) , ui( new Ui::ArtistInfoWidget ) , m_artist( artist ) { QWidget* widget = new QWidget; ui->setupUi( widget ); QPalette pal = palette(); pal.setColor( QPalette::Window, QColor( "#454e59" ) ); widget->setPalette( pal ); widget->setAutoFillBackground( true ); m_plInterface = Tomahawk::playlistinterface_ptr( new MetaArtistInfoInterface( this ) ); /* TomahawkUtils::unmarginLayout( ui->layoutWidget->layout() ); TomahawkUtils::unmarginLayout( ui->layoutWidget1->layout() ); TomahawkUtils::unmarginLayout( ui->layoutWidget2->layout() ); TomahawkUtils::unmarginLayout( ui->albumHeader->layout() );*/ m_albumsModel = new PlayableModel( ui->albums ); ui->albums->setPlayableModel( m_albumsModel ); ui->topHits->setEmptyTip( tr( "Sorry, we could not find any albums for this artist!" ) ); m_relatedModel = new PlayableModel( ui->relatedArtists ); ui->relatedArtists->setPlayableModel( m_relatedModel ); ui->relatedArtists->proxyModel()->sort( -1 ); ui->topHits->setEmptyTip( tr( "Sorry, we could not find any related artists!" ) ); m_topHitsModel = new PlaylistModel( ui->topHits ); ui->topHits->proxyModel()->setStyle( PlayableProxyModel::Short ); ui->topHits->setPlayableModel( m_topHitsModel ); ui->topHits->setSortingEnabled( false ); ui->topHits->setEmptyTip( tr( "Sorry, we could not find any top hits for this artist!" ) ); ui->relatedArtists->setAutoFitItems( false ); ui->relatedArtists->setWrapping( false ); ui->relatedArtists->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); ui->relatedArtists->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); ui->relatedArtists->delegate()->setItemSize( QSize( 170, 170 ) ); ui->albums->setAutoFitItems( false ); ui->albums->setWrapping( false ); ui->albums->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); ui->albums->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); ui->albums->delegate()->setItemSize( QSize( 170, 170 ) ); ui->albums->proxyModel()->setHideDupeItems( true ); ui->topHits->setFrameShape( QFrame::StyledPanel ); ui->topHits->setAttribute( Qt::WA_MacShowFocusRect, 0 ); m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultArtistImage, TomahawkUtils::ScaledCover, QSize( 48, 48 ) ); ui->cover->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultArtistImage, TomahawkUtils::ScaledCover, QSize( ui->cover->sizeHint() ) ) ); ui->biography->setFrameShape( QFrame::NoFrame ); ui->biography->setAttribute( Qt::WA_MacShowFocusRect, 0 ); TomahawkUtils::styleScrollBar( ui->biography->verticalScrollBar() ); QFont f = font(); f.setBold( true ); f.setPointSize( 14 ); ui->artistLabel->setFont( f ); QPalette p = ui->biography->palette(); p.setColor( QPalette::Foreground, Qt::white ); p.setColor( QPalette::Text, Qt::white ); ui->artistLabel->setPalette( p ); ui->biography->setPalette( p ); ui->label->setPalette( p ); ui->label_2->setPalette( p ); ui->label_3->setPalette( p ); QScrollArea* area = new QScrollArea(); area->setWidgetResizable( true ); area->setWidget( widget ); area->setStyleSheet( "QScrollArea { background-color: #454e59; }" ); area->setFrameShape( QFrame::NoFrame ); area->setAttribute( Qt::WA_MacShowFocusRect, 0 ); QVBoxLayout* layout = new QVBoxLayout(); layout->addWidget( area ); setLayout( layout ); TomahawkUtils::unmarginLayout( layout ); TomahawkUtils::styleScrollBar( ui->albums->horizontalScrollBar() ); TomahawkUtils::styleScrollBar( ui->relatedArtists->horizontalScrollBar() ); ui->biography->setStyleSheet( "QTextBrowser#biography { background-color: transparent; }" ); ui->albums->setStyleSheet( "QListView { background-color: transparent; }" ); ui->albumFrame->setStyleSheet( "QFrame#albumFrame { background-color: transparent; }" "QFrame#albumFrame { " "border-image: url(" RESPATH "images/scrollbar-vertical-handle.png) 3 3 3 3 stretch stretch;" "border-top: 3px transparent; border-bottom: 3px transparent; border-right: 3px transparent; border-left: 3px transparent; }" ); ui->relatedArtists->setStyleSheet( "QListView { background-color: transparent; }" ); ui->artistFrame->setStyleSheet( "QFrame#artistFrame { background-color: transparent; }" "QFrame#artistFrame { " "border-image: url(" RESPATH "images/scrollbar-vertical-handle.png) 3 3 3 3 stretch stretch;" "border-top: 3px transparent; border-bottom: 3px transparent; border-right: 3px transparent; border-left: 3px transparent; }" ); // ui->topHits->setStyleSheet( "QTreeView#topHits { background-color: transparent; }" ); ui->trackFrame->setStyleSheet( "QFrame#trackFrame { background-color: transparent; }" "QFrame#trackFrame { " "border-image: url(" RESPATH "images/scrollbar-vertical-handle.png) 3 3 3 3 stretch stretch;" "border-top: 3px transparent; border-bottom: 3px transparent; border-right: 3px transparent; border-left: 3px transparent; }" ); load( artist ); }
ProofPage::ProofPage(ResizableStackedWidget *pageStack, Model *model, QWidget *parent) : QWidget(parent) { this->model = model; this->pageStack = pageStack; proofEditForm = new ProofForm(); proofEditDialog = new Dialog(this, proofEditForm, "Edit the proof...", "Change", "Cancel"); proofDeleteDialog = new Dialog(this, nullptr, "Are you sure you want to delete this proof?", "Delete", "Cancel"); QVBoxLayout *outerLayout = new QVBoxLayout(this); // ## ## ####### ### ##### ####### ##### // ## ## ## ## ## ## ## ## ## ## // ## ## ## ## ## ## ## ## ## ## // ####### ##### ## ## ## ## ##### ## ## // ## ## ## ####### ## ## ## ##### // ## ## ## ## ## ## ## ## ## ## // ## ## ####### ## ## ##### ####### ## ## // The breadcrumbs show the current course and provide // a way to go back to the courses screen. // It is presented like a filepath. QHBoxLayout *crumbBorderLayout = new QHBoxLayout(); breadCrumbs = new BreadCrumbs(3, model, pageStack); breadCrumbs->setFixedWidth(700); crumbBorderLayout->addStretch(1); crumbBorderLayout->addWidget(breadCrumbs); crumbBorderLayout->addStretch(1); outerLayout->addLayout(crumbBorderLayout); // Now show the name of the current proof and some buttons to // edit it, delete it or add a new dependency. QHBoxLayout *topBorderLayout = new QHBoxLayout(); QWidget *topWidget = new QWidget(); topWidget->setFixedWidth(700); QHBoxLayout *topLayout = new QHBoxLayout(topWidget); topLayout->setContentsMargins(0, 0, 0, 0); proofLabel = new QLabel(); proofLabel->setWordWrap(true); proofLabel->setScaledContents(true); QFont proofFont = proofLabel->font(); proofFont.setPointSize(24); proofLabel->setFont(proofFont); trafficLight = new TrafficLight(TrafficLight::AMBER); trafficLight->setFixedSize(QSize(32, 32)); QVBoxLayout *trafficLightVLayout = new QVBoxLayout(); trafficLightVLayout->addSpacing(16); trafficLightVLayout->addWidget(trafficLight); editProofButton = new ImageButton(QPixmap(":/images/pencil_black.png"), QSize(32, 32)); QVBoxLayout *editProofVLayout = new QVBoxLayout(); editProofVLayout->addSpacing(16); editProofVLayout->addWidget(editProofButton); deleteProofButton = new ImageButton(QPixmap(":/images/trash_black.png"), QSize(32, 32)); QVBoxLayout *deleteProofVLayout = new QVBoxLayout(); deleteProofVLayout->addSpacing(16); deleteProofVLayout->addWidget(deleteProofButton); topLayout->addWidget(proofLabel); topLayout->addLayout(trafficLightVLayout); topLayout->addSpacing(10); topLayout->addLayout(editProofVLayout); topLayout->addSpacing(10); topLayout->addLayout(deleteProofVLayout); topBorderLayout->addStretch(1); topBorderLayout->addWidget(topWidget); topBorderLayout->addStretch(1); outerLayout->addLayout(topBorderLayout); outerLayout->addSpacing(20); outerLayout->addWidget(new HorizontalSeperator(QColor(66, 139, 202), 2)); outerLayout->addSpacing(20); // ###### ##### ##### ## ## // ## ## ## ## ## ### ## ## // ## ## ## ## ## ## #### // ###### ## ## ## ## ## // ## ## ## ## ## ## ## // ## ## ## ## ## ### ## // ###### ##### ##### ## // Use a vertical splitter to divide the areas. splitter = new Splitter(Qt::Vertical); outerLayout->addWidget(splitter); splitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); // The first area is a large text editing widget, this is // used to edit the proof's body. // The QTextEdit does its own scrolling. bodyTextEdit = new QTextEdit(); QFont font = bodyTextEdit->font(); font.setFamily("Courier"); font.setPointSize(12); bodyTextEdit->setFont(font); bodyHighlighter = new LatexHighlighter(bodyTextEdit->document()); splitter->addWidget(bodyTextEdit); QTimer *bodySaveTimer = new QTimer(this); bodySaveTimer->setSingleShot(true); bodySaveTimer->setInterval(200); connect(bodyTextEdit, SIGNAL(textChanged()), bodySaveTimer, SLOT(start())); connect(bodySaveTimer, SIGNAL(timeout()), this, SLOT(saveBody())); // The second area contains the rendered body. QScrollArea *bodyScrollArea = new QScrollArea(); bodyScrollArea->setWidgetResizable(true); bodyScrollArea->setFrameShape(QFrame::NoFrame); QWidget *bodyWidget = new QWidget(); QPalette palette = bodyWidget->palette(); palette.setColor(QPalette::Background, Qt::white); bodyWidget->setPalette(palette); bodyWidget->setAutoFillBackground(true); bodyImage = new ResizableImage(""); QHBoxLayout *bodyHLayout = new QHBoxLayout(); bodyHLayout->addStretch(1); bodyHLayout->addWidget(bodyImage); bodyHLayout->addStretch(1); QVBoxLayout *bodyVLayout = new QVBoxLayout(); bodyVLayout->addLayout(bodyHLayout); bodyVLayout->addStretch(1); bodyWidget->setLayout(bodyVLayout); bodyScrollArea->setWidget(bodyWidget); splitter->addWidget(bodyScrollArea); // ##### #### ##### ## ## ### ## ##### // ## ## ## ## ## ### ## ## ## ## ## ## // ## ## ## ### ## ## ## ## ## // ### ## ## ####### ## ## ## ### // ## ## ## ### ## ### ####### ## ## // ## ## ## ## ## ## ### ## ## ## ## ## // ##### #### ##### ## ## ## ## ####### ##### connect(editProofButton, SIGNAL(clicked()), this, SLOT(proofEditButtonClicked())); connect(proofEditDialog, SIGNAL(accepted()), this, SLOT(proofEditDialogCompleted())); connect(proofEditDialog, SIGNAL(rejected()), proofEditDialog, SLOT(close())); connect(deleteProofButton, SIGNAL(clicked()), proofDeleteDialog, SLOT(show())); connect(proofDeleteDialog, SIGNAL(accepted()), this, SLOT(proofDeleteDialogAccepted())); connect(proofDeleteDialog, SIGNAL(rejected()), proofDeleteDialog, SLOT(close())); connect(model, SIGNAL(proofSelectedChanged(Proof)), this, SLOT(proofSelectedChangedSlot(Proof))); connect(model, SIGNAL(proofEdited(Proof)), this, SLOT(proofEditedSlot(Proof))); connect(model, SIGNAL(proofDeleted(int)), this, SLOT(proofDeletedSlot(int))); }
QArvMainWindow::QArvMainWindow(QWidget* parent, bool standalone_) : QMainWindow(parent) , camera(NULL) , decoder(NULL) , playing(false) , recording(false) , started(false) , drawHistogram(false) , standalone(standalone_) , imageTransform() , imageTransform_flip(0) , imageTransform_rot(0) , toDisableWhenPlaying() , toDisableWhenRecording() , futureHoldsAHistogram(false) , recordingTimeCumulative(0) { setAttribute(Qt::WA_DeleteOnClose); logMessage() << "Please ignore \"Could not resolve property\" warnings " "unless icons look bad."; setupUi(this); on_statusTimeoutSpinbox_valueChanged(statusTimeoutSpinbox->value()); messageList->connect(&QArvDebug::messageSender, SIGNAL(newDebugMessage(QString)), SLOT(appendPlainText(QString))); workthread = new Workthread(this); connect(workthread, SIGNAL(frameRendered()), SLOT(frameRendered())); connect(workthread, SIGNAL(recordingStopped()), SLOT(stopRecording())); // Setup theme icons if available. /* bool usingFallbackIcons = false; QMap<QAbstractButton*, QString> icons; icons[unzoomButton] = "zoom-original"; icons[playButton] = "media-playback-start"; icons[refreshCamerasButton] = "view-refresh"; icons[chooseFilenameButton] = "document-open"; icons[chooseSnappathButton] = "document-open"; icons[editGainButton] = "edit-clear-locationbar-rtl"; icons[editExposureButton] = "edit-clear-locationbar-rtl"; icons[histogramLog] = "view-object-histogram-logarithmic"; icons[pickROIButton] = "edit-select"; for (auto i = icons.begin(); i != icons.end(); i++) { if (!QIcon::hasThemeIcon(*i)) { i.key()->setIcon(QIcon(QString(qarv_datafiles) + *i + ".svgz")); usingFallbackIcons = true; } } QMap<QAction*, QString> aicons; aicons[showVideoAction] = "video-display"; aicons[recordAction] = "media-record"; aicons[closeFileAction] = "media-playback-stop"; aicons[showHistogramAction] = "office-chart-bar"; aicons[messageAction] = "dialog-information"; for (auto i = aicons.begin(); i != aicons.end(); i++) { if (!QIcon::hasThemeIcon(*i)) { i.key()->setIcon(QIcon(QString(qarv_datafiles) + *i + ".svgz")); usingFallbackIcons = true; } } if (usingFallbackIcons) logMessage() << "Some icons are not available in your theme, using bundled icons."; */ { auto d = QDate::currentDate(); int y = d.year(), l = d.month(), a = d.day(); int j = y % 19; int k = y / 100; int h = y % 100; int m = k / 4; int n = k % 4; int p = (k + 8) / 25; int q = (k - p + 1) / 3; int r = (19 * j + k - m - q + 15) % 30; int s = h / 4; int u = h % 4; int v = (32 + 2 * n + 2 * s - r - u) % 7; int w = (j + 11 * r + 22 * v) / 451; int x = r + v - 7 * w + 114; int z = x % 31 + 1; x = x / 31; if (l == x && (z == a || z + 1 == a || z - 1 == a)) { QWidget* wgt = new QWidget(this); wgt->setLayout(new QHBoxLayout); wgt->layout()->setMargin(30); char tmp[10]; std::strcpy(tmp, "$6872F=E"); for (int i = 0; i < 8; i++) tmp[i] = (tmp[i] + (16 ^ 63)) % (1 << 7); auto r = new QPushButton(tmp); wgt->layout()->addWidget(r); connect(r, SIGNAL(clicked(bool)), SLOT(on_replayButton_clicked(bool))); QPalette p = wgt->palette(); p.setColor(wgt->backgroundRole(), qRgb(226, 53, 48)); wgt->setPalette(p); wgt->setAutoFillBackground(true); } } // Setup the subwindows menu. auto submenu = new QMenu; submenu->addAction(showVideoAction); submenu->addAction(showHistogramAction); submenu->addAction(messageAction); auto toolbutton = new QToolButton; toolbutton->setMenu(submenu); toolbutton->setPopupMode(QToolButton::InstantPopup); toolbutton->setToolButtonStyle(Qt::ToolButtonTextOnly); toolbutton->setText(tr("Subwindows")); subwindowToolbar->addWidget(toolbutton); // Setup the postproc filter menu auto plugins = QPluginLoader::staticInstances(); auto postprocMenu = new QMenu; foreach (auto plugin, plugins) { auto filterPlugin = qobject_cast<ImageFilterPlugin*>(plugin); if (filterPlugin != NULL) { auto action = new QAction(filterPlugin->name(), this); action->setData(QVariant::fromValue(filterPlugin)); connect(action, SIGNAL(triggered(bool)), SLOT(addPostprocFilter())); postprocMenu->addAction(action); } }
void KexiDBAutoField::createEditor() { if (subwidget()) { delete(QWidget *)subwidget(); } QWidget *newSubwidget; //qDebug() << "widgetType:" << d->widgetType; switch (d->widgetType) { case Text: case Double: //! @todo setup validator case Integer: //! @todo setup validator case Date: case Time: case DateTime: { KexiDBLineEdit *le = new KexiDBLineEdit(this); newSubwidget = le; le->setFrame(false); break; } case MultiLineText: newSubwidget = new KexiDBTextEdit(this); break; case Boolean: newSubwidget = new KexiDBCheckBox(dataSource(), this); break; case Image: newSubwidget = new KexiDBImageBox(designMode(), this); break; case ComboBox: { KexiDBComboBox *cbox = new KexiDBComboBox(this); newSubwidget = cbox; cbox->setDesignMode(designMode()); break; } default: newSubwidget = 0; changeText(d->caption); break; } //qDebug() << newSubwidget; setSubwidget(newSubwidget); //this will also allow to declare subproperties, see KFormDesigner::WidgetWithSubpropertiesInterface if (newSubwidget) { newSubwidget->setObjectName( QString::fromLatin1("KexiDBAutoField_") + newSubwidget->metaObject()->className()); dynamic_cast<KexiDataItemInterface*>(newSubwidget)->setParentDataItemInterface(this); dynamic_cast<KexiFormDataItemInterface*>(newSubwidget) ->setColumnInfo(columnInfo()); //needed at least by KexiDBImageBox dynamic_cast<KexiFormDataItemInterface*>(newSubwidget) ->setVisibleColumnInfo(visibleColumnInfo()); //needed at least by KexiDBComboBox newSubwidget->setProperty("dataSource", dataSource()); //needed at least by KexiDBImageBox KFormDesigner::DesignTimeDynamicChildWidgetHandler::childWidgetAdded(this); newSubwidget->show(); d->label->setBuddy(newSubwidget); if (d->focusPolicyChanged) {//if focusPolicy is changed at top level, editor inherits it newSubwidget->setFocusPolicy(focusPolicy()); } else {//if focusPolicy is not changed at top level, inherit it from editor QWidget::setFocusPolicy(newSubwidget->focusPolicy()); } setFocusProxy(newSubwidget); //ok? if (parentWidget()) newSubwidget->setPalette(qApp->palette()); copyPropertiesToEditor(); } setLabelPosition(labelPosition()); }
/***************************************************************************** * CameraExample */ CameraExample::CameraExample(QWidget *parent) : QMainWindow(parent) { setWindowTitle("QCameraExample"); // Opitimizations for screen update and drawing qwidget setAutoFillBackground(false); // Prevent to screensaver to activate m_systemScreenSaver = new QSystemScreenSaver(this); m_systemScreenSaver->setScreenSaverInhibit(); m_myVideoSurface = 0; pictureCaptured = false; showViewFinder = false; m_focusing = false; // Black background QPalette palette = this->palette(); palette.setColor(QPalette::Background, Qt::black); setPalette(palette); // Main widget & layout QWidget* mainWidget = new QWidget(this); mainWidget->setPalette(palette); QHBoxLayout* hboxl = new QHBoxLayout; hboxl->setSpacing(0); hboxl->setMargin(0); // UI stack m_stackedWidget = new QStackedWidget(); m_stackedWidget->setPalette(palette); // First widget to stack m_videoWidget = new QWidget(); m_videoWidget->setPalette(palette); m_stackedWidget->addWidget(m_videoWidget); // Second widget to stack QWidget* secondWidget = new QWidget(this); secondWidget->setPalette(palette); m_stackedWidget->addWidget(secondWidget); m_stackedWidget->setCurrentIndex(0); hboxl->addWidget(m_stackedWidget); // Buttons QSize iconSize(80, 80); QVBoxLayout* vboxl = new QVBoxLayout; vboxl->setSpacing(0); vboxl->setMargin(0); // Camera button m_cameraBtn = new Button(this); QObject::connect(m_cameraBtn, SIGNAL(pressed()), this, SLOT(searchAndLock())); QPixmap p = QPixmap(":/images/camera.png"); m_cameraBtn->setPixmap(p.scaled(iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation)); vboxl->addWidget(m_cameraBtn); vboxl->setAlignment(m_cameraBtn, Qt::AlignCenter); // Exit button m_exit = new Button(this); QObject::connect(m_exit, SIGNAL(pressed()), qApp, SLOT(quit())); p = QPixmap(":/images/exit.png"); m_exit->setPixmap(p.scaled(iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation)); vboxl->addWidget(m_exit); vboxl->setAlignment(m_exit, Qt::AlignHCenter | Qt::AlignTop); hboxl->addLayout(vboxl); mainWidget->setLayout(hboxl); setCentralWidget(mainWidget); // Enable camera after 1s, so that the application is started // and widget is created to landscape orientation QTimer::singleShot(1000,this,SLOT(enableCamera())); }
/** * Request the video to avoid the conflicts **/ WId VideoWidget::request( int *pi_x, int *pi_y, unsigned int *pi_width, unsigned int *pi_height, bool b_keep_size ) { msg_Dbg( p_intf, "Video was requested %i, %i", *pi_x, *pi_y ); if( reparentable != NULL ) { msg_Dbg( p_intf, "embedded video already in use" ); return NULL; } if( b_keep_size ) { *pi_width = size().width(); *pi_height = size().height(); } /* The Qt4 UI needs a fixed a widget ("this"), so that the parent layout is * not messed up when we the video is reparented. Hence, we create an extra * reparentable widget, that will be within the VideoWidget in windowed * mode, and within the root window (NULL parent) in full-screen mode. */ reparentable = new ReparentableWidget( this ); QLayout *innerLayout = new QHBoxLayout( reparentable ); innerLayout->setContentsMargins( 0, 0, 0, 0 ); /* The owner of the video window needs a stable handle (WinId). Reparenting * in Qt4-X11 changes the WinId of the widget, so we need to create another * dummy widget that stays within the reparentable widget. */ QWidget *stable = new QWidget(); QPalette plt = palette(); plt.setColor( QPalette::Window, Qt::black ); stable->setPalette( plt ); stable->setAutoFillBackground(true); /* Indicates that the widget wants to draw directly onto the screen. Widgets with this attribute set do not participate in composition management */ stable->setAttribute( Qt::WA_PaintOnScreen, true ); innerLayout->addWidget( stable ); layout->addWidget( reparentable ); #ifdef Q_WS_X11 /* HACK: Only one X11 client can subscribe to mouse button press events. * VLC currently handles those in the video display. * Force Qt4 to unsubscribe from mouse press and release events. */ Display *dpy = QX11Info::display(); Window w = stable->winId(); XWindowAttributes attr; XGetWindowAttributes( dpy, w, &attr ); attr.your_event_mask &= ~(ButtonPressMask|ButtonReleaseMask); XSelectInput( dpy, w, attr.your_event_mask ); #endif videoSync(); #ifndef NDEBUG msg_Dbg( p_intf, "embedded video ready (handle %p)", (void *)stable->winId() ); #endif return stable->winId(); }