void CustomLabel::paintEvent(QPaintEvent *pe) { if ((!text().isEmpty()) && (textFormat() == Qt::PlainText || (textFormat() == Qt::AutoText && !Qt::mightBeRichText(text())))) { QPainter painter(this); #ifndef DEBUG_CUSTOMLABEL QRectF lr = contentsRect(); lr.moveBottom(lr.bottom() - 1); // angry and dirty hack! QStyleOption opt; opt.initFrom(this); int align = QStyle::visualAlignment(text().isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight, alignment()); int flags = align | (!text().isRightToLeft() ? Qt::TextForceLeftToRight : Qt::TextForceRightToLeft); if (wordWrap()) flags |= Qt::TextWordWrap; switch (shadowType) { case NoShadow: flags |= TF_NOSHADOW; break; case DarkShadow: flags |= TF_DARKSHADOW; break; case LightShadow: flags |= TF_LIGHTSHADOW; break; default: break; } QString textToDraw = elidedText(); style()->drawItemText(&painter, lr.toRect(), flags, opt.palette, isEnabled(), textToDraw, QPalette::WindowText); #else // DEBUG_CUSTOMLABEL QTextDocument *doc = textDocument(); QAbstractTextDocumentLayout::PaintContext ctx = textDocumentPaintContext(doc); QString shadowKey; switch (shadowType) { case DarkShadow: shadowKey = GFX_TEXTSHADOWS; break; case LightShadow: shadowKey = GFX_NOTICEWIDGET; break; case NoShadow: default: break; } // magic numbers int dx = -2; int dy = -2; // adding margins dx += contentsMargins().left(); dy += contentsMargins().top(); # if 1 // for debug set 0 QGraphicsDropShadowEffect *shadow = qobject_cast<QGraphicsDropShadowEffect *>(GraphicsEffectsStorage::staticStorage(RSR_STORAGE_GRAPHICSEFFECTS)->getFirstEffect(shadowKey)); # else // debug shadow QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect; shadow->setColor(Qt::red); shadow->setOffset(1, 1); # endif if (shadow) { # if 0 // for "image method" set 1 QImage shadowedText(size(), QImage::Format_ARGB32_Premultiplied); # if defined(Q_WS_MAC) && !defined(__MAC_OS_X_NATIVE_FULLSCREEN) // TODO: fix that shadowedText.fill(Qt::red); // DUNNO WHY!!! # else shadowedText.fill(Qt::transparent); # endif QPainter tmpPainter(&shadowedText); tmpPainter.setRenderHint(QPainter::Antialiasing); tmpPainter.setRenderHint(QPainter::HighQualityAntialiasing); tmpPainter.setRenderHint(QPainter::TextAntialiasing); tmpPainter.setRenderHint(QPainter::SmoothPixmapTransform); tmpPainter.translate(dx, dy); doc->documentLayout()->draw(&tmpPainter, ctx); painter.drawImage(0, 0, shadowedText); # else // text method QPalette origPal = ctx.palette; ctx.palette.setColor(QPalette::Text, shadow->color()); // draw shadow painter.save(); painter.translate(dx + shadow->xOffset(), dy + shadow->yOffset()); doc->documentLayout()->draw(&painter, ctx); painter.restore(); ctx.palette = origPal; // draw text painter.save(); painter.translate(dx, dy); doc->documentLayout()->draw(&painter, ctx); painter.restore(); # endif // shadow method } else { painter.save(); painter.translate(dx, dy); doc->documentLayout()->draw(&painter, ctx); painter.restore(); } doc->deleteLater(); #endif // DEBUG_CUSTOMLABEL } else QLabel::paintEvent(pe); }
void MainWindow::setShadow(QPushButton* pButton) { QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect(); effect->setBlurRadius(2); //Adjust accordingly effect->setOffset(3,3); //Adjust accordingly pButton->setGraphicsEffect(effect); }
void window::set_window_content(widget *a_widget_ptr) { if (priv->m_window_content) { return; } priv->m_window_content = a_widget_ptr; priv->m_window_content->setParentItem(this); float window_bordr_height = window_title_height(); QRectF content_geometry(a_widget_ptr->boundingRect()); #ifdef __APPLE__ content_geometry.setHeight(content_geometry.height() + window_title_height() + 30); content_geometry.setWidth(content_geometry.width() + 30); #else content_geometry.setHeight(content_geometry.height() + window_title_height()); content_geometry.setWidth(content_geometry.width() + 2); #endif if (priv->m_window_type == kApplicationWindow) { #ifdef __APPLE__ priv->m_window_content->setPos(15.0, window_bordr_height + 10); content_geometry.setHeight(content_geometry.height()); #else priv->m_window_content->setPos(1.0, window_bordr_height); content_geometry.setHeight(content_geometry.height() + 8); #endif setGeometry(content_geometry); } else if (priv->m_window_type == kNotificationWindow) { #ifdef __APPLE__ priv->m_window_content->setPos(15.0, window_bordr_height + 10); #else priv->m_window_content->setPos(0.0, window_bordr_height); #endif priv->m_window_close_button->hide(); setGeometry(content_geometry); } else if (priv->m_window_type == kPanelWindow) { priv->m_window_close_button->hide(); #ifdef __APPLE__ setGeometry(content_geometry); priv->m_window_content->setPos(15.0, window_bordr_height); a_widget_ptr->setFlag(QGraphicsItem::ItemIsMovable, false); #else setGeometry(priv->m_window_content->geometry()); priv->m_window_content->setPos(0, 4); #endif setFlag(QGraphicsItem::ItemIsMovable, false); setFlag(QGraphicsItem::ItemIsFocusable, true); } else if (priv->m_window_type == kPopupWindow) { priv->m_window_close_button->hide(); setGeometry(content_geometry); #ifdef __APPLE__ priv->m_window_content->setPos(15, window_bordr_height + 10); #else priv->m_window_content->setPos(0, window_bordr_height); #endif } else { priv->m_window_close_button->hide(); setGeometry(content_geometry); priv->m_window_content->setPos(0, window_bordr_height + window_title_height()); } if (priv->m_window_type != kFramelessWindow) { #ifndef __APPLE__ QGraphicsDropShadowEffect *lEffect = new QGraphicsDropShadowEffect(this); lEffect->setColor(QColor("#111111")); lEffect->setBlurRadius(26); lEffect->setXOffset(0); lEffect->setYOffset(0); setGraphicsEffect(lEffect); setCacheMode(NoCache); #endif } if (priv->m_window_type == kFramelessWindow) { setFlag(QGraphicsItem::ItemIsMovable, false); setFlag(QGraphicsItem::ItemIsFocusable, true); enable_window_background(false); } request_update(); }
void KeyWidget::paintEvent(QPaintEvent*){ const QColor bgColor(68, 64, 64); const QColor keyColor(112, 110, 110); const QColor sniperColor(130, 90, 90); const QColor highlightColor(136, 176, 240); const QColor highlightAnimColor(136, 200, 240); const QColor animColor(112, 200, 110); // Determine which keys to highlight QBitArray highlight; switch(mouseDownMode){ case SET: highlight = newSelection; break; case ADD: highlight = selection | newSelection; break; case SUBTRACT: highlight = selection & ~newSelection; break; case TOGGLE: highlight = selection ^ newSelection; break; default: highlight = selection; } QPainter painter(this); #if QT_VERSION >= QT_VERSION_CHECK(5, 3, 0) int ratio = painter.device()->devicePixelRatio(); #else int ratio = 1; #endif int wWidth = width(), wHeight = height(); KeyMap::Model model = keyMap.model(); float scale, offX, offY; drawInfo(scale, offX, offY); // Draw background painter.setPen(Qt::NoPen); painter.setRenderHint(QPainter::Antialiasing, true); if(model == KeyMap::M65){ // M65: Draw overlay if(!m65Overlay) m65Overlay = new QImage(":/img/overlay_m65.png"); const QImage& overlay = *m65Overlay; painter.setBrush(palette().brush(QPalette::Window)); painter.drawRect(0, 0, width(), height()); float oXScale = scale / 9.f, oYScale = scale / 9.f; // The overlay has a resolution of 9px per keymap unit float x = (2.f + offX) * scale, y = (-2.f + offY) * scale; // It is positioned at (2, -2) int w = overlay.width() * oXScale, h = overlay.height() * oYScale; // We need to transform the image with QImage::scaled() because painter.drawImage() will butcher it, even with smoothing enabled // However, the width/height need to be rounded to integers int iW = round(w), iH = round(h); painter.drawImage(QRectF(x - (iW - w) / 2.f, y - (iH - h) / 2.f, iW, iH), overlay.scaled(iW, iH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); } else { // Otherwise, draw a solid background painter.setBrush(QBrush(bgColor)); painter.drawRect(0, 0, width(), height()); } // Draw mouse highlight (if any) if(mouseDownMode != NONE && (mouseDownX != mouseCurrentX || mouseDownY != mouseCurrentY)){ int x1 = (mouseDownX > mouseCurrentX) ? mouseCurrentX : mouseDownX; int x2 = (mouseDownX > mouseCurrentX) ? mouseDownX : mouseCurrentX; int y1 = (mouseDownY > mouseCurrentY) ? mouseCurrentY : mouseDownY; int y2 = (mouseDownY > mouseCurrentY) ? mouseDownY : mouseCurrentY; painter.setPen(QPen(highlightColor, 0.5)); QColor bColor = highlightColor; bColor.setAlpha(128); painter.setBrush(QBrush(bColor)); painter.drawRect(x1, y1, x2 - x1, y2 - y1); } // Draw key backgrounds on a separate pixmap so that a drop shadow can be applied to them. QPixmap keyBG(wWidth * ratio, wHeight * ratio); keyBG.fill(QColor(0, 0, 0, 0)); QPainter bgPainter(&keyBG); bgPainter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); bgPainter.setPen(Qt::NoPen); QHashIterator<QString, Key> k(keyMap); uint i = -1; while(k.hasNext()){ k.next(); i++; const Key& key = k.value(); float x = key.x + offX - key.width / 2.f + 1.f; float y = key.y + offY - key.height / 2.f + 1.f; float w = key.width - 2.f; float h = key.height - 2.f; // In RGB mode, ignore keys without LEDs if((_rgbMode && !key.hasLed) || (!_rgbMode && !key.hasScan)) continue; // Set color based on key highlight bgPainter.setOpacity(1.); if(highlight.testBit(i)){ if(animation.testBit(i)) bgPainter.setBrush(QBrush(highlightAnimColor)); else bgPainter.setBrush(QBrush(highlightColor)); } else if(animation.testBit(i)){ bgPainter.setBrush(QBrush(animColor)); } else { if(!strcmp(key.name, "sniper")) // Sniper key uses a reddish base color instead of the usual grey bgPainter.setBrush(QBrush(sniperColor)); else { bgPainter.setBrush(QBrush(keyColor)); if(KeyMap::isMouse(model)) bgPainter.setOpacity(0.7); } } if(!strcmp(key.name, "mr") || !strcmp(key.name, "m1") || !strcmp(key.name, "m2") || !strcmp(key.name, "m3") || !strcmp(key.name, "light") || !strcmp(key.name, "lock") || (model == KeyMap::K65 && !strcmp(key.name, "mute"))){ // Switch keys are circular x += w / 8.f; y += h / 8.f; w *= 0.75f; h *= 0.75f; bgPainter.drawEllipse(QRectF(x * scale, y * scale, w * scale, h * scale)); } else { if(!strcmp(key.name, "enter")){ if(key.height == 24){ // ISO enter key isn't rectangular y = key.y + 1.f; h = 10.f; bgPainter.drawRect(QRectF((x + w - 13.f) * scale, y * scale, 13.f * scale, 22.f * scale)); } else { // US enter key isn't perfectly centered, needs an extra pixel on the left to appear correctly x -= 1.f; w += 1.f; } } else if(!strcmp(key.name, "rshift") || !strcmp(key.name, "stop")){ // A few other keys also need extra pixels x -= 1.f; w += 1.f; } else if(!strcmp(key.name, "caps") || !strcmp(key.name, "lshift") || !strcmp(key.name, "next")){ w += 1.f; } bgPainter.drawRect(QRectF(x * scale, y * scale, w * scale, h * scale)); } } // Render the key decorations (RGB -> light circles, binding -> key names) on yet another layer QPixmap decoration(wWidth * ratio, wHeight * ratio); decoration.fill(QColor(0, 0, 0, 0)); QPainter decPainter(&decoration); decPainter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); if(_rgbMode){ // Draw key colors (RGB mode) decPainter.setPen(QPen(QColor(255, 255, 255), 1.5)); QHashIterator<QString, Key> k(keyMap); uint i = -1; while(k.hasNext()){ k.next(); i++; const Key& key = k.value(); if(!key.hasLed) continue; float x = key.x + offX - 1.8f; float y = key.y + offY - 1.8f; float w = 3.6f; float h = 3.6f; if(_displayColorMap.contains(key.name)) decPainter.setBrush(QBrush(_displayColorMap.value(key.name))); else decPainter.setBrush(QBrush(_colorMap.value(key.name))); decPainter.drawEllipse(QRectF(x * scale, y * scale, w * scale, h * scale)); } } else { // Draw key names decPainter.setBrush(Qt::NoBrush); QFont font = painter.font(); font.setBold(true); font.setPixelSize(5.25f * scale); QFont font0 = font; QHashIterator<QString, Key> k(keyMap); uint i = -1; while(k.hasNext()){ k.next(); i++; const Key& key = k.value(); if(!key.hasScan) continue; float x = key.x + offX - key.width / 2.f + 1.f; float y = key.y + offY - key.height / 2.f; float w = key.width - 2.f; float h = key.height; // Print the key's friendly name (with some exceptions) QString keyName = KbBind::globalRemap(key.name); QString name = key.friendlyName(false); name = name.split(" ").last(); struct { const char* keyName, *displayName; } names[] = { {"light", "☼"}, {"lock", "☒"}, {"mute", "◖⊘"}, {"volup", keyMap.model() == KeyMap::K65 ? "◖))" : "▲"}, {"voldn", keyMap.model() == KeyMap::K65 ? "◖)" : "▼"}, {"prtscn", "PrtScn\nSysRq"}, {"scroll", "Scroll\nLock"}, {"pause", "Pause\nBreak"}, {"stop", "▪"}, {"prev", "|◂◂"}, {"play", "▸||"}, {"next", "▸▸|"}, {"pgup", "Page\nUp"}, {"pgdn", "Page\nDown"}, {"numlock", "Num\nLock"}, {"caps", "Caps"}, {"lshift", "Shift"}, {"rshift", "Shift"}, #ifdef Q_OS_MACX {"lctrl", "⌃"}, {"rctrl", "⌃"}, {"lwin", "⌘"}, {"rwin", "⌘"}, {"lalt", "⌥"}, {"ralt", "⌥"}, #else {"lctrl", "Ctrl"}, {"rctrl", "Ctrl"}, {"lwin", "❖"}, {"rwin", "❖"}, {"lalt", "Alt"}, {"ralt", "Alt"}, #endif {"rmenu", "▤"}, {"up", "▲"}, {"left", "◀"}, {"down", "▼"}, {"right", "▶"}, {"mouse1", ""}, {"mouse2", ""}, {"mouse3", "∙"}, {"dpiup", "▲"}, {"dpidn", "▼"}, {"wheelup", "▲"}, {"wheeldn", "▼"}, {"dpi", "◉"}, {"mouse5", "▲"}, {"mouse4", "▼"}, {"sniper", "⊕"} }; for(uint k = 0; k < sizeof(names) / sizeof(names[0]); k++){ if(keyName == names[k].keyName){ name = names[k].displayName; break; } } if(keyName == "mr" || keyName == "m1" || keyName == "m2" || keyName == "m3" || keyName == "up" || keyName == "down" || keyName == "left" || keyName == "right") // Use a smaller size for MR, M1 - M3, and arrow keys font.setPixelSize(font.pixelSize() * 0.75); else if(keyName == "end") // Use a smaller size for "End" to match everything else in that area font.setPixelSize(font.pixelSize() * 0.65); else if(keyName == "light" #ifndef Q_OS_MACX || keyName == "lwin" || keyName == "rwin" #endif ) // Use a larger font size for Super (Linux only) and Brightness to compensate for the unicode symbols looking smaller font.setPixelSize(font.pixelSize() * 1.3); // Determine the appropriate size to draw the text at decPainter.setFont(font); QRectF rect(x * scale, y * scale - 1, w * scale, h * scale); int flags = Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextWordWrap; QRectF bounds = decPainter.boundingRect(rect, flags, name); while((bounds.height() >= rect.height() - 8. || bounds.width() >= rect.width() - 2.) && font.pixelSize() >= 5){ // Scale font size down until it fits inside the key font.setPixelSize(font.pixelSize() - 2); decPainter.setFont(font); bounds = decPainter.boundingRect(rect, flags, name); } // Pick color based on key function QString bind = _bindMap.value(key.name); QString def = KbBind::defaultAction(key.name); if(bind.isEmpty()) // Unbound - red decPainter.setPen(QColor(255, 136, 136)); else if(KeyAction(bind).isProgram()) // Custom program - orange decPainter.setPen(QColor(255, 224, 192)); else if(KeyAction(bind).isSpecial() && (bind == def || !KeyAction(def).isSpecial())) // Special function - blue (only if not mapped to a different function - if a special function is remapped, color it yellow) decPainter.setPen(QColor(128, 224, 255)); else if(KeyAction(bind).isMedia() && (bind == def || !KeyAction(def).isMedia())) // Media key - green decPainter.setPen(QColor(160, 255, 168)); else if(bind == def) // Standard key - white decPainter.setPen(QColor(255, 255, 255)); else // Remapped key - yellow decPainter.setPen(QColor(255, 248, 128)); decPainter.drawText(rect, flags, name); font = font0; } } // Create drop shadow effects QGraphicsDropShadowEffect* bgEffect = new QGraphicsDropShadowEffect; // Have to use "new", creating these on the stack causes a crash... bgEffect->setBlurRadius(2.); bgEffect->setColor(QColor(0, 0, 0, 32)); bgEffect->setOffset(0, 1); QGraphicsDropShadowEffect* decEffect = new QGraphicsDropShadowEffect; decEffect->setBlurRadius(4.); decEffect->setColor(QColor(0, 0, 0, 104)); decEffect->setOffset(0, 1); // Apply them to the pixmaps QGraphicsPixmapItem* bgItem = new QGraphicsPixmapItem(keyBG); bgItem->setGraphicsEffect(bgEffect); QGraphicsPixmapItem* decItem = new QGraphicsPixmapItem(decoration); decItem->setGraphicsEffect(decEffect); // Render everything QGraphicsScene* scene = new QGraphicsScene; scene->addItem(bgItem); scene->addItem(decItem); // It has to be rendered onto yet another pixmap or else DPI scaling will look terrible... QPixmap final(wWidth * ratio, wHeight * ratio); final.fill(QColor(0, 0, 0, 0));
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { setupUi(this); Finished_Init = false; AllowInit = false; PreBuf_timer = new QTimer; Update_timer= new QTimer; Ping_timer= new QTimer; Spectrum_timer = new QTimer; BufferStatusUpdate_timer= new QTimer; singleClickTimer=new QTimer; m_msgbox = NULL; isPlaying=false; syncLost=false; currentRadio=NULL; currentTrack=""; dConnectionProgress=NULL; dDelConfirm=NULL; dShowHistory=NULL; netManager=NULL; currentRadioURL=-1; streamsErrLoop=false; pSpec=NULL; mMoving=false; savedVolume=0.5; isMuted=false; treeSelectionChanged=false; isRecording=false; newVersionAnimation=NULL; recButtonAnimation=NULL; isRootOperation=false; #ifdef VISUALS isVisResized=false; isVisRendering=false; visWin=new VisWinCL(this); bigVis=false; bigVisRunning=false; #endif initBitRate(); initOggQualityMap(); qDebug()<<"Cheking BASS version"; if (HIWORD(BASS_GetVersion())!=BASSVERSION) { qDebug()<<"An incorrect version of BASS.DLL was loaded"; QMessageBox::warning(this,QString("warning"),QString("An incorrect version of BASS.DLL was loaded")); } BASS_SetConfigPtr(BASS_CONFIG_NET_AGENT, (void*) _T(PLAYER_HTTPAGENT)); #ifdef Q_OS_WIN if (BASS_PluginLoad("bass_aac.dll",0)==0) { qDebug()<<"Unable to load bass_aac.ddl BassError="<<BASS_ErrorGetCode(); } #elif Q_OS_LINUX if (BASS_PluginLoad("bass_aac.so",0)==0) { qDebug()<<"Unable to load bass_aac.ddl BassError="<<BASS_ErrorGetCode(); } #endif QSettings tSettings(AppPath+CONFIG_FILENAME,QSettings::IniFormat); tSettings.setIniCodec("ISO 8859-1"); Proxy=tSettings.value("proxy","").toString(); ProxyPort=tSettings.value("proxyport","").toString(); ProxyUser=tSettings.value("proxyuser","").toString(); ProxyPass=tSettings.value("proxypass","").toString(); visualPlugin=tSettings.value("visual",VIS_WIN_PLUG).toString(); qDebug()<<"visualPlugin="<<visualPlugin; recPath=tSettings.value("recpath","").toString(); recPath=recPath.replace("\\","\\\\"); #ifdef Q_OS_WIN if (recPath!="" && recPath.at(recPath.length()-1)!='\\') recPath=recPath+"\\"; #else if (recPath!="" && recPath.at(recPath.length()-1)!='/') recPath=recPath+"/"; #endif if (recPath=="") { #ifdef Q_OS_WIN recPath=QDir::toNativeSeparators(QStandardPaths::standardLocations(QStandardPaths::MusicLocation).at(0)+"/"); #endif #ifdef Q_OS_MAC recPath=AppPath.fromLatin1(argv[0]); recPath+="/"; #endif } qDebug()<<"Recording path ="<<recPath; if (Proxy!="") { qDebug()<<"Proxy="<<Proxy; QString tBassProxyStr=ProxyUser; if (ProxyPass!="") tBassProxyStr+=":"+ProxyPass; if (ProxyUser!="") tBassProxyStr+="@"; tBassProxyStr+=Proxy+":"+ProxyPort; qDebug()<<"BASSProxy="<<tBassProxyStr; qDebug()<<"BASSProxy="<<tBassProxyStr.toLatin1().data(); //strcpy(proxyStrChar,Proxy.toLatin1().data()); BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY,tBassProxyStr.toLatin1().data()); //BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY,&proxyStrChar); } else { BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY, NULL); } //if( !InitVersion() ) ErrorMsgBox(_T("\n Error Setting up Version strings \n")); if( !InitBassErrorMap() ) ErrorMsgBox(_T("\n Error setting up Error Msgs \n")); if (!BASS_Init(-1,44100,0,NULL,NULL)) { ErrorMsgBox(_T("\nUnable to initialize BASS library\n"), 86, false); exit(86); } savedVolume=BASS_GetVolume(); slVolume->setValue(savedVolume*slVolume->maximum()); #ifdef Q_OS_WIN // allocate ACM format buffer, using suggested buffer size acmformlen = BASS_Encode_GetACMFormat(0,NULL,0,NULL,0); acmform = (WAVEFORMATEX*)malloc(acmformlen); memset(acmform,0,acmformlen); acmduncil = (WAVEFORMATEX*)malloc(acmformlen); memset(acmduncil, 0, acmformlen); // #endif connect(radioTree,SIGNAL(AddStationSig(QModelIndex,RadioCL*)),this,SLOT(AddStation(QModelIndex,RadioCL*))); connect(radioTree, SIGNAL(treeSelectionChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(radioTreeSelectionChanges(const QModelIndex &, const QModelIndex &))); qDebug()<<"Connecting timers signals "; connect(PreBuf_timer, SIGNAL(timeout()), this, SLOT(prebufTimeout())); connect(Update_timer, SIGNAL(timeout()), this, SLOT(updateTimeout())); connect(Ping_timer, SIGNAL(timeout()),this, SLOT(pingRadio())); connect(Spectrum_timer, SIGNAL(timeout()), this, SLOT(specTimeout())); connect(BufferStatusUpdate_timer, SIGNAL(timeout()),this, SLOT(updateBufferStatus())); connect(singleClickTimer, SIGNAL(timeout()),this, SLOT(singleClickTimeout())); qDebug()<<"Connecting mgh signals"; connect( &mgh, SIGNAL(SendUpdTrackInfo(QString)), this, SLOT(on_UpdTrackInfo(QString)) ); connect( &mgh, SIGNAL(SendUpdRadioInfo(QString,QString,QString,QString)), this, SLOT(on_UpdRadioInfo(QString,QString,QString,QString))); connect( &mgh, SIGNAL(SendSyncLost()), this, SLOT(on_SyncLost()) ); connect( &mgh, SIGNAL(SendPlaybackStarts()), this, SLOT(on_PlaybackStarts()) ); connect( &mgh, SIGNAL(SendClickRecord()), this, SLOT(on_ClickRecord()) ); qDebug()<<"Creating actions"; createActions(); qDebug()<<"Creating tray icon"; createTrayIcon(); qDebug()<<"Setting tray icon"; setIcon(PLAYER_STATUS_INACTIVE); trayIcon->setVisible(true); trayIcon->show(); setWindowTitle(QString(PLAYER_NAME)+" v"+RADIOLA_VERSION); qDebug()<<"Initializing spectrum image"; specbuf = NULL; specmode = DEFAULT_SPEC_MODE; // spectrum mode specpos = 0; // spectrum mode (and marker pos for 2nd mode) pSpec = new QImage(SPECWIDTH, SPECHEIGHT, QImage::Format_Indexed8); // setup palette pSpec->setColor(0, qRgb(0,0,0)); for(int a=1; a < 128; a++) { pSpec->setColor(a, qRgb(2*a, 256-2*a, 0)); } for(int a=0; a < 32; a++) { pSpec->setColor(128+a, qRgb(0, 0, 8*a)); pSpec->setColor(128+32+a, qRgb(8*a, 0, 255)); pSpec->setColor(128+64+a, qRgb(255, 8*a, 8*(31-a))); //pSpec->setColor(128+64+a, qRgb(8*(31-a), 8*a, 8*a)); pSpec->setColor(128+96+a, qRgb(255, 255, 8*a)); //pSpec->setColor(128+96+a, qRgb(255, 255, 8*a)); } pSpec->setColor(254, qRgb(112, 112, 255)); pSpec->setColor(253, qRgb(255, 128, 128)); pSpec->setColor(255, qRgb(212,208,200)); // background color // create the bitmap specbuf = (BYTE*)pSpec->bits(); pSpec->fill(255); specButton->setSpec(pSpec); readSettings(); qDebug()<<"Connecting tray signals "; connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); setupRadioTree(); historyFile.setFileName(GetHistoryDir()); if (!historyFile.open(QIODevice::ReadWrite | QIODevice::Append)) { qDebug()<<"Unable to open history file for write"<<historyFile.fileName(); return; } StopPlayback(); QIcon icon = QIcon(MAINWIN_ICON); setWindowIcon(icon); new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_S), this, SLOT(showSettings())); new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_E), this, SLOT(showRecPath())); new QShortcut(QKeySequence(Qt::Key_F1), this, SLOT(showHelp())); new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_H), this, SLOT(showHistory())); #ifdef Q_OS_WIN new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_V), this, SLOT(showVisualization())); #endif new QShortcut(QKeySequence(Qt::Key_Space), this, SLOT(on_pbPlay_clicked())); new QShortcut(QKeySequence(Qt::Key_MediaPlay), this, SLOT(on_pbPlay_clicked())); new QShortcut(QKeySequence(Qt::Key_Delete), this, SLOT(removeRow())); new QShortcut(QKeySequence(Qt::Key_Insert), this, SLOT(insertStation())); new QShortcut(QKeySequence(Qt::Key_Plus), this, SLOT(insertSubfolder())); QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect(); effect->setBlurRadius(1); //Adjust accordingly effect->setOffset(3,3); //Adjust accordingly setShadow(bnShowHistory); setShadow(pbPlay); setShadow(pbRecord); setShadow(pbQuit); recButtonAnimation=new QMovie(":/images/rec_animation.gif"); connect(recButtonAnimation,SIGNAL(frameChanged(int)),this,SLOT(setRecButtonIcon(int))); singleClickTimer->setInterval(QApplication::doubleClickInterval()); singleClickTimer->setSingleShot(true); CheckNewVersion(); netManager = new QNetworkAccessManager(this); if (Proxy!="") { netManager->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy,Proxy,ProxyPort.toInt(),ProxyUser,ProxyPass)); } connect(netManager, SIGNAL(finished(QNetworkReply*)),this, SLOT(pingReply(QNetworkReply*))); }
ProcessorGraphicsItem::ProcessorGraphicsItem(Processor* processor) : ProcessorObserver() , LabelGraphicsItemObserver() , processor_(processor) , processorMeta_(nullptr) , progressItem_(nullptr) , statusItem_(nullptr) , linkItem_(nullptr) , highlight_(false) #if IVW_PROFILING , processCount_(0) , countLabel_(nullptr) , maxEvalTime_(0.0) , evalTime_(0.0) , totEvalTime_(0.0) #endif { setZValue(PROCESSORGRAPHICSITEM_DEPTH); setFlags(ItemIsMovable | ItemIsSelectable | ItemIsFocusable | ItemSendsGeometryChanges); setCacheMode(QGraphicsItem::DeviceCoordinateCache); setRect(-width / 2, -height / 2, width, height); QGraphicsDropShadowEffect* processorShadowEffect = new QGraphicsDropShadowEffect(); processorShadowEffect->setOffset(3.0); processorShadowEffect->setBlurRadius(3.0); setGraphicsEffect(processorShadowEffect); nameLabel_ = new LabelGraphicsItem(this); nameLabel_->setCrop(9, 8); nameLabel_->setPos(-width / 2.0 + labelHeight, -height / 2.0 + 0.6 * labelHeight); nameLabel_->setDefaultTextColor(Qt::white); QFont nameFont("Segoe", labelHeight, QFont::Black, false); nameFont.setPixelSize(pointSizeToPixelSize(labelHeight)); nameLabel_->setFont(nameFont); LabelGraphicsItemObserver::addObservation(nameLabel_); classLabel_ = new LabelGraphicsItem(this); classLabel_->setCrop(9, 8); classLabel_->setPos(-width / 2.0 + labelHeight, -height / 2.0 + labelHeight * 2.0); classLabel_->setDefaultTextColor(Qt::lightGray); QFont classFont("Segoe", labelHeight, QFont::Normal, true); classFont.setPixelSize(pointSizeToPixelSize(labelHeight)); classLabel_->setFont(classFont); nameLabel_->setText(QString::fromStdString(processor_->getIdentifier())); classLabel_->setText(QString::fromStdString(processor_->getDisplayName() + " " + processor_->getTags().getString())); processor_->ProcessorObservable::addObserver(this); processorMeta_ = processor->getMetaData<ProcessorMetaData>(ProcessorMetaData::CLASS_IDENTIFIER); processorMeta_->addObserver(this); linkItem_ = new ProcessorLinkGraphicsItem(this); std::vector<Inport*> inports = processor_->getInports(); std::vector<Outport*> outports = processor_->getOutports(); inportX = rect().left() + 12.5f; inportY = rect().top() + 4.5f; outportX = rect().left() + 12.5f; outportY = rect().bottom() - 4.5f; for (auto& inport : inports) { addInport(inport); } for (auto& outport : outports) { addOutport(outport); } statusItem_ = new ProcessorStatusGraphicsItem(this, processor_); if (auto progressBarOwner = dynamic_cast<ProgressBarOwner*>(processor_)) { progressItem_ = new ProcessorProgressGraphicsItem(this, &(progressBarOwner->getProgressBar())); progressBarOwner->getProgressBar().ActivityIndicator::addObserver(statusItem_); } if (auto activityInd = dynamic_cast<ActivityIndicatorOwner*>(processor_)){ activityInd->getActivityIndicator().addObserver(statusItem_); } #if IVW_PROFILING countLabel_ = new LabelGraphicsItem(this); countLabel_->setCrop(9,8); countLabel_->setPos(rect().left() + labelHeight, height / 2 - labelHeight*2.5); countLabel_->setDefaultTextColor(Qt::lightGray); countLabel_->setFont(classFont); countLabel_->setTextWidth(width - 2*labelHeight); #endif setVisible(processorMeta_->isVisible()); setSelected(processorMeta_->isSelected()); setPos(QPointF(processorMeta_->getPosition().x, processorMeta_->getPosition().y)); }
Principal::Principal() { // On crée un QSettings QSettings::Format XmlFormat = QSettings::registerFormat("xml", readXmlFile, writeXmlFile); QSettings::setPath(XmlFormat, QSettings::UserScope,QDir::currentPath()); QSettings settings(XmlFormat, QSettings::UserScope, "settings"); //settings.clear(); // Remet tous les paramètres à leur valeur par défaut // Initialisation des attributs avec le QSettings // urlFiltreDevises = settings.value("afficherDevises/urlchoixCouples", "WHERE jour=date('now')").toString() ; urlChoixDevises = settings.value("Options/urlChoixCouples", "1; 2; 3; 4; 6; 9; 10; 11; 12; 13;").toString() ; serveur = settings.value("Options/serveur", "127.0.0.1").toString(); nomBdd = settings.value("Options/nomBdd", "bddForex.db").toString() ; loginBdd = settings.value("Options/loginBdd", "admin").toString() ; passwordBdd = settings.value("Options/passwordBdd", "admin").toString() ; urlForex = settings.value("Options/urlForex", "http://fxrates.investing.com").toString() ; //http://fxrates.fr.forexprostools.com pour le site francais delaiTimer = settings.value("Options/timer", 10000).toInt() ; // On crée la base de donnée et le modèle qui la lira, // on crée aussi un modele de filtre qui sera placé entre le modele // et la vue. // Et on initialise un webview qui enverra la requete HTTP et qui // appelle la méthode recupereDonnees a chaque fois qu'il aura recu // la réponse du site source. // creerBdd() ; modeleQ = new QSqlQueryModel ; QSortFilterProxyModel* proxyModel = new QSortFilterProxyModel; proxyModel->setSourceModel( modeleQ ); rafraichitSQLQueryModel(); webView = new QWebView(this); webView->hide(); connect (webView, SIGNAL(loadFinished(bool)), this, SLOT(recupereDonnees())) ; // On lance la requete http et on lance le timer // pour répéter la requete à intervalle régulier // connexionHttp(); QTimer* timerRequete = new QTimer(); connect (timerRequete, SIGNAL(timeout()), this, SLOT(connexionHttp())) ; timerRequete->start(delaiTimer); // Design de la fenêtre principale // setWindowIcon(QIcon(":/images/glyphicons-264-bank.png")); zoneCentrale = new QWidget; // Barre de menu QMenuBar* barreDeMenu = menuBar() ; QMenu* menuFichier = barreDeMenu->addMenu("Système") ; QMenu* menuDevises = barreDeMenu->addMenu("Affichage") ; menuFichier->addAction(QIcon(":/images/glyphicons-140-adjust-alt.png"), "Options", this, SLOT(options())) ; menuFichier->addAction(QIcon(":/images/glyphicons-64-power.png"),"Quitter", qApp, SLOT(quit())) ; menuDevises->addAction(QIcon(":/images/glyphicons-517-menu-hamburger.png"),"Choix d'affichage", this, SLOT(choixCoupleDevises())) ; menuDevises->addAction(QIcon(":/images/glyphicons-42-charts.png"),"Affichage des courbes", this, SLOT(afficheGraphique())) ; menuDevises->addAction(QIcon(":/images/glyphicons-46-calendar.png"),"Intervalle de temps", this, SLOT(intervalleTemps())) ; menuDevises->addAction(QIcon(":/images/glyphicons-81-retweet.png"),"Simulation de transactions", this, SLOT(simulationTransaction())) ; menuDevises->addAction(QIcon(":/images/glyphicons-228-usd.png"),"Calculateur de profit", this, SLOT(transactionAuto())) ; // Le tableview qui affichera les cotations en temps réel tableView = new QTableView(this); tableView->setObjectName("view"); tableView->setModel(proxyModel); tableView->verticalHeader()->hide(); tableView->setShowGrid(false); tableView->setSortingEnabled(true); tableView->sortByColumn(0, Qt::AscendingOrder); tableView->verticalHeader()->setDefaultSectionSize(20); tableView->horizontalHeader()->setDefaultSectionSize(80); tableView->horizontalHeader()->setStretchLastSection(true); tableView->setSelectionBehavior(QAbstractItemView::SelectRows); tableView->setMinimumSize(500,400); connect (tableView, SIGNAL(clicked(QModelIndex)), this, SLOT(requeteGraph(QModelIndex))) ; // Le graphique de courbes qui affichera les valeurs du couple de devises sélectionné. graph = new QWebView ; graph->hide(); graph->load(QUrl("http://charts.investing.com/index.php?pair_ID=1×cale=300&candles=50&style=line")); graph->setMinimumSize(600,400); graph->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); // Les boutons permettant d'accéder aux différentes fonctions de l'application QPushButton* boutonGraph = new QPushButton("Graphique"); connect (boutonGraph, SIGNAL(clicked()), this, SLOT(afficheGraphique())); QPushButton* boutonInterval = new QPushButton("Intervalle"); connect (boutonInterval, SIGNAL(clicked()), this, SLOT(intervalleTemps())); QPushButton* boutonSimulation = new QPushButton("Simulation"); connect (boutonSimulation, SIGNAL(clicked()), this, SLOT(simulationTransaction())); QPushButton* boutonTransaction = new QPushButton("Profit"); connect (boutonTransaction, SIGNAL(clicked()), this, SLOT(transactionAuto())); // On place le tout dans des layouts QHBoxLayout* layoutBoutons = new QHBoxLayout; layoutBoutons->addStretch(); layoutBoutons->addWidget(boutonGraph); layoutBoutons->addWidget(boutonInterval); layoutBoutons->addWidget(boutonSimulation); layoutBoutons->addWidget(boutonTransaction); layoutBoutons->addStretch(); layoutGauche = new QVBoxLayout; layoutGauche->addWidget(tableView); layoutGauche->addLayout(layoutBoutons); layoutGauche->addStretch(); layoutDroit = new QVBoxLayout; layoutDroit->addWidget(graph); layout = new QHBoxLayout; layout->addLayout(layoutGauche); layout->addStretch(); layout->addLayout(layoutDroit); zoneCentrale->setLayout(layout); setCentralWidget(zoneCentrale); // On rajoute quelques effets graphiques QGraphicsOpacityEffect* effetTransparent = new QGraphicsOpacityEffect; effetTransparent->setOpacity(0.9); QGraphicsDropShadowEffect * ombrePortee = new QGraphicsDropShadowEffect(); ombrePortee->setBlurRadius(10); ombrePortee->setOffset(4); tableView->setGraphicsEffect(ombrePortee); graph->setGraphicsEffect(effetTransparent); // Et on applique la feuille de style // définie dans le fichier d'entête CssStyleSheet.h qApp->setStyleSheet(stylesheet); }
CustomColorDialog::CustomColorDialog(QWidget *parent) : QFrame(parent ) { setFrameStyle(QFrame::NoFrame); setFrameShape(QFrame::StyledPanel); setFrameShadow(QFrame::Sunken); QGraphicsDropShadowEffect *dropShadowEffect = new QGraphicsDropShadowEffect; dropShadowEffect->setBlurRadius(6); dropShadowEffect->setOffset(2, 2); setGraphicsEffect(dropShadowEffect); setAutoFillBackground(true); m_hueControl = new HueControl(this); m_colorBox = new ColorBox(this); QWidget *colorFrameWidget = new QWidget(this); QVBoxLayout* vBox = new QVBoxLayout(colorFrameWidget); colorFrameWidget->setLayout(vBox); vBox->setSpacing(0); vBox->setMargin(0); vBox->setContentsMargins(0,5,0,28); m_beforeColorWidget = new QFrame(colorFrameWidget); m_beforeColorWidget->setFixedSize(30, 18); m_beforeColorWidget->setAutoFillBackground(true); m_currentColorWidget = new QFrame(colorFrameWidget); m_currentColorWidget->setFixedSize(30, 18); m_currentColorWidget->setAutoFillBackground(true); vBox->addWidget(m_beforeColorWidget); vBox->addWidget(m_currentColorWidget); m_rSpinBox = new QDoubleSpinBox(this); m_gSpinBox = new QDoubleSpinBox(this); m_bSpinBox = new QDoubleSpinBox(this); m_alphaSpinBox = new QDoubleSpinBox(this); QGridLayout *gridLayout = new QGridLayout(this); gridLayout->setSpacing(4); gridLayout->setVerticalSpacing(4); gridLayout->setMargin(4); setLayout(gridLayout); gridLayout->addWidget(m_colorBox, 0, 0, 4, 1); gridLayout->addWidget(m_hueControl, 0, 1, 4, 1); gridLayout->addWidget(colorFrameWidget, 0, 2, 2, 1); gridLayout->addWidget(new QLabel("R", this), 0, 3, 1, 1); gridLayout->addWidget(new QLabel("G", this), 1, 3, 1, 1); gridLayout->addWidget(new QLabel("B", this), 2, 3, 1, 1); gridLayout->addWidget(new QLabel("A", this), 3, 3, 1, 1); gridLayout->addWidget(m_rSpinBox, 0, 4, 1, 1); gridLayout->addWidget(m_gSpinBox, 1, 4, 1, 1); gridLayout->addWidget(m_bSpinBox, 2, 4, 1, 1); gridLayout->addWidget(m_alphaSpinBox, 3, 4, 1, 1); QDialogButtonBox *buttonBox = new QDialogButtonBox(this); QPushButton *cancelButton = buttonBox->addButton(QDialogButtonBox::Cancel); QPushButton *applyButton = buttonBox->addButton(QDialogButtonBox::Apply); gridLayout->addWidget(buttonBox, 4, 0, 1, 2); resize(sizeHint()); connect(m_colorBox, SIGNAL(colorChanged()), this, SLOT(onColorBoxChanged())); connect(m_alphaSpinBox, SIGNAL(valueChanged(double)), this, SLOT(spinBoxChanged())); connect(m_rSpinBox, SIGNAL(valueChanged(double)), this, SLOT(spinBoxChanged())); connect(m_gSpinBox, SIGNAL(valueChanged(double)), this, SLOT(spinBoxChanged())); connect(m_bSpinBox, SIGNAL(valueChanged(double)), this, SLOT(spinBoxChanged())); connect(m_hueControl, SIGNAL(hueChanged(int)), this, SLOT(onHueChanged(int))); connect(applyButton, SIGNAL(pressed()), this, SLOT(onAccept())); connect(cancelButton, SIGNAL(pressed()), this, SIGNAL(rejected())); m_alphaSpinBox->setMaximum(1); m_rSpinBox->setMaximum(1); m_gSpinBox->setMaximum(1); m_bSpinBox->setMaximum(1); m_alphaSpinBox->setSingleStep(0.1); m_rSpinBox->setSingleStep(0.1); m_gSpinBox->setSingleStep(0.1); m_bSpinBox->setSingleStep(0.1); m_blockUpdate = false; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), selectInteractor(0), newLineItemInteractor(0), newRectItemInteractor(0), newTextItemInteractor(0) { setObjectName(QStringLiteral("MainWindow")); resize(1024, 768); graphicsSheet = new GraphicsSheet(this); QList<QString> itemClasses = graphicsSheet->getSupportedItemClasses(); qDebug() << "Item classes supported by the graphics sheet:"; qDebug() << itemClasses; QGraphicsDropShadowEffect* shadow = new QGraphicsDropShadowEffect(graphicsSheet); shadow->setBlurRadius(20); shadow->setColor(QColor(0xa0, 0xa0, 0xa0)); graphicsSheet->setGraphicsEffect(shadow); graphicsSheet->setScaleBackground(QColor(0xFF, 0xFF, 0xF8)); QLayout* layout = new ScrollAreaLayout(); layout->addWidget(graphicsSheet); QWidget *centralwidget = new QWidget(this); centralwidget->setLayout(layout); setCentralWidget(centralwidget); /*****************************************************************************/ menubar = new QMenuBar(this); menubar->setObjectName(QStringLiteral("menubar")); menubar->setGeometry(QRect(0, 0, 401, 21)); setMenuBar(menubar); statusbar = new QStatusBar(this); statusbar->setObjectName(QStringLiteral("statusbar")); setStatusBar(statusbar); toolBar = new QToolBar(this); toolBar->setObjectName(QStringLiteral("toolBar")); addToolBar(Qt::TopToolBarArea, toolBar); /*****************************************************************************/ /* Initialize zoom, scale, and paper formats */ graphicsSheet->addScale("1:10", 0.1); graphicsSheet->addScale("1:5", 0.2); graphicsSheet->addScale("1:2", 0.5); graphicsSheet->addScale("1:1", 1.0); graphicsSheet->addScale("2:1", 2.0); graphicsSheet->addScale("5:1", 5.0); graphicsSheet->addScale("10:1", 10.0); LabelledComboBox* scaleWidget = new LabelledComboBox(toolBar, "Scale: "); scaleWidget->getComboBox()->addItems(graphicsSheet->getScaleNames()); toolBar->addWidget(scaleWidget); QObject::connect(scaleWidget->getComboBox(), SIGNAL(currentIndexChanged(int)), graphicsSheet, SLOT(setScale(int))); graphicsSheet->addZoom("50%", 0.5); graphicsSheet->addZoom("75%", 0.75); graphicsSheet->addZoom("100%", 1.0); graphicsSheet->addZoom("125%", 1.25); graphicsSheet->addZoom("150%", 1.5); graphicsSheet->addZoom("200%", 2.0); LabelledComboBox* zoomWidget = new LabelledComboBox(toolBar, "Zoom: "); zoomWidget->getComboBox()->addItems(graphicsSheet->getZoomNames()); toolBar->addWidget(zoomWidget); QObject::connect(zoomWidget->getComboBox(), SIGNAL(currentIndexChanged(int)), graphicsSheet, SLOT(setZoom(int))); graphicsSheet->setUnit("mm"); graphicsSheet->addSize("DIN A3", QSizeF(297.0, 420.0)); graphicsSheet->addSize("DIN A4", QSizeF(210.0, 297.0)); graphicsSheet->addSize("Letter", QSizeF(215.9, 279.4)); graphicsSheet->addSize("DIN A5", QSizeF(148.0, 210.0)); LabelledComboBox* sizeWidget = new LabelledComboBox(toolBar, "Sheet Size: "); sizeWidget->getComboBox()->addItems(graphicsSheet->getSizeNames()); toolBar->addWidget(sizeWidget); QObject::connect(sizeWidget->getComboBox(), SIGNAL(currentIndexChanged(int)), graphicsSheet, SLOT(setSize(int))); QCheckBox* checkbox = new QCheckBox("Landscape", toolBar); toolBar->addWidget(checkbox); QObject::connect(checkbox, SIGNAL(stateChanged(int)), graphicsSheet, SLOT(setDirection(int))); QIcon icon; icon.addFile(QStringLiteral(":/Icons/file-load.png"), QSize(), QIcon::Normal, QIcon::Off); actionLoad = new QAction(icon, "Load drawing ...", this); toolBar->addAction(actionLoad); QObject::connect(actionLoad, SIGNAL(triggered()), this, SLOT(doActionLoad())); QIcon icon2; icon2.addFile(QStringLiteral(":/Icons/file-save.png"), QSize(), QIcon::Normal, QIcon::Off); actionSave = new QAction(icon2, "Save drawing", this); toolBar->addAction(actionSave); QObject::connect(actionSave, SIGNAL(triggered()), this, SLOT(doActionSave())); QIcon icon3; icon3.addFile(QStringLiteral(":/Icons/file-save-as.png"), QSize(), QIcon::Normal, QIcon::Off); actionSaveAs = new QAction(icon3, "Save drawing as ...", this); toolBar->addAction(actionSaveAs); QObject::connect(actionSaveAs, SIGNAL(triggered()), this, SLOT(doActionSaveAs())); QIcon icon4; icon4.addFile(QStringLiteral(":/Icons/object-select.png"), QSize(), QIcon::Normal, QIcon::Off); actionSelect = new QAction(icon4, "Edit object", this); actionSelect->setCheckable(true); toolBar->addAction(actionSelect); QObject::connect(actionSelect, SIGNAL(triggered()), this, SLOT(doActionSelect())); QIcon icon5; icon5.addFile(QStringLiteral(":/Icons/object-newline.png"), QSize(), QIcon::Normal, QIcon::Off); actionNewLineItem = new QAction(icon5, "New line", this); actionNewLineItem->setCheckable(true); toolBar->addAction(actionNewLineItem); QObject::connect(actionNewLineItem, SIGNAL(triggered()), this, SLOT(doActionNewLineItem())); QIcon icon6; icon6.addFile(QStringLiteral(":/Icons/object-newrect.png"), QSize(), QIcon::Normal, QIcon::Off); actionNewRectItem = new QAction(icon6, "New rectangle", this); actionNewRectItem->setCheckable(true); toolBar->addAction(actionNewRectItem); QObject::connect(actionNewRectItem, SIGNAL(triggered()), this, SLOT(doActionNewRectItem())); QIcon icon7; icon7.addFile(QStringLiteral(":/Icons/object-newtext.png"), QSize(), QIcon::Normal, QIcon::Off); actionNewTextItem = new QAction(icon7, "New text rectangle", this); actionNewTextItem->setCheckable(true); toolBar->addAction(actionNewTextItem); QObject::connect(actionNewTextItem, SIGNAL(triggered()), this, SLOT(doActionNewTextItem())); QIcon icon8; icon8.addFile(QStringLiteral(":/Icons/object-newcircle.png"), QSize(), QIcon::Normal, QIcon::Off); actionNewCircleItem = new QAction(icon8, "New circle", this); actionNewCircleItem->setCheckable(true); toolBar->addAction(actionNewCircleItem); QObject::connect(actionNewCircleItem, SIGNAL(triggered()), this, SLOT(doActionNewCircleItem())); QIcon icon9; icon9.addFile(QStringLiteral(":/Icons/object-newellipse.png"), QSize(), QIcon::Normal, QIcon::Off); actionNewEllipseItem = new QAction(icon9, "New ellipse", this); actionNewEllipseItem->setCheckable(true); toolBar->addAction(actionNewEllipseItem); QObject::connect(actionNewEllipseItem, SIGNAL(triggered()), this, SLOT(doActionNewEllipseItem())); QIcon icon10; icon10.addFile(QStringLiteral(":/Icons/object-newbezier.png"), QSize(), QIcon::Normal, QIcon::Off); actionNewBezierItem = new QAction(icon10, "New bezier curve", this); actionNewBezierItem->setCheckable(true); toolBar->addAction(actionNewBezierItem); QObject::connect(actionNewBezierItem, SIGNAL(triggered()), this, SLOT(doActionNewBezierItem())); QIcon icon11; icon11.addFile(QStringLiteral(":/Icons/object-delete.png"), QSize(), QIcon::Normal, QIcon::Off); actionDeleteItem = new QAction(icon11, "Delete selected objects", this); toolBar->addAction(actionDeleteItem); QObject::connect(actionDeleteItem, SIGNAL(triggered()), graphicsSheet, SLOT(deleteSelectedItems())); QIcon icon12; icon12.addFile(QStringLiteral(":/Icons/edit-redo.png"), QSize(), QIcon::Normal, QIcon::Off); actionRedo = new QAction(icon12, "Redo last undone action", this); toolBar->addAction(actionRedo); QObject::connect(actionRedo, SIGNAL(triggered()), this, SLOT(doActionRedo())); QIcon icon13; icon13.addFile(QStringLiteral(":/Icons/edit-undo.png"), QSize(), QIcon::Normal, QIcon::Off); actionUndo = new QAction(icon13, "Undo last action", this); toolBar->addAction(actionUndo); QObject::connect(actionUndo, SIGNAL(triggered()), this, SLOT(doActionUndo())); QActionGroup* actionGroup = new QActionGroup(this); actionGroup->addAction(actionSelect); actionGroup->addAction(actionNewLineItem); actionGroup->addAction(actionNewRectItem); actionGroup->addAction(actionNewTextItem); actionGroup->addAction(actionNewCircleItem); actionGroup->addAction(actionNewEllipseItem); actionGroup->addAction(actionNewBezierItem); actionSelect->setChecked(true); #if 0 QAction* actionInfo = new QAction("Info", this); toolBar->addAction(actionInfo); QObject::connect(actionInfo, SIGNAL(triggered(bool)), this, SLOT(printInfo())); QAction* actionRotate = new QAction("Rotate", this); toolBar->addAction(actionRotate); QObject::connect(actionRotate, SIGNAL(triggered(bool)), this, SLOT(rotateItem())); QAction* actionResize = new QAction("ResizeHandle", this); toolBar->addAction(actionResize); QObject::connect(actionResize, SIGNAL(triggered(bool)), this, SLOT(resizeItem())); #endif zoomWidget->getComboBox()->setCurrentIndex(2); sizeWidget->getComboBox()->setCurrentIndex(3); scaleWidget->getComboBox()->setCurrentIndex(2); checkbox->setChecked(true); /*****************************************************************************/ GraphicsScene* scene = dynamic_cast<GraphicsScene*>(graphicsSheet->scene()); QObject::connect(scene, SIGNAL(selectionChanged()), this, SLOT(selectionChanged())); scene->loadFromFile("sample.drw"); selectInteractor = new EditItemInteractor(); newLineItemInteractor = graphicsSheet->createNewItemInteractor("LineItem"); QObject::connect(newLineItemInteractor, SIGNAL(editDone()), this, SLOT(toggleActionSelect())); newRectItemInteractor = graphicsSheet->createNewItemInteractor("RectItem"); QObject::connect(newRectItemInteractor, SIGNAL(editDone()), this, SLOT(toggleActionSelect())); newTextItemInteractor = graphicsSheet->createNewItemInteractor("TextItem"); QObject::connect(newTextItemInteractor, SIGNAL(editDone()), this, SLOT(toggleActionSelect())); newCircleItemInteractor = graphicsSheet->createNewItemInteractor("CircleItem"); QObject::connect(newCircleItemInteractor, SIGNAL(editDone()), this, SLOT(toggleActionSelect())); newEllipseItemInteractor = graphicsSheet->createNewItemInteractor("EllipseItem"); QObject::connect(newEllipseItemInteractor, SIGNAL(editDone()), this, SLOT(toggleActionSelect())); newBezierItemInteractor = graphicsSheet->createNewItemInteractor("BezierItem"); QObject::connect(newBezierItemInteractor, SIGNAL(editDone()), this, SLOT(toggleActionSelect())); graphicsSheet->setInteractor(selectInteractor); graphicsSheet->setSnapper(new EdgeSnapper(new GridSnapper())); propertyEditor = new ObjectController(); QDockWidget* propertiesDock = new QDockWidget(this); propertiesDock->setObjectName(QStringLiteral("propertiesDock")); propertiesDock->setFeatures(QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable); propertiesDock->setWindowTitle("Item properties"); propertiesDock->setWidget(propertyEditor); addDockWidget(static_cast<Qt::DockWidgetArea>(2), propertiesDock); }
Channel::Channel(int channel, ChannelSettings& channelSettings, QWidget* parent) : QWidget(parent) , _channel(channel) , _channelSettings(channelSettings) , _curvePlot(new QCustomPlot(this)) { ui.setupUi(this); //QPalette::ColorRole ui.dialFactor->setBackgroundRole(QPalette::ColorRole::Highlight); //ui.dialFactor->setPalette(qApp->palette()); QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect(); effect->setBlurRadius(30); effect->setOffset(0, 0); ui.btnSumScan->setGraphicsEffect(effect); _curvePlot->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); _curvePlot->setBackground(qApp->palette().button()); QPen pen(qApp->palette().midlight().color()); pen.setStyle(Qt::PenStyle::DotLine); _curvePlot->xAxis->grid()->setPen(pen); _curvePlot->yAxis->grid()->setPen(pen); _curvePlot->xAxis2->grid()->setPen(pen); _curvePlot->yAxis2->grid()->setPen(pen); _curvePlot->xAxis->setTicks(false); _curvePlot->yAxis->setTicks(false); _curvePlot->xAxis2->setTicks(false); _curvePlot->yAxis2->setTicks(false); ui.layoutCurvePlot->addWidget(_curvePlot); QStringList notes; notes << "C" << "C#" << "D" << "D#" << "E" << "F" << "F#" << "G" << "G#" << "A" << "A#" << "B"; QStringList oktaves; for(int i = 0; i < 128; ++i) { oktaves << QString::number(int(i / 12) - 1) + " " + notes[i % 12] + ""; } ui.cbNote->clear(); ui.cbNote->addItems(oktaves); auto curve = _curvePlot->addGraph(); curve->setPen(QPen(qApp->palette().buttonText().color())); _curvePlot->xAxis->setRange(0, 127); _curvePlot->yAxis->setRange(0, 127); _curvePlot->setMinimumHeight(60); //auto thresholdCurve = _curvePlot->addGraph(_curvePlot->xAxis, _curvePlot->yAxis); //thresholdCurve->setPen(QPen(Qt::red)); _curvePlot->axisRect()->setAutoMargins(QCP::msNone); _curvePlot->axisRect()->setMargins(QMargins(1, 1, 1, 1)); ui.leName->setPlaceholderText("Channel " + QString::number(channel + 1)); update(); connect(ui.leName, &QLineEdit::editingFinished, [this]() { auto name = ui.leName->text(); memset(_channelSettings.name, 0, sizeof(_channelSettings.name)); auto size = std::min((size_t)name.size() * sizeof(QChar), sizeof(_channelSettings.name) - 1); memcpy(_channelSettings.name, name.data(), size); update(); }); connect(ui.cbSensor, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [this](int index) {_channelSettings.type = (Type)index; update(); }); connect(ui.cbNote, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [this](int index) {_channelSettings.note = index; update(); }); connect(ui.dialThreshold, &QDial::valueChanged, [this](int value) {_channelSettings.threshold = value; update(); }); connect(ui.btnSumScan, &QPushButton::toggled, [this](bool checked) {_channelSettings.sum = checked; update(); }); connect(ui.dialScanTime, &QDial::valueChanged, [this](int value) {_channelSettings.scanTime = value; update(); }); connect(ui.dialMaskTime, &QDial::valueChanged, [this](int value) {_channelSettings.maskTime = value; update(); }); connect(ui.cbCurveType, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [this](int index) { _channelSettings.curve.type = (Curve)index; update(); }); connect(ui.dialValue, &QDial::valueChanged, [this](int value) {_channelSettings.curve.value = value; update(); }); connect(ui.dialOffset, &QDial::valueChanged, [this](int value) {_channelSettings.curve.offset = value; update(); }); connect(ui.dialFactor, &QDial::valueChanged, [this](int value) {_channelSettings.curve.factor = value; update(); }); }
void Button::init() { setFlags(ItemIsFocusable); setAcceptHoverEvents(true); setAcceptedMouseButtons(Qt::LeftButton); title = new QPixmap(size.toSize()); title->fill(QColor(0, 0, 0, 0)); QPainter pt(title); pt.setFont(font); pt.setPen(Config.TextEditColor); pt.setRenderHint(QPainter::TextAntialiasing); pt.drawText(boundingRect(), Qt::AlignCenter, label); title_item = new QGraphicsPixmapItem(this); title_item->setPixmap(*title); title_item->show(); QGraphicsDropShadowEffect *de = new QGraphicsDropShadowEffect; de->setOffset(0); de->setBlurRadius(12); de->setColor(QColor(255, 165, 0)); title_item->setGraphicsEffect(de); QImage bgimg("image/system/button/button.png"); outimg = new QImage(size.toSize(), QImage::Format_ARGB32); qreal pad = 10; int w = bgimg.width(); int h = bgimg.height(); int tw = outimg->width(); int th = outimg->height(); qreal xc = (w - 2 * pad) / (tw - 2 * pad); qreal yc = (h - 2 * pad) / (th - 2 * pad); for (int i = 0; i < tw; i++) { for (int j = 0; j < th; j++) { int x = i; int y = j; if (x >= pad && x <= (tw - pad)) x = pad + (x - pad) * xc; else if (x >= (tw - pad)) x = w - (tw - x); if (y >= pad && y <= (th - pad)) y = pad + (y - pad) * yc; else if (y >= (th - pad)) y = h - (th - y); QRgb rgb = bgimg.pixel(x, y); outimg->setPixel(i, j, rgb); } } QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect; effect->setBlurRadius(5); effect->setOffset(this->boundingRect().height() / 7.0); effect->setColor(QColor(0, 0, 0, 200)); this->setGraphicsEffect(effect); glow = 0; timer_id = 0; }
void QBrick::draw(){ if(brick == nullptr){ setText(""); setStyleSheet("QBrick { background: rgb(204,192,179); border-radius: 10px; }"); } else{ int brickNum = brick->getVal(); setText(QString::number(brickNum)); // Set corresponding colors if(brickNum == 2){ setStyleSheet("QBrick { background: rgb(238,228,218); color: rgb(119,110,101); font: bold; border-radius: 10px; font: 40pt; }"); } else if(brickNum == 4){ setStyleSheet("QBrick { background: rgb(237,224,200); color: rgb(119,110,101); font: bold; border-radius: 10px; font: 40pt; }"); } else if(brickNum == 8){ setStyleSheet("QBrick { background: rgb(242,177,121); color: rgb(255,255,255); font: bold; border-radius: 10px; font: 40pt; }"); } else if(brickNum == 16){ setStyleSheet("QBrick { background: rgb(245,150,100); color: rgb(255,255,255); font: bold; border-radius: 10px; font: 40pt; }"); } else if(brickNum == 32){ setStyleSheet("QBrick { background: rgb(245,125,95); color: rgb(255,255,255); font: bold; border-radius: 10px; font: 40pt; }"); } else if(brickNum == 64){ setStyleSheet("QBrick { background: rgb(245,95,60); color: rgb(255,255,255); font: bold; border-radius: 10px; font: 40pt; }"); } else if(brickNum == 128){ setStyleSheet("QBrick { background: rgb(237,207,114); color: rgb(255,255,255); font: bold; border-radius: 10px; font: 40pt; }"); } else if(brickNum == 256){ QGraphicsDropShadowEffect *dse = new QGraphicsDropShadowEffect(); dse->setColor(Qt::yellow); dse->setBlurRadius(20); dse->setOffset(-1); setGraphicsEffect(dse); setStyleSheet("QBrick { background: rgb(237,204,97); color: rgb(255,255,255); font: bold; border-radius: 10px; font: 40pt; }"); } else if(brickNum == 512){ QGraphicsDropShadowEffect *dse = new QGraphicsDropShadowEffect(); dse->setColor(Qt::yellow); dse->setBlurRadius(30); dse->setOffset(-1); setGraphicsEffect(dse); setStyleSheet("QBrick { background: rgb(237,204,97); color: rgb(255,255,255); font: bold; border-radius: 10px; font: 40pt; }"); } else if(brickNum == 1024){ QGraphicsDropShadowEffect *dse = new QGraphicsDropShadowEffect(); dse->setColor(Qt::yellow); dse->setBlurRadius(40); dse->setOffset(-1); setGraphicsEffect(dse); setStyleSheet("QBrick { background: rgb(237,204,97); color: rgb(255,255,255); font: bold; border-radius: 10px; font: 40pt; }"); } else if(brickNum == 2048){ QGraphicsDropShadowEffect *dse = new QGraphicsDropShadowEffect(); dse->setColor(Qt::yellow); dse->setBlurRadius(50); dse->setOffset(-1); setGraphicsEffect(dse); setStyleSheet("QBrick { background: rgb(237,204,97); color: rgb(255,255,255); font: bold; border-radius: 10px; font: 40pt; }"); } else{ setStyleSheet("QTile { background: rgb(238,228,218); color: rgb(119,110,101); font: bold; border-radius: 10px; font: 40pt; }"); } } }
void loadFromXml( mlt_producer producer, QGraphicsScene *scene, const char *templateXml, const char *templateText ) { scene->clear(); mlt_properties producer_props = MLT_PRODUCER_PROPERTIES( producer ); QDomDocument doc; QString data = QString::fromUtf8(templateXml); QString replacementText = QString::fromUtf8(templateText); doc.setContent(data); QDomElement title = doc.documentElement(); // Check for invalid title if ( title.isNull() || title.tagName() != "kdenlivetitle" ) return; // Check title locale if ( title.hasAttribute( "LC_NUMERIC" ) ) { QString locale = title.attribute( "LC_NUMERIC" ); QLocale::setDefault( locale ); } int originalWidth; int originalHeight; if ( title.hasAttribute("width") ) { originalWidth = title.attribute("width").toInt(); originalHeight = title.attribute("height").toInt(); scene->setSceneRect(0, 0, originalWidth, originalHeight); } else { originalWidth = scene->sceneRect().width(); originalHeight = scene->sceneRect().height(); } if ( title.hasAttribute( "out" ) ) { mlt_properties_set_position( producer_props, "_animation_out", title.attribute( "out" ).toDouble() ); } else { mlt_properties_set_position( producer_props, "_animation_out", mlt_producer_get_out( producer ) ); } mlt_properties_set_int( producer_props, "_original_width", originalWidth ); mlt_properties_set_int( producer_props, "_original_height", originalHeight ); QDomNode node; QDomNodeList items = title.elementsByTagName("item"); for ( int i = 0; i < items.count(); i++ ) { QGraphicsItem *gitem = NULL; node = items.item( i ); QDomNamedNodeMap nodeAttributes = node.attributes(); int zValue = nodeAttributes.namedItem( "z-index" ).nodeValue().toInt(); if ( zValue > -1000 ) { if ( nodeAttributes.namedItem( "type" ).nodeValue() == "QGraphicsTextItem" ) { QDomNamedNodeMap txtProperties = node.namedItem( "content" ).attributes(); QFont font( txtProperties.namedItem( "font" ).nodeValue() ); QDomNode propsNode = txtProperties.namedItem( "font-bold" ); if ( !propsNode.isNull() ) { // Old: Bold/Not bold. font.setBold( propsNode.nodeValue().toInt() ); } else { // New: Font weight (QFont::) font.setWeight( txtProperties.namedItem( "font-weight" ).nodeValue().toInt() ); } font.setItalic( txtProperties.namedItem( "font-italic" ).nodeValue().toInt() ); font.setUnderline( txtProperties.namedItem( "font-underline" ).nodeValue().toInt() ); // Older Kdenlive version did not store pixel size but point size if ( txtProperties.namedItem( "font-pixel-size" ).isNull() ) { QFont f2; f2.setPointSize( txtProperties.namedItem( "font-size" ).nodeValue().toInt() ); font.setPixelSize( QFontInfo( f2 ).pixelSize() ); } else font.setPixelSize( txtProperties.namedItem( "font-pixel-size" ).nodeValue().toInt() ); QColor col( stringToColor( txtProperties.namedItem( "font-color" ).nodeValue() ) ); QString text = node.namedItem( "content" ).firstChild().nodeValue(); if ( !replacementText.isEmpty() ) { text = text.replace( "%s", replacementText ); } QGraphicsTextItem *txt = scene->addText(text, font); if (txtProperties.namedItem("font-outline").nodeValue().toDouble()>0.0){ QTextDocument *doc = txt->document(); // Make sure some that the text item does not request refresh by itself doc->blockSignals(true); QTextCursor cursor(doc); cursor.select(QTextCursor::Document); QTextCharFormat format; format.setTextOutline( QPen(QColor( stringToColor( txtProperties.namedItem( "font-outline-color" ).nodeValue() ) ), txtProperties.namedItem("font-outline").nodeValue().toDouble(), Qt::SolidLine,Qt::RoundCap,Qt::RoundJoin) ); format.setForeground(QBrush(col)); cursor.mergeCharFormat(format); } else { txt->setDefaultTextColor( col ); } // Effects if (!txtProperties.namedItem( "typewriter" ).isNull()) { // typewriter effect mlt_properties_set_int( producer_props, "_animated", 1 ); QStringList effetData = QStringList() << "typewriter" << text << txtProperties.namedItem( "typewriter" ).nodeValue(); txt->setData(0, effetData); if ( !txtProperties.namedItem( "textwidth" ).isNull() ) txt->setData( 1, txtProperties.namedItem( "textwidth" ).nodeValue() ); } if ( txtProperties.namedItem( "alignment" ).isNull() == false ) { txt->setTextWidth( txt->boundingRect().width() ); QTextOption opt = txt->document()->defaultTextOption (); opt.setAlignment(( Qt::Alignment ) txtProperties.namedItem( "alignment" ).nodeValue().toInt() ); txt->document()->setDefaultTextOption (opt); } if ( !txtProperties.namedItem( "kdenlive-axis-x-inverted" ).isNull() ) { //txt->setData(OriginXLeft, txtProperties.namedItem("kdenlive-axis-x-inverted").nodeValue().toInt()); } if ( !txtProperties.namedItem( "kdenlive-axis-y-inverted" ).isNull() ) { //txt->setData(OriginYTop, txtProperties.namedItem("kdenlive-axis-y-inverted").nodeValue().toInt()); } gitem = txt; } else if ( nodeAttributes.namedItem( "type" ).nodeValue() == "QGraphicsRectItem" ) { QString rect = node.namedItem( "content" ).attributes().namedItem( "rect" ).nodeValue(); QString br_str = node.namedItem( "content" ).attributes().namedItem( "brushcolor" ).nodeValue(); QString pen_str = node.namedItem( "content" ).attributes().namedItem( "pencolor" ).nodeValue(); double penwidth = node.namedItem( "content" ).attributes().namedItem( "penwidth") .nodeValue().toDouble(); QGraphicsRectItem *rec = scene->addRect( stringToRect( rect ), QPen( QBrush( stringToColor( pen_str ) ), penwidth, Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin ), QBrush( stringToColor( br_str ) ) ); gitem = rec; } else if ( nodeAttributes.namedItem( "type" ).nodeValue() == "QGraphicsPixmapItem" ) { const QString url = node.namedItem( "content" ).attributes().namedItem( "url" ).nodeValue(); const QString base64 = items.item(i).namedItem("content").attributes().namedItem("base64").nodeValue(); QImage img; if (base64.isEmpty()){ img.load(url); }else{ img.loadFromData(QByteArray::fromBase64(base64.toAscii())); } ImageItem *rec = new ImageItem(img); scene->addItem( rec ); gitem = rec; } else if ( nodeAttributes.namedItem( "type" ).nodeValue() == "QGraphicsSvgItem" ) { QString url = items.item(i).namedItem("content").attributes().namedItem("url").nodeValue(); QString base64 = items.item(i).namedItem("content").attributes().namedItem("base64").nodeValue(); QGraphicsSvgItem *rec = NULL; if (base64.isEmpty()){ rec = new QGraphicsSvgItem(url); }else{ rec = new QGraphicsSvgItem(); QSvgRenderer *renderer= new QSvgRenderer(QByteArray::fromBase64(base64.toAscii()), rec ); rec->setSharedRenderer(renderer); } if (rec){ scene->addItem(rec); gitem = rec; } } } //pos and transform if ( gitem ) { QPointF p( node.namedItem( "position" ).attributes().namedItem( "x" ).nodeValue().toDouble(), node.namedItem( "position" ).attributes().namedItem( "y" ).nodeValue().toDouble() ); gitem->setPos( p ); gitem->setTransform( stringToTransform( node.namedItem( "position" ).firstChild().firstChild().nodeValue() ) ); int zValue = nodeAttributes.namedItem( "z-index" ).nodeValue().toInt(); gitem->setZValue( zValue ); #if QT_VERSION >= 0x040600 // effects QDomNode eff = items.item(i).namedItem("effect"); if (!eff.isNull()) { QDomElement e = eff.toElement(); if (e.attribute("type") == "blur") { QGraphicsBlurEffect *blur = new QGraphicsBlurEffect(); blur->setBlurRadius(e.attribute("blurradius").toInt()); gitem->setGraphicsEffect(blur); } else if (e.attribute("type") == "shadow") { QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(); shadow->setBlurRadius(e.attribute("blurradius").toInt()); shadow->setOffset(e.attribute("xoffset").toInt(), e.attribute("yoffset").toInt()); gitem->setGraphicsEffect(shadow); } } #endif } } QDomNode n = title.firstChildElement("background"); if (!n.isNull()) { QColor color = QColor( stringToColor( n.attributes().namedItem( "color" ).nodeValue() ) ); if (color.alpha() > 0) { QGraphicsRectItem *rec = scene->addRect(0, 0, scene->width(), scene->height() , QPen( Qt::NoPen ), QBrush( color ) ); rec->setZValue(-1100); } } QString startRect; n = title.firstChildElement( "startviewport" ); // Check if node exists, if it has an x attribute, it is an old version title, don't use viewport if (!n.isNull() && !n.toElement().hasAttribute("x")) { startRect = n.attributes().namedItem( "rect" ).nodeValue(); } n = title.firstChildElement( "endviewport" ); // Check if node exists, if it has an x attribute, it is an old version title, don't use viewport if (!n.isNull() && !n.toElement().hasAttribute("x")) { QString rect = n.attributes().namedItem( "rect" ).nodeValue(); if (startRect != rect) mlt_properties_set( producer_props, "_endrect", rect.toUtf8().data() ); } if (!startRect.isEmpty()) { mlt_properties_set( producer_props, "_startrect", startRect.toUtf8().data() ); } return; }
void FramelessWindow::styleWindow(bool bActive, bool bNoState) { if (bActive) { if (bNoState) { layout()->setMargin(15); ui->windowTitlebar->setStyleSheet(QStringLiteral( "#windowTitlebar{border: 0px none palette(shadow); " "border-top-left-radius:5px; border-top-right-radius:5px; " "background-color:palette(shadow); height:20px;}")); ui->windowFrame->setStyleSheet(QStringLiteral( "#windowFrame{border:1px solid palette(highlight); border-radius:5px " "5px 5px 5px; background-color:palette(Window);}")); QGraphicsEffect *oldShadow = ui->windowFrame->graphicsEffect(); if (oldShadow) delete oldShadow; QGraphicsDropShadowEffect *windowShadow = new QGraphicsDropShadowEffect; windowShadow->setBlurRadius(9.0); windowShadow->setColor(palette().color(QPalette::Highlight)); windowShadow->setOffset(0.0); ui->windowFrame->setGraphicsEffect(windowShadow); } else { layout()->setMargin(0); ui->windowTitlebar->setStyleSheet(QStringLiteral( "#windowTitlebar{border: 0px none palette(shadow); " "border-top-left-radius:0px; border-top-right-radius:0px; " "background-color:palette(shadow); height:20px;}")); ui->windowFrame->setStyleSheet(QStringLiteral( "#windowFrame{border:1px solid palette(dark); border-radius:0px 0px " "0px 0px; background-color:palette(Window);}")); QGraphicsEffect *oldShadow = ui->windowFrame->graphicsEffect(); if (oldShadow) delete oldShadow; ui->windowFrame->setGraphicsEffect(nullptr); } // if (bNoState) else maximize } else { if (bNoState) { layout()->setMargin(15); ui->windowTitlebar->setStyleSheet(QStringLiteral( "#windowTitlebar{border: 0px none palette(shadow); " "border-top-left-radius:5px; border-top-right-radius:5px; " "background-color:palette(dark); height:20px;}")); ui->windowFrame->setStyleSheet(QStringLiteral( "#windowFrame{border:1px solid #000000; border-radius:5px 5px 5px " "5px; background-color:palette(Window);}")); QGraphicsEffect *oldShadow = ui->windowFrame->graphicsEffect(); if (oldShadow) delete oldShadow; QGraphicsDropShadowEffect *windowShadow = new QGraphicsDropShadowEffect; windowShadow->setBlurRadius(9.0); windowShadow->setColor(palette().color(QPalette::Shadow)); windowShadow->setOffset(0.0); ui->windowFrame->setGraphicsEffect(windowShadow); } else { layout()->setMargin(0); ui->windowTitlebar->setStyleSheet(QStringLiteral( "#titlebarWidget{border: 0px none palette(shadow); " "border-top-left-radius:0px; border-top-right-radius:0px; " "background-color:palette(dark); height:20px;}")); ui->windowFrame->setStyleSheet(QStringLiteral( "#windowFrame{border:1px solid palette(shadow); border-radius:0px " "0px 0px 0px; background-color:palette(Window);}")); QGraphicsEffect *oldShadow = ui->windowFrame->graphicsEffect(); if (oldShadow) delete oldShadow; ui->windowFrame->setGraphicsEffect(nullptr); } // if (bNoState) { else maximize } // if (bActive) { else no focus }