Skip to content

Commit 2f22734

Browse files
committed
Create behaviour.{ui,h,cpp}
1 parent eda3f4d commit 2f22734

File tree

6 files changed

+107
-35
lines changed

6 files changed

+107
-35
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,16 @@ find_package(LibXml2 REQUIRED)
3535
set(PROJECT_SOURCES
3636
src/main.cpp
3737
src/maindialog.cpp src/maindialog.h src/maindialog.ui
38+
3839
src/layoutmodel.cpp src/layoutmodel.h
40+
3941
src/environment.cpp src/environment.h
4042
src/settings.cpp src/settings.h
4143
src/xml.cpp src/xml.h
42-
src/appearance.cpp src/appearance.h src/appearance.ui
4344
src/find-themes.cpp src/find-themes.h
45+
46+
src/appearance.cpp src/appearance.h src/appearance.ui
47+
src/behaviour.cpp src/behaviour.h src/behaviour.ui
4448
)
4549
set(PROJECT_OTHER_FILES
4650
.github/workflows/build.yml

src/behaviour.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include "behaviour.h"
2+
#include "find-themes.h"
3+
#include "macros.h"
4+
#include "settings.h"
5+
#include "./ui_behaviour.h"
6+
7+
Behaviour::Behaviour(QWidget *parent) : QWidget(parent), ui(new Ui::pageBehaviour)
8+
{
9+
ui->setupUi(this);
10+
}
11+
12+
Behaviour::~Behaviour()
13+
{
14+
delete ui;
15+
}
16+
17+
void Behaviour::activate()
18+
{
19+
/* Placement Policy */
20+
QStringList policies = { "", "Automatic", "Cascade", "Center", "Cursor" };
21+
ui->placementPolicy->addItems(policies);
22+
ui->placementPolicy->setCurrentIndex(
23+
policies.indexOf(getStr("/labwc_config/placement/policy")));
24+
}
25+
26+
void Behaviour::onApply()
27+
{
28+
setStr("/labwc_config/placement/policy", TEXT(ui->placementPolicy));
29+
}

src/behaviour.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#ifndef BEHAVIOUR_H
2+
#define BEHAVIOUR_H
3+
#include <QWidget>
4+
5+
QT_BEGIN_NAMESPACE
6+
namespace Ui {
7+
class pageBehaviour;
8+
}
9+
QT_END_NAMESPACE
10+
11+
class Behaviour : public QWidget
12+
{
13+
Q_OBJECT
14+
15+
public:
16+
Behaviour(QWidget *parent = nullptr);
17+
~Behaviour();
18+
19+
void activate();
20+
void onApply();
21+
22+
private:
23+
Ui::pageBehaviour *ui;
24+
};
25+
#endif // BEHAVIOUR_H

src/behaviour.ui

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>pageBehaviour</class>
4+
<widget class="QWidget" name="pageBehaviour">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>251</width>
10+
<height>153</height>
11+
</rect>
12+
</property>
13+
<layout class="QFormLayout" name="layPage">
14+
<property name="leftMargin">
15+
<number>6</number>
16+
</property>
17+
<property name="topMargin">
18+
<number>6</number>
19+
</property>
20+
<property name="rightMargin">
21+
<number>6</number>
22+
</property>
23+
<property name="bottomMargin">
24+
<number>6</number>
25+
</property>
26+
<item row="0" column="0">
27+
<widget class="QLabel" name="label_7">
28+
<property name="text">
29+
<string>Placement Policy</string>
30+
</property>
31+
</widget>
32+
</item>
33+
<item row="0" column="1">
34+
<widget class="QComboBox" name="placementPolicy"/>
35+
</item>
36+
</layout>
37+
</widget>
38+
<resources/>
39+
<connections/>
40+
</ui>

src/maindialog.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,8 @@ void MainDialog::deleteSelectedLayout(void)
6060

6161
void MainDialog::activate()
6262
{
63-
/* # APPEARANCE */
6463
ui->pageAppearance->activate();
65-
66-
/* # BEHAVIOUR */
67-
QStringList policies = { "", "Automatic", "Cascade", "Center", "Cursor" };
68-
ui->placementPolicy->addItems(policies);
69-
ui->placementPolicy->setCurrentIndex(
70-
policies.indexOf(getStr("/labwc_config/placement/policy")));
64+
ui->pageBehaviour->activate();
7165

7266
/* # MOUSE & TOUCHPAD */
7367

@@ -96,10 +90,10 @@ void MainDialog::activate()
9690
void MainDialog::onApply()
9791
{
9892
ui->pageAppearance->onApply();
93+
ui->pageBehaviour->onApply();
9994

10095
/* ~/.config/labwc/rc.xml */
10196
setBool("/labwc_config/libinput/device/naturalScroll", TEXT(ui->naturalScroll));
102-
setStr("/labwc_config/placement/policy", TEXT(ui->placementPolicy));
10397
xml_save();
10498

10599
/* ~/.config/labwc/environment */

src/maindialog.ui

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -89,32 +89,7 @@
8989
<item>
9090
<widget class="QStackedWidget" name="stack">
9191
<widget class="Appearance" name="pageAppearance"/>
92-
<widget class="QWidget" name="page">
93-
<layout class="QFormLayout" name="layPage">
94-
<property name="leftMargin">
95-
<number>6</number>
96-
</property>
97-
<property name="topMargin">
98-
<number>6</number>
99-
</property>
100-
<property name="rightMargin">
101-
<number>6</number>
102-
</property>
103-
<property name="bottomMargin">
104-
<number>6</number>
105-
</property>
106-
<item row="0" column="0">
107-
<widget class="QLabel" name="label_7">
108-
<property name="text">
109-
<string>Placement Policy</string>
110-
</property>
111-
</widget>
112-
</item>
113-
<item row="0" column="1">
114-
<widget class="QComboBox" name="placementPolicy"/>
115-
</item>
116-
</layout>
117-
</widget>
92+
<widget class="Behaviour" name="pageBehaviour"/>
11893
<widget class="QWidget" name="page2">
11994
<layout class="QFormLayout" name="layPage2">
12095
<property name="leftMargin">
@@ -258,6 +233,11 @@
258233
<extends>QWidget</extends>
259234
<header>appearance.h</header>
260235
</customwidget>
236+
<customwidget>
237+
<class>Behaviour</class>
238+
<extends>QWidget</extends>
239+
<header>behaviour.h</header>
240+
</customwidget>
261241
</customwidgets>
262242
<resources/>
263243
<connections>

0 commit comments

Comments
 (0)