diff --git a/dde-introduction.qrc b/dde-introduction.qrc
index 46f3bc6..9672a9d 100644
--- a/dde-introduction.qrc
+++ b/dde-introduction.qrc
@@ -16,5 +16,8 @@
resources/fashion_mode_big@2x.png
resources/fashion_mode_small.png
resources/fashion_mode_small@2x.png
+ resources/config.json
+ resources/list_select.png
+ resources/list_select@2x.png
diff --git a/resources/config.json b/resources/config.json
new file mode 100644
index 0000000..422811a
--- /dev/null
+++ b/resources/config.json
@@ -0,0 +1,43 @@
+{
+ "groups": [
+ {
+ "key": "introduce",
+ "name": "introduce",
+ "groups": [
+ {
+ "key": "introduce",
+ "name": "introduce",
+ "options": [
+ {
+ "key": "DesktopMode",
+ "name": "DesktopMode",
+ "type": "desktopMode"
+ }
+ ]
+ },
+ {
+ "key": "desktopmode",
+ "name": "desktopmode",
+ "options": [
+ {
+ "key": "wmmode",
+ "name": "wmmode",
+ "type": "wmMode"
+ }
+ ]
+ },
+ {
+ "key": "iconmode",
+ "name": "iconmode",
+ "options": [
+ {
+ "key": "iconmode",
+ "name": "iconmode",
+ "type": "iconMode"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+}
diff --git a/resources/list_select.png b/resources/list_select.png
new file mode 100644
index 0000000..8867361
Binary files /dev/null and b/resources/list_select.png differ
diff --git a/resources/list_select@2x.png b/resources/list_select@2x.png
new file mode 100644
index 0000000..a04e6e4
Binary files /dev/null and b/resources/list_select@2x.png differ
diff --git a/src/main.cc b/src/main.cc
index 95ecc95..708f417 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -17,7 +17,7 @@
*/
#include "mainwindow.h"
-
+#include "normalwindow.h"
#include
#include
@@ -42,5 +42,9 @@ int main(int argc, char *argv[])
w.moveToCenter();
w.exec();
- return a.exec();
+ NormalWindow n;
+ n.setFixedWidth(750);
+ n.exec();
+
+ return 0;
}
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 17050bc..e4218fc 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -117,6 +117,9 @@ void MainWindow::updateModule(const int index)
case 4:
m_current = initIconModule();
break;
+ case 5:
+ close();
+ break;
default:
break;
}
@@ -148,7 +151,10 @@ BaseModuleWidget *MainWindow::initVideoWidgt()
BaseModuleWidget *MainWindow::initDesktopModeModule()
{
- BaseModuleWidget* w = new BaseModuleWidget(new DesktopModeModule, m_fakerWidget);
+ DesktopModeModule *module = new DesktopModeModule;
+ module->updateBigIcon();
+
+ BaseModuleWidget* w = new BaseModuleWidget(module, m_fakerWidget);
w->setTitle(tr("Please select desktop mode"));
w->setDescribe(tr("You can switch it in Mode by right clicking on dock"));
return w;
@@ -156,13 +162,19 @@ BaseModuleWidget *MainWindow::initDesktopModeModule()
BaseModuleWidget *MainWindow::initWMModeModule()
{
- BaseModuleWidget* w = new BaseModuleWidget(new WMModeModule, m_fakerWidget);
+ WMModeModule *module = new WMModeModule;
+ module->updateBigIcon();
+
+ BaseModuleWidget* w = new BaseModuleWidget(module, m_fakerWidget);
return w;
}
BaseModuleWidget *MainWindow::initIconModule()
{
- BaseModuleWidget* w = new BaseModuleWidget(new IconModule, m_fakerWidget);
+ IconModule *module = new IconModule;
+ module->updateBigIcon();
+
+ BaseModuleWidget* w = new BaseModuleWidget(module, m_fakerWidget);
w->setTitle(tr("Please select icon theme"));
w->setDescribe(tr("You can change it in Control Center > Personalization > Theme > Icon Theme"));
return w;
diff --git a/src/model.h b/src/model.h
index 65de1a5..15953d2 100644
--- a/src/model.h
+++ b/src/model.h
@@ -28,7 +28,7 @@ struct IconStruct {
QString Id;
QString Path;
bool Deletable;
- QPixmap Pixmap;
+ QString Pixmap;
bool operator ==(const IconStruct &icon) const {
return Id == icon.Id;
@@ -50,7 +50,7 @@ struct IconStruct {
Icon.Id = object["Id"].toString();
Icon.Path = object["Path"].toString();
Icon.Deletable = object["Deletable"].toBool();
- Icon.Pixmap = QPixmap(object["Pixmap"].toString());
+ Icon.Pixmap = object["Pixmap"].toString();
return Icon;
}
@@ -72,6 +72,11 @@ class Model : public QObject
WM_3D
};
+ enum IconType {
+ Big,
+ Small
+ };
+
inline IconStruct currentIcon() { return m_currentIcon; }
inline QList iconList() { return m_iconList; }
inline WMType wmType() const { return m_wmType; }
diff --git a/src/modules/desktopmodemodule.cc b/src/modules/desktopmodemodule.cc
index 0435ec6..3c5bd70 100644
--- a/src/modules/desktopmodemodule.cc
+++ b/src/modules/desktopmodemodule.cc
@@ -19,19 +19,14 @@
#include "desktopmodemodule.h"
DesktopModeModule::DesktopModeModule(QWidget *parent)
- : QFrame(parent)
+ : ModuleInterface(parent)
, m_layout(new QHBoxLayout(this))
- , m_model(Model::Instance())
- , m_worker(Worker::Instance())
, m_efficientWidget(new BaseWidget(this))
, m_fashionWidget(new BaseWidget(this))
{
m_efficientWidget->setTitle(tr("Efficient Mode"));
m_fashionWidget->setTitle(tr("Fashion Mode"));
- m_efficientWidget->setPixmap(":/resources/effective_mode_big.png");
- m_fashionWidget->setPixmap(":/resources/fashion_mode_big.png");
-
connect(m_model, &Model::desktopModeChanged, this, &DesktopModeModule::onDesktopTypeChanged);
connect(m_fashionWidget, &BaseWidget::clicked, this, [=] {
m_worker->setDesktopMode(Model::FashionMode);
@@ -65,4 +60,16 @@ void DesktopModeModule::onDesktopTypeChanged(Model::DesktopMode mode)
}
}
+void DesktopModeModule::updateBigIcon()
+{
+ m_efficientWidget->setPixmap(":/resources/effective_mode_big.png");
+ m_fashionWidget->setPixmap(":/resources/fashion_mode_big.png");
+}
+
+void DesktopModeModule::updateSmaillIcon()
+{
+ m_efficientWidget->setPixmap(":/resources/effective_mode_small.png");
+ m_fashionWidget->setPixmap(":/resources/fashion_mode_small.png");
+}
+
diff --git a/src/modules/desktopmodemodule.h b/src/modules/desktopmodemodule.h
index c39d1ca..7c837cf 100644
--- a/src/modules/desktopmodemodule.h
+++ b/src/modules/desktopmodemodule.h
@@ -19,6 +19,7 @@
#ifndef DESKTOPMODEMODULE_H
#define DESKTOPMODEMODULE_H
+#include "moduleinterface.h"
#include "../widgets/basewidget.h"
#include "../model.h"
#include "../worker.h"
@@ -26,19 +27,21 @@
#include
#include
-class DesktopModeModule : public QFrame
+class DesktopModeModule : public ModuleInterface
{
Q_OBJECT
public:
explicit DesktopModeModule(QWidget *parent = nullptr);
+ void updateBigIcon() Q_DECL_OVERRIDE;
+ void updateSmaillIcon() Q_DECL_OVERRIDE;
+
private Q_SLOTS:
void onDesktopTypeChanged(Model::DesktopMode mode);
+
private:
QHBoxLayout* m_layout;
- Model* m_model;
- Worker* m_worker;
BaseWidget* m_efficientWidget;
BaseWidget* m_fashionWidget;
};
diff --git a/src/modules/iconmodule.cc b/src/modules/iconmodule.cc
index b4de01a..818b8a6 100644
--- a/src/modules/iconmodule.cc
+++ b/src/modules/iconmodule.cc
@@ -18,11 +18,11 @@
#include "iconmodule.h"
+#include
+
IconModule::IconModule(QWidget *parent)
- : QScrollArea(parent)
+ : ModuleInterface(parent)
, m_layout(new DFlowLayout(this))
- , m_model(Model::Instance())
- , m_worker(Worker::Instance())
{
connect(m_model, &Model::iconAdded, this, &IconModule::addIcon);
connect(m_model, &Model::iconRemoved, this, &IconModule::removeIcon);
@@ -37,19 +37,7 @@ IconModule::IconModule(QWidget *parent)
m_layout->setSpacing(20);
m_layout->setContentsMargins(15, 0, 10, 0);
- QWidget *content = new QWidget;
- content->setLayout(m_layout);
-
- setWidget(content);
- setWidgetResizable(true);
- setFocusPolicy(Qt::NoFocus);
- setFrameStyle(QFrame::NoFrame);
- setContentsMargins(0, 0, 0, 0);
- setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- setStyleSheet("background-color:transparent;");
-
- setFixedSize(750, 300);
+ setLayout(m_layout);
}
void IconModule::addIcon(const IconStruct &icon)
@@ -59,7 +47,12 @@ void IconModule::addIcon(const IconStruct &icon)
}
BaseWidget *base = new BaseWidget(this);
- base->setPixmap(icon.Pixmap);
+
+ QPixmap pixmap(icon.Pixmap);
+ pixmap.setDevicePixelRatio(devicePixelRatioF());
+
+ base->setPixmap(pixmap);
+ base->setTitle(icon.Id);
connect(base, &BaseWidget::clicked, this, [=] {
m_worker->setIcon(icon);
@@ -90,3 +83,13 @@ void IconModule::currentIconChanged(const IconStruct &icon)
map.next();
}
}
+
+void IconModule::updateBigIcon()
+{
+ setFixedWidth(750);
+}
+
+void IconModule::updateSmaillIcon()
+{
+
+}
diff --git a/src/modules/iconmodule.h b/src/modules/iconmodule.h
index 4f3360e..a008800 100644
--- a/src/modules/iconmodule.h
+++ b/src/modules/iconmodule.h
@@ -19,6 +19,7 @@
#ifndef ICONMODULE_H
#define ICONMODULE_H
+#include "moduleinterface.h"
#include "../widgets/basewidget.h"
#include "../model.h"
#include "../worker.h"
@@ -29,12 +30,15 @@
DWIDGET_USE_NAMESPACE
-class IconModule : public QScrollArea
+class IconModule : public ModuleInterface
{
Q_OBJECT
public:
explicit IconModule(QWidget *parent = nullptr);
+ void updateBigIcon() Q_DECL_OVERRIDE;
+ void updateSmaillIcon() Q_DECL_OVERRIDE;
+
private Q_SLOTS:
void addIcon(const IconStruct &icon);
void removeIcon(const IconStruct &icon);
@@ -42,8 +46,6 @@ private Q_SLOTS:
private:
DFlowLayout* m_layout;
- Model* m_model;
- Worker* m_worker;
QMap m_iconList;
};
diff --git a/src/modules/moduleinterface.cc b/src/modules/moduleinterface.cc
new file mode 100644
index 0000000..edf4d01
--- /dev/null
+++ b/src/modules/moduleinterface.cc
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd.
+ *
+ * Author: kirigaya
+ * 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
+ * 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 .
+ */
+
+#include "moduleinterface.h"
+
+ModuleInterface::ModuleInterface(QWidget *parent)
+ : QFrame(parent)
+ , m_model(Model::Instance())
+ , m_worker(Worker::Instance())
+{
+
+}
+
+void ModuleInterface::setIconType(Model::IconType type)
+{
+ switch (type) {
+ case Model::Big:
+ updateBigIcon();
+ break;
+ case Model::Small:
+ updateSmaillIcon();
+ break;
+ default:
+ break;
+ }
+}
diff --git a/src/modules/moduleinterface.h b/src/modules/moduleinterface.h
new file mode 100644
index 0000000..3e41490
--- /dev/null
+++ b/src/modules/moduleinterface.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd.
+ *
+ * Author: kirigaya
+ * 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
+ * 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 .
+ */
+
+#ifndef MODULEINTERFACE_H
+#define MODULEINTERFACE_H
+
+#include "../model.h"
+#include "../worker.h"
+
+
+#include
+class ModuleInterface : public QFrame
+{
+ Q_OBJECT
+public:
+ explicit ModuleInterface(QWidget *parent = nullptr);
+
+ void setIconType(Model::IconType type);
+
+ virtual void updateBigIcon() = 0;
+ virtual void updateSmaillIcon() = 0;
+
+protected:
+ Model *m_model;
+ Worker *m_worker;
+};
+
+#endif // MODULEINTERFACE_H
diff --git a/src/modules/wmmodemodule.cc b/src/modules/wmmodemodule.cc
index b995aeb..1ccd258 100644
--- a/src/modules/wmmodemodule.cc
+++ b/src/modules/wmmodemodule.cc
@@ -19,19 +19,14 @@
#include "wmmodemodule.h"
WMModeModule::WMModeModule(QWidget *parent)
- : QFrame(parent)
+ : ModuleInterface(parent)
, m_layout(new QHBoxLayout(this))
- , m_model(Model::Instance())
- , m_worker(Worker::Instance())
, m_efficientWidget(new BaseWidget(this))
, m_fashionWidget(new BaseWidget(this))
{
m_efficientWidget->setTitle(tr("Efficient Mode"));
m_fashionWidget->setTitle(tr("Fashion Mode"));
- m_efficientWidget->setPixmap(":/resources/3d_big.png");
- m_fashionWidget->setPixmap(":/resources/2d_big.png");
-
connect(m_model, &Model::wmTypeChanged, this, &WMModeModule::onWMModeChanged);
connect(m_fashionWidget, &BaseWidget::clicked, this, [=] {
m_worker->setWMMode(Model::WM_2D);
@@ -48,6 +43,18 @@ WMModeModule::WMModeModule(QWidget *parent)
setLayout(m_layout);
}
+void WMModeModule::updateBigIcon()
+{
+ m_efficientWidget->setPixmap(":/resources/3d_big.png");
+ m_fashionWidget->setPixmap(":/resources/2d_big.png");
+}
+
+void WMModeModule::updateSmaillIcon()
+{
+ m_efficientWidget->setPixmap(":/resources/3d_small.png");
+ m_fashionWidget->setPixmap(":/resources/2d_small.png");
+}
+
void WMModeModule::onWMModeChanged(Model::WMType type)
{
diff --git a/src/modules/wmmodemodule.h b/src/modules/wmmodemodule.h
index 5f1402b..145ca98 100644
--- a/src/modules/wmmodemodule.h
+++ b/src/modules/wmmodemodule.h
@@ -19,6 +19,7 @@
#ifndef WMMODEMODULE_H
#define WMMODEMODULE_H
+#include "moduleinterface.h"
#include "../widgets/basewidget.h"
#include "../model.h"
#include "../worker.h"
@@ -26,19 +27,20 @@
#include
#include
-class WMModeModule : public QFrame
+class WMModeModule : public ModuleInterface
{
Q_OBJECT
public:
explicit WMModeModule(QWidget *parent = nullptr);
+ void updateBigIcon() Q_DECL_OVERRIDE;
+ void updateSmaillIcon() Q_DECL_OVERRIDE;
+
private Q_SLOTS:
void onWMModeChanged(Model::WMType type);
private:
QHBoxLayout* m_layout;
- Model* m_model;
- Worker* m_worker;
BaseWidget* m_efficientWidget;
BaseWidget* m_fashionWidget;
};
diff --git a/src/normalwindow.cc b/src/normalwindow.cc
new file mode 100644
index 0000000..10bf0c1
--- /dev/null
+++ b/src/normalwindow.cc
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd.
+ *
+ * Author: kirigaya
+ * 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
+ * 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 .
+ */
+
+#include "normalwindow.h"
+#include "modules/desktopmodemodule.h"
+#include "modules/wmmodemodule.h"
+#include "modules/iconmodule.h"
+#include "basemodulewidget.h"
+
+#include
+
+DCORE_USE_NAMESPACE
+
+static QWidget *createDesktopModeHandle(QObject *opt) {
+ Q_UNUSED(opt);
+
+ DesktopModeModule *module = new DesktopModeModule;
+ module->updateSmaillIcon();
+
+ return new BaseModuleWidget(module);
+}
+
+static QWidget *createWMModeHandle(QObject *opt) {
+ Q_UNUSED(opt);
+
+ WMModeModule *module = new WMModeModule;
+ module->updateSmaillIcon();
+
+ return new BaseModuleWidget(module);
+}
+
+static QWidget *createIconHandle(QObject *opt) {
+ Q_UNUSED(opt);
+
+ return new BaseModuleWidget(new IconModule);
+}
+
+NormalWindow::NormalWindow(QWidget *parent)
+ : DSettingsDialog(parent)
+{
+ widgetFactory()->registerWidget("desktopMode", createDesktopModeHandle);
+ widgetFactory()->registerWidget("wmMode", createWMModeHandle);
+ widgetFactory()->registerWidget("iconMode", createIconHandle);
+
+ DSettings *backend = DSettings::fromJsonFile(":/resources/config.json");
+ updateSettings(backend);
+}
diff --git a/src/normalwindow.h b/src/normalwindow.h
new file mode 100644
index 0000000..b46f24d
--- /dev/null
+++ b/src/normalwindow.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd.
+ *
+ * Author: kirigaya
+ * 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
+ * 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 .
+ */
+
+#ifndef NORMALWINDOW_H
+#define NORMALWINDOW_H
+
+#include
+#include
+#include
+
+DWIDGET_USE_NAMESPACE
+
+class NormalWindow : public DSettingsDialog
+{
+ Q_OBJECT
+public:
+ explicit NormalWindow(QWidget *parent = nullptr);
+
+};
+
+#endif // NORMALWINDOW_H
diff --git a/src/widgets/basewidget.cc b/src/widgets/basewidget.cc
index 8b68e73..9c8be36 100644
--- a/src/widgets/basewidget.cc
+++ b/src/widgets/basewidget.cc
@@ -18,6 +18,7 @@
#include "basewidget.h"
#include
+#include
DWIDGET_USE_NAMESPACE
@@ -26,7 +27,10 @@ BaseWidget::BaseWidget(QWidget *parent)
, m_layout(new QVBoxLayout(this))
, m_title(new QLabel(this))
, m_borderWidget(new BorderWidget(this))
- , m_selectBtn(new DImageButton(this))
+ , m_selectBtn(new DImageButton(":/resources/list_select.png",
+ ":/resources/list_select.png",
+ ":/resources/list_select.png",
+ this))
{
m_layout->setMargin(0);
m_layout->setSpacing(0);
@@ -44,13 +48,10 @@ void BaseWidget::setPixmap(const QString &url) {
void BaseWidget::setPixmap(const QPixmap &pixmap)
{
- m_borderWidget->setFixedSize(pixmap.size() / devicePixelRatioF() + QSize(5, 5));
+ m_borderWidget->setFixedSize(pixmap.size() / devicePixelRatioF() + QSize(6, 6));
m_borderWidget->setPixmap(pixmap);
adjustSize();
-
- m_selectBtn->raise();
- m_selectBtn->move(rect().topRight());
}
void BaseWidget::setTitle(const QString &title)
@@ -60,7 +61,9 @@ void BaseWidget::setTitle(const QString &title)
void BaseWidget::setChecked(const bool checked)
{
-
+ m_selectBtn->raise();
+ m_selectBtn->move(m_borderWidget->rect().topRight());
+ m_selectBtn->setVisible(checked);
}
void BaseWidget::mouseReleaseEvent(QMouseEvent *event)
diff --git a/src/widgets/borderwidget.cc b/src/widgets/borderwidget.cc
index 4f62fa9..e530ff2 100644
--- a/src/widgets/borderwidget.cc
+++ b/src/widgets/borderwidget.cc
@@ -42,15 +42,15 @@ void BorderWidget::paintEvent(QPaintEvent *event)
QPainterPath contentPath;
- QRect pixRect(QPoint(0, 0), m_pixmap.size() / devicePixelRatioF());
+ QRect pixRect(QPoint(3, 3), m_pixmap.size() / devicePixelRatioF());
- contentPath.addRoundedRect(pixRect.adjusted(4, 4, -4, -4), 4, 4);
+ contentPath.addRoundedRect(pixRect, 5, 5);
painter.setClipPath(contentPath);
- painter.drawPixmap(pixRect.adjusted(4, 4, -4, -4), m_pixmap);
+ painter.drawPixmap(pixRect, m_pixmap);
QPainterPath path;
- path.addRoundedRect(pixRect.adjusted(2, 2, -2, -2), 4, 4);
+ path.addRoundedRect(rect().adjusted(1, 1, -1, -1), 5, 5);
painter.setClipRect(QRect(), Qt::NoClip);
QPen pen(QColor("#2CA7F8"));