void SlideWidget::setImage( const QImage &image ) { QPalette palette; palette.setBrush( backgroundRole(), QBrush( QPixmap::fromImage( image ) ) ); setPalette( palette ); }
void MainWindow::makeUI() { setObjectName(QString::fromUtf8("MainWindow")); #if 1 action_Exit = new QAction(this); action_Exit->setObjectName(QString::fromUtf8("action_Exit")); //connect(action_Exit, SIGNAL(triggered()), qApp, SLOT(quit())); connect(action_Exit, SIGNAL(triggered()), this, SLOT(close())); #endif centralwidget = new QWidget(this); centralwidget->setObjectName(QString::fromUtf8("centralwidget")); widget = new QWidget(centralwidget); widget->setObjectName(QString::fromUtf8("widget")); widget->setGeometry(QRect(190, 0, 1080, 821)); widget->setMinimumSize(QSize(400, 0)); vboxLayout = new QVBoxLayout(widget); vboxLayout->setSpacing(0); vboxLayout->setMargin(0); vboxLayout->setObjectName(QString::fromUtf8("vboxLayout")); dockWidget = new QDockWidget(widget); dockWidget->setObjectName(QString::fromUtf8("dockWidget")); QSizePolicy sizePolicy(static_cast<QSizePolicy::Policy>(7), static_cast<QSizePolicy::Policy>(7)); sizePolicy.setHorizontalStretch(0); sizePolicy.setVerticalStretch(0); sizePolicy.setHeightForWidth(dockWidget->sizePolicy().hasHeightForWidth()); dockWidget->setSizePolicy(sizePolicy); dockWidgetContents = new QWidget(dockWidget); dockWidgetContents->setObjectName(QString::fromUtf8("dockWidgetContents")); vdockLayout = new QVBoxLayout(widget); vdockLayout->setSpacing(0); vdockLayout->setMargin(0); vdockLayout->setObjectName(QString::fromUtf8("vdockLayout")); stackedWidget = new QStackedWidget(dockWidgetContents); stackedWidget->setObjectName(QString::fromUtf8("stackedWidget")); stackedWidget->setGeometry(QRect(0, 0, 1080, 821)); dockWidget->setWidget(dockWidgetContents); vboxLayout->addWidget(dockWidget); dockWidgetContents->setLayout(vdockLayout); vdockLayout->addWidget(stackedWidget); tabWidget = new QTabWidget(centralwidget); tabWidget->setObjectName(QString::fromUtf8("tabWidget")); tabWidget->setGeometry(QRect(0, 0, 190, 821)); QSizePolicy sizePolicy1(static_cast<QSizePolicy::Policy>(5), static_cast<QSizePolicy::Policy>(5)); sizePolicy1.setHorizontalStretch(0); sizePolicy1.setVerticalStretch(0); sizePolicy1.setHeightForWidth(tabWidget->sizePolicy().hasHeightForWidth()); tabWidget->setSizePolicy(sizePolicy1); tabWidget->setMaximumSize(QSize(16777215, 16777215)); tabWidget->setTabPosition(QTabWidget::West); tabWidget->setTabShape(QTabWidget::Triangular); tabWidget->setElideMode(Qt::ElideNone); tab_0 = new QWidget(); tab_0->setObjectName(QString::fromUtf8("tab_0")); QFont font; font.setPointSize(14); vboxLayout0 = new QVBoxLayout(tab_0); vboxLayout0->setSpacing(6); vboxLayout0->setMargin(9); vboxLayout0->setAlignment(Qt::AlignTop); vboxLayout0->setObjectName(QString::fromUtf8("vboxLayout0")); pushButton[0] = new QPushButton(tab_0); pushButton[0]->setObjectName(QString::fromUtf8("pushButton_0")); pushButton[0]->setFont(font); pushButton[0]->setText(QApplication::translate("MainWindow", "PMS In Board", 0, QApplication::UnicodeUTF8)); vboxLayout0->addWidget(pushButton[0]); pushButton[1] = new QPushButton(tab_0); pushButton[1]->setObjectName(QString::fromUtf8("pushButton_1")); pushButton[1]->setFont(font); pushButton[1]->setText(QApplication::translate("MainWindow", "PMS Out Board", 0, QApplication::UnicodeUTF8)); vboxLayout0->addWidget(pushButton[1]); QSpacerItem *spacerItem; //spacerItem = new QSpacerItem(31, 61, QSizePolicy::Minimum, QSizePolicy::Expanding); spacerItem = new QSpacerItem(31, 61, QSizePolicy::Minimum, QSizePolicy::Fixed); vboxLayout0->addItem(spacerItem); //Add Code. archiveList = new QComboBox(tab_0); archiveList->setObjectName(QString::fromUtf8("archiveList")); vboxLayout0->addWidget(archiveList); Start_dateTime = new QDateTimeEdit(tab_0); Start_dateTime->setObjectName(QString::fromUtf8("Start_dateTime")); Start_dateTime->setDisplayFormat("yyyy/MM/dd hh:mm:ss"); Start_dateTime->setDateTime(QDateTime(QDate(2012,5,29), QTime(12,0,0))); vboxLayout0->addWidget(Start_dateTime); End_dateTime = new QDateTimeEdit(tab_0); End_dateTime->setObjectName(QString::fromUtf8("End_dateTime")); End_dateTime->setDisplayFormat("yyyy/MM/dd hh:mm:ss"); End_dateTime->setDateTime(QDateTime(QDate(2012,5,29), QTime(13,0,0))); vboxLayout0->addWidget(End_dateTime); RButton = new QPushButton(tab_0); RButton->setObjectName(QString::fromUtf8("RButton")); RButton->setText("OK"); if(RButton!=0) connect(RButton, SIGNAL(clicked()), this, SLOT(getChannelValues())); //RButton->setGeometry(QRect(980, 20, 80, 27)); vboxLayout0->addWidget(RButton); currentTimeLabel = new QLabel(tab_0); currentTimeLabel->setObjectName(QString::fromUtf8("currentTimeLabel")); currentTimeLabel->setText("Current Index Time"); //currentTimeLabel->setGeometry(QRect(760, 7, 161, 21)); vboxLayout0->addWidget(currentTimeLabel); timeSlider = new QSlider(tab_0); timeSlider->setObjectName(QString::fromUtf8("timeSlider")); //timeSlider->setGeometry(QRect(760, 24, 201, 16)); timeSlider->setValue(-1); timeSlider->setOrientation(Qt::Horizontal); connect(timeSlider, SIGNAL(valueChanged(int)), this, SLOT(readValue(int))); vboxLayout0->addWidget(timeSlider); //--> Splitter splitter = new QSplitter(tab_0); splitter->setObjectName(QString::fromUtf8("splitter")); splitter->setOrientation(Qt::Horizontal); incButtonDouble = new QPushButton(splitter); incButtonDouble->setObjectName(QString::fromUtf8("incButtonDouble")); QSizePolicy sizePol(QSizePolicy::Fixed, QSizePolicy::Fixed); sizePol.setHeightForWidth(incButtonDouble->sizePolicy().hasHeightForWidth()); incButtonDouble->setSizePolicy(sizePol); incButtonDouble->setText("<<"); connect(incButtonDouble,SIGNAL(clicked()), this, SLOT(decDouble())); splitter->addWidget(incButtonDouble); incButton = new QPushButton(splitter); incButton->setObjectName(QString::fromUtf8("incButton")); sizePol.setHeightForWidth(incButton->sizePolicy().hasHeightForWidth()); incButton->setSizePolicy(sizePol); incButton->setText("<"); connect(incButton,SIGNAL(clicked()), this, SLOT(decrease())); splitter->addWidget(incButton); decButton = new QPushButton(splitter); decButton->setObjectName(QString::fromUtf8("decButton")); sizePol.setHeightForWidth(decButton->sizePolicy().hasHeightForWidth()); decButton->setSizePolicy(sizePol); decButton->setText(">"); connect(decButton,SIGNAL(clicked()), this, SLOT(increase())); splitter->addWidget(decButton); decButtonDouble = new QPushButton(splitter); decButtonDouble->setObjectName(QString::fromUtf8("decButtonDouble")); sizePol.setHeightForWidth(decButtonDouble->sizePolicy().hasHeightForWidth()); decButtonDouble->setSizePolicy(sizePol); decButtonDouble->setText(">>"); connect(decButtonDouble,SIGNAL(clicked()), this, SLOT(incDouble())); splitter->addWidget(decButtonDouble); vboxLayout0->addWidget(splitter); //<-- Splitter splitter2 = new QSplitter(tab_0); splitter2->setObjectName(QString::fromUtf8("splitter2")); splitter2->setOrientation(Qt::Horizontal); stopButton = new QPushButton(splitter2); stopButton->setObjectName(QString::fromUtf8("stopButton")); sizePol.setHeightForWidth(stopButton->sizePolicy().hasHeightForWidth()); stopButton->setSizePolicy(sizePol); stopButton->setText("Stop"); connect(stopButton,SIGNAL(clicked()), this, SLOT(timerStop())); splitter2->addWidget(stopButton); startButton = new QPushButton(splitter2); startButton->setObjectName(QString::fromUtf8("startButton")); sizePol.setHeightForWidth(startButton->sizePolicy().hasHeightForWidth()); startButton->setSizePolicy(sizePol); startButton->setText("Run"); connect(startButton,SIGNAL(clicked()), this, SLOT(timerRun())); splitter2->addWidget(startButton); vboxLayout0->addWidget(splitter2); tabWidget->addTab(tab_0, QApplication::translate("MainWindow", "PMS Panel", 0, QApplication::UnicodeUTF8)); menubar = new QMenuBar(this); menubar->setObjectName(QString::fromUtf8("menubar")); menubar->setGeometry(QRect(0, 0, 1280, 30)); menu_File = new QMenu(menubar); menu_File->setObjectName(QString::fromUtf8("menu_File")); menu_Util = new QMenu(menubar); menu_Util->setObjectName(QString::fromUtf8("menu_Util")); menu_Help = new QMenu(menubar); menu_Help->setObjectName(QString::fromUtf8("menu_Help")); setMenuBar(menubar); QLabel *slabel1 = new QLabel("Set your mouse on the dynamic value to read PVNAME."); slabel1->setAlignment(Qt::AlignHCenter); slabel1->setMinimumSize(slabel1->sizeHint()); slabel1->setFrameStyle(QFrame::Panel | QFrame::Plain); QFrame *sframe = new QFrame(); QVBoxLayout *svlayout = new QVBoxLayout(sframe); svlayout->setSpacing(1); svlayout->setMargin(2); statusBar()->addWidget(sframe,1); toolBar = new QToolBar(this); toolBar->setObjectName(QString::fromUtf8("toolBar")); QPalette palette; QBrush brush(QColor(108, 147, 255, 100)); brush.setStyle(Qt::SolidPattern); palette.setBrush(QPalette::Active, QPalette::Base, brush); palette.setBrush(QPalette::Active, QPalette::AlternateBase, brush); QBrush brush1(QColor(44, 51, 91, 100)); brush1.setStyle(Qt::SolidPattern); palette.setBrush(QPalette::Active, QPalette::Window, brush1); QBrush brush2(QColor(108, 147, 255, 100)); brush2.setStyle(Qt::SolidPattern); palette.setBrush(QPalette::Inactive, QPalette::Base, brush2); QBrush brush3(QColor(44, 51, 91, 100)); brush3.setStyle(Qt::SolidPattern); palette.setBrush(QPalette::Inactive, QPalette::Window, brush3); QBrush brush4(QColor(44, 51, 91, 100)); brush4.setStyle(Qt::SolidPattern); palette.setBrush(QPalette::Disabled, QPalette::Base, brush4); QBrush brush5(QColor(44, 51, 91, 100)); brush5.setStyle(Qt::SolidPattern); palette.setBrush(QPalette::Disabled, QPalette::Window, brush5); toolBar->setPalette(palette); toolBar->setOrientation(Qt::Horizontal); addToolBar(static_cast<Qt::ToolBarArea>(4), toolBar); menubar->addAction(menu_File->menuAction()); menubar->addAction(menu_Util->menuAction()); menubar->addSeparator(); menubar->addAction(menu_Help->menuAction()); menu_File->addAction(action_Exit); QSize size(1280, 1024); size = size.expandedTo(minimumSizeHint()); resize(size); tabWidget->setCurrentIndex(0); QMetaObject::connectSlotsByName(this); msgframe = new QFrame(centralwidget); msgframe->setObjectName(QString::fromUtf8("msgframe")); QSizePolicy sizePolicy4(static_cast<QSizePolicy::Policy>(5), static_cast<QSizePolicy::Policy>(5)); sizePolicy4.setHorizontalStretch(0); sizePolicy4.setVerticalStretch(0); msgframe->setGeometry(QRect(19, 820, 1255, 90)); //msgframe->setSizePolicy(sizePolicy4); //msgframe->setGeometry(QRect(18, 880, 1254, 70)); //msgframe->setMinimumSize(QSize(1164, 90)); //msgframe->setFrameShape(QFrame::StyledPanel); //msgframe->setFrameShadow(QFrame::Raised); setCentralWidget(centralwidget); QObject::connect(tabWidget, SIGNAL(currentChanged(int)), SLOT(setDefaultIndex(int))); // Set Object Text. setWindowTitle(QApplication::translate("MainWindow", "PMS (Plant Monitoring System)", 0, QApplication::UnicodeUTF8)); action_Exit->setText(QApplication::translate("MainWindow", "e&Xit", 0, QApplication::UnicodeUTF8)); tabWidget->setTabText(tabWidget->indexOf(tab_0), QApplication::translate("MainWindow", "PMS Data Retrieval", 0, QApplication::UnicodeUTF8)); menu_File->setTitle(QApplication::translate("MainWindow", "&File", 0, QApplication::UnicodeUTF8)); menu_Util->setTitle(QApplication::translate("MainWindow", "&Util", 0, QApplication::UnicodeUTF8)); menu_Help->setTitle(QApplication::translate("MainWindow", "&Help", 0, QApplication::UnicodeUTF8)); } // makeUI
void DesktopWindow::setForeground(const QColor& color) { QPalette p = listView_->palette(); p.setBrush(QPalette::Text, color); listView_->setPalette(p); fgColor_ = color; }
Color RenderThemeQt::platformInactiveSelectionForegroundColor() const { QPalette pal = QApplication::palette(); return pal.brush(QPalette::Inactive, QPalette::HighlightedText).color(); }
void QgsComposerLabel::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget ) { Q_UNUSED( itemStyle ); Q_UNUSED( pWidget ); if ( !painter ) { return; } if ( !shouldDrawItem() ) { return; } drawBackground( painter ); painter->save(); //antialiasing on painter->setRenderHint( QPainter::Antialiasing, true ); double penWidth = hasFrame() ? ( pen().widthF() / 2.0 ) : 0; double xPenAdjust = mMarginX < 0 ? -penWidth : penWidth; double yPenAdjust = mMarginY < 0 ? -penWidth : penWidth; QRectF painterRect( xPenAdjust + mMarginX, yPenAdjust + mMarginY, rect().width() - 2 * xPenAdjust - 2 * mMarginX, rect().height() - 2 * yPenAdjust - 2 * mMarginY ); QString textToDraw = displayText(); if ( mHtmlState ) { painter->scale( 1.0 / mHtmlUnitsToMM / 10.0, 1.0 / mHtmlUnitsToMM / 10.0 ); QWebPage *webPage = new QWebPage(); webPage->setNetworkAccessManager( QgsNetworkAccessManager::instance() ); //Setup event loop and timeout for rendering html QEventLoop loop; QTimer timeoutTimer; timeoutTimer.setSingleShot( true ); //This makes the background transparent. Found on http://blog.qt.digia.com/blog/2009/06/30/transparent-qwebview-or-qwebpage/ QPalette palette = webPage->palette(); palette.setBrush( QPalette::Base, Qt::transparent ); webPage->setPalette( palette ); //webPage->setAttribute(Qt::WA_OpaquePaintEvent, false); //this does not compile, why ? webPage->setViewportSize( QSize( painterRect.width() * mHtmlUnitsToMM * 10.0, painterRect.height() * mHtmlUnitsToMM * 10.0 ) ); webPage->mainFrame()->setZoomFactor( 10.0 ); webPage->mainFrame()->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff ); webPage->mainFrame()->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAlwaysOff ); // QGIS segfaults when rendering web page while in composer if html // contains images. So if we are not printing the composition, then // disable image loading if ( mComposition->plotStyle() != QgsComposition::Print && mComposition->plotStyle() != QgsComposition::Postscript ) { webPage->settings()->setAttribute( QWebSettings::AutoLoadImages, false ); } //Connect timeout and webpage loadFinished signals to loop connect( &timeoutTimer, SIGNAL( timeout() ), &loop, SLOT( quit() ) ); connect( webPage, SIGNAL( loadFinished( bool ) ), &loop, SLOT( quit() ) ); //mHtmlLoaded tracks whether the QWebPage has completed loading //its html contents, set it initially to false. The loadingHtmlFinished slot will //set this to true after html is loaded. mHtmlLoaded = false; connect( webPage, SIGNAL( loadFinished( bool ) ), SLOT( loadingHtmlFinished( bool ) ) ); webPage->mainFrame()->setHtml( textToDraw ); //For very basic html labels with no external assets, the html load will already be //complete before we even get a chance to start the QEventLoop. Make sure we check //this before starting the loop if ( !mHtmlLoaded ) { // Start a 20 second timeout in case html loading will never complete timeoutTimer.start( 20000 ); // Pause until html is loaded loop.exec(); } webPage->mainFrame()->render( painter );//DELETE WEBPAGE ? } else {
rightmanager::rightmanager(QWidget *parent) : QWidget(parent) { clsBtn = new QPushButton; QPixmap mypixmap; mypixmap.load(":/CLSBTN"); clsBtn->setIconSize(QSize(mypixmap.width(),mypixmap.height())); clsBtn->setIcon(mypixmap); clsBtn->setStyleSheet("border:0px;background-color:rgb(41, 48, 62)"); connect(clsBtn,SIGNAL(clicked()),this,SLOT(clickclsBtn())); minBtn = new QPushButton; QPixmap mypixmap2; mypixmap2.load(":/MINBTN"); minBtn->setIcon(mypixmap2); minBtn->setIconSize(QSize(mypixmap2.width(),mypixmap2.height())); minBtn->setStyleSheet("border:0px;background-color:rgb(41, 48, 62)"); connect(minBtn,SIGNAL(clicked()),this,SLOT(clickminBtn())); QLabel *rightlabel = new QLabel; rightlabel->setFixedSize(50,250); rightlabel->setStyleSheet("background-color:#29303e"); tipBtn = new QPushButton; QPixmap mypixmap4; mypixmap4.load(":/tipico"); tipBtn->setIcon(mypixmap4); tipBtn->setIconSize(QSize(50,50)); tipBtn->setStyleSheet("border-style:hidden;"); connect(tipBtn,SIGNAL(clicked()),this,SLOT(clicktipBtn())); QLabel *firelabel = new QLabel; firelabel->setPixmap(QPixmap(":/fireico")); // firelabel->setStyleSheet(""); fireBtn = new QPushButton; fireBtn->setText("开启"); QPalette fireBtnPal; fireBtnPal.setColor(QPalette::ButtonText,QColor(255,255,255)); fireBtn->setPalette(fireBtnPal); /* mypixmap4.load("./FIREBTN"); fireBtn->setIcon(mypixmap4); fireBtn->setIconSize(QSize(50,50));*/ fireBtn->setStyleSheet("border:0px;background-color:#29303e;"); connect(fireBtn,SIGNAL(clicked()),this,SLOT(clickfireBtn())); flowBtn = new QPushButton; QPixmap mypixmap3; mypixmap3.load(":/FLOWBTN"); flowBtn->setIcon(mypixmap3); flowBtn->setIconSize(QSize(50,50)); flowBtn->setStyleSheet("border-style:hidden;"); connect(flowBtn,SIGNAL(clicked()),this,SLOT(clickflowBtn())); QLabel *rightlabel2 = new QLabel; rightlabel2->setFixedSize(50,20); rightlabel2->setStyleSheet("background-color:#29303e"); QLabel *rightlabel3 = new QLabel; rightlabel3->setFixedSize(50,30); rightlabel3->setStyleSheet("background-color:#29303e"); vlayout = new QVBoxLayout(this); vlayout->addWidget(clsBtn); vlayout->addWidget(minBtn); //vlayout->addStretch(0); vlayout->addWidget(rightlabel); vlayout->addWidget(tipBtn); vlayout->addWidget(flowBtn); vlayout->addWidget(firelabel); vlayout->addWidget(fireBtn); //vlayout->addStretch(0); vlayout->addWidget(rightlabel2); vlayout->addWidget(rightlabel3); vlayout->setContentsMargins(0,0,0,0); vlayout->setSpacing(0); this->setLayout(vlayout); this->setFixedSize(50,550); }
void DColorButton::setPalette ( const QPalette & pal) { m_color = pal.button().color(); }
void AppearanceSettingsPage::Load() { QSettings s; s.beginGroup(Appearance::kSettingsGroup); QPalette p = QApplication::palette(); // Keep in mind originals colors, in case the user clicks on Cancel, to be // able to restore colors original_use_a_custom_color_set_ = s.value(Appearance::kUseCustomColorSet, false).toBool(); original_foreground_color_ = s.value(Appearance::kForegroundColor, p.color(QPalette::WindowText)).value<QColor>(); current_foreground_color_ = original_foreground_color_; original_background_color_ = s.value(Appearance::kBackgroundColor, p.color(QPalette::Window)).value<QColor>(); current_background_color_ = original_background_color_; InitColorSelectorsColors(); s.endGroup(); // Playlist settings s.beginGroup(Playlist::kSettingsGroup); playlist_view_background_image_type_ = static_cast<PlaylistView::BackgroundImageType>( s.value(PlaylistView::kSettingBackgroundImageType).toInt()); playlist_view_background_image_filename_ = s.value(PlaylistView::kSettingBackgroundImageFilename).toString(); ui_->use_system_color_set->setChecked(!original_use_a_custom_color_set_); ui_->use_a_custom_color_set->setChecked(original_use_a_custom_color_set_); switch (playlist_view_background_image_type_) { case PlaylistView::None: ui_->use_no_background->setChecked(true); DisableBlurSlider(true); break; case PlaylistView::AlbumCover: ui_->use_album_cover_background->setChecked(true); break; case PlaylistView::Custom: ui_->use_custom_background_image->setChecked(true); break; case PlaylistView::Default: default: ui_->use_default_background->setChecked(true); DisableBlurSlider(true); } ui_->background_image_filename->setText(playlist_view_background_image_filename_); s.endGroup(); // Moodbar settings s.beginGroup("Moodbar"); ui_->moodbar_show->setChecked(s.value("show", true).toBool()); ui_->moodbar_style->setCurrentIndex(s.value("style", 0).toInt()); ui_->moodbar_calculate->setChecked(!s.value("calculate", true).toBool()); ui_->moodbar_save->setChecked(s.value("save_alongside_originals", false).toBool()); s.endGroup(); InitMoodbarPreviews(); }
SongEditorPanel::SongEditorPanel(QWidget *pParent) : QWidget( pParent ) , Object( __class_name ) , m_actionMode( DRAW_ACTION ) { m_nInitialWidth = 600; m_nInitialHeight = 250; Preferences *pPref = Preferences::get_instance(); Hydrogen* pEngine = Hydrogen::get_instance(); Song* pSong = pEngine->getSong(); setWindowTitle( trUtf8( "Song Editor" ) ); // background PixmapWidget *pBackPanel = new PixmapWidget( NULL ); pBackPanel->setFixedSize( 196, 49 ); pBackPanel->setPixmap( "/songEditor/bg_topPanel.png" ); // time line toggle button m_pTimeLineToggleBtn = new ToggleButton( pBackPanel, "/songEditor/btn_bpm_on.png", "/songEditor/btn_bpm_off.png", "/songEditor/btn_bpm_over.png", QSize( 54, 13 ) ); m_pTimeLineToggleBtn->move( 133, 6 ); m_pTimeLineToggleBtn->setToolTip( trUtf8( "Enable time line edit") ); connect( m_pTimeLineToggleBtn, SIGNAL( clicked( Button* ) ), this, SLOT( timeLineBtnPressed(Button* ) ) ); m_pTimeLineToggleBtn->setPressed( pPref->getUseTimelineBpm() ); // clear sequence button m_pClearPatternSeqBtn = new Button( pBackPanel, "/songEditor/btn_clear_on.png", "/songEditor/btn_clear_off.png", "/songEditor/btn_clear_over.png", QSize(53,13) ); m_pClearPatternSeqBtn->move( 6, 5 + 25 ); m_pClearPatternSeqBtn->setToolTip( trUtf8("Clear pattern sequence") ); connect( m_pClearPatternSeqBtn, SIGNAL( clicked( Button* ) ), this, SLOT( clearSequence(Button*) ) ); // new pattern button Button *newPatBtn = new Button( pBackPanel, "/songEditor/btn_new_on.png", "/songEditor/btn_new_off.png", "/songEditor/btn_new_over.png", QSize(19, 13) ); newPatBtn->move( 64, 5 + 25); newPatBtn->setToolTip( trUtf8("Create new pattern") ); connect( newPatBtn, SIGNAL( clicked( Button* ) ), this, SLOT( newPatBtnClicked( Button* ) ) ); // down button m_pDownBtn = new Button( pBackPanel, "/songEditor/btn_down_on.png", "/songEditor/btn_down_off.png", "/songEditor/btn_down_over.png", QSize(18,13) ); m_pDownBtn->move( 89, 5 + 25); m_pDownBtn->setToolTip( trUtf8("Move the selected pattern down") ); connect( m_pDownBtn, SIGNAL( clicked( Button* ) ), this, SLOT( downBtnClicked( Button* ) ) ); // up button m_pUpBtn = new Button( pBackPanel, "/songEditor/btn_up_on.png", "/songEditor/btn_up_off.png", "/songEditor/btn_up_over.png", QSize(18,13) ); m_pUpBtn->move( 106, 5 + 25 ); m_pUpBtn->setToolTip( trUtf8("Move the selected pattern up") ); connect( m_pUpBtn, SIGNAL( clicked( Button* ) ), this, SLOT( upBtnClicked( Button* ) ) ); // select toggle button m_pPointerActionBtn = new ToggleButton( pBackPanel, "/songEditor/btn_select_on.png", "/songEditor/btn_select_off.png", "/songEditor/btn_select_over.png", QSize( 18, 13 ) ); m_pPointerActionBtn->move( 128, 5 + 25 ); m_pPointerActionBtn->setToolTip( trUtf8( "Select mode" ) ); connect( m_pPointerActionBtn, SIGNAL( clicked( Button* ) ), this, SLOT( pointerActionBtnPressed(Button*) ) ); // draw toggle button m_pDrawActionBtn = new ToggleButton( pBackPanel, "/songEditor/btn_draw_on.png", "/songEditor/btn_draw_off.png", "/songEditor/btn_draw_over.png", QSize( 18, 13 ) ); m_pDrawActionBtn->move( 147, 5 + 25 ); m_pDrawActionBtn->setToolTip( trUtf8( "Draw mode") ); connect( m_pDrawActionBtn, SIGNAL( clicked( Button* ) ), this, SLOT( drawActionBtnPressed(Button* ) ) ); m_pDrawActionBtn->setPressed( true ); m_pModeActionBtn = new ToggleButton( pBackPanel, "/songEditor/btn_mode_on.png", "/songEditor/btn_mode_off.png", "/songEditor/btn_mode_over.png", QSize( 18, 13 ) ); m_pModeActionBtn->move( 169, 5 + 25 ); m_pModeActionBtn->setToolTip( trUtf8( "stacked mode") ); m_pModeActionBtn->setPressed( pPref->patternModePlaysSelected() ); connect( m_pModeActionBtn, SIGNAL( clicked( Button* ) ), this, SLOT( modeActionBtnPressed() ) ); // ZOOM m_pHScrollBar = new QScrollBar( Qt::Horizontal,NULL ); connect( m_pHScrollBar, SIGNAL(valueChanged(int)), this, SLOT( syncToExternalScrollBar() ) ); // zoom-in btn Button* pZoomInBtn = new Button( NULL, "/songEditor/btn_new_on.png", "/songEditor/btn_new_off.png", "/songEditor/btn_new_over.png", QSize( 19, 13 ) ); connect( pZoomInBtn, SIGNAL( clicked( Button* ) ), this, SLOT( zoomOutBtnPressed(Button* ) ) ); // zoom-out btn Button* pZoomOutBtn = new Button( NULL, "/songEditor/btn_minus_on.png", "/songEditor/btn_minus_off.png", "/songEditor/btn_minus_over.png", QSize( 19, 13 ) ); connect( pZoomOutBtn, SIGNAL( clicked( Button* ) ), this, SLOT( zoomInBtnPressed(Button* ) ) ); // view playback track toggle button m_pViewPlaybackToggleBtn = new ToggleButton( NULL, "/songEditor/btn_viewPL_on.png", "/songEditor/btn_viewPL_off.png", "/songEditor/btn_viewPL_over.png", QSize( 19, 13 ) ); m_pViewPlaybackToggleBtn->setToolTip( trUtf8( "View playback track") ); connect( m_pViewPlaybackToggleBtn, SIGNAL( clicked( Button* ) ), this, SLOT( viewPlaybackTrackBtnPressed(Button* ) ) ); m_pViewPlaybackToggleBtn->setPressed( false ); // Playback Fader m_pPlaybackTrackFader = new VerticalFader( pBackPanel, false, false ); m_pPlaybackTrackFader->move( 6, 2 ); m_pPlaybackTrackFader->setMinValue( 0.0 ); m_pPlaybackTrackFader->setMaxValue( 1.5 ); m_pPlaybackTrackFader->setValue( pSong->get_playback_track_volume() ); m_pPlaybackTrackFader->hide(); connect( m_pPlaybackTrackFader, SIGNAL( valueChanged(Fader*) ), this, SLOT( faderChanged(Fader*) ) ); // mute playback track toggle button m_pMutePlaybackToggleBtn = new ToggleButton( pBackPanel, "/mixerPanel/master_mute_on.png", "/mixerPanel/master_mute_off.png", "/mixerPanel/master_mute_over.png", QSize( 42, 13 ) ); m_pMutePlaybackToggleBtn->setToolTip( trUtf8( "Mute playback track") ); m_pMutePlaybackToggleBtn->move( 151, 6 ); m_pMutePlaybackToggleBtn->hide(); connect( m_pMutePlaybackToggleBtn, SIGNAL( clicked( Button* ) ), this, SLOT( mutePlaybackTrackBtnPressed(Button* ) ) ); m_pMutePlaybackToggleBtn->setPressed( !pSong->get_playback_track_enabled() ); // edit playback track toggle button m_pEditPlaybackBtn = new Button( pBackPanel, "/mixerPanel/edit_on.png", "/mixerPanel/edit_off.png", "/mixerPanel/edit_over.png", QSize( 42, 13 ) ); m_pEditPlaybackBtn->setToolTip( trUtf8( "Choose playback track") ); m_pEditPlaybackBtn->move( 124, 6 ); m_pEditPlaybackBtn->hide(); connect( m_pEditPlaybackBtn, SIGNAL( clicked( Button* ) ), this, SLOT( editPlaybackTrackBtnPressed(Button* ) ) ); m_pEditPlaybackBtn->setPressed( false ); // timeline view toggle button m_pViewTimeLineToggleBtn = new ToggleButton( NULL, "/songEditor/btn_viewTL_on.png", "/songEditor/btn_viewTL_off.png", "/songEditor/btn_viewTL_over.png", QSize( 19, 13 ) ); m_pViewTimeLineToggleBtn->setToolTip( trUtf8( "View timeline") ); connect( m_pViewTimeLineToggleBtn, SIGNAL( clicked( Button* ) ), this, SLOT( viewTimeLineBtnPressed(Button* ) ) ); m_pViewTimeLineToggleBtn->setPressed( true ); QHBoxLayout *pHZoomLayout = new QHBoxLayout(); pHZoomLayout->setSpacing( 0 ); pHZoomLayout->setMargin( 0 ); pHZoomLayout->addWidget( m_pViewPlaybackToggleBtn ); pHZoomLayout->addWidget( m_pViewTimeLineToggleBtn ); pHZoomLayout->addWidget( m_pHScrollBar ); pHZoomLayout->addWidget( pZoomInBtn ); pHZoomLayout->addWidget( pZoomOutBtn ); QWidget *pHScrollbarPanel = new QWidget(); pHScrollbarPanel->setLayout( pHZoomLayout ); //~ ZOOM // PATTERN LIST m_pPatternListScrollView = new QScrollArea( NULL ); m_pPatternListScrollView->setFrameShape( QFrame::NoFrame ); m_pPatternListScrollView->setFixedWidth( m_nPatternListWidth ); m_pPatternListScrollView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); m_pPatternListScrollView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); connect( m_pPatternListScrollView->verticalScrollBar(), SIGNAL( valueChanged(int) ), this, SLOT( on_patternListScroll() ) ); m_pPatternList = new SongEditorPatternList( m_pPatternListScrollView->viewport() ); m_pPatternListScrollView->setWidget( m_pPatternList ); // EDITOR m_pEditorScrollView = new QScrollArea( NULL ); m_pEditorScrollView->setFrameShape( QFrame::NoFrame ); m_pEditorScrollView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); m_pEditorScrollView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); m_pSongEditor = new SongEditor( m_pEditorScrollView->viewport() ); m_pEditorScrollView->setWidget( m_pSongEditor ); connect( m_pEditorScrollView->horizontalScrollBar(), SIGNAL( valueChanged(int) ), this, SLOT( on_EditorScroll() ) ); connect( m_pEditorScrollView->verticalScrollBar(), SIGNAL( valueChanged(int) ), this, SLOT( on_EditorScroll() ) ); // POSITION RULER m_pPositionRulerScrollView = new QScrollArea( NULL ); m_pPositionRulerScrollView->setFrameShape( QFrame::NoFrame ); m_pPositionRulerScrollView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); m_pPositionRulerScrollView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); m_pPositionRulerScrollView->setFixedHeight( 50 ); m_pWidgetStack = new QStackedWidget( m_pPositionRulerScrollView ); m_pPositionRuler = new SongEditorPositionRuler( NULL ); m_pWaveDisplay = new WaveDisplay( m_pPositionRulerScrollView->viewport() ); InstrumentComponent *pCompo = AudioEngine::get_instance()->get_sampler()->__preview_instrument->get_components()->front(); assert(pCompo); m_pWaveDisplay->updateDisplay( pCompo->get_layer(0) ); m_pWidgetStack->addWidget( m_pPositionRuler ); m_pWidgetStack->addWidget( m_pWaveDisplay ); m_pPositionRulerScrollView->setWidgetResizable(true); m_pPositionRulerScrollView->setWidget( m_pWidgetStack ); m_pAutomationPathScrollView = new QScrollArea( NULL ); m_pAutomationPathScrollView->setFrameShape( QFrame::NoFrame ); m_pAutomationPathScrollView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); m_pAutomationPathScrollView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); m_pAutomationPathView = new AutomationPathView( m_pAutomationPathScrollView->viewport() ); m_pAutomationPathScrollView->setWidget( m_pAutomationPathView ); m_pAutomationPathScrollView->setFixedHeight( 64 ); connect( m_pAutomationPathView, SIGNAL( valueChanged() ), this, SLOT( automationPathChanged() ) ); connect( m_pAutomationPathView, SIGNAL( pointAdded(float, float) ), this, SLOT( automationPathPointAdded(float,float) ) ); connect( m_pAutomationPathView, SIGNAL( pointRemoved(float, float) ), this, SLOT( automationPathPointRemoved(float,float) ) ); connect( m_pAutomationPathView, SIGNAL( pointMoved(float, float, float, float) ), this, SLOT( automationPathPointMoved(float,float, float, float) ) ); m_pAutomationCombo = new LCDCombo( NULL, 22 ); m_pAutomationCombo->setToolTip( trUtf8("Adjust parameter values in time") ); m_pAutomationCombo->addItem( trUtf8("Velocity") ); m_pAutomationCombo->set_text( trUtf8("Velocity") ); m_pAutomationCombo->update(); m_pVScrollBar = new QScrollBar( Qt::Vertical, NULL ); connect( m_pVScrollBar, SIGNAL(valueChanged(int)), this, SLOT( syncToExternalScrollBar() ) ); // ok...let's build the layout QGridLayout *pGridLayout = new QGridLayout(); pGridLayout->setSpacing( 0 ); pGridLayout->setMargin( 0 ); pGridLayout->addWidget( pBackPanel, 0, 0 ); pGridLayout->addWidget( m_pPositionRulerScrollView, 0, 1 ); pGridLayout->addWidget( m_pPatternListScrollView, 1, 0 ); pGridLayout->addWidget( m_pEditorScrollView, 1, 1 ); pGridLayout->addWidget( m_pVScrollBar, 1, 2, 2, 1 ); pGridLayout->addWidget( m_pAutomationPathScrollView, 2, 1); pGridLayout->addWidget( m_pAutomationCombo, 2, 0, Qt::AlignTop | Qt::AlignRight ); pGridLayout->addWidget( pHScrollbarPanel, 3, 1 ); if( !pPref->getShowAutomationArea() ){ m_pAutomationPathScrollView->hide(); m_pAutomationCombo->hide(); } this->setLayout( pGridLayout ); QPalette defaultPalette; defaultPalette.setColor( QPalette::Background, QColor( 58, 62, 72 ) ); this->setPalette( defaultPalette ); show(); updateAll(); HydrogenApp::get_instance()->addEventListener( this ); m_pTimer = new QTimer(this); connect(m_pTimer, SIGNAL(timeout()), this, SLOT( updatePlayHeadPosition() ) ); connect(m_pTimer, SIGNAL(timeout()), this, SLOT( updatePlaybackFaderPeaks() ) ); m_pTimer->start(100); }
void ModelValidationWidget::updateValidation(ValidationInfo val_info) { QTreeWidgetItem *item=new QTreeWidgetItem, *item1=nullptr, *item2=nullptr; QLabel *label=new QLabel, *label1=nullptr, *label2=nullptr; vector<BaseObject *> refs; BaseTable *table=nullptr; TableObject *tab_obj=nullptr; QString ref_name; if(val_info.getValidationType()==ValidationInfo::BROKEN_REFERENCE) label->setText(trUtf8("The object <strong>%1</strong> <em>(%2)</em> [id: %3] is being referenced by <strong>%4</strong> object(s) before its creation.") .arg(Utf8String::create(val_info.getObject()->getName(true).remove("\""))) .arg(val_info.getObject()->getTypeName()) .arg(val_info.getObject()->getObjectId()) .arg(val_info.getReferences().size())); else if(val_info.getValidationType()==ValidationInfo::SP_OBJ_BROKEN_REFERENCE) { QString str_aux; if(TableObject::isTableObject(val_info.getObject()->getObjectType())) { TableObject *tab_obj=dynamic_cast<TableObject *>(val_info.getObject()); str_aux=QString(" owned by table <strong>%1</strong> ").arg(tab_obj->getParentTable()->getName(true).remove("\"")); } label->setText(trUtf8("The object <strong>%1</strong> <em>(%2)</em> [id: %3]%4 is referencing columns created by <strong>%5</strong> relationship(s) but is created before them.") .arg(Utf8String::create(val_info.getObject()->getName(true).remove("\""))) .arg(val_info.getObject()->getTypeName()) .arg(val_info.getObject()->getObjectId()) .arg(str_aux) .arg(val_info.getReferences().size())); } else if(val_info.getValidationType()==ValidationInfo::NO_UNIQUE_NAME) { tab_obj=dynamic_cast<TableObject *>(val_info.getObject()); if(tab_obj) { table=tab_obj->getParentTable(); ref_name=table->getName(true).remove("\"") + "." + val_info.getObject()->getName(true).remove("\""); } else ref_name=val_info.getObject()->getName(true).remove("\""); label->setText(trUtf8("The object <strong>%1</strong> <em>(%2)</em> has a name that conflicts with <strong>%3</strong> object's name(s).") .arg(Utf8String::create(ref_name)) .arg(val_info.getObject()->getTypeName()) .arg(val_info.getReferences().size())); } else if(val_info.getValidationType()==ValidationInfo::SQL_VALIDATION_ERR) label->setText(trUtf8("SQL validation failed due to error(s) below. <strong>NOTE:</strong><em> These errors does not invalidates the model thus you can save it without any problem.</em>")); else label->setText(val_info.getErrors().at(0)); if(val_info.getValidationType()==ValidationInfo::SQL_VALIDATION_ERR || val_info.getValidationType()==ValidationInfo::VALIDATION_ABORTED) { QStringList errors=val_info.getErrors(); QFont fnt; item->setIcon(0, QPixmap(QString(":/icones/icones/msgbox_alerta.png"))); validation_prog_pb->setValue(validation_prog_pb->maximum()); reenableValidation(); if(val_info.getValidationType()==ValidationInfo::SQL_VALIDATION_ERR) { //Adding all the sql errors into the output pane while(!errors.isEmpty()) { item1=new QTreeWidgetItem(item); label1=new QLabel; label1->setText(errors.back()); fnt=label1->font(); fnt.setPointSizeF(8.0f); label1->setFont(fnt); output_trw->setItemWidget(item1, 0, label1); errors.pop_back(); } } } else { item->setIcon(0, QPixmap(QString(":/icones/icones/msgbox_erro.png"))); //Listing the referrer object on output pane refs=val_info.getReferences(); while(!refs.empty()) { item1=new QTreeWidgetItem(item); label1=new QLabel; item1->setIcon(0, QPixmap(QString(":/icones/icones/") + refs.back()->getSchemaName() + QString(".png"))); if(val_info.getValidationType()==ValidationInfo::NO_UNIQUE_NAME) { TableObject *tab_obj=dynamic_cast<TableObject *>(refs.back()); ref_name=refs.back()->getName(true); //If the referrer object is a table object, concatenates the parent table name if(tab_obj) { ref_name=dynamic_cast<TableObject *>(refs.back())->getParentTable()->getName(true) + "." + ref_name; if(tab_obj->isAddedByRelationship()) { QPalette pal; item2=new QTreeWidgetItem(item1); label2=new QLabel; pal.setColor(QPalette::Text, QColor(255,0,0)); label2->setPalette(pal); label2->setText(trUtf8("<em>The above object was created by a relationship. Change the name pattern on it's generator relationship. Fix will not be applied!</em>")); output_trw->setItemWidget(item2, 0, label2); item1->setExpanded(true); } } label1->setText(trUtf8("Conflicting object: <strong>%1</strong> <em>(%2)</em>.") .arg(Utf8String::create(ref_name).remove("\"")) .arg(Utf8String::create(refs.back()->getTypeName()))); } else { if(val_info.getValidationType()==ValidationInfo::SP_OBJ_BROKEN_REFERENCE) label1->setText(trUtf8("Relationship: <strong>%1</strong> [id: %2].") .arg(Utf8String::create(refs.back()->getName(true))) .arg(refs.back()->getObjectId())); else { label1->setText(trUtf8("Referrer object: <strong>%1</strong> <em>(%2)</em> [id: %3].") .arg(Utf8String::create(refs.back()->getName(true))) .arg(Utf8String::create(refs.back()->getTypeName())) .arg(refs.back()->getObjectId())); } } output_trw->setItemWidget(item1, 0, label1); refs.pop_back(); } } output_trw->addTopLevelItem(item); output_trw->setItemWidget(item, 0, label); item->setExpanded(false); //Stores the validatin on the current tree item item->setData(0, Qt::UserRole, QVariant::fromValue<ValidationInfo>(val_info)); warn_count_lbl->setText(QString("%1").arg(validation_helper.getWarningCount())); error_count_lbl->setText(QString("%1").arg(validation_helper.getErrorCount())); output_trw->setItemHidden(item, false); output_trw->scrollToBottom(); }
bitInvaderView::bitInvaderView( Instrument * _instrument, QWidget * _parent ) : InstrumentView( _instrument, _parent ) { setAutoFillBackground( true ); QPalette pal; pal.setBrush( backgroundRole(), PLUGIN_NAME::getIconPixmap( "artwork" ) ); setPalette( pal ); m_sampleLengthKnob = new Knob( knobDark_28, this ); m_sampleLengthKnob->move( 6, 201 ); m_sampleLengthKnob->setHintText( tr( "Sample Length" ), "" ); m_graph = new Graph( this, Graph::NearestStyle, 204, 134 ); m_graph->move(23,59); // 55,120 - 2px border m_graph->setAutoFillBackground( true ); m_graph->setGraphColor( QColor( 255, 255, 255 ) ); ToolTip::add( m_graph, tr ( "Draw your own waveform here " "by dragging your mouse on this graph." )); pal = QPalette(); pal.setBrush( backgroundRole(), PLUGIN_NAME::getIconPixmap("wavegraph") ); m_graph->setPalette( pal ); m_sinWaveBtn = new PixmapButton( this, tr( "Sine wave" ) ); m_sinWaveBtn->move( 131, 205 ); m_sinWaveBtn->setActiveGraphic( embed::getIconPixmap( "sin_wave_active" ) ); m_sinWaveBtn->setInactiveGraphic( embed::getIconPixmap( "sin_wave_inactive" ) ); ToolTip::add( m_sinWaveBtn, tr( "Click for a sine-wave." ) ); m_triangleWaveBtn = new PixmapButton( this, tr( "Triangle wave" ) ); m_triangleWaveBtn->move( 131 + 14, 205 ); m_triangleWaveBtn->setActiveGraphic( embed::getIconPixmap( "triangle_wave_active" ) ); m_triangleWaveBtn->setInactiveGraphic( embed::getIconPixmap( "triangle_wave_inactive" ) ); ToolTip::add( m_triangleWaveBtn, tr( "Click here for a triangle-wave." ) ); m_sawWaveBtn = new PixmapButton( this, tr( "Saw wave" ) ); m_sawWaveBtn->move( 131 + 14*2, 205 ); m_sawWaveBtn->setActiveGraphic( embed::getIconPixmap( "saw_wave_active" ) ); m_sawWaveBtn->setInactiveGraphic( embed::getIconPixmap( "saw_wave_inactive" ) ); ToolTip::add( m_sawWaveBtn, tr( "Click here for a saw-wave." ) ); m_sqrWaveBtn = new PixmapButton( this, tr( "Square wave" ) ); m_sqrWaveBtn->move( 131 + 14*3, 205 ); m_sqrWaveBtn->setActiveGraphic( embed::getIconPixmap( "square_wave_active" ) ); m_sqrWaveBtn->setInactiveGraphic( embed::getIconPixmap( "square_wave_inactive" ) ); ToolTip::add( m_sqrWaveBtn, tr( "Click here for a square-wave." ) ); m_whiteNoiseWaveBtn = new PixmapButton( this, tr( "White noise wave" ) ); m_whiteNoiseWaveBtn->move( 131 + 14*4, 205 ); m_whiteNoiseWaveBtn->setActiveGraphic( embed::getIconPixmap( "white_noise_wave_active" ) ); m_whiteNoiseWaveBtn->setInactiveGraphic( embed::getIconPixmap( "white_noise_wave_inactive" ) ); ToolTip::add( m_whiteNoiseWaveBtn, tr( "Click here for white-noise." ) ); m_usrWaveBtn = new PixmapButton( this, tr( "User defined wave" ) ); m_usrWaveBtn->move( 131 + 14*5, 205 ); m_usrWaveBtn->setActiveGraphic( embed::getIconPixmap( "usr_wave_active" ) ); m_usrWaveBtn->setInactiveGraphic( embed::getIconPixmap( "usr_wave_inactive" ) ); ToolTip::add( m_usrWaveBtn, tr( "Click here for a user-defined shape." ) ); m_smoothBtn = new PixmapButton( this, tr( "Smooth" ) ); m_smoothBtn->move( 131 + 14*6, 205 ); m_smoothBtn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "smooth_active" ) ); m_smoothBtn->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "smooth_inactive" ) ); ToolTip::add( m_smoothBtn, tr( "Click here to smooth waveform." ) ); m_interpolationToggle = new LedCheckBox( "Interpolation", this, tr( "Interpolation" ), LedCheckBox::Yellow ); m_interpolationToggle->move( 131, 221 ); m_normalizeToggle = new LedCheckBox( "Normalize", this, tr( "Normalize" ), LedCheckBox::Green ); m_normalizeToggle->move( 131, 236 ); connect( m_sinWaveBtn, SIGNAL (clicked () ), this, SLOT ( sinWaveClicked() ) ); connect( m_triangleWaveBtn, SIGNAL ( clicked () ), this, SLOT ( triangleWaveClicked() ) ); connect( m_sawWaveBtn, SIGNAL (clicked () ), this, SLOT ( sawWaveClicked() ) ); connect( m_sqrWaveBtn, SIGNAL ( clicked () ), this, SLOT ( sqrWaveClicked() ) ); connect( m_whiteNoiseWaveBtn, SIGNAL ( clicked () ), this, SLOT ( noiseWaveClicked() ) ); connect( m_usrWaveBtn, SIGNAL ( clicked () ), this, SLOT ( usrWaveClicked() ) ); connect( m_smoothBtn, SIGNAL ( clicked () ), this, SLOT ( smoothClicked() ) ); connect( m_interpolationToggle, SIGNAL( toggled( bool ) ), this, SLOT ( interpolationToggled( bool ) ) ); connect( m_normalizeToggle, SIGNAL( toggled( bool ) ), this, SLOT ( normalizeToggled( bool ) ) ); }
void ContactWidget::init() { _ignoreSignals = false; _titleSingular = tr("Contact"); _titlePlural = tr("Contacts"); _query = "SELECT cntct.*, crmacct_name " "FROM cntct() LEFT OUTER JOIN crmacct ON (cntct_crmacct_id = crmacct_id) "; _layoutDone = false; _minimalLayout = false; _searchAcctId = -1; _list = new QPushButton(tr("..."), this); _list->setObjectName("_list"); _list->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); #ifndef Q_OS_MAC _list->setMaximumWidth(25); #else _list->setMinimumWidth(60); _list->setMinimumHeight(32); #endif _grid->removeWidget(_label); // will be reinserted _grid->removeWidget(_description); delete _description; _description = 0; _grid->setMargin(0); _grid->setSpacing(2); _nameBox = new QHBoxLayout; _nameBox->setSpacing(2); _initialsBox = new QHBoxLayout; _initialsBox->setSpacing(2); _titleBox = new QHBoxLayout; _titleBox->setSpacing(2); _change = new XLineEdit(this); _numberLit = new QLabel(tr("Number:"), this); _numberLit->setObjectName("_numberLit"); _number = new XLineEdit(this, "_number"); _change->hide(); _number->hide(); _numberLit->hide(); _nameLit = new QLabel(tr("Name:"), this); _nameLit->setObjectName("_nameLit"); _honorific = new XComboBox(this, "_honorific"); _first = new XLineEdit(this, "_first"); _middle = new XLineEdit(this, "_middle"); _middle->setFixedWidth(20); _last = new XLineEdit(this, "_last"); _suffix = new XLineEdit(this, "_suffix"); _suffix->setFixedWidth(30); _initialsLit = new QLabel(tr("Initials:"), this); _initialsLit->setObjectName("_initialsLit"); _initials = new XLineEdit(this, "_initials"); _initials->setFixedWidth(_initials->size().width() / 3); _titleLit = new QLabel(tr("Job Title:"), this); _titleLit->setObjectName("_titleLit"); _title = new XLineEdit(this, "_title"); _mapper = new XDataWidgetMapper(this); //_nameBox->addWidget(_nameLit, 0); _nameBox->addWidget(_honorific, 0); _nameBox->addWidget(_first, 1); _nameBox->addWidget(_middle, 0); _nameBox->addWidget(_last, 2); _nameBox->addWidget(_suffix, 0); _nameBox->addWidget(_list, 0, Qt::AlignRight); //_initialsBox->addWidget(_initialsLit, 0); _initialsBox->addWidget(_initials, 0); _initialsBox->addStretch(0); //_titleBox->addWidget(_titleLit, 0); _titleBox->addWidget(_title, 2); _buttonBox = new QGridLayout; _crmAcct = new CRMAcctCluster(this, "_crmAcct"); _active = new QCheckBox(tr("Active"), this); _active->setObjectName("_active"); _owner = new UsernameCluster(this, "_owner"); _buttonBox->addWidget(_crmAcct, 0, 1, Qt::AlignTop); _buttonBox->addWidget(_owner, 0, 2, Qt::AlignTop); QRegExp rx("^([0-9a-z]+[-._+&])*[0-9a-z]+@([-0-9a-z]+[.])+[a-z]{2,6}$"); QValidator *validator = new QRegExpValidator(rx, this); _phoneLit = new QLabel(tr("Voice:"), this); _phoneLit->setObjectName("_phoneLit"); _phone = new XLineEdit(this, "_phone"); _phone2Lit = new QLabel(tr("Alternate:"), this); _phone2Lit->setObjectName("_phone2Lit"); _phone2 = new XLineEdit(this, "_phone2"); _faxLit = new QLabel(tr("Fax:"), this); _faxLit->setObjectName("_faxLit"); _fax = new XLineEdit(this, "_fax"); _emailLit = new QLabel(tr("E-Mail:"), this); _emailLit->setObjectName("_emailLit"); _email = new XComboBox(this, "_email"); _email->setEditable(true); _email->setValidator(validator); _email->lineEdit()->installEventFilter(this); _email->insertEditor(XComboBox::Adhoc, this, SLOT(sEditEmailList())); _webaddrLit = new QLabel(tr("Web:"), this); _webaddrLit->setObjectName("_webaddrLit"); _webaddr = new XLineEdit(this, "_webaddr"); _address = new AddressCluster(this, "_address"); //So we can manipulate just the line edit QLineEdit* emailEdit = _email->lineEdit(); #if defined Q_OS_MAC _honorific->setMinimumHeight(26); _first->setMinimumHeight(22); _middle->setMinimumHeight(22); _last->setMinimumHeight(22); _suffix->setMinimumHeight(22); _phone->setMinimumWidth(140); _crmAcct->setMinimumHeight(72); #endif QPalette p = _email->palette(); p.setColor(QPalette::Text, Qt::blue); emailEdit->setPalette(p); _webaddr->setPalette(p); QFont newFont = _email->font(); newFont.setUnderline(true); emailEdit->setFont(newFont); _webaddr->setFont(newFont); _numberLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _label->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); _nameLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _titleLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _phoneLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _phone2Lit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _faxLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _emailLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _initialsLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _webaddrLit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); _honorific->setEditable(true); _honorific->setType(XComboBox::Honorifics); _crmAcct->setLabel(tr("Account:")); _owner->setLabel(tr("Owner:")); layout(); connect(_list, SIGNAL(clicked()), this, SLOT(sEllipses())); connect(_honorific, SIGNAL(newID(int)), this, SIGNAL(changed())); connect(_first, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_middle, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_last, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_suffix, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_initials, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_crmAcct, SIGNAL(newId(int)), this, SIGNAL(changed())); connect(_title, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_phone, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_phone2, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_fax, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_email, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_webaddr, SIGNAL(textChanged(const QString&)), this, SIGNAL(changed())); connect(_address, SIGNAL(changed()), this, SIGNAL(changed())); connect(this, SIGNAL(changed()), this, SLOT(setChanged())); connect(_honorific, SIGNAL(newID(int)), this, SLOT(sCheck())); connect(_first, SIGNAL(editingFinished()), this, SLOT(sCheck())); connect(_middle, SIGNAL(editingFinished()), this, SLOT(sCheck())); connect(_last, SIGNAL(editingFinished()), this, SLOT(sCheck())); connect(_suffix, SIGNAL(editingFinished()), this, SLOT(sCheck())); connect(_initials, SIGNAL(editingFinished()), this, SLOT(sCheck())); connect(_crmAcct, SIGNAL(newId(int)), this, SLOT(sCheck())); connect(_title, SIGNAL(editingFinished()), this, SLOT(sCheck())); connect(_phone, SIGNAL(editingFinished()), this, SLOT(sCheck())); connect(_phone2, SIGNAL(editingFinished()), this, SLOT(sCheck())); connect(_fax, SIGNAL(editingFinished()), this, SLOT(sCheck())); connect(emailEdit, SIGNAL(editingFinished()), this, SLOT(sCheck())); connect(_webaddr, SIGNAL(editingFinished()), this, SLOT(sCheck())); connect(_address, SIGNAL(changed()), this, SLOT(sCheck())); connect(_webaddr, SIGNAL(doubleClicked()), this, SLOT(sLaunchWebaddr())); setListVisible(true); connect(_first, SIGNAL(editingFinished()), this, SLOT(findDuplicates())); connect(_last, SIGNAL(editingFinished()), this, SLOT(findDuplicates())); connect(_crmAcct, SIGNAL(newId(int)), this, SLOT(setSearchAcct(int))); setFocusPolicy(Qt::StrongFocus); setFocusProxy(_honorific); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); setLabel(""); _limits = 0; silentSetId(-1); setOwnerVisible(false); _mode = Edit; }
// Update whole channel info state. bool ChannelStrip::updateChannelInfo (void) { if (m_pChannel == NULL) return false; // Check for error limit/recycle... if (m_iErrorCount > QSAMPLER_ERROR_LIMIT) return true; // Update strip caption. QString sText = m_pChannel->channelName(); setWindowTitle(sText); m_ui.ChannelSetupPushButton->setText('&' + sText); // Check if we're up and connected. MainForm* pMainForm = MainForm::getInstance(); if (pMainForm->client() == NULL) return false; // Read actual channel information. m_pChannel->updateChannelInfo(); // Engine name... if (m_pChannel->engineName().isEmpty()) { m_ui.EngineNameTextLabel->setText( ' ' + Channel::noEngineName()); } else { m_ui.EngineNameTextLabel->setText( ' ' + m_pChannel->engineName()); } // Instrument name... updateInstrumentName(false); // MIDI Port/Channel... QString sMidiPortChannel = QString::number(m_pChannel->midiPort()) + " / "; if (m_pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL) sMidiPortChannel += tr("All"); else sMidiPortChannel += QString::number(m_pChannel->midiChannel() + 1); m_ui.MidiPortChannelTextLabel->setText(sMidiPortChannel); // Common palette... QPalette pal; const QColor& rgbFore = pal.color(QPalette::Foreground); // Instrument status... int iInstrumentStatus = m_pChannel->instrumentStatus(); if (iInstrumentStatus < 0) { pal.setColor(QPalette::Foreground, Qt::red); m_ui.InstrumentStatusTextLabel->setPalette(pal); m_ui.InstrumentStatusTextLabel->setText( tr("ERR%1").arg(iInstrumentStatus)); m_iErrorCount++; return false; } // All seems normal... pal.setColor(QPalette::Foreground, iInstrumentStatus < 100 ? Qt::yellow : Qt::green); m_ui.InstrumentStatusTextLabel->setPalette(pal); m_ui.InstrumentStatusTextLabel->setText( QString::number(iInstrumentStatus) + '%'); m_iErrorCount = 0; #ifdef CONFIG_MUTE_SOLO // Mute/Solo button state coloring... bool bMute = m_pChannel->channelMute(); const QColor& rgbButton = pal.color(QPalette::Button); pal.setColor(QPalette::Foreground, rgbFore); pal.setColor(QPalette::Button, bMute ? Qt::yellow : rgbButton); m_ui.ChannelMutePushButton->setPalette(pal); m_ui.ChannelMutePushButton->setDown(bMute); bool bSolo = m_pChannel->channelSolo(); pal.setColor(QPalette::Button, bSolo ? Qt::cyan : rgbButton); m_ui.ChannelSoloPushButton->setPalette(pal); m_ui.ChannelSoloPushButton->setDown(bSolo); #else m_ui.ChannelMutePushButton->setEnabled(false); m_ui.ChannelSoloPushButton->setEnabled(false); #endif // And update the both GUI volume elements; // return success if, and only if, intrument is fully loaded... return updateChannelVolume() && (iInstrumentStatus == 100); }
InfoBar::InfoBar( QWidget* parent ) : QWidget( parent ) , ui( new Ui::InfoBar ) , m_queryLabel( 0 ) { ui->setupUi( this ); TomahawkUtils::unmarginLayout( layout() ); layout()->setContentsMargins( 8, 4, 8, 4 ); QFont boldFont = ui->captionLabel->font(); boldFont.setPixelSize( 18 ); boldFont.setBold( true ); ui->captionLabel->setFont( boldFont ); ui->captionLabel->setElideMode( Qt::ElideRight ); boldFont.setPixelSize( 12 ); ui->descriptionLabel->setFont( boldFont ); QFont regFont = ui->longDescriptionLabel->font(); regFont.setPixelSize( 11 ); ui->longDescriptionLabel->setFont( regFont ); QPalette whitePal = ui->captionLabel->palette(); whitePal.setColor( QPalette::Foreground, Qt::white ); ui->captionLabel->setPalette( whitePal ); ui->descriptionLabel->setPalette( whitePal ); ui->longDescriptionLabel->setPalette( whitePal ); ui->captionLabel->setMargin( 6 ); ui->descriptionLabel->setMargin( 6 ); ui->longDescriptionLabel->setMargin( 4 ); ui->captionLabel->setText( QString() ); ui->descriptionLabel->setText( QString() ); ui->longDescriptionLabel->setText( QString() ); ui->imageLabel->setText( QString() ); m_queryLabel = new QueryLabel( this ); m_queryLabel->setType( QueryLabel::Artist ); m_queryLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); m_queryLabel->setTextPen( palette().brightText().color() ); m_queryLabel->setFont( boldFont ); m_queryLabel->hide(); connect( m_queryLabel, SIGNAL( clickedArtist() ), this, SLOT( artistClicked() ) ); m_autoUpdate = new QCheckBox( this ); m_autoUpdate->setText( tr( "Automatically update" ) ); m_autoUpdate->setLayoutDirection( Qt::RightToLeft ); m_autoUpdate->setPalette( whitePal ); connect( m_autoUpdate, SIGNAL( toggled( bool ) ), this, SIGNAL( autoUpdateChanged( bool ) ) ); ui->horizontalLayout->addWidget( m_autoUpdate ); m_searchWidget = new QSearchField( this ); m_searchWidget->setPlaceholderText( tr( "Filter..." ) ); m_searchWidget->setMinimumWidth( 180 ); connect( m_searchWidget, SIGNAL( textChanged( QString ) ), this, SLOT( onFilterEdited() ) ); ui->horizontalLayout->addWidget( m_searchWidget ); setAutoFillBackground( true ); setMinimumHeight( geometry().height() ); setMaximumHeight( geometry().height() ); createTile(); connect( ViewManager::instance(), SIGNAL( filterAvailable( bool ) ), SLOT( setFilterAvailable( bool ) ) ); connect( ViewManager::instance(), SIGNAL( autoUpdateAvailable( bool ) ), SLOT( setAutoUpdateAvailable( bool ) ) ); }
void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { if (!panelWidget(widget) && !qobject_cast<const QMenu *>(widget)) return QProxyStyle::drawControl(element, option, painter, widget); switch (element) { case CE_TabBarTabShape: // Most styles draw a single dark outline. This looks rather ugly when combined with our // single pixel dark separator so we adjust the first tab to compensate for this if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) { QStyleOptionTab adjustedTab = *tab; if (tab->cornerWidgets == QStyleOptionTab::NoCornerWidgets && ( tab->position == QStyleOptionTab::Beginning || tab->position == QStyleOptionTab::OnlyOneTab)) { if (option->direction == Qt::LeftToRight) adjustedTab.rect = adjustedTab.rect.adjusted(-1, 0, 0, 0); else adjustedTab.rect = adjustedTab.rect.adjusted(0, 0, 1 ,0); } QProxyStyle::drawControl(element, &adjustedTab, painter, widget); return; } break; case CE_MenuItem: painter->save(); if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { const bool enabled = mbi->state & State_Enabled; QStyleOptionMenuItem item = *mbi; item.rect = mbi->rect; const QColor color = creatorTheme()->color(enabled ? Theme::MenuItemTextColorNormal : Theme::MenuItemTextColorDisabled); if (color.isValid()) { QPalette pal = mbi->palette; pal.setBrush(QPalette::Text, color); item.palette = pal; } QProxyStyle::drawControl(element, &item, painter, widget); } painter->restore(); break; case CE_MenuBarItem: painter->save(); if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { const bool act = mbi->state & (State_Sunken | State_Selected); const bool dis = !(mbi->state & State_Enabled); if (creatorTheme()->widgetStyle() == Theme::StyleFlat) painter->fillRect(option->rect, creatorTheme()->color(Theme::MenuBarItemBackgroundColor)); else StyleHelper::menuGradient(painter, option->rect, option->rect); QStyleOptionMenuItem item = *mbi; item.rect = mbi->rect; QPalette pal = mbi->palette; pal.setBrush(QPalette::ButtonText, dis ? creatorTheme()->color(Theme::MenuBarItemTextColorDisabled) : creatorTheme()->color(Theme::MenuBarItemTextColorNormal)); item.palette = pal; QCommonStyle::drawControl(element, &item, painter, widget); if (act) { // Fill| QColor baseColor = StyleHelper::baseColor(); QLinearGradient grad(option->rect.topLeft(), option->rect.bottomLeft()); grad.setColorAt(0, baseColor.lighter(120)); grad.setColorAt(1, baseColor.lighter(130)); painter->fillRect(option->rect, grad); QPalette pal = mbi->palette; uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; if (!styleHint(SH_UnderlineShortcut, mbi, widget)) alignment |= Qt::TextHideMnemonic; pal.setBrush(QPalette::Text, dis ? Qt::gray : QColor(0, 0, 0, 60)); drawItemText(painter, item.rect.translated(0, 1), alignment, pal, mbi->state & State_Enabled, mbi->text, QPalette::Text); pal.setBrush(QPalette::Text, dis ? Qt::gray : Qt::white); drawItemText(painter, item.rect, alignment, pal, mbi->state & State_Enabled, mbi->text, QPalette::Text); } } painter->restore(); break; case CE_ComboBoxLabel: if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { if (panelWidget(widget)) { painter->save(); QRect editRect = subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget); QPalette customPal = cb->palette; bool drawIcon = !(widget && widget->property("hideicon").toBool()); if (!cb->currentIcon.isNull() && drawIcon) { QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode); QRect iconRect(editRect); iconRect.setWidth(cb->iconSize.width() + 4); iconRect = alignedRect(cb->direction, Qt::AlignLeft | Qt::AlignVCenter, iconRect.size(), editRect); if (cb->editable) painter->fillRect(iconRect, customPal.brush(QPalette::Base)); drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); if (cb->direction == Qt::RightToLeft) editRect.translate(-4 - cb->iconSize.width(), 0); else editRect.translate(cb->iconSize.width() + 4, 0); // Reserve some space for the down-arrow editRect.adjust(0, 0, -13, 0); } QLatin1Char asterisk('*'); int elideWidth = editRect.width(); bool notElideAsterisk = widget && widget->property("notelideasterisk").toBool() && cb->currentText.endsWith(asterisk) && option->fontMetrics.width(cb->currentText) > elideWidth; QString text; if (notElideAsterisk) { elideWidth -= option->fontMetrics.width(asterisk); text = asterisk; } text.prepend(option->fontMetrics.elidedText(cb->currentText, Qt::ElideRight, elideWidth)); if (creatorTheme()->flag(Theme::ComboBoxDrawTextShadow) && (option->state & State_Enabled)) { painter->setPen(QColor(0, 0, 0, 70)); painter->drawText(editRect.adjusted(1, 0, -1, 0), Qt::AlignLeft | Qt::AlignVCenter, text); } if (!(option->state & State_Enabled)) painter->setOpacity(0.8); painter->setPen(creatorTheme()->color(Theme::ComboBoxTextColor)); painter->drawText(editRect.adjusted(1, 0, -1, 0), Qt::AlignLeft | Qt::AlignVCenter, text); painter->restore(); } else { QProxyStyle::drawControl(element, option, painter, widget); } } break; case CE_SizeGrip: { painter->save(); QColor dark = Qt::white; dark.setAlphaF(0.1); int x, y, w, h; option->rect.getRect(&x, &y, &w, &h); int sw = qMin(h, w); if (h > w) painter->translate(0, h - w); else painter->translate(w - h, 0); int sx = x; int sy = y; int s = 4; painter->setPen(dark); if (option->direction == Qt::RightToLeft) { sx = x + sw; for (int i = 0; i < 4; ++i) { painter->drawLine(x, sy, sx, sw); sx -= s; sy += s; } } else { for (int i = 0; i < 4; ++i) { painter->drawLine(sx, sw, sw, sy); sx += s; sy += s; } } painter->restore(); } break; case CE_MenuBarEmptyArea: { if (creatorTheme()->widgetStyle() == Theme::StyleDefault) { StyleHelper::menuGradient(painter, option->rect, option->rect); painter->save(); painter->setPen(StyleHelper::borderColor()); painter->drawLine(option->rect.bottomLeft() + QPointF(0.5, 0.5), option->rect.bottomRight() + QPointF(0.5, 0.5)); painter->restore(); } else { painter->fillRect(option->rect, creatorTheme()->color(Theme::MenuBarEmptyAreaBackgroundColor)); } } break; case CE_ToolBar: { QRect rect = option->rect; const QRectF borderRect = QRectF(rect).adjusted(0.5, 0.5, -0.5, -0.5); bool horizontal = option->state & State_Horizontal; // Map offset for global window gradient QRect gradientSpan; if (widget) { QPoint offset = widget->window()->mapToGlobal(option->rect.topLeft()) - widget->mapToGlobal(option->rect.topLeft()); gradientSpan = QRect(offset, widget->window()->size()); } bool drawLightColored = lightColored(widget); // draws the background of the 'Type hierarchy', 'Projects' headers if (creatorTheme()->widgetStyle() == Theme::StyleFlat) painter->fillRect (rect, creatorTheme()->color(Theme::ToolBarBackgroundColor)); else if (horizontal) StyleHelper::horizontalGradient(painter, gradientSpan, rect, drawLightColored); else StyleHelper::verticalGradient(painter, gradientSpan, rect, drawLightColored); if (!drawLightColored) painter->setPen(StyleHelper::borderColor()); else painter->setPen(QColor(0x888888)); if (horizontal) { // Note: This is a hack to determine if the // toolbar should draw the top or bottom outline // (needed for the find toolbar for instance) QColor lighter(StyleHelper::sidebarHighlight()); if (drawLightColored) lighter = QColor(255, 255, 255, 180); if (widget && widget->property("topBorder").toBool()) { painter->drawLine(borderRect.topLeft(), borderRect.topRight()); painter->setPen(lighter); painter->drawLine(borderRect.topLeft() + QPointF(0, 1), borderRect.topRight() + QPointF(0, 1)); } else { painter->drawLine(borderRect.bottomLeft(), borderRect.bottomRight()); painter->setPen(lighter); painter->drawLine(borderRect.topLeft(), borderRect.topRight()); } } else { painter->drawLine(borderRect.topLeft(), borderRect.bottomLeft()); painter->drawLine(borderRect.topRight(), borderRect.bottomRight()); } } break; default: QProxyStyle::drawControl(element, option, painter, widget); break; } }
MainWidget::MainWidget(QWidget *parent) : DropShadowWidget(parent) { initLocalConnection(); setMinimumSize(900, 600); setWindowIcon(QIcon(":/img/safe")); statked_widget = new QStackedWidget(); title_widget = new TitleWidget(); content_widget = new ContentWidget(); kill_mummy_widget = new KillMummyWidget(); main_menu = new MainMenu(); character_widget = new CharacterWidget(); about_us_dialog = new AboutUsDialog(this); setting_dialog = new SettingDialog(this); login_dialog = new LoginDialog(this); register_widget = new RegisterWidget(this); skin_widget = new SkinWidget(this); system_tray = new SystemTray(this); QPalette palette; palette.setBrush(QPalette::Window, QBrush(Qt::white)); statked_widget->setPalette(palette); statked_widget->setAutoFillBackground(true); statked_widget->addWidget(content_widget); statked_widget->addWidget(kill_mummy_widget); QVBoxLayout *center_layout = new QVBoxLayout(); center_layout->addWidget(statked_widget); center_layout->setSpacing(0); center_layout->setContentsMargins(0, 0, 0, 0); QVBoxLayout *main_layout = new QVBoxLayout(); main_layout->addWidget(title_widget); main_layout->addLayout(center_layout); main_layout->setSpacing(0); main_layout->setContentsMargins(SHADOW_WIDTH, SHADOW_WIDTH, SHADOW_WIDTH, SHADOW_WIDTH); setLayout(main_layout); connect(title_widget, SIGNAL(showSkin()), this, SLOT(showSkinWidget())); connect(title_widget, SIGNAL(showMainMenu()), this, SLOT(showMainMenu())); connect(title_widget, SIGNAL(showMin()), this, SLOT(showMinimized())); connect(title_widget, SIGNAL(closeWidget()), this, SLOT(hide())); connect(title_widget, SIGNAL(turnPage(int)), this, SLOT(turnPage(int))); connect(main_menu, SIGNAL(showSettingDialog()), this, SLOT(showSettingDialog())); connect(main_menu, SIGNAL(showNewCharacter()), this, SLOT(showNewCharacter())); connect(main_menu, SIGNAL(showAboutUs()), this, SLOT(showAboutUs())); connect(content_widget, SIGNAL(showLoginDialog()), this, SLOT(showLoginDialog())); connect(content_widget, SIGNAL(showRegisterDialog()), this, SLOT(showRegisterDialog())); connect(setting_dialog, SIGNAL(changeLanguage(LANGUAGE)), this, SLOT(changeLanguage(LANGUAGE))); connect(skin_widget, SIGNAL(changeSkin(QString)), this, SLOT(changeSkin(QString))); connect(system_tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconIsActived(QSystemTrayIcon::ActivationReason))); connect(system_tray, SIGNAL(showWidget()), this, SLOT(showWidget())); system_tray->show(); title_widget->turnPage("0"); skin_name = Util::getSkinName(); if( QString::compare(skin_name, QString("")) == 0) { this->changeSkin(DEFAULT_SKIN); } }
void _ZFP_textColorSet(ZF_IN ZFUIColor v) { QPalette palette = this->palette(); palette.setColor(QPalette::WindowText, ZFImpl_sys_Qt_ZFUIKit_ZFUIColorToQColor(v)); this->setPalette(palette); }
MainWindow::MainWindow() : QbWindow(config().geometry.mainWindow) { setObjectName("main-window"); setWindowTitle(string() << bsnesTitle << " v" << bsnesVersion); setCloseOnEscape(false); //menu bar #if defined(PLATFORM_OSX) menuBar = new QMenuBar(0); #else menuBar = new QMenuBar; #endif system = menuBar->addMenu("&System"); system_load = system->addAction("Load &Cartridge ..."); system_load->setIcon(QIcon(":/16x16/document-open.png")); system_loadSpecial = system->addMenu("Load &Special"); system_loadSpecial->setIcon(QIcon(":/16x16/document-open.png")); system_loadSpecial_bsxSlotted = system_loadSpecial->addAction("Load BS-X &Slotted Cartridge ..."); system_loadSpecial_bsxSlotted->setIcon(QIcon(":/16x16/document-open.png")); system_loadSpecial_bsx = system_loadSpecial->addAction("Load &BS-X Cartridge ..."); system_loadSpecial_bsx->setIcon(QIcon(":/16x16/document-open.png")); system_loadSpecial_sufamiTurbo = system_loadSpecial->addAction("Load Sufami &Turbo Cartridge ..."); system_loadSpecial_sufamiTurbo->setIcon(QIcon(":/16x16/document-open.png")); system_loadSpecial_superGameBoy = system_loadSpecial->addAction("Load Super &Game Boy Cartridge ..."); system_loadSpecial_superGameBoy->setIcon(QIcon(":/16x16/document-open.png")); system->addSeparator(); system->addAction(system_power = new QbCheckAction("&Power", 0)); system_reset = system->addAction("&Reset"); system_reset->setIcon(QIcon(":/16x16/view-refresh.png")); system->addSeparator(); system_port1 = system->addMenu("Controller Port &1"); system_port1->setIcon(QIcon(":/16x16/input-gaming.png")); system_port1->addAction(system_port1_none = new QbRadioAction("&None", 0)); system_port1->addAction(system_port1_gamepad = new QbRadioAction("&Gamepad", 0)); system_port1->addAction(system_port1_asciipad = new QbRadioAction("&asciiPad", 0)); system_port1->addAction(system_port1_multitap = new QbRadioAction("&Multitap", 0)); system_port1->addAction(system_port1_mouse = new QbRadioAction("&Mouse", 0)); system_port2 = system->addMenu("Controller Port &2"); system_port2->setIcon(QIcon(":/16x16/input-gaming.png")); system_port2->addAction(system_port2_none = new QbRadioAction("&None", 0)); system_port2->addAction(system_port2_gamepad = new QbRadioAction("&Gamepad", 0)); system_port2->addAction(system_port2_asciipad = new QbRadioAction("&asciiPad", 0)); system_port2->addAction(system_port2_multitap = new QbRadioAction("&Multitap", 0)); system_port2->addAction(system_port2_mouse = new QbRadioAction("&Mouse", 0)); system_port2->addAction(system_port2_superscope = new QbRadioAction("&Super Scope", 0)); system_port2->addAction(system_port2_justifier = new QbRadioAction("&Justifier", 0)); system_port2->addAction(system_port2_justifiers = new QbRadioAction("Two &Justifiers", 0)); #if !defined(PLATFORM_OSX) system->addSeparator(); #endif system_exit = system->addAction("E&xit"); system_exit->setIcon(QIcon(":/16x16/process-stop.png")); system_exit->setMenuRole(QAction::QuitRole); settings = menuBar->addMenu("S&ettings"); settings_videoMode = settings->addMenu("Video &Mode"); settings_videoMode->setIcon(QIcon(":/16x16/video-display.png")); settings_videoMode->addAction(settings_videoMode_1x = new QbRadioAction("Scale &1x", 0)); settings_videoMode->addAction(settings_videoMode_2x = new QbRadioAction("Scale &2x", 0)); settings_videoMode->addAction(settings_videoMode_3x = new QbRadioAction("Scale &3x", 0)); settings_videoMode->addAction(settings_videoMode_4x = new QbRadioAction("Scale &4x", 0)); settings_videoMode->addAction(settings_videoMode_5x = new QbRadioAction("Scale &5x", 0)); settings_videoMode->addSeparator(); settings_videoMode->addAction(settings_videoMode_correctAspectRatio = new QbCheckAction("Correct &Aspect Ratio", 0)); settings_videoMode->addSeparator(); settings_videoMode->addAction(settings_videoMode_ntsc = new QbRadioAction("&NTSC", 0)); settings_videoMode->addAction(settings_videoMode_pal = new QbRadioAction("&PAL", 0)); if(filter.opened()) { settings_videoFilter = settings->addMenu("Video &Filter"); settings_videoFilter->setIcon(QIcon(":/16x16/image-x-generic.png")); settings_videoFilter_configure = settings_videoFilter->addAction("&Configure Active Filter ..."); settings_videoFilter_configure->setIcon(QIcon(":/16x16/preferences-desktop.png")); settings_videoFilter->addSeparator(); settings_videoFilter->addAction(settings_videoFilter_none = new QbRadioAction("&None", 0)); settings_videoFilter_list.add(settings_videoFilter_none); lstring filterlist; filterlist.split(";", filter.dl_supported()); for(unsigned i = 0; i < filterlist.size(); i++) { QbRadioAction *action = new QbRadioAction(filterlist[i], 0); settings_videoFilter->addAction(action); settings_videoFilter_list.add(action); } } settings->addAction(settings_smoothVideo = new QbCheckAction("&Smooth Video Output", 0)); settings->addSeparator(); settings->addAction(settings_muteAudio = new QbCheckAction("&Mute Audio Output", 0)); settings->addSeparator(); settings_emulationSpeed = settings->addMenu("Emulation &Speed"); settings_emulationSpeed->setIcon(QIcon(":/16x16/appointment-new.png")); settings_emulationSpeed->addAction(settings_emulationSpeed_slowest = new QbRadioAction("Slowest", 0)); settings_emulationSpeed->addAction(settings_emulationSpeed_slow = new QbRadioAction("Slow", 0)); settings_emulationSpeed->addAction(settings_emulationSpeed_normal = new QbRadioAction("Normal", 0)); settings_emulationSpeed->addAction(settings_emulationSpeed_fast = new QbRadioAction("Fast", 0)); settings_emulationSpeed->addAction(settings_emulationSpeed_fastest = new QbRadioAction("Fastest", 0)); settings_emulationSpeed->addSeparator(); settings_emulationSpeed->addAction(settings_emulationSpeed_syncVideo = new QbCheckAction("Sync &Video", 0)); settings_emulationSpeed->addAction(settings_emulationSpeed_syncAudio = new QbCheckAction("Sync &Audio", 0)); settings_configuration = settings->addAction("&Configuration ..."); settings_configuration->setIcon(QIcon(":/16x16/preferences-desktop.png")); settings_configuration->setMenuRole(QAction::PreferencesRole); tools = menuBar->addMenu("&Tools"); tools_movies = tools->addMenu("&Movies"); tools_movies->setIcon(QIcon(":/16x16/applications-multimedia.png")); tools_movies_play = tools_movies->addAction("Play Movie ..."); tools_movies_play->setIcon(QIcon(":/16x16/media-playback-start.png")); tools_movies_stop = tools_movies->addAction("Stop"); tools_movies_stop->setIcon(QIcon(":/16x16/media-playback-stop.png")); tools_movies_recordFromPowerOn = tools_movies->addAction("Record Movie (and restart system)"); tools_movies_recordFromPowerOn->setIcon(QIcon(":/16x16/media-record.png")); tools_movies_recordFromHere = tools_movies->addAction("Record Movie (starting from here)"); tools_movies_recordFromHere->setIcon(QIcon(":/16x16/media-record.png")); tools_captureScreenshot = tools->addAction("&Capture Screenshot"); tools_captureScreenshot->setIcon(QIcon(":/16x16/image-x-generic.png")); tools->addSeparator(); tools_dialog = tools->addAction("&Tools Dialog ..."); tools_dialog->setIcon(QIcon(":/16x16/preferences-desktop.png")); tools_debugger = tools->addAction("&Debugger ..."); tools_debugger->setIcon(QIcon(":/16x16/utilities-terminal.png")); #if !defined(DEBUGGER) tools_debugger->setVisible(false); #endif help = menuBar->addMenu("&Help"); help_documentation = help->addAction("&Documentation ..."); help_documentation->setIcon(QIcon(":/16x16/text-x-generic.png")); help_license = help->addAction("&License ..."); help_license->setIcon(QIcon(":/16x16/text-x-generic.png")); #if !defined(PLATFORM_OSX) help->addSeparator(); #endif help_about = help->addAction("&About ..."); help_about->setIcon(QIcon(":/16x16/help-browser.png")); help_about->setMenuRole(QAction::AboutRole); //canvas canvasContainer = new CanvasObject; canvasContainer->setAcceptDrops(true); { canvasContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); canvasContainer->setObjectName("backdrop"); canvasLayout = new QVBoxLayout; { canvasLayout->setMargin(0); canvasLayout->setAlignment(Qt::AlignCenter); canvas = new CanvasWidget; canvas->setAcceptDrops(true); canvas->setFocusPolicy(Qt::StrongFocus); canvas->setAttribute(Qt::WA_PaintOnScreen, true); //disable Qt painting on focus / resize QPalette palette; palette.setColor(QPalette::Window, QColor(0, 0, 0)); canvas->setPalette(palette); canvas->setAutoFillBackground(true); } canvasLayout->addWidget(canvas); } canvasContainer->setLayout(canvasLayout); //status bar statusBar = new QStatusBar; statusBar->showMessage(""); systemState = new QLabel; statusBar->addPermanentWidget(systemState); //layout layout = new QVBoxLayout; layout->setMargin(0); layout->setSpacing(0); #if !defined(PLATFORM_OSX) layout->addWidget(menuBar); #endif layout->addWidget(canvasContainer); layout->addWidget(statusBar); setLayout(layout); //slots connect(system_load, SIGNAL(triggered()), this, SLOT(loadCartridge())); connect(system_loadSpecial_bsxSlotted, SIGNAL(triggered()), this, SLOT(loadBsxSlottedCartridge())); connect(system_loadSpecial_bsx, SIGNAL(triggered()), this, SLOT(loadBsxCartridge())); connect(system_loadSpecial_sufamiTurbo, SIGNAL(triggered()), this, SLOT(loadSufamiTurboCartridge())); connect(system_loadSpecial_superGameBoy, SIGNAL(triggered()), this, SLOT(loadSuperGameBoyCartridge())); connect(system_power, SIGNAL(triggered()), this, SLOT(power())); connect(system_reset, SIGNAL(triggered()), this, SLOT(reset())); connect(system_port1_none, SIGNAL(triggered()), this, SLOT(setPort1None())); connect(system_port1_gamepad, SIGNAL(triggered()), this, SLOT(setPort1Gamepad())); connect(system_port1_asciipad, SIGNAL(triggered()), this, SLOT(setPort1Asciipad())); connect(system_port1_multitap, SIGNAL(triggered()), this, SLOT(setPort1Multitap())); connect(system_port1_mouse, SIGNAL(triggered()), this, SLOT(setPort1Mouse())); connect(system_port2_none, SIGNAL(triggered()), this, SLOT(setPort2None())); connect(system_port2_gamepad, SIGNAL(triggered()), this, SLOT(setPort2Gamepad())); connect(system_port2_asciipad, SIGNAL(triggered()), this, SLOT(setPort2Asciipad())); connect(system_port2_multitap, SIGNAL(triggered()), this, SLOT(setPort2Multitap())); connect(system_port2_mouse, SIGNAL(triggered()), this, SLOT(setPort2Mouse())); connect(system_port2_superscope, SIGNAL(triggered()), this, SLOT(setPort2SuperScope())); connect(system_port2_justifier, SIGNAL(triggered()), this, SLOT(setPort2Justifier())); connect(system_port2_justifiers, SIGNAL(triggered()), this, SLOT(setPort2Justifiers())); connect(system_exit, SIGNAL(triggered()), this, SLOT(quit())); connect(settings_videoMode_1x, SIGNAL(triggered()), this, SLOT(setVideoMode1x())); connect(settings_videoMode_2x, SIGNAL(triggered()), this, SLOT(setVideoMode2x())); connect(settings_videoMode_3x, SIGNAL(triggered()), this, SLOT(setVideoMode3x())); connect(settings_videoMode_4x, SIGNAL(triggered()), this, SLOT(setVideoMode4x())); connect(settings_videoMode_5x, SIGNAL(triggered()), this, SLOT(setVideoMode5x())); connect(settings_videoMode_correctAspectRatio, SIGNAL(triggered()), this, SLOT(toggleAspectCorrection())); connect(settings_videoMode_ntsc, SIGNAL(triggered()), this, SLOT(setVideoNtsc())); connect(settings_videoMode_pal, SIGNAL(triggered()), this, SLOT(setVideoPal())); if(filter.opened()) { connect(settings_videoFilter_configure, SIGNAL(triggered()), this, SLOT(configureFilter())); for(unsigned i = 0; i < settings_videoFilter_list.size(); i++) { connect(settings_videoFilter_list[i], SIGNAL(triggered()), this, SLOT(setFilter())); } } connect(settings_smoothVideo, SIGNAL(triggered()), this, SLOT(toggleSmoothVideo())); connect(settings_muteAudio, SIGNAL(triggered()), this, SLOT(muteAudio())); connect(settings_emulationSpeed_slowest, SIGNAL(triggered()), this, SLOT(setSpeedSlowest())); connect(settings_emulationSpeed_slow, SIGNAL(triggered()), this, SLOT(setSpeedSlow())); connect(settings_emulationSpeed_normal, SIGNAL(triggered()), this, SLOT(setSpeedNormal())); connect(settings_emulationSpeed_fast, SIGNAL(triggered()), this, SLOT(setSpeedFast())); connect(settings_emulationSpeed_fastest, SIGNAL(triggered()), this, SLOT(setSpeedFastest())); connect(settings_emulationSpeed_syncVideo, SIGNAL(triggered()), this, SLOT(syncVideo())); connect(settings_emulationSpeed_syncAudio, SIGNAL(triggered()), this, SLOT(syncAudio())); connect(settings_configuration, SIGNAL(triggered()), this, SLOT(showConfigWindow())); connect(tools_movies_play, SIGNAL(triggered()), this, SLOT(playMovie())); connect(tools_movies_stop, SIGNAL(triggered()), this, SLOT(stopMovie())); connect(tools_movies_recordFromPowerOn, SIGNAL(triggered()), this, SLOT(recordMovieFromPowerOn())); connect(tools_movies_recordFromHere, SIGNAL(triggered()), this, SLOT(recordMovieFromHere())); connect(tools_captureScreenshot, SIGNAL(triggered()), this, SLOT(saveScreenshot())); connect(tools_debugger, SIGNAL(triggered()), this, SLOT(showDebugger())); connect(tools_dialog, SIGNAL(triggered()), this, SLOT(showToolsDialog())); connect(help_documentation, SIGNAL(triggered()), this, SLOT(showDocumentation())); connect(help_license, SIGNAL(triggered()), this, SLOT(showLicense())); connect(help_about, SIGNAL(triggered()), this, SLOT(showAbout())); syncUi(); }
// TODO remove void SkLabel::setPaletteBackgroundColor (const QColor &color) { QPalette palette; palette.setColor (backgroundRole (), color); setPalette(palette); }
void AmeNavBarItem::setTextColor (const QColor& color) { QPalette palette = d->labelText->palette(); palette.setColor(QPalette::WindowText, color); d->labelText->setPalette(palette); }
Color RenderThemeQt::platformActiveSelectionBackgroundColor() const { QPalette pal = QApplication::palette(); return pal.brush(QPalette::Active, QPalette::Highlight).color(); }
StyleWidget::StyleWidget(QWidget *parent) : QWidget(parent) { solid = new RenderArea(new QBrush(Qt::SolidPattern)); dense1 = new RenderArea(new QBrush(Qt::Dense1Pattern)); dense2 = new RenderArea(new QBrush(Qt::Dense2Pattern)); dense3 = new RenderArea(new QBrush(Qt::Dense3Pattern)); dense4 = new RenderArea(new QBrush(Qt::Dense4Pattern)); dense5 = new RenderArea(new QBrush(Qt::Dense5Pattern)); dense6 = new RenderArea(new QBrush(Qt::Dense6Pattern)); dense7 = new RenderArea(new QBrush(Qt::Dense7Pattern)); no = new RenderArea(new QBrush(Qt::NoBrush)); hor = new RenderArea(new QBrush(Qt::HorPattern)); ver = new RenderArea(new QBrush(Qt::VerPattern)); cross = new RenderArea(new QBrush(Qt::CrossPattern)); bdiag = new RenderArea(new QBrush(Qt::BDiagPattern)); fdiag = new RenderArea(new QBrush(Qt::FDiagPattern)); diagCross = new RenderArea(new QBrush(Qt::DiagCrossPattern)); linear = new RenderArea(new QBrush(QLinearGradient())); radial = new RenderArea(new QBrush(QRadialGradient())); conical = new RenderArea(new QBrush(QConicalGradient())); texture = new RenderArea(new QBrush(QPixmap("qt-logo.png"))); solidLabel = new QLabel("Qt::SolidPattern"); dense1Label = new QLabel("Qt::Dense1Pattern"); dense2Label = new QLabel("Qt::Dense2Pattern"); dense3Label = new QLabel("Qt::Dense3Pattern"); dense4Label = new QLabel("Qt::Dense4Pattern"); dense5Label = new QLabel("Qt::Dense5Pattern"); dense6Label = new QLabel("Qt::Dense6Pattern"); dense7Label = new QLabel("Qt::Dense7Pattern"); noLabel = new QLabel("Qt::NoPattern"); horLabel = new QLabel("Qt::HorPattern"); verLabel = new QLabel("Qt::VerPattern"); crossLabel = new QLabel("Qt::CrossPattern"); bdiagLabel = new QLabel("Qt::BDiagPattern"); fdiagLabel = new QLabel("Qt::FDiagPattern"); diagCrossLabel = new QLabel("Qt::DiagCrossPattern"); linearLabel = new QLabel("Qt::LinearGradientPattern"); radialLabel = new QLabel("Qt::RadialGradientPattern"); conicalLabel = new QLabel("Qt::ConicalGradientPattern"); textureLabel = new QLabel("Qt::TexturePattern"); QGridLayout *layout = new QGridLayout; layout->addWidget(solid, 0, 0); layout->addWidget(dense1, 0, 1); layout->addWidget(dense2, 0, 2); layout->addWidget(solidLabel, 1, 0); layout->addWidget(dense1Label, 1, 1); layout->addWidget(dense2Label, 1, 2); layout->addWidget(dense3, 2, 0 ); layout->addWidget(dense4, 2, 1); layout->addWidget(dense5, 2, 2); layout->addWidget(dense3Label, 3, 0); layout->addWidget(dense4Label, 3, 1); layout->addWidget(dense5Label, 3, 2); layout->addWidget(dense6, 4, 0); layout->addWidget(dense7, 4, 1); layout->addWidget(no, 4, 2); layout->addWidget(dense6Label, 5, 0); layout->addWidget(dense7Label, 5, 1); layout->addWidget(noLabel, 5, 2); layout->addWidget(hor, 6, 0); layout->addWidget(ver, 6, 1); layout->addWidget(cross, 6, 2); layout->addWidget(horLabel, 7, 0); layout->addWidget(verLabel, 7, 1); layout->addWidget(crossLabel, 7, 2); layout->addWidget(bdiag, 8, 0); layout->addWidget(fdiag, 8, 1); layout->addWidget(diagCross, 8, 2); layout->addWidget(bdiagLabel, 9, 0); layout->addWidget(fdiagLabel, 9, 1); layout->addWidget(diagCrossLabel, 9, 2); layout->addWidget(linear, 10, 0); layout->addWidget(radial, 10, 1); layout->addWidget(conical, 10, 2); layout->addWidget(linearLabel, 11, 0); layout->addWidget(radialLabel, 11, 1); layout->addWidget(conicalLabel, 11, 2); layout->addWidget(texture, 12, 0, 1, 3); layout->addWidget(textureLabel, 13, 0, 1, 3); setLayout(layout); QPalette newPalette = palette(); newPalette.setColor(QPalette::Window, Qt::white); setPalette(newPalette); setWindowTitle(tr("Brush Styles")); resize(430, 605); }
/** * Request the video to avoid the conflicts **/ WId VideoWidget::request( struct vout_window_t *p_wnd, unsigned int *pi_width, unsigned int *pi_height, bool b_keep_size ) { if( stable ) { msg_Dbg( p_intf, "embedded video already in use" ); return 0; } assert( !p_window ); if( b_keep_size ) { *pi_width = size().width(); *pi_height = size().height(); } /* 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. */ stable = new QWidget(); QPalette plt = palette(); plt.setColor( QPalette::Window, Qt::black ); stable->setPalette( plt ); stable->setAutoFillBackground(true); /* Force the widget to be native so that it gets a winId() */ stable->setAttribute( Qt::WA_NativeWindow, true ); /* Indicates that the widget wants to draw directly onto the screen. Widgets with this attribute set do not participate in composition management */ /* This is currently disabled on X11 as it does not seem to improve * performance, but causes the video widget to be transparent... */ #if !defined (Q_WS_X11) && !defined (Q_WS_QPA) stable->setAttribute( Qt::WA_PaintOnScreen, true ); #endif layout->addWidget( stable ); #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); attr.your_event_mask &= ~PointerMotionMask; XSelectInput( dpy, w, attr.your_event_mask ); # ifdef HAVE_XI int n; XIEventMask *xi_masks = XIGetSelectedEvents( dpy, w, &n ); if( xi_masks != NULL ) { for( int i = 0; i < n; i++ ) if( xi_masks[i].mask_len >= 1 ) { xi_masks[i].mask[0] &= ~XI_ButtonPressMask; xi_masks[i].mask[0] &= ~XI_ButtonReleaseMask; xi_masks[i].mask[0] &= ~XI_MotionMask; } XISelectEvents( dpy, w, xi_masks, n ); XFree( xi_masks ); } # endif #endif sync(); p_window = p_wnd; return stable->winId(); }
void applyDiscount::populate() { XSqlQuery applypopulate; applypopulate.prepare("SELECT (vend_number|| '-' || vend_name) as f_vend," " CASE WHEN (apopen_doctype='V') THEN :voucher" " WHEN (apopen_doctype='D') THEN :debitmemo" " ELSE apopen_doctype" " END AS f_doctype," " apopen_docnumber," " apopen_docdate, " " (terms_code || '-' || terms_descrip) AS f_terms," " determineDiscountDate(apopen_terms_id, apopen_docdate) AS discdate," " terms_discprcnt," " apopen_amount, apopen_discountable_amount, apopen_curr_id, applied, " " noNeg(apopen_discountable_amount *" " CASE WHEN (CURRENT_DATE <= determineDiscountDate(terms_id, apopen_docdate)) THEN terms_discprcnt" " ELSE 0.0 END - applied) AS amount," " (determineDiscountDate(terms_id, apopen_docdate) < CURRENT_DATE) AS past" " FROM apopen LEFT OUTER JOIN terms ON (apopen_terms_id=terms_id)" " JOIN vendinfo ON (apopen_vend_id=vend_id), " " (SELECT COALESCE(SUM(apapply_amount),0) AS applied" " FROM apapply, apopen" " WHERE ((apapply_target_apopen_id=:apopen_id)" " AND (apapply_source_apopen_id=apopen_id)" " AND (apopen_discount)) ) AS data" " WHERE (apopen_id=:apopen_id); "); applypopulate.bindValue(":apopen_id", _apopenid); applypopulate.bindValue(":voucher", tr("Voucher")); applypopulate.bindValue(":debitmemo", tr("Debit Memo")); applypopulate.exec(); if(applypopulate.first()) { _vend->setText(applypopulate.value("f_vend").toString()); _doctype->setText(applypopulate.value("f_doctype").toString()); _docnum->setText(applypopulate.value("apopen_docnumber").toString()); _docdate->setDate(applypopulate.value("apopen_docdate").toDate()); _terms->setText(applypopulate.value("f_terms").toString()); _discdate->setDate(applypopulate.value("discdate").toDate()); if(applypopulate.value("past").toBool()) { QPalette tmpPalette = _discdate->palette(); tmpPalette.setColor(QPalette::HighlightedText, namedColor("error")); _discdate->setPalette(tmpPalette); _discdate->setForegroundRole(QPalette::HighlightedText); // why doesn't the date turn ERROR? _discdateLit->setPalette(tmpPalette); _discdateLit->setForegroundRole(QPalette::HighlightedText); } _discprcnt->setDouble(applypopulate.value("terms_discprcnt").toDouble() * 100); _owed->setLocalValue(applypopulate.value("apopen_amount").toDouble()); _discountableOwed->setLocalValue(applypopulate.value("apopen_discountable_amount").toDouble()); _applieddiscounts->setLocalValue(applypopulate.value("applied").toDouble()); _amount->set(applypopulate.value("amount").toDouble(), applypopulate.value("apopen_curr_id").toInt(), applypopulate.value("apopen_docdate").toDate(), false); } else if (applypopulate.lastError().type() != QSqlError::NoError) systemError(this, applypopulate.lastError().databaseText(), __FILE__, __LINE__); }
void paintContact(QPainter* mp, const QStyleOptionViewItem& option, const QModelIndex& index, GCUserViewItem* item) const { mp->save(); QStyleOptionViewItem o = option; QPalette palette = o.palette; MUCItem::Role r = item->s.mucItem().role(); QRect rect = o.rect; if(nickColoring_) { if(r == MUCItem::Moderator) palette.setColor(QPalette::Text, colorModerator_); else if(r == MUCItem::Participant) palette.setColor(QPalette::Text, colorParticipant_); else if(r == MUCItem::Visitor) palette.setColor(QPalette::Text, colorVisitor_); else palette.setColor(QPalette::Text, colorNoRole_); } mp->fillRect(rect, (o.state & QStyle::State_Selected) ? palette.color(QPalette::Highlight) : palette.color(QPalette::Base)); if(showAvatar_) { QPixmap ava = item->avatar(); if(ava.isNull()) { ava = IconsetFactory::iconPixmap("psi/default_avatar"); } ava = AvatarFactory::roundedAvatar(ava, avatarRadius_, avatarSize_); QRect avaRect(rect); avaRect.setWidth(ava.width()); avaRect.setHeight(ava.height()); if(!avatarAtLeft_) { avaRect.moveTopRight(rect.topRight()); avaRect.translate(-1, 1); rect.setRight(avaRect.left() - 1); } else { avaRect.translate(1, 1); rect.setLeft(avaRect.right() + 1); } mp->drawPixmap(avaRect, ava); } QPixmap status = showStatusIcons_ ? item->icon() : QPixmap(); int h = rect.height(); int sh = status.isNull() ? 0 : status.height(); rect.setHeight(qMax(sh, fontHeight_)); rect.moveTop(rect.top() + (h - rect.height())/2); if(!status.isNull()) { QRect statusRect(rect); statusRect.setWidth(status.width()); statusRect.setHeight(status.height()); statusRect.translate(1, 1); mp->drawPixmap(statusRect, status); rect.setLeft(statusRect.right() + 2); } else rect.setLeft(rect.left() + 2); mp->setPen(QPen((o.state & QStyle::State_Selected) ? palette.color(QPalette::HighlightedText) : palette.color(QPalette::Text))); mp->setFont(o.font); mp->setClipRect(rect); QTextOption to; to.setWrapMode(QTextOption::NoWrap); mp->drawText(rect, index.data(Qt::DisplayRole).toString(), to); QList<QPixmap> rightPixs; if(showClients_) { GCUserView *gcuv = (GCUserView*)item->treeWidget(); GCMainDlg* dlg = gcuv->mainDlg(); QPixmap clientPix; if(dlg) { UserListItem u; const QString &nick = item->text(0); Jid caps_jid(/*s.mucItem().jid().isEmpty() ? */ dlg->jid().withResource(nick) /* : s.mucItem().jid()*/); CapsManager *cm = dlg->account()->client()->capsManager(); QString client_name = cm->clientName(caps_jid); QString client_version = (client_name.isEmpty() ? QString() : cm->clientVersion(caps_jid)); UserResource ur; ur.setStatus(item->s); ur.setClient(client_name,client_version,""); u.userResourceList().append(ur); QStringList clients = u.clients(); if(!clients.isEmpty()) clientPix = IconsetFactory::iconPixmap("clients/" + clients.takeFirst()); } if(!clientPix.isNull()) rightPixs.push_back(clientPix); } if(showAffiliations_) { MUCItem::Affiliation a = item->s.mucItem().affiliation(); QPixmap pix; if(a == MUCItem::Owner) pix = IconsetFactory::iconPixmap("affiliation/owner"); else if(a == MUCItem::Admin) pix = IconsetFactory::iconPixmap("affiliation/admin"); else if(a == MUCItem::Member) pix = IconsetFactory::iconPixmap("affiliation/member"); else if(a == MUCItem::Outcast) pix = IconsetFactory::iconPixmap("affiliation/outcast"); else pix = IconsetFactory::iconPixmap("affiliation/noaffiliation"); if(!pix.isNull()) rightPixs.push_back(pix); } mp->restore(); if(rightPixs.isEmpty()) return; int sumWidth = 0; foreach (const QPixmap& pix, rightPixs) { sumWidth += pix.width(); } sumWidth += rightPixs.count(); QColor bgc = (option.state & QStyle::State_Selected) ? palette.color(QPalette::Highlight) : palette.color(QPalette::Base); QColor tbgc = bgc; tbgc.setAlpha(0); QLinearGradient grad(rect.right() - sumWidth - 20, 0, rect.right() - sumWidth, 0); grad.setColorAt(0, tbgc); grad.setColorAt(1, bgc); QBrush tbakBr(grad); QRect gradRect(rect); gradRect.setLeft(gradRect.right() - sumWidth - 20); mp->fillRect(gradRect, tbakBr); QRect iconRect(rect); for (int i=0; i<rightPixs.size(); i++) { const QPixmap pix = rightPixs[i]; iconRect.setRight(iconRect.right() - pix.width() -1); mp->drawPixmap(iconRect.topRight(), pix); } }
void PresentationCaptionPage::slotCommentsFontColorChanged() { QPalette palette = m_fontSampleLbl->palette(); palette.setColor(m_fontSampleLbl->foregroundRole(), m_commentsFontColor->color()); m_fontSampleLbl->setPalette(palette); }
HtmlEditor::HtmlEditor(QWidget *parent) : QWidget(parent) , ui(new Ui_HtmlEditor) , sourceDirty(true) , highlighter(0) , ui_dialog(0) , insertHtmlDialog(0) { ui->setupUi(this); QPalette pal = ui->webView->page()->palette(); pal.setColor(QPalette::Base, Qt::gray); ui->webView->page()->setPalette(pal); ui->tabWidget->setTabText(0, tr("WYSIWYG Editor")); ui->tabWidget->setTabText(1, tr("View Source")); connect(ui->tabWidget, SIGNAL(currentChanged(int)), SLOT(changeTab(int))); highlighter = new Highlighter(ui->plainTextEdit->document()); QWidget *spacer = new QWidget(this); spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); ui->standardToolBar->insertWidget(ui->actionZoomOut, spacer); zoomLabel = new QLabel; ui->standardToolBar->insertWidget(ui->actionZoomOut, zoomLabel); zoomSlider = new QSlider(this); zoomSlider->setOrientation(Qt::Horizontal); zoomSlider->setMaximumWidth(150); zoomSlider->setRange(25, 400); zoomSlider->setSingleStep(25); zoomSlider->setPageStep(100); connect(zoomSlider, SIGNAL(valueChanged(int)), SLOT(changeZoom(int))); ui->standardToolBar->insertWidget(ui->actionZoomIn, zoomSlider); connect(ui->actionFileNew, SIGNAL(triggered()), SLOT(fileNew())); connect(ui->actionFileOpen, SIGNAL(triggered()), SLOT(fileOpen())); connect(ui->actionFileSave, SIGNAL(triggered()), SLOT(fileSave())); connect(ui->actionFileSaveAs, SIGNAL(triggered()), SLOT(fileSaveAs())); connect(ui->actionExit, SIGNAL(triggered()), SLOT(close())); connect(ui->actionInsertImage, SIGNAL(triggered()), SLOT(insertImage())); connect(ui->actionCreateLink, SIGNAL(triggered()), SLOT(createLink())); connect(ui->actionInsertHtml, SIGNAL(triggered()), SLOT(insertHtml())); connect(ui->actionZoomOut, SIGNAL(triggered()), SLOT(zoomOut())); connect(ui->actionZoomIn, SIGNAL(triggered()), SLOT(zoomIn())); // these are forward to internal QWebView FORWARD_ACTION(ui->actionEditUndo, QWebPage::Undo); FORWARD_ACTION(ui->actionEditRedo, QWebPage::Redo); FORWARD_ACTION(ui->actionEditCut, QWebPage::Cut); FORWARD_ACTION(ui->actionEditCopy, QWebPage::Copy); FORWARD_ACTION(ui->actionEditPaste, QWebPage::Paste); FORWARD_ACTION(ui->actionFormatBold, QWebPage::ToggleBold); FORWARD_ACTION(ui->actionFormatItalic, QWebPage::ToggleItalic); FORWARD_ACTION(ui->actionFormatUnderline, QWebPage::ToggleUnderline); // Qt 4.5.0 has a bug: always returns 0 for QWebPage::SelectAll connect(ui->actionEditSelectAll, SIGNAL(triggered()), SLOT(editSelectAll())); connect(ui->actionStyleParagraph, SIGNAL(triggered()), SLOT(styleParagraph())); connect(ui->actionStyleHeading1, SIGNAL(triggered()), SLOT(styleHeading1())); connect(ui->actionStyleHeading2, SIGNAL(triggered()), SLOT(styleHeading2())); connect(ui->actionStyleHeading3, SIGNAL(triggered()), SLOT(styleHeading3())); connect(ui->actionStyleHeading4, SIGNAL(triggered()), SLOT(styleHeading4())); connect(ui->actionStyleHeading5, SIGNAL(triggered()), SLOT(styleHeading5())); connect(ui->actionStyleHeading6, SIGNAL(triggered()), SLOT(styleHeading6())); connect(ui->actionStylePreformatted, SIGNAL(triggered()), SLOT(stylePreformatted())); connect(ui->actionStyleAddress, SIGNAL(triggered()), SLOT(styleAddress())); connect(ui->actionFormatFontName, SIGNAL(triggered()), SLOT(formatFontName())); connect(ui->actionFormatFontSize, SIGNAL(triggered()), SLOT(formatFontSize())); connect(ui->actionFormatTextColor, SIGNAL(triggered()), SLOT(formatTextColor())); connect(ui->actionFormatBackgroundColor, SIGNAL(triggered()), SLOT(formatBackgroundColor())); // no page action exists yet for these, so use execCommand trick connect(ui->actionFormatStrikethrough, SIGNAL(triggered()), SLOT(formatStrikeThrough())); connect(ui->actionFormatAlignLeft, SIGNAL(triggered()), SLOT(formatAlignLeft())); connect(ui->actionFormatAlignCenter, SIGNAL(triggered()), SLOT(formatAlignCenter())); connect(ui->actionFormatAlignRight, SIGNAL(triggered()), SLOT(formatAlignRight())); connect(ui->actionFormatAlignJustify, SIGNAL(triggered()), SLOT(formatAlignJustify())); connect(ui->actionFormatDecreaseIndent, SIGNAL(triggered()), SLOT(formatDecreaseIndent())); connect(ui->actionFormatIncreaseIndent, SIGNAL(triggered()), SLOT(formatIncreaseIndent())); connect(ui->actionFormatNumberedList, SIGNAL(triggered()), SLOT(formatNumberedList())); connect(ui->actionFormatBulletedList, SIGNAL(triggered()), SLOT(formatBulletedList())); // necessary to sync our actions connect(ui->webView->page(), SIGNAL(selectionChanged()), SLOT(adjustActions())); connect(ui->webView->page(), SIGNAL(contentsChanged()), SLOT(adjustSource())); ui->webView->setFocus(); setCurrentFileName(QString()); fileNew(); adjustActions(); adjustSource(); setWindowModified(false); // changeZoom(100); }
void AudioNoiseWidget::paintEvent(QPaintEvent *) { QPainter paint(this); QPalette pal; paint.fillRect(rect(), pal.color(QPalette::Background)); AudioInputPtr ai = g.ai; if (ai.get() == NULL || ! ai->sppPreprocess) return; QPolygonF poly; ai->qmSpeex.lock(); spx_int32_t ps_size = 0; speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_PSD_SIZE, &ps_size); STACKVAR(spx_int32_t, noise, ps_size); STACKVAR(spx_int32_t, ps, ps_size); speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_PSD, ps); speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_NOISE_PSD, noise); ai->qmSpeex.unlock(); qreal sx, sy; sx = (static_cast<float>(width()) - 1.0f) / static_cast<float>(ps_size); sy = static_cast<float>(height()) - 1.0f; poly << QPointF(0.0f, height() - 1); float fftmul = 1.0 / (32768.0); for (int i=0; i < ps_size; i++) { qreal xp, yp; xp = i * sx; yp = sqrtf(sqrtf(static_cast<float>(noise[i]))) - 1.0f; yp = yp * fftmul; yp = qMin<qreal>(yp * 3000.0f, 1.0f); yp = (1 - yp) * sy; poly << QPointF(xp, yp); } poly << QPointF(width() - 1, height() - 1); poly << QPointF(0.0f, height() - 1); paint.setPen(Qt::blue); paint.setBrush(Qt::blue); paint.drawPolygon(poly); poly.clear(); for (int i=0;i < ps_size; i++) { qreal xp, yp; xp = i * sx; yp = sqrtf(sqrtf(static_cast<float>(ps[i]))) - 1.0f; yp = yp * fftmul; yp = qMin(yp * 3000.0, 1.0); yp = (1 - yp) * sy; poly << QPointF(xp, yp); } paint.setPen(Qt::red); paint.drawPolyline(poly); }
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), 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, 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(hasVideoChanged(bool)), this, SLOT(slotHasVideoChanged(bool))); // 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_NEPOMUK m_metaDataWidget = new KFileMetaDataWidget(parent); #else m_metaDataWidget = new Nepomuk2::FileMetaDataWidget(parent); #endif 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); m_placesItemModel = new PlacesItemModel(this); }
void DesktopItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { Q_ASSERT(index.isValid()); QStyleOptionViewItemV4 opt = option; initStyleOption(&opt, index); const QWidget* widget = opt.widget; QStyle* style = widget ? widget->style() : QApplication::style(); painter->save(); painter->setClipRect(option.rect); opt.decorationAlignment = Qt::AlignHCenter | Qt::AlignTop; opt.displayAlignment = Qt::AlignTop | Qt::AlignHCenter; // draw the icon QIcon::Mode iconMode; if(opt.state & QStyle::State_Enabled) { if(opt.state & QStyle::State_Selected) iconMode = QIcon::Selected; else { iconMode = QIcon::Normal; } } else iconMode = QIcon::Disabled; QPoint iconPos(opt.rect.x() + (opt.rect.width() - opt.decorationSize.width()) / 2, opt.rect.y()); QPixmap pixmap = opt.icon.pixmap(opt.decorationSize, iconMode); painter->drawPixmap(iconPos, pixmap); // draw text QRectF textRect(opt.rect.x(), opt.rect.y() + opt.decorationSize.height(), opt.rect.width(), opt.rect.height() - opt.decorationSize.height()); QTextLayout layout(opt.text, opt.font); QTextOption textOption; textOption.setAlignment(opt.displayAlignment); textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); textOption.setTextDirection(opt.direction); layout.setTextOption(textOption); qreal height = 0; qreal width = 0; int visibleLines = 0; layout.beginLayout(); QString elidedText; for(;;) { QTextLine line = layout.createLine(); if(!line.isValid()) break; line.setLineWidth(textRect.width()); height += opt.fontMetrics.leading(); line.setPosition(QPointF(0, height)); if((height + line.height() + textRect.y()) > textRect.bottom()) { // if part of this line falls outside the textRect, ignore it and quit. QTextLine lastLine = layout.lineAt(visibleLines - 1); elidedText = opt.text.mid(lastLine.textStart()); elidedText = opt.fontMetrics.elidedText(elidedText, opt.textElideMode, textRect.width()); break; } height += line.height(); width = qMax(width, line.naturalTextWidth()); ++ visibleLines; } layout.endLayout(); QRectF boundRect = layout.boundingRect(); boundRect.setWidth(width); boundRect.moveTo(textRect.x() + (textRect.width() - width)/2, textRect.y()); if(opt.state & QStyle::State_Selected) { QPalette palette = widget->palette(); // qDebug("w: %f, h:%f, m:%f", boundRect.width(), boundRect.height(), layout.minimumWidth()); painter->fillRect(boundRect, palette.highlight()); } else { // only draw shadow for non-selected items // draw shadow, FIXME: is it possible to use QGraphicsDropShadowEffect here? QPen prevPen = painter->pen(); painter->setPen(QPen(shadowColor_)); for(int i = 0; i < visibleLines; ++i) { QTextLine line = layout.lineAt(i); if(i == (visibleLines - 1) && !elidedText.isEmpty()) { // the last line, draw elided text QPointF pos(textRect.x() + line.position().x() + 1, textRect.y() + line.y() + line.ascent() + 1); painter->drawText(pos, elidedText); } else { line.draw(painter, textRect.topLeft() + QPointF(1, 1)); } } painter->setPen(prevPen); } // draw text for(int i = 0; i < visibleLines; ++i) { QTextLine line = layout.lineAt(i); if(i == (visibleLines - 1) && !elidedText.isEmpty()) { // the last line, draw elided text QPointF pos(textRect.x() + line.position().x(), textRect.y() + line.y() + line.ascent()); painter->drawText(pos, elidedText); } else { line.draw(painter, textRect.topLeft()); } } if(opt.state & QStyle::State_HasFocus) { // FIXME: draw focus rect } painter->restore(); }