Skip to content

Commit

Permalink
Add developer mode accessed by tapping 7 times on the Papyros logo
Browse files Browse the repository at this point in the history
  • Loading branch information
iBelieve committed Jan 18, 2016
1 parent ac9c387 commit 0bf3871
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 1 deletion.
1 change: 1 addition & 0 deletions modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ install_settings_module(io.papyros.settings.display display)
install_settings_module(io.papyros.settings.network network)
install_settings_module(io.papyros.settings.sound sound)
install_settings_module(io.papyros.settings.users users)
install_settings_module(io.papyros.settings.developer developer)
28 changes: 28 additions & 0 deletions modules/about/qml/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ import Material.ListItems 0.1 as ListItem
import Papyros.Desktop 0.1

Item {
property int developerClickCount: 0
readonly property int developerTotalClicks: 7
readonly property int developerClickRemaining: developerTotalClicks - developerClickCount

Column {
id: column
anchors.centerIn: parent
Expand All @@ -33,6 +37,26 @@ Item {
height: width

source: Qt.resolvedUrl("papyros-icon.png")

MouseArea {
anchors.fill: parent
onClicked: {
if (developerSettings.developerMode == "true")
return

developerClickCount++

print(developerClickCount, developerClickRemaining)

if (developerClickRemaining == 0) {
snackbar.open("You are now a developer!")
developerSettings.developerMode = "true"
} else if (developerClickRemaining <= 3) {
snackbar.open(("You are now %1 steps from becoming a " +
"developer").arg(developerClickRemaining))
}
}
}
}

Row {
Expand Down Expand Up @@ -86,4 +110,8 @@ Item {
}
}
}

Snackbar {
id: snackbar
}
}
4 changes: 3 additions & 1 deletion modules/appearance/qml/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ ModuleView {

ListItem.Standard {
text: "Transparent app shelf"
interactive: false

onClicked: appShelfSwitch.checked = !appShelfSwitch.checked

secondaryItem: Switch {
id: appShelfSwitch
anchors.centerIn: parent

checked: ShellSettings.appShelf.transparentShelf
Expand Down
16 changes: 16 additions & 0 deletions modules/developer/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Developer",
"iconSource": "icon://device/developer_mode",
"category": "system",
"keywords": [
"developer",
"mode",
"advanced",
"tweak",
"tools",
"terminal",
"pro"
],
"priority": 0,
"developerOnly": true
}
61 changes: 61 additions & 0 deletions modules/developer/qml/Main.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* System Settings - Settings app for Papyros
* Copyright (C) 2016 Michael Spencer <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.4
import Material 0.2
import Material.Extras 0.1
import Material.ListItems 0.1 as ListItem
import Papyros.Desktop 0.1
import io.papyros.settings 0.1
import QtAccountsService 1.0

ModuleView {

Subheader {
text: "Terminal"
textColor: Theme.accentColor
}

ListItem.Standard {
text: "Hide warning when pasting sudo commands"

onClicked: hideSudoWarningSwitch.checked = !hideSudoWarningSwitch.checked

secondaryItem: Switch {
id: hideSudoWarningSwitch
anchors.centerIn: parent

checked: terminalSettings.hideSudoWarning
onCheckedChanged: {
terminalSettings.hideSudoWarning = checked
checked = Qt.binding(function() {
return terminalSettings.hideSudoWarning
})
}
}
}

KQuickConfig {
id: terminalSettings

file: "papyros-terminal"
group: "general"
defaults: {
"hideSudoWarning": "false"
}
}
}
10 changes: 10 additions & 0 deletions src/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,13 @@ int Module::priority() const
return 1;
}
}

bool Module::developerOnly() const
{
if (json.contains("developerOnly")) {
return json["developerOnly"].toVariant().toBool();
}
else {
return false;
}
}
2 changes: 2 additions & 0 deletions src/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Module : public QObject
Q_PROPERTY(QStringList keywords READ keywords CONSTANT)
Q_PROPERTY(QUrl componentUrl READ componentUrl CONSTANT)
Q_PROPERTY(int priority READ priority CONSTANT)
Q_PROPERTY(bool developerOnly READ developerOnly CONSTANT)

Q_ENUMS(Category)

Expand All @@ -53,6 +54,7 @@ class Module : public QObject
QStringList keywords() const;
QUrl componentUrl() const;
int priority() const;
bool developerOnly() const;

private:
QJsonObject json;
Expand Down
13 changes: 13 additions & 0 deletions src/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ ApplicationWindow {
onClicked: moduleContainer.module = edit
showDivider: index == personalRepeater.count - 1
dividerInset: 0
visible: developerSettings.developerMode == "true" || !edit.developerOnly
}
}

Expand All @@ -86,6 +87,7 @@ ApplicationWindow {
onClicked: moduleContainer.module = edit
showDivider: index == hardwareRepeater.count - 1
dividerInset: 0
visible: developerSettings.developerMode == "true" || !edit.developerOnly
}
}

Expand All @@ -103,6 +105,7 @@ ApplicationWindow {
text: edit.name
selected: moduleContainer.module == edit
onClicked: moduleContainer.module = edit
visible: developerSettings.developerMode == "true" || !edit.developerOnly
}
}
}
Expand Down Expand Up @@ -143,4 +146,14 @@ ApplicationWindow {
"selectedModule": ""
}
}

KQuickConfig {
id: developerSettings

file: "papyros"
group: "developer"
defaults: {
"developerMode": "false"
}
}
}

0 comments on commit 0bf3871

Please sign in to comment.