mirror of
https://github.com/oguzhaninan/Stacer.git
synced 2026-05-19 22:06:35 -04:00
added start on boot option to settings page
This commit is contained in:
@@ -53,6 +53,19 @@ void SettingsPage::init()
|
||||
QString dk = apm->getDiskName();
|
||||
ui->disksCmb->setCurrentText(dk);
|
||||
|
||||
// start on boot
|
||||
startupAppPath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
|
||||
startupAppPath.append("/autostart/stacer.desktop");
|
||||
|
||||
QFile startupAppFile(startupAppPath);
|
||||
if (startupAppFile.exists()) {
|
||||
QStringList appContent = FileUtil::readListFromFile(startupAppPath);
|
||||
QString isHidden = Utilities::getDesktopValue(QRegExp("^Hidden=.*"), appContent).toLower();
|
||||
ui->checkAutostart->setChecked(isHidden == "false");
|
||||
} else {
|
||||
ui->checkAutostart->setChecked(false);
|
||||
}
|
||||
|
||||
// effects
|
||||
Utilities::addDropShadow(ui->languagesCmb, 40);
|
||||
Utilities::addDropShadow(ui->themesCmb, 40);
|
||||
@@ -84,3 +97,27 @@ void SettingsPage::diskCmbChanged(const int &index)
|
||||
|
||||
apm->setDiskName(diskName);
|
||||
}
|
||||
|
||||
void SettingsPage::on_checkAutostart_clicked(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
QString appTemplate = QString("[Desktop Entry]\n"
|
||||
"Name=Stacer\n"
|
||||
"Comment=Linux System Optimizer and Monitoring\n"
|
||||
"Exec=/usr/share/stacer/stacer -m \n"
|
||||
"Type=Application\n"
|
||||
"Terminal=false\n"
|
||||
"Hidden=false");
|
||||
|
||||
QFile autostartApp(startupAppPath);
|
||||
|
||||
if (autostartApp.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||
QTextStream stream(&autostartApp);
|
||||
stream << appTemplate << endl;
|
||||
|
||||
autostartApp.close();
|
||||
}
|
||||
} else {
|
||||
QFile::remove(startupAppPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,12 +24,15 @@ private slots:
|
||||
void themesCmbChanged(const int &index);
|
||||
void languagesCmbChanged(const int &index);
|
||||
void diskCmbChanged(const int &index);
|
||||
void on_checkAutostart_clicked(bool checked);
|
||||
|
||||
private:
|
||||
Ui::SettingsPage *ui;
|
||||
|
||||
private:
|
||||
AppManager *apm;
|
||||
|
||||
QString startupAppPath;
|
||||
};
|
||||
|
||||
#endif // SETTINGS_PAGE_H
|
||||
|
||||
@@ -38,83 +38,19 @@
|
||||
<property name="verticalSpacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item row="0" column="1" alignment="Qt::AlignLeft">
|
||||
<widget class="QLabel" name="themeLabel">
|
||||
<property name="text">
|
||||
<string>Theme</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QComboBox" name="disksCmb">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<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="0" column="2">
|
||||
<item row="0" column="2" alignment="Qt::AlignLeft">
|
||||
<widget class="QLabel" name="lblDisks">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Disks</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" alignment="Qt::AlignLeft">
|
||||
<widget class="QComboBox" name="themesCmb">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" alignment="Qt::AlignLeft">
|
||||
<widget class="QComboBox" name="languagesCmb">
|
||||
<property name="minimumSize">
|
||||
@@ -142,12 +78,56 @@
|
||||
</item>
|
||||
<item row="0" column="0" alignment="Qt::AlignLeft">
|
||||
<widget class="QLabel" name="langLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Language</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3" rowspan="2">
|
||||
<item row="1" column="2">
|
||||
<widget class="QComboBox" name="disksCmb">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" alignment="Qt::AlignLeft">
|
||||
<widget class="QLabel" name="themeLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Theme</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4" rowspan="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@@ -160,7 +140,7 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="4" alignment="Qt::AlignRight">
|
||||
<item row="5" column="0" colspan="5" alignment="Qt::AlignRight">
|
||||
<widget class="QLabel" name="lblCreatedBy">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>Created by <a href="https://github.com/oguzhaninan"><span style=" text-decoration: underline; color:#007af4;">Oğuzhan İNAN</span></a></p></body></html></string>
|
||||
@@ -176,6 +156,86 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<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="2" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>10</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1" alignment="Qt::AlignLeft">
|
||||
<widget class="QComboBox" name="themesCmb">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3" alignment="Qt::AlignLeft">
|
||||
<widget class="QCheckBox" name="checkAutostart">
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3" alignment="Qt::AlignLeft">
|
||||
<widget class="QLabel" name="lblDisks_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start on boot</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
||||
@@ -18,7 +18,7 @@ StartupAppEdit::StartupAppEdit(QWidget *parent) :
|
||||
"Exec=%3\n"
|
||||
"Type=Application\n"
|
||||
"Terminal=false\n"
|
||||
"Hidden=true")
|
||||
"Hidden=true\n")
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -78,20 +78,17 @@ void StartupAppEdit::changeDesktopValue(QStringList &lines, const QRegExp ®,
|
||||
|
||||
void StartupAppEdit::on_saveBtn_clicked()
|
||||
{
|
||||
if(isValid())
|
||||
{
|
||||
if(! selectedFilePath.isEmpty())
|
||||
{
|
||||
if(isValid()) {
|
||||
if(! selectedFilePath.isEmpty()) {
|
||||
QStringList lines = FileUtil::readListFromFile(selectedFilePath);
|
||||
|
||||
changeDesktopValue(lines, NAME_REG, QString("Name=%1").arg(ui->appNameTxt->text()));
|
||||
changeDesktopValue(lines, COMMENT_REG, QString("Comment=%1").arg(ui->appCommentTxt->text()));
|
||||
changeDesktopValue(lines, EXEC_REG, QString("Exec=%1").arg(ui->appCommandTxt->text()));
|
||||
|
||||
FileUtil::writeFile(selectedFilePath, QString(lines.join("\n")), QIODevice::ReadWrite | QIODevice::Truncate);
|
||||
FileUtil::writeFile(selectedFilePath, lines.join("\n").append('\n'), QIODevice::ReadWrite | QIODevice::Truncate);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
// new file content
|
||||
QString appContent = newAppTemplate
|
||||
.arg(ui->appNameTxt->text())
|
||||
@@ -109,7 +106,7 @@ void StartupAppEdit::on_saveBtn_clicked()
|
||||
}
|
||||
|
||||
close();
|
||||
closeWindow(); // signal
|
||||
emit closeWindow(); // signal
|
||||
}
|
||||
else {
|
||||
ui->errorMsg->show();
|
||||
|
||||
@@ -82,11 +82,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2" alignment="Qt::AlignHCenter">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="title">
|
||||
<property name="text">
|
||||
<string>Application</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
|
||||
@@ -19,8 +19,8 @@ UninstallerPage::UninstallerPage(QWidget *parent) :
|
||||
|
||||
void UninstallerPage::init()
|
||||
{
|
||||
auto path = QString(":/static/themes/%1/img/loading.gif").arg(AppManager::ins()->getThemeName());
|
||||
auto loadingMovie = new QMovie(path, QByteArray(), this);
|
||||
QString path = QString(":/static/themes/%1/img/loading.gif").arg(AppManager::ins()->getThemeName());
|
||||
QMovie *loadingMovie = new QMovie(path, QByteArray(), this);
|
||||
ui->loading->setMovie(loadingMovie);
|
||||
loadingMovie->start();
|
||||
ui->loading->hide();
|
||||
|
||||
@@ -63,6 +63,7 @@ int main(int argc, char *argv[])
|
||||
splashShadowEffect->setOffset(0);
|
||||
|
||||
QSplashScreen splash(pixmap);
|
||||
|
||||
splash.setGraphicsEffect(splashShadowEffect);
|
||||
|
||||
splash.show();
|
||||
|
||||
@@ -67,5 +67,6 @@
|
||||
<file>static/themes/default/img/sidebar-icons/ppa-manager.png</file>
|
||||
<file>static/themes/default/img/ppa-repository.png</file>
|
||||
<file>static/splashscreen.png</file>
|
||||
<file>static/loading.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
33
stacer/static/loading.svg
Normal file
33
stacer/static/loading.svg
Normal file
@@ -0,0 +1,33 @@
|
||||
<!-- By Sam Herbert (@sherb), for everyone. More @ http://goo.gl/7AJzbL -->
|
||||
<svg width="120" height="30" viewBox="0 0 120 30" xmlns="http://www.w3.org/2000/svg" fill="#fff">
|
||||
<circle cx="15" cy="15" r="15">
|
||||
<animate attributeName="r" from="15" to="15"
|
||||
begin="0s" dur="0.8s"
|
||||
values="15;9;15" calcMode="linear"
|
||||
repeatCount="indefinite" />
|
||||
<animate attributeName="fill-opacity" from="1" to="1"
|
||||
begin="0s" dur="0.8s"
|
||||
values="1;.5;1" calcMode="linear"
|
||||
repeatCount="indefinite" />
|
||||
</circle>
|
||||
<circle cx="60" cy="15" r="9" fill-opacity="0.3">
|
||||
<animate attributeName="r" from="9" to="9"
|
||||
begin="0s" dur="0.8s"
|
||||
values="9;15;9" calcMode="linear"
|
||||
repeatCount="indefinite" />
|
||||
<animate attributeName="fill-opacity" from="0.5" to="0.5"
|
||||
begin="0s" dur="0.8s"
|
||||
values=".5;1;.5" calcMode="linear"
|
||||
repeatCount="indefinite" />
|
||||
</circle>
|
||||
<circle cx="105" cy="15" r="15">
|
||||
<animate attributeName="r" from="15" to="15"
|
||||
begin="0s" dur="0.8s"
|
||||
values="15;9;15" calcMode="linear"
|
||||
repeatCount="indefinite" />
|
||||
<animate attributeName="fill-opacity" from="1" to="1"
|
||||
begin="0s" dur="0.8s"
|
||||
values="1;.5;1" calcMode="linear"
|
||||
repeatCount="indefinite" />
|
||||
</circle>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
Reference in New Issue
Block a user