Skip to content

Commit

Permalink
Merge pull request #148 from dolphinoracle/gtk3
Browse files Browse the repository at this point in the history
add plasma discover tray utility autostart enable-disable
  • Loading branch information
dolphinoracle authored Aug 14, 2024
2 parents 9df26cd + a59a8f4 commit 5699120
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 111 deletions.
43 changes: 43 additions & 0 deletions defaultlook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,7 @@ void defaultlook::setuppanel()

void defaultlook::setupPlasma()
{
QString home_path = QDir::homePath();
//get panel ID
plasmaPanelId = runCmd(QStringLiteral("grep --max-count 1 -B 8 panel $HOME/.config/plasma-org.kde.plasma.desktop-appletsrc |grep Containment")).output;
QString panellocation = readPlasmaPanelConfig(QStringLiteral("location"));
Expand All @@ -1206,6 +1207,18 @@ void defaultlook::setupPlasma()
default: ui->comboPlasmaPanelLocation->setCurrentIndex(PanelIndex::Bottom);
}

//setup plasma-discover autostart
if (QFile("/usr/lib/x86_64-linux-gnu/libexec/DiscoverNotifier").exists()){
QString plasmadiscoverautostart = home_path + "/.config/autostart/org.kde.discover.notifier.desktop";
if (runCmd("grep Hidden=true " + plasmadiscoverautostart).exitCode == 0 ){
ui->checkBoxPlasmaDiscoverUpdater->setChecked(false);
} else {
ui->checkBoxPlasmaDiscoverUpdater->setChecked(true);
}
} else {
ui->checkBoxPlasmaDiscoverUpdater->hide();
}

//setup singleclick
QString singleclick = runCmd(QStringLiteral("kreadconfig5 --group KDE --key SingleClick")).output;
ui->checkBoxPlasmaSingleClick->setChecked(singleclick != QLatin1String("false"));
Expand All @@ -1228,6 +1241,7 @@ void defaultlook::setupPlasma()
plasmasingleclickflag = false;
plasmaresetflag = false;
plasmasystrayiconsizeflag = false;
plasmadisoverautostartflag = false;
}

QString defaultlook::readTaskmanagerConfig(const QString &key) const
Expand Down Expand Up @@ -3453,6 +3467,7 @@ void defaultlook::on_checkboxplasmaresetdock_clicked()

void defaultlook::on_ButtonApplyPlasma_clicked()
{
QString home_path = QDir::homePath();
if (plasmaresetflag) {
plasmaplacementflag = false;
plasmasingleclickflag = false;
Expand Down Expand Up @@ -3492,6 +3507,26 @@ void defaultlook::on_ButtonApplyPlasma_clicked()
writeTaskmanagerConfig(QStringLiteral("showOnlyCurrentDesktop"), value);
}

//plasma-discover autostart
if (plasmadisoverautostartflag){
QString plasmadiscoverautostart = home_path + "/.config/autostart/org.kde.discover.notifier.desktop";
qDebug() << "discover autostart path is " << plasmadiscoverautostart;
if (ui->checkBoxPlasmaDiscoverUpdater->isChecked()){
//delete any Hidden=true lines to make sure its processed by xdg autostart
runCmd("sed -i /Hidden=true/d " + plasmadiscoverautostart);
} else {
//copy if it doesn't exist already
if (!QFile(plasmadiscoverautostart).exists()){
if (QFile("/etc/xdg/autostart/org.kde.discover.notifier.desktop").exists()){
runCmd("cp /etc/xdg/autostart/org.kde.discover.notifier.desktop " + plasmadiscoverautostart);
}
}
//remove any previous Hidden= attribute, then add Hidden=true to make it not autostart
runCmd("sed -i /Hidden=*/d " + plasmadiscoverautostart);
runCmd("echo Hidden=true >> " + plasmadiscoverautostart); //this also creates file if the /etc/xdg version is missing
}
}

//time to reset kwin and plasmashell
if (plasmaworkspacesflag || plasmasingleclickflag || plasmaplacementflag || plasmaresetflag || plasmasystrayiconsizeflag) {
//restart kwin first
Expand All @@ -3500,6 +3535,7 @@ void defaultlook::on_ButtonApplyPlasma_clicked()
QString cmd =QStringLiteral("sleep 1; plasmashell --replace &");
system(cmd.toUtf8());
}

setupPlasma();

}
Expand Down Expand Up @@ -4161,3 +4197,10 @@ void defaultlook::on_spinBoxPointerSize_valueChanged(int arg1)
set_cursor_size();
}


