Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:llunak:attic
kde4-plasmoid-coremoid
bug-544202-plasma-rendering.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File bug-544202-plasma-rendering.patch of Package kde4-plasmoid-coremoid
--- coremoidapplet.cpp~ 2008-04-06 01:08:17.000000000 +0200 +++ coremoidapplet.cpp 2009-10-04 19:02:04.000000000 +0200 @@ -117,7 +117,7 @@ m_size.setHeight(50); break; case 1: - m_size.setWidth(60); + m_size.setWidth(50); m_size.setHeight(100); break; } @@ -144,11 +144,44 @@ p->setRenderHint ( QPainter::SmoothPixmapTransform ); p->setRenderHint ( QPainter::Antialiasing ); - int text_height; - if ( m_show_governor ) - text_height = 15; - else - text_height = 0; + int outer_margin = contentsRect.width()*0.05; + int inner_margin = contentsRect.width()*0.05; + + int label_height=0; + if ( m_show_governor ) { + QString label_text=m_current_govenor!="" ? m_current_govenor : "no governor"; + int freq = getCurrentFreq(); + if (freq>=1000) { + label_text+=" "+QString::number(freq/1000)+"."+QString::number((freq/100)%10)+ " GHz"; + } else if(freq>0) { + label_text+=" "+QString::number(freq) + " MHz"; + } + + m_font.setWeight(QFont::Bold); + p->setFont(m_font); + + QFontMetrics fm(m_font); + QRect label_rect; + label_rect.setLeft(contentsRect.left()+outer_margin); + label_rect.setRight(contentsRect.right()-outer_margin); + label_rect.setTop(contentsRect.bottom()-outer_margin-fm.height()); + label_rect.setBottom(contentsRect.bottom()-outer_margin); + + p->setPen(m_boxColor); + if (m_isHovered) { + m_boxColor.setAlpha(m_boxHoverAlpha); + } + p->setBrush(m_boxColor); + + float round_prop = label_rect.width() / label_rect.height(); + int round_radius = 35; + p->drawRoundRect(label_rect, (int)(round_radius/round_prop), round_radius); + p->setPen(m_textColor); + p->drawText(label_rect, Qt::AlignCenter, label_text); + + m_boxColor.setAlpha(m_boxAlpha); + label_height=label_rect.height()+inner_margin*2; + } for(int i = 0; i < m_cpu_count; i++) { double user = m_stats_new[i].getUser() - m_stats[i].getUser(); @@ -162,38 +195,24 @@ int height, width; switch(m_orientation) { case 0: - height = (contentsRect.height() - text_height) / m_cpu_count; - - m_rects[i].setLeft(5); - m_rects[i].setWidth(contentsRect.width() - 10); - m_rects[i].setTop(height / 6 + i * height); - m_rects[i].setHeight(height * 2 / 3); + height = (contentsRect.height()-outer_margin*2-label_height+inner_margin*2)/m_cpu_count; + width = contentsRect.width()-outer_margin*2; + m_rects[i].setLeft(contentsRect.left()+outer_margin); + m_rects[i].setRight(contentsRect.right()-outer_margin); + m_rects[i].setTop(contentsRect.top()+outer_margin+height*i); + m_rects[i].setBottom(contentsRect.top()+outer_margin-2*inner_margin+height*(i+1)); break; case 1: - width = contentsRect.width() / m_cpu_count; - - m_rects[i].setLeft(width / 6 + i * width); - m_rects[i].setWidth(width * 2 / 3); - m_rects[i].setTop(5); - m_rects[i].setHeight(contentsRect.height() - 10 - text_height); + height = contentsRect.height()-outer_margin*2-label_height; + width = (contentsRect.width()-outer_margin*2+inner_margin*2)/m_cpu_count; + m_rects[i].setLeft(contentsRect.left()+outer_margin+width*i); + m_rects[i].setRight(contentsRect.left()+outer_margin+width*(i+1)-2*inner_margin); + m_rects[i].setTop(contentsRect.top()+outer_margin); + m_rects[i].setBottom(contentsRect.bottom()-outer_margin-label_height); break; } paintBar(p, m_rects[i], (int)usage, m_orientation); } - - if ( m_show_governor ) { - QRect rect_text(5, contentsRect.height() - text_height, contentsRect.width() - 10, text_height); - paintText(p, rect_text, m_current_govenor); - } - - if ( m_current_govenor == "ondemand" || m_current_govenor == "conservative" ) { - int freq = getCurrentFreq(); - if (freq>=1000) { - paintLabel(p, contentsRect, QString::number(freq/1000)+"."+QString::number((freq/100)%10)+ " GHz"); - } else { - paintLabel(p, contentsRect, QString::number(freq) + " MHz"); - } - } } /*! @@ -403,67 +422,6 @@ m_current_govenor = name; } -// This function ist adapted from battery applet -void CoreMoidApplet::paintLabel(QPainter *p, const QRect &contentsRect, const QString& labelText) -{ - // Store font size, we want to restore it shortly - int original_font_size = m_font.pointSize(); - - // Fonts smaller than smallestReadableFont don't make sense. - m_font.setPointSize(qMax(KGlobalSettings::smallestReadableFont().pointSize(), m_font.pointSize())); - QFontMetrics fm(m_font); - int text_width = fm.width(labelText); - - // Longer texts get smaller fonts - if (labelText.length() > 4) { - if (original_font_size/1.5 < KGlobalSettings::smallestReadableFont().pointSize()) { - m_font.setPointSize((int)(KGlobalSettings::smallestReadableFont().pointSize())); - } else { - m_font.setPointSize((int)(original_font_size/1.5)); - } - fm = QFontMetrics(m_font); - text_width = (int)(fm.width(labelText) * 1.2); - } else { - // Smaller texts get a wider box - text_width = (int)(text_width * 1.4); - } - if (formFactor() == Plasma::Horizontal || - formFactor() == Plasma::Vertical) { - m_font = KGlobalSettings::smallestReadableFont(); - m_font.setWeight(QFont::Bold); - fm = QFontMetrics(m_font); - text_width = (int)(fm.width(labelText)+8); - } - p->setFont(m_font); - - // Let's find a good position for painting the background - QRect text_rect = QRect(contentsRect.left()+(contentsRect.width()-text_width)/2, - (int)(contentsRect.top()+((contentsRect.height() - (int)fm.height())/2*0.9)), - text_width, - (int)(fm.height()*1.2)); - - // Poor man's highlighting - p->setPen(m_boxColor); - if (m_isHovered) { - m_boxColor.setAlpha(m_boxHoverAlpha); - } - p->setBrush(m_boxColor); - - // Find sensible proportions for the rounded corners - float round_prop = text_rect.width() / text_rect.height(); - - // Tweak the rounding edge a bit with the proportions of the textbox - int round_radius = 35; - p->drawRoundRect(text_rect, (int)(round_radius/round_prop), round_radius); - - p->setPen(m_textColor); - p->drawText(text_rect, Qt::AlignCenter, labelText); - - // Reset font and box - m_font.setPointSize(original_font_size); - m_boxColor.setAlpha(m_boxAlpha); -} - int CoreMoidApplet::getCurrentFreq() { QFile file_cur("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", this);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor