Skip to content

Commit

Permalink
Add settings for theme selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Iktwo committed Sep 30, 2016
1 parent fabd9d3 commit af092e0
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ public class CustomFirebaseMessagingService extends FirebaseMessagingService {

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.d(TAG, "From: " + remoteMessage.getFrom());
// Log.d(TAG, "From: " + remoteMessage.getFrom());

if (remoteMessage.getData().size() > 0) {
Log.d(TAG, "Message data payload: " + remoteMessage.getData());
// Log.d(TAG, "Message data payload: " + remoteMessage.getData());
}

if (remoteMessage.getNotification() != null) {
Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
// Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import com.google.firebase.analytics.FirebaseAnalytics;

public class QuteLauncherFlavored extends QuteLauncher {
private FirebaseAnalytics mFirebaseAnalytics;
private FirebaseAnalytics firebaseAnalytics;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
firebaseAnalytics = FirebaseAnalytics.getInstance(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public void onReceive(final Context context, Intent intent) {
final String packageName = intent.getData().getSchemeSpecificPart();

if (packageName == null || packageName.length() == 0) {
// they sent us a bad intent
return;
}

Expand Down
3 changes: 0 additions & 3 deletions src/android/src/com/iktwo/qutelauncher/QuteLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,8 @@ public static void launchApplication(String packageName) {
}

public static byte[] getApplicationIcon(String packageName) {
// Log.d(TAG, "TRYING TO GET ICON FOR: " + packageName);

Drawable icon;

/// Get application icon
try {
ApplicationInfo app = mPm.getApplicationInfo(packageName, 0);
Resources resources = mPm.getResourcesForApplication(app);
Expand Down
8 changes: 8 additions & 0 deletions src/qml/IntroView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,17 @@ FocusScope {
maximumFlickVelocity: width * 2

delegate: Item {
property int parentIndex: listView.currentIndex

height: ListView.view.height
width: ListView.view.width

onParentIndexChanged: {
if (parentIndex === index + 1) {
loader.item.next()
}
}

Loader {
id: loader

Expand Down
32 changes: 32 additions & 0 deletions src/qml/components/RadioButtonStyleDefault.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import QtQuick 2.6
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import com.iktwo.qutelauncher 1.0 as QL

RadioButtonStyle {
label: Label {
text: control.text
color: "#ffffff"
}

indicator: Rectangle {
implicitWidth: QL.ScreenValues.dp * 16
implicitHeight: QL.ScreenValues.dp * 16
radius: QL.ScreenValues.dp * 9
border {
color: control.activeFocus ? "darkblue" : "gray"
width: QL.ScreenValues.dp * 1
}

Rectangle {
anchors {
fill: parent
margins: QL.ScreenValues.dp * 4
}

visible: control.checked
color: "#555"
radius: QL.ScreenValues.dp * 9
}
}
}
1 change: 1 addition & 0 deletions src/qml/components/qmldir
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
MenuItem 1.0 MenuItem.qml
RadioButtonStyleDefault 1.0 RadioButtonStyleDefault.qml
PressAndHoldMenu 1.0 PressAndHoldMenu.qml
7 changes: 3 additions & 4 deletions src/qml/intro/IntroEnd.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ import QtQuick 2.6
import QtQuick.Controls 1.4
import com.iktwo.qutelauncher 1.0 as QL

Item {
IntroScreen {
id: root

signal done

Button {
anchors.centerIn: parent

text: "DONE"
text: qsTr("DONE")

onClicked: root.done()
}
}
2 changes: 1 addition & 1 deletion src/qml/intro/IntroMain.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import QtQuick 2.6
import QtQuick.Controls 1.4
import com.iktwo.qutelauncher 1.0 as QL

Item {
IntroScreen {

Column {
anchors {
Expand Down
11 changes: 11 additions & 0 deletions src/qml/intro/IntroScreen.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import QtQuick 2.0
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import Qt.labs.settings 1.0
import com.iktwo.qutelauncher 1.0 as QL
import components 1.0 as C

FocusScope {
signal done
signal next
}
39 changes: 39 additions & 0 deletions src/qml/intro/IntroSelection.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import QtQuick 2.0
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import Qt.labs.settings 1.0
import com.iktwo.qutelauncher 1.0 as QL
import components 1.0 as C

IntroScreen {
Column {
anchors.centerIn: parent

Repeater {
id: repeater

model: ["Classic", "Tiles"]

RadioButton {
text: modelData
checked: index === 0

style: C.RadioButtonStyleDefault { }

exclusiveGroup: exclusiveGroupTheme
}
}
}

Settings {
id: settings

property string theme: repeater.model[0].toLowerCase()
}

ExclusiveGroup {
id: exclusiveGroupTheme
}

onNext: settings.theme = exclusiveGroupTheme.current.text.toLowerCase()
}
67 changes: 32 additions & 35 deletions src/qml/main.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Window 2.2
import Qt.labs.settings 1.0
import com.iktwo.qutelauncher 1.0 as QL
import config 1.0 as Config
import debug 1.0 as D
Expand All @@ -24,6 +25,8 @@ ApplicationWindow {

property bool activeScreen: Qt.application.state === Qt.ApplicationActive

property string currentTheme

function updatePortraitMode() {
if (height >= width)
Config.Theme.portrait = true
Expand Down Expand Up @@ -63,50 +66,38 @@ ApplicationWindow {
Config.Theme.tablet = QL.ScreenValues.isTablet
}

FocusScope {
id: keyHandler

height: 1
width: 1

focus: true
Timer {
interval: 550
running: true

Keys.onBackPressed: {
if (loaderMainTheme.item && loaderMainTheme.item.opened) {
QL.Launcher.minimize()
}
onTriggered: {
QL.Launcher.registerMethods()
QL.PackageManager.registerBroadcast()
}
}

Keys.onUpPressed: {
if (Qt.platform.os !== "android")
explandableItem.open()

event.accepted = false
}
Component {
id: componentSettings

Keys.onDownPressed: {
if (Qt.platform.os !== "android")
explandableItem.close()
Item {

event.accepted = false
}
}

Timer {
interval: 550
running: true
Settings {
property string theme

onTriggered: {
QL.Launcher.registerMethods()
QL.PackageManager.registerBroadcast()
}
onThemeChanged: currentTheme = theme
}

Loader {
id: loaderMainTheme

anchors.fill: parent
source: "themes/classic/ThemeMain.qml"

focus: true

source: currentTheme !== "" ? ("themes/" + currentTheme + "/ThemeMain.qml") : undefined
}

Loader {
Expand All @@ -118,7 +109,15 @@ ApplicationWindow {

anchors.fill: parent

sourceComponent: !QL.ApplicationInfo.hasShownInitialDialog ? introView : undefined
sourceComponent: !QL.ApplicationInfo.hasShownInitialDialog ? introView : componentSettings

focus: true

Keys.onBackPressed: {
if (loaderMainTheme.item && loaderMainTheme.item.opened) {
QL.Launcher.minimize()
}
}

Component {
id: introView
Expand All @@ -129,21 +128,19 @@ ApplicationWindow {
statusbarMargin: QL.ScreenValues.statusBarHeight
navbarMargin: QL.ScreenValues.navBarVisible ? QL.ScreenValues.navigationBarHeight : 0

// enabled: false
// visible: false

model: ListModel {
ListElement { name: "IntroMain.qml"; backgroundColor: "#424242" }
ListElement { name: "IntroEnd.qml"; backgroundColor: "#2c3e50" }
ListElement { name: "IntroSelection.qml"; backgroundColor: "#2c3e50" }
ListElement { name: "IntroEnd.qml"; backgroundColor: "#424242" }
}

onDone: {
QL.ApplicationInfo.hasShownInitialDialog = true
loader.unload()
loader.sourceComponent = componentSettings
}
}
}

}

Image {
Expand Down
18 changes: 17 additions & 1 deletion src/qml/themes/classic/ThemeMain.qml
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
import QtQuick 2.0
import com.iktwo.qutelauncher 1.0 as QL

Item {
FocusScope {
id: root

property int navbarMargin: QL.ScreenValues.navBarVisible ? QL.ScreenValues.navigationBarHeight : 0
property int statusbarMargin: QL.ScreenValues.statusBarHeight

property bool opened: explandableItem.isOpened

focus: true

Keys.onUpPressed: {
if (Qt.platform.os !== "android")
explandableItem.open()

event.accepted = false
}

Keys.onDownPressed: {
if (Qt.platform.os !== "android")
explandableItem.close()

event.accepted = false
}

MouseArea {
anchors.fill: parent

Expand Down
3 changes: 2 additions & 1 deletion src/qml/themes/tiles/ApplicationList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Item {
bottom: parent.bottom
}

cacheBuffer: height * 9
cacheBuffer: height >= 0 ? (height * 9) : root.height
maximumFlickVelocity: root.height * 2.5

section {
Expand Down Expand Up @@ -133,6 +133,7 @@ Item {

Image {
anchors.fill: parent

antialiasing: true
/// TODO: verify this
source: "qrc:/images/menu"
Expand Down
3 changes: 3 additions & 0 deletions src/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
<file>qml/components/qmldir</file>
<file>qml/themes/classic/ApplicationGridMenu.qml</file>
<file>qml/components/MenuItem.qml</file>
<file>qml/intro/IntroSelection.qml</file>
<file>qml/components/RadioButtonStyleDefault.qml</file>
<file>qml/intro/IntroScreen.qml</file>
</qresource>
<qresource prefix="/images">
<file alias="test">resources/images/test.png</file>
Expand Down

0 comments on commit af092e0

Please sign in to comment.