void defaultlook::on_checkBoxPlasmaDiscoverUpdater_clicked()
{
plasmadisoverautostartflag = true;
ui->ButtonApplyPlasma->setEnabled(true);
}

3 changes: 3 additions & 0 deletions defaultlook.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class defaultlook : public QDialog
bool isKDE = false;
bool liqKernelUpdateFlag = false;
bool debianKernelUpdateFlag = false;
bool plasmadisoverautostartflag = false;



Expand Down Expand Up @@ -312,6 +313,8 @@ private slots:

void on_spinBoxPointerSize_valueChanged(int arg1);

void on_checkBoxPlasmaDiscoverUpdater_clicked();

private:
Ui::defaultlook *ui;
};
Expand Down
141 changes: 74 additions & 67 deletions defaultlook.ui
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>1</number>
<number>6</number>
</property>
<widget class="QWidget" name="Panel">
<attribute name="title">
Expand Down Expand Up @@ -1728,13 +1728,79 @@
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item row="6" column="0" colspan="3">
<widget class="QLabel" name="label_24">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Reset Defaults&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_7">
<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 row="8" column="0">
<spacer name="verticalSpacer_12">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="0" colspan="3">
<widget class="QCheckBox" name="checkBoxPlasmaShowAllWorkspaces">
<property name="text">
<string>Show windows from all workspaces in panel</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_21">
<property name="text">
<string>Placement</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="3">
<widget class="QCheckBox" name="checkBoxPlasmaSingleClick">
<property name="text">
<string>Enable single-click</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="3">
<widget class="QCheckBox" name="checkboxplasmaresetdock">
<property name="text">
<string>Reset KDE/Plasma defaults</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_22">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Affects 1st panel</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboPlasmaPanelLocation">
<property name="currentText">
Expand Down Expand Up @@ -1762,19 +1828,19 @@
</item>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_22">
<item row="2" column="0">
<widget class="QLabel" name="label_23">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Affects 1st panel</string>
<string>Workspace</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="3">
<item row="9" column="0" colspan="3">
<widget class="QPushButton" name="ButtonApplyPlasma">
<property name="minimumSize">
<size>
Expand All @@ -1791,69 +1857,10 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_23">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Workspace</string>
</property>
</widget>
</item>
<item row="7" column="0">
<spacer name="verticalSpacer_12">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_7">
<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 row="4" column="0" colspan="3">
<widget class="QCheckBox" name="checkBoxPlasmaShowAllWorkspaces">
<property name="text">
<string>Show windows from all workspaces in panel</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<widget class="QCheckBox" name="checkBoxPlasmaSingleClick">
<property name="text">
<string>Enable single-click</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="3">
<widget class="QLabel" name="label_24">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Reset Defaults&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="3">
<widget class="QCheckBox" name="checkboxplasmaresetdock">
<item row="3" column="0">
<widget class="QCheckBox" name="checkBoxPlasmaDiscoverUpdater">
<property name="text">
<string>Reset KDE/Plasma defaults</string>
<string extracomment="enable or disable autostartup of plasma-discover updater utility on login">Autostart plasma-discover system tray update notification utility</string>
</property>
</widget>
</item>
Expand Down
Loading

0 comments on commit 5699120

Please sign in to comment.