mirror of
				https://github.com/arcan1s/awesome-widgets.git
				synced 2025-10-31 05:13:40 +00:00 
			
		
		
		
	some intermediate commit
This commit is contained in:
		| @ -24,6 +24,7 @@ | ||||
| #include <Plasma/Containment> | ||||
| #include <Plasma/Corona> | ||||
| #include <Plasma/Theme> | ||||
| #include <QBuffer> | ||||
| #include <QDebug> | ||||
| #include <QFile> | ||||
| #include <QGraphicsGridLayout> | ||||
| @ -117,6 +118,26 @@ void DesktopPanel::init() | ||||
| } | ||||
|  | ||||
|  | ||||
| DesktopPanel::DesktopWindowsInfo DesktopPanel::getInfoByDesktop(const int num) | ||||
| { | ||||
|     if (debug) qDebug() << PDEBUG; | ||||
|     if (debug) qDebug() << PDEBUG << ":" << "Number" << num; | ||||
|  | ||||
|  | ||||
|     DesktopWindowsInfo info; | ||||
|     info.desktop = KWindowSystem::workArea(num); | ||||
|  | ||||
|     QList<WId> windows = KWindowSystem::windows(); | ||||
|     for (int i=0; i<windows.count(); i++) { | ||||
|         KWindowInfo winInfo = KWindowSystem::windowInfo(windows[i], NET::Property::WMDesktop | NET::Property::WMGeometry); | ||||
|         if (winInfo.isOnDesktop(num)) continue; | ||||
|         info.windows.append(winInfo.geometry()); | ||||
|     } | ||||
|  | ||||
|     return info; | ||||
| } | ||||
|  | ||||
|  | ||||
| QList<Plasma::Containment *> DesktopPanel::getPanels() | ||||
| { | ||||
|     if (debug) qDebug() << PDEBUG; | ||||
| @ -276,6 +297,17 @@ void DesktopPanel::updateText(const bool first) | ||||
|         else | ||||
|             text = formatLine[0] + line + formatLine[1]; | ||||
|         labels[i]->setText(text); | ||||
|  | ||||
|         // update tooltip | ||||
|         if (configuration[QString("tooltip")].toInt() == 2) { | ||||
|             QPixmap pixmap("/home/arcanis/testicon.jpg"); | ||||
|             pixmap.scaledToWidth(configuration[QString("tooltipWidth")].toInt()); | ||||
|             QByteArray byteArray; | ||||
|             QBuffer buffer(&byteArray); | ||||
|             pixmap.save(&buffer, "PNG"); | ||||
|             QString url = QString("<html><img src=\"data:image/png;base64,") + byteArray.toBase64() + QString("\"/></html>"); | ||||
|             labels[i]->setToolTip(url); | ||||
|         } | ||||
|     } | ||||
|     int height = 0; | ||||
|     int width = 0; | ||||
| @ -328,6 +360,11 @@ void DesktopPanel::createConfigurationInterface(KConfigDialog *parent) | ||||
|     uiToggleConfig.setupUi(toggleWidget); | ||||
|  | ||||
|     uiWidConfig.textEdit_elements->setPlainText(configuration[QString("pattern")]); | ||||
|     if (configuration[QString("tooltip")].toInt() == 0) | ||||
|         uiWidConfig.checkBox_tooltip->setCheckState(Qt::Unchecked); | ||||
|     else | ||||
|         uiWidConfig.checkBox_tooltip->setCheckState(Qt::Checked); | ||||
|     uiWidConfig.spinBox_tooltip->setValue(configuration[QString("tooltipWidth")].toInt()); | ||||
|     if (configuration[QString("background")].toInt() == 0) | ||||
|         uiWidConfig.checkBox_background->setCheckState(Qt::Unchecked); | ||||
|     else | ||||
| @ -412,6 +449,8 @@ void DesktopPanel::configAccepted() | ||||
|     KConfigGroup cg = config(); | ||||
|  | ||||
|     cg.writeEntry("pattern", uiWidConfig.textEdit_elements->toPlainText()); | ||||
|     cg.writeEntry("tooltip", QString::number(uiWidConfig.checkBox_tooltip->checkState())); | ||||
|     cg.writeEntry("tooltipWidth", QString::number(uiWidConfig.spinBox_tooltip->value())); | ||||
|     cg.writeEntry("background", QString::number(uiWidConfig.checkBox_background->checkState())); | ||||
|     cg.writeEntry("layout", QString::number(uiWidConfig.checkBox_layout->checkState())); | ||||
|     cg.writeEntry("interval", QString::number(uiWidConfig.spinBox_interval->value())); | ||||
| @ -448,6 +487,8 @@ void DesktopPanel::configChanged() | ||||
|     KConfigGroup cg = config(); | ||||
|  | ||||
|     configuration[QString("pattern")] = cg.readEntry("pattern", "[$fullmark$number/$total: $name]"); | ||||
|     configuration[QString("tooltip")] = cg.readEntry("tooltip", "2"); | ||||
|     configuration[QString("tooltipWidth")] = cg.readEntry("tooltipWidth", "200"); | ||||
|     configuration[QString("background")] = cg.readEntry("background", "2"); | ||||
|     configuration[QString("desktopcmd")] = cg.readEntry("desktopcmd", "qdbus org.kde.kwin /KWin setCurrentDesktop $number"); | ||||
|     configuration[QString("interval")] = cg.readEntry("interval", "1000"); | ||||
|  | ||||
| @ -60,10 +60,16 @@ class DesktopPanel : public Plasma::Applet | ||||
| { | ||||
|     Q_OBJECT | ||||
|  | ||||
|     typedef struct { | ||||
|         QRect desktop; | ||||
|         QList<QRect> windows; | ||||
|     } DesktopWindowsInfo; | ||||
|  | ||||
| public: | ||||
|     DesktopPanel(QObject *parent, const QVariantList &args); | ||||
|     ~DesktopPanel(); | ||||
|     void init(); | ||||
|     DesktopWindowsInfo getInfoByDesktop(const int num); | ||||
|     QString parsePattern(const QString rawLine, const int num); | ||||
|  | ||||
| public slots: | ||||
|  | ||||
| @ -6,8 +6,8 @@ | ||||
|    <rect> | ||||
|     <x>0</x> | ||||
|     <y>0</y> | ||||
|     <width>729</width> | ||||
|     <height>428</height> | ||||
|     <width>725</width> | ||||
|     <height>424</height> | ||||
|    </rect> | ||||
|   </property> | ||||
|   <property name="minimumSize"> | ||||
| @ -20,7 +20,38 @@ | ||||
|    <string notr="true">Widget</string> | ||||
|   </property> | ||||
|   <layout class="QGridLayout" name="gridLayout"> | ||||
|    <item row="4" column="0"> | ||||
|    <item row="6" column="0"> | ||||
|     <widget class="QCheckBox" name="checkBox_layout"> | ||||
|      <property name="text"> | ||||
|       <string>Vertical layout</string> | ||||
|      </property> | ||||
|     </widget> | ||||
|    </item> | ||||
|    <item row="10" column="0"> | ||||
|     <layout class="QHBoxLayout" name="layout_desktopcmd"> | ||||
|      <item> | ||||
|       <widget class="QLabel" name="label_desktopcmd"> | ||||
|        <property name="minimumSize"> | ||||
|         <size> | ||||
|          <width>200</width> | ||||
|          <height>0</height> | ||||
|         </size> | ||||
|        </property> | ||||
|        <property name="text"> | ||||
|         <string>Command to change desktop</string> | ||||
|        </property> | ||||
|       </widget> | ||||
|      </item> | ||||
|      <item> | ||||
|       <widget class="QLineEdit" name="lineEdit_desktopcmd"> | ||||
|        <property name="toolTip"> | ||||
|         <string>Command which will change the current desktop</string> | ||||
|        </property> | ||||
|       </widget> | ||||
|      </item> | ||||
|     </layout> | ||||
|    </item> | ||||
|    <item row="8" column="0"> | ||||
|     <layout class="QHBoxLayout" name="layout_interval"> | ||||
|      <item> | ||||
|       <widget class="QLabel" name="label_interval"> | ||||
| @ -75,14 +106,14 @@ | ||||
|      </item> | ||||
|     </layout> | ||||
|    </item> | ||||
|    <item row="2" column="0"> | ||||
|    <item row="4" column="0"> | ||||
|     <widget class="QCheckBox" name="checkBox_background"> | ||||
|      <property name="text"> | ||||
|       <string>Enable background</string> | ||||
|      </property> | ||||
|     </widget> | ||||
|    </item> | ||||
|    <item row="5" column="0"> | ||||
|    <item row="9" column="0"> | ||||
|     <layout class="QHBoxLayout" name="layout_mark"> | ||||
|      <item> | ||||
|       <widget class="QLabel" name="label_mark"> | ||||
| @ -179,37 +210,16 @@ | ||||
|      </item> | ||||
|     </layout> | ||||
|    </item> | ||||
|    <item row="3" column="0"> | ||||
|     <widget class="QCheckBox" name="checkBox_layout"> | ||||
|      <property name="text"> | ||||
|       <string>Vertical layout</string> | ||||
|    <item row="1" column="0"> | ||||
|     <widget class="QTextEdit" name="textEdit_elements"> | ||||
|      <property name="lineWrapMode"> | ||||
|       <enum>QTextEdit::NoWrap</enum> | ||||
|      </property> | ||||
|      <property name="acceptRichText"> | ||||
|       <bool>false</bool> | ||||
|      </property> | ||||
|     </widget> | ||||
|    </item> | ||||
|    <item row="6" column="0"> | ||||
|     <layout class="QHBoxLayout" name="layout_desktopcmd"> | ||||
|      <item> | ||||
|       <widget class="QLabel" name="label_desktopcmd"> | ||||
|        <property name="minimumSize"> | ||||
|         <size> | ||||
|          <width>200</width> | ||||
|          <height>0</height> | ||||
|         </size> | ||||
|        </property> | ||||
|        <property name="text"> | ||||
|         <string>Command to change desktop</string> | ||||
|        </property> | ||||
|       </widget> | ||||
|      </item> | ||||
|      <item> | ||||
|       <widget class="QLineEdit" name="lineEdit_desktopcmd"> | ||||
|        <property name="toolTip"> | ||||
|         <string>Command which will change the current desktop</string> | ||||
|        </property> | ||||
|       </widget> | ||||
|      </item> | ||||
|     </layout> | ||||
|    </item> | ||||
|    <item row="0" column="0"> | ||||
|     <layout class="QHBoxLayout" name="layput_mainFormating"> | ||||
|      <item> | ||||
| @ -392,16 +402,62 @@ | ||||
|      </item> | ||||
|     </layout> | ||||
|    </item> | ||||
|    <item row="1" column="0"> | ||||
|     <widget class="QTextEdit" name="textEdit_elements"> | ||||
|      <property name="lineWrapMode"> | ||||
|       <enum>QTextEdit::NoWrap</enum> | ||||
|      </property> | ||||
|      <property name="acceptRichText"> | ||||
|       <bool>false</bool> | ||||
|    <item row="2" column="0"> | ||||
|     <widget class="QCheckBox" name="checkBox_tooltip"> | ||||
|      <property name="text"> | ||||
|       <string>Enable tooltip</string> | ||||
|      </property> | ||||
|     </widget> | ||||
|    </item> | ||||
|    <item row="3" column="0"> | ||||
|     <layout class="QHBoxLayout" name="layout_tooltip"> | ||||
|      <item> | ||||
|       <widget class="QLabel" name="label_tooltip"> | ||||
|        <property name="text"> | ||||
|         <string>Tooltip width</string> | ||||
|        </property> | ||||
|       </widget> | ||||
|      </item> | ||||
|      <item> | ||||
|       <spacer name="spacer_tooltip"> | ||||
|        <property name="orientation"> | ||||
|         <enum>Qt::Horizontal</enum> | ||||
|        </property> | ||||
|        <property name="sizeHint" stdset="0"> | ||||
|         <size> | ||||
|          <width>40</width> | ||||
|          <height>20</height> | ||||
|         </size> | ||||
|        </property> | ||||
|       </spacer> | ||||
|      </item> | ||||
|      <item> | ||||
|       <widget class="QSpinBox" name="spinBox_tooltip"> | ||||
|        <property name="minimumSize"> | ||||
|         <size> | ||||
|          <width>180</width> | ||||
|          <height>0</height> | ||||
|         </size> | ||||
|        </property> | ||||
|        <property name="alignment"> | ||||
|         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> | ||||
|        </property> | ||||
|        <property name="specialValueText"> | ||||
|         <string>px</string> | ||||
|        </property> | ||||
|        <property name="minimum"> | ||||
|         <number>100</number> | ||||
|        </property> | ||||
|        <property name="maximum"> | ||||
|         <number>1000</number> | ||||
|        </property> | ||||
|        <property name="singleStep"> | ||||
|         <number>25</number> | ||||
|        </property> | ||||
|       </widget> | ||||
|      </item> | ||||
|     </layout> | ||||
|    </item> | ||||
|   </layout> | ||||
|  </widget> | ||||
|  <resources/> | ||||
|  | ||||
| @ -1,9 +1,9 @@ | ||||
| # is this script is active? | ||||
| # is this script active? | ||||
| ACTIVE=false | ||||
| # update interval in default plasmoid interval | ||||
| INTERVAL=1 | ||||
| # does this script have output? | ||||
| # set to 'false' if it is an action and will not show in the plasmoid | ||||
| # set to 'false' if it is an action and will not show text in the plasmoid | ||||
| OUTPUT=true | ||||
| # prefix to run this script. Usually this field should be blank, | ||||
| # but you may want to set command (e.g. script language) directly | ||||
|  | ||||
		Reference in New Issue
	
	Block a user