Skip to content

Tuesday, 9 April 2024

C++11线程特性

std::thread

标准库

C++11引入了std::thread来创建线程,支持对线程join或者detach.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <thread>

using namespace std;

int main() {
auto func = []() {
for (int i = 0; i < 10; ++i) {
cout << i << " ";
}
cout << endl;
};
std::thread t(func);
if (t.joinable()) {
t.detach();
}
auto func1 = [](int k) {
for (int i = 0; i < k; ++i) {
cout << i << " ";
}
cout << endl;
};
std::thread tt(func1, 20);
if (tt.joinable()) { // 检查线程可否被join
tt.join();
}
return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class ThreadGuard
{
public:
enum class DeAction{join,detach};
ThreadGuard(std::thread&& t,DeAction action): m_t(move(t)) , m_action(action){};
~ThreadGuard()
{
if(m_t.joinable())
{
if(m_action==DeAction::join)
{
m_t.join();
}
else
{
m_t.detach();
}
}
}
ThreadGuard(ThreadGuard&&)=default;
ThreadGuard& operator=(ThreadGuard&&)=default;
private:
std::thread m_t;
DeAction m_action;
};

c++11还提供了获取线程id,或者系统cpu个数,获取thread native_handle,使得线程休眠等功能

1
2
3
4
5
std::thread t(func);
cout << "当前线程ID " << t.get_id() << endl;
cout << "当前cpu个数 " << std::thread::hardware_concurrency() << endl;
auto handle = t.native_handle();// handle可用于pthread相关操作
std::this_thread::sleep_for(std::chrono::seconds(1));

std::mutex

std::mutex是一种线程同步的手段,用于保存多线程同时操作的共享数据。

文库

mutex分为四种:

  • std::mutex:独占的互斥量,不能递归使用,不带超时功能

  • std::recursive_mutex:递归互斥量,可重入,不带超时功能

  • std::timed_mutex:带超时的互斥量,不能递归

  • std::recursive_timed_mutex:带超时的互斥量,可以递归使用

    std::mutex

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
#include <mutex>
#include <thread>

using namespace std;
std::mutex mutex_;

int main() {
auto func1 = [](int k) {
mutex_.lock();
for (int i = 0; i < k; ++i) {
cout << i << " ";
}
cout << endl;
mutex_.unlock();
};
std::thread threads[5];
for (int i = 0; i < 5; ++i) {
threads[i] = std::thread(func1, 200);
}
for (auto& th : threads) {
th.join();
}
return 0;
}

std::timed_mutex

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
#include <mutex>
#include <thread>
#include <chrono>

using namespace std;
std::timed_mutex timed_mutex_;

int main() {
auto func1 = [](int k) {
timed_mutex_.try_lock_for(std::chrono::milliseconds(200));
for (int i = 0; i < k; ++i) {
cout << i << " ";
}
cout << endl;
timed_mutex_.unlock();
};
std::thread threads[5];
for (int i = 0; i < 5; ++i) {
threads[i] = std::thread(func1, 200);
}
for (auto& th : threads) {
th.join();
}
return 0;
}

std::lock相关

这里主要介绍两种RAII方式的锁封装,可以动态的释放锁资源,防止线程由于编码失误导致一直持有锁。

c++11主要有std::lock_guard和std::unique_lock两种方式,使用方式都类似,如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <mutex>
#include <thread>
#include <chrono>

using namespace std;
std::mutex mutex_;

int main() {
auto func1 = [](int k) {
// std::lock_guard<std::mutex> lock(mutex_);
std::unique_lock<std::mutex> lock(mutex_);
for (int i = 0; i < k; ++i) {
cout << i << " ";
}
cout << endl;
};
std::thread threads[5];
for (int i = 0; i < 5; ++i) {
threads[i] = std::thread(func1, 200);
}
for (auto& th : threads) {
th.join();
}
return 0;
}

std::lock_guard

1
2
3
4
#include <mutex>

template <class Mutex>
class lock_guard;

Mutex 是互斥量的类型。

使用 std::lock_guard 时,只需在需要保护的代码块中创建一个 std::lock_guard 对象,并将需要保护的互斥量传递给它的构造函数。当 std::lock_guard 对象创建时,会自动锁定互斥量,当对象销毁时,会自动解锁互斥量。

std::unique_lock

1
2
3
4
#include <mutex>

template <class Mutex>
class unique_lock;

Mutex 是互斥量的类型。

std::lock_guard 不同,std::unique_lock 对象可以在构造时不锁定互斥量,并且可以在后续的代码中手动锁定或解锁。此外,std::unique_lock 还提供了更多的功能,如可延迟锁定、条件变量的支持等。

std::atomic

c++11提供了原子类型std::atomic,理论上这个T可以是任意类型,但是我平时只存放整形,别的还真的没用过,整形有这种原子变量已经足够方便,就不需要使用std::mutex来保护该变量啦。看一个计数器的代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
struct OriginCounter { // 普通的计数器
int count;
std::mutex mutex_;
void add() {
std::lock_guard<std::mutex> lock(mutex_);
++count;
}

void sub() {
std::lock_guard<std::mutex> lock(mutex_);
--count;
}

int get() {
std::lock_guard<std::mutex> lock(mutex_);
return count;
}
};

struct NewCounter { // 使用原子变量的计数器
std::atomic<int> count;
void add() {
++count;
// count.store(++count);这种方式也可以
}

void sub() {
--count;
// count.store(--count);
}

int get() {
return count.load();
}
};

std::call_once

c++11提供了std::call_once来保证某一函数在多线程环境中只调用一次,它需要配合std::once_flag使用,直接看使用代码吧:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
std::once_flag onceflag;

void CallOnce() {
std::call_once(onceflag, []() {
cout << "call once" << endl;
});
}

int main() {
std::thread threads[5];
for (int i = 0; i < 5; ++i) {
threads[i] = std::thread(CallOnce);
}
for (auto& th : threads) {
th.join();
}
return 0;
}

volatile

volatile通常用来建立内存屏障,volatile修饰的变量,编译器对访问该变量的代码通常不再进行优化,看下面代码:

1
2
3
int *p = xxx;
int a = *p;
int b = *p;

a和b都等于p指向的值,一般编译器会对此做优化,把*p的放入寄存器,之后a,b都等于寄存器的值,但是如果把中间p地址的值改变,内存值改变了,但a,b还是从寄存器中取的值(不一定,看编译器的优化结果),这不符合需求,所以对p加上volatile修饰可以避免此类优化.

注意:volatile不能解决多线程安全问题,针对特种内存才需要使用volatile,它和atomic的特点如下:

  • std::atomic用于多线程访问的数据,且不用互斥量,用于并发编程中
  • volatile用于读写操作不可以被优化掉的内存,用于特种内存中

std::condition_variable

条件变量是c++11引入的一种同步机制,它可以阻塞一个线程或者个线程,直到有线程通知或者超时才会唤醒正在阻塞的线程,条件变量需要和锁配合使用,这里的锁就是上面介绍的std::unique_lock。

成员函数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class CountDownLatch {
public:
explicit CountDownLatch(uint32_t count) : count_(count);

void CountDown() {
std::unique_lock<std::mutex> lock(mutex_);
--count_;
if (count_ == 0) {
cv_.notify_all();
}
}

void Await(uint32_t time_ms = 0) {
std::unique_lock<std::mutex> lock(mutex_);
while (count_ > 0) {
if (time_ms > 0) {
cv_.wait_for(lock, std::chrono::milliseconds(time_ms));
} else {
cv_.wait(lock);
}
}
}

uint32_t GetCount() const {
std::unique_lock<std::mutex> lock(mutex_);
return count_;
}

private:
std::condition_variable cv_;
mutable std::mutex mutex_;
uint32_t count_ = 0;
};
  • notify_one

    • 通知一个线程等待
  • notify_all

    • 通知所有线程等待
  • wait

    • 阻塞当前线程,直到条件变量被唤醒
  • wait_for

    • 阻塞当前线程,知道条件变量被唤醒或指定的超时时间后
  • wait_until

    • 阻塞当前线程,直到条件变量被唤醒或到达指定时间点

std::future

c++11关于异步操作提供了future相关的类,主要有std::future、std::promise和std::packaged_task,std::future比std::thread高级些,std::future作为异步结果的传输通道,通过get()可以很方便的获取线程函数的返回值,std::promise用来包装一个值,将数据和future绑定起来,而std::packaged_task则用来包装一个调用对象,将函数和future绑定起来,方便异步调用。而std::future是不可以复制的,如果需要复制放到容器中可以使用std::shared_future。

std::promise与std::future配合使用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <functional>
#include <future>
#include <iostream>
#include <thread>

using namespace std;

void func(std::future<int>& fut) {
int x = fut.get();
cout << "value: " << x << endl;
}

int main() {
std::promise<int> prom;
std::future<int> fut = prom.get_future();
std::thread t(func, std::ref(fut));
prom.set_value(144);
t.join();
return 0;
}

std::packaged_task与std::future配合使用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <functional>
#include <future>
#include <iostream>
#include <thread>

using namespace std;

int func(int in) {
return in + 1;
}

int main() {
std::packaged_task<int(int)> task(func);
std::future<int> fut = task.get_future();
std::thread(std::move(task), 5).detach();
cout << "result " << fut.get() << endl;
return 0;
}

std::future用于访问异步操作的结果,而std::promise和std::packaged_task在future高一层,它们内部都有一个future,promise包装的是一个值,packaged_task包装的是一个函数,当需要获取线程中的某个值,可以使用std::promise,当需要获取线程函数返回值,可以使用std::packaged_task。

async

async是比future,packaged_task,promise更高级的东西,它是基于任务的异步操作,通过async可以直接创建异步的任务,返回的结果会保存在future中,不需要像packaged_task和promise那么麻烦,关于线程操作应该优先使用async,看一段使用代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <functional>
#include <future>
#include <iostream>
#include <thread>

using namespace std;

int func(int in) { return in + 1; }

int main() {
auto res = std::async(func, 5);
// res.wait();
cout << res.get() << endl; // 阻塞直到函数返回
return 0;
}

async具体语法如下:

1
async(std::launch::async | std::launch::deferred, func, args...);

第一个参数是创建策略:

  • std::launch::async表示任务执行在另一线程
  • std::launch::deferred表示延迟执行任务,调用get或者wait时才会执行,不会创建线程,惰性执行在当前线程。

如果不明确指定创建策略,以上两个都不是async的默认策略,而是未定义,它是一个基于任务的程序设计,内部有一个调度器(线程池),会根据实际情况决定采用哪种策略。

若从 std::async 获得的 std::future 未被移动或绑定到引用,则在完整表达式结尾, std::future的析构函数将阻塞直至异步计算完成,实际上相当于同步操作:

1
2
std::async(std::launch::async, []{ f(); }); // 临时量的析构函数等待 f()
std::async(std::launch::async, []{ g(); }); // f() 完成前不开始

注意:关于async启动策略这里网上和各种书籍介绍的五花八门,这里会以cppreference为主。

有时候我们如果想真正执行异步操作可以对async进行封装,强制使用std::launch::async策略来调用async。

1
2
3
4
template <typename F, typename... Args>
inline auto ReallyAsync(F&& f, Args&&... params) {
return std::async(std::launch::async, std::forward<F>(f), std::forward<Args>(params)...);
}

原文章

补充

Sunday, 7 April 2024

Friday, 5 April 2024

KDE had a feature a lot of people didn’t know about. You could run a command when a notification triggered. The feature wasn’t very well documented and nobody really blogged about it.

However with the release of KDE Plasma 6, the feature was removed. I learned about it by accident, as it is tracked by Bug #481069. I really need the feature and I re-implemented it in KDE Plasma 6. I will be available in KDE Plasma 6.1 and KDE Frameworks 6.1.

KDE: Run a command
KDE: Run a command

Text-to-Speech for calendar events

I’m using the “Run a command” feature for calendar events. Normally you get a popup notification. The popup notification is small and pop up where all of them are shown. When I’m concentrated and working on some code I simply miss them. If I play a game, I miss them.

The solution for me is to use a Text to Speech (TTS) Engine. I’ve setup speech-dispatcher with piper-tts on my system. When an a reminder triggers it says: “Andreas, you have an appointment in 10 minutes: Samba Meeting”.

You can find the python script I use here.

Endless possibilities

The opportunities for doing cool stuff with this are endless. Here are some ideas what else you could do:

  • Start your meeting/conferencing application prior to the meeting
  • Change the desktop activity before a meeting
  • Lock the screen if a specific WiFi gets disconnected

If you have some nice idea or already used it in the past, leave a comment to let me know what else you can do.

KStars v3.7.0 is released on 2024.04.05 for Windows, MacOS & Linux. It's a bi-monthly bug-fix release with a couple of exciting features.

CI & CD Infrastructure


We say goodbye to KDE's binary factory as we transition to fully use Gitlab's CI/CD pipelines to build, test, and publish KStars. Over the last two months, Eric Dejouhanet worked with the KDE's Craft & System admin teams to transition KStars pipelines to the new framework. 



Short status on pipelines:
  • Merge requests run the custom build and the CI builds
  • Master runs the CI build (though there could be other things we run, such as CVE scans)
  • Craft recipes are run from the last commit of the master or release branch, they require "build" and "build-and-test-stable" to be run manually beforehand.
  • Publishing to Microsoft store is available after the Windows Craft is run.
This is still an ongoing process and we hope to have this process fully automated by 3.7.1 release where we will automatically publish latest releases for both stable and master branches.

Donut Buster


Rejoice Newtonian, SCT, and RC owners! With KStars new Donut Buster feature, your donut focusing woes might be something of the past. John Evans implemented this experimental feature to help protect against outliers that might affect your autofocus routine. In addition to that, the Focus Advisor is now automatically applied when creating new profiles. Based on the type of equipment you have in your optical train, the Focus Advisor would try to guess the optimal focus settings for your setup. Both features are experimental and would benefit from your feedback.

Custom Views


Akarsh Simha introduced the ability to orient the sky map to match the view through any instrument.

A view is a collection of settings: the orientation of the sky map, how the orientation changes as the sky map is panned, whether it is mirrored or not, and optionally the field-of-view to set the map to.

If no views are defined, KStars introduces a set of standard / "demo" views by default. Existing views can be edited and new views can be added using the "Edit Views..." interface. They can also be re-ordered in the interface. The ordering of the views in the "Edit Views..." dialog defines the order in which views will be cycled through using the keyboard shortcuts Shift + Page Up and Shift + Page Down. Thus, you can set up the views for easily switching between naked eye / finder scope / telescope views for easy star-hopping.


Furthermore, there is a new option in the View menu that enables mirroring the sky map so as to be able to match the view through an erecting prism used for example on a Schmidt-Cassegrain or Refracting type telescope.

The rotation feature overlay now also marks East in addition to north and zenith, so as to know easily whether the display is mirrored or not.

Blinking


Hy Murveit
added a very useful Blinking feature to the FITS Viewer tool. This adds several ways to blink; that is, compare multiple images.

In Analyze, one can now move from one session to the next (forward or backward).
Keyboard shortcuts are provided for that.

Another set of keyboard shortcuts both advance and show the next image in the same FITS Viewer.

Thus, for example, one can advance through all the captured images of the evening, showing all the captures on the FITS Viewer by repeating a keyboard shortcut.

A useful complement to this might be adding the ability to delete bad captures, but for now that will have to wait for a rainy day.


In the FITS Viewer, the Open File menu command (both in the main KStars top menu, and in the FITS Viewer menu) now allows multiple files to be selected. If they are then the files are opened in individual tabs.

Shift-selecting would select files from the first to the shift-clicked file. Clearly one wouldn't want to select 100 files resulting in 100 tabs, but this can be used to, e.g. compare 10 images.

Going along with the above, keyboard shortcuts have been added to move to the next or previous FITS Viewer tab, Also helpful to the above is a new command to zoom in/out all tabs (not just the current one).

There is a new Blink Directory menu command (in both menus, as above) which will open a single tab with a list of all the images below the directory selected (that is, both in that directory, and in directories below it). It initially displays the first image, but new commands work in that tab to switch to displaying the next (or previous) image file in the list. This could be used to blink hundreds of files.

Sky Flats


Dušan Poizl
added an option to capturing sky flats. When shooting flats at sky it often end up in never-ending loop of adjusting exposure because intensity of light change and calculation of exposure break down. Adjust the tolerance to 2000 ADU to higher for a better chance at capturing sky flats.

Scheduler Refactor


Wolfgang Reissenberger continues with his work on Separating Business Logic from UI in Scheduler. Over the years the Scheduler has grown to one of the most complex classes. With this release we refactored the Scheduler class and separated the UI from the underlying state model and its business logic. This opens the door for future development of new scheduling features and a much modular approach towards more flexible sequencing approaches.

Standalone Editor


To add any job to the scheduler, you need at minimum the following:
  1. Target
  2. Sequence File
The sequence file contains all your sequence settings (e.g. Capture 20x15 LRGB images). To create this file, you first need to add sequence job in the Capture module and then save the corresponding sequence. While this facilitates re-usability across different sessions, some users wanted to create sequence on-the-fly in the scheduler.




Hy Murveit developed the standalone sequence editor in the scheduler module where it relies on settings saved from your last astrophotography session. Now it's easier than ever to plan scheduler jobs without having Ekos or your equipment profile running!

   

Thursday, 4 April 2024

Recently news went around about explicit sync being merged into Wayland protocols, and in the wake of that I saw a lot of people having questions about it, and why it was such a big deal… So here’s a short-ish explanation of what it is, why it’s needed and what the benefits are over the old model.

Why is synchronization needed?

When applications “render” things, that rendering doesn’t happen immediately. Instead, they effectively record a list of commands with OpenGL or Vulkan for the GPU to execute, and that list then gets handed to the GPU to execute at its own pace.

This is needed for performance reasons: If the CPU had to wait for the GPU to execute each command one by one, both CPU and GPU would often sit around, doing nothing except waiting for the other one to finish its task. By executing commands on the GPU while the CPU does other things, like preparing new commands for the GPU, both can do a lot more work in the same time.

However, in practice, rendering commands don’t stand alone on their own. You might be running one task to render an image, and another one to process the result into something else, or to read it back to the CPU, so that it can be saved as a file on disk. If you do that without synchronization, you might be reading from the image in the middle of rendering, or even before the GPU has started to work on the buffer at all.

The “old” model: Implicit sync

Traditionally with graphics APIs like OpenGL, the necessary synchronization has been done implicitly, without the application’s involvement. This means that the kernel and/or the userspace graphics driver look at the commands the application is sending to the GPU, check which images the commands are using, which previous tasks have to be completed before it, and potentially make the application wait until the dependencies of the commands it wants to execute are resolved.

The so-called dma buffer infrastructure that the Linux graphics stack uses for exchanging images between applications - like Wayland apps and the compositor - also uses the same model. When the render commands from the compositor try to read from an app’s buffer, the kernel will delay the command’s execution until the app has completed its rendering to the buffer.

This model makes it easy for application developers to write correctly working applications, but it can also cause issues. The most relevant of them for Wayland is that the application isn’t aware of which tasks it’s synchronizing to, and it can happen that you accidentally and unknowingly synchronize to GPU commands that don’t have any relevance to your task.

This has been a problem that Wayland compositors have been affected by for a long time: When presenting application images to the screen, compositors picked the latest image that the application has provided, which could still have GPU tasks running on it, instead of an earlier image that’s actually ready for presentation. This meant that sometimes presentation was delayed by the kernel, and you’d see a frame be dropped entirely, instead of just a slightly older image. This issue has been solved for most compositors in the last two years using the kernel’s implicit-explicit sync interop mechanism1; I won’t explain the details of that here, but you can read Michel Dänzer’s blog post about it instead.

The “new” model: Explicit sync

The name already suggests exactly what it does: Instead of the driver or the kernel doing potentially unexpected things in the background, the application explicitly tells the relevant components (driver / kernel / compositor / other apps) when rendering is complete and what tasks to synchronize to in the first place, using various synchronization primitives.

On the application side, explicit sync is used in Vulkan, and the Wayland protocol specifically is used internally by OpenGL and Vulkan drivers to synchronize with the Wayland compositor.

This explicit way of synchronizing GPU commands doesn’t just help avoid accidental synchronizations, it also helps improve performance by reducing the work drivers have to do. Instead of having to figure out the dependencies of tasks from a relatively opaque list of commands, apps just tell them directly.

An important thing to mention here is that we already had a protocol for explicit sync, zwp_linux_explicit_synchronization_unstable_v1, but it shared a limitation with implicit sync: In order to get a synchronization primitive, it still required the GPU commands to be first submitted to the kernel. The new protocol in contrast allows to create and share synchronization primitives without submitting work to the GPU first, which - at least in theory - will allow applications to squeeze a little bit more performance out of your hardware in the future.

Do keep in mind though that these performance improvements are minor. While there may be some special cases where implicit sync between app and compositor was the bottleneck before, you’re unlikely to notice the individual difference between implicit and explicit sync at all.

Why the big fuzz then?

If we already have most of the compositor-side problems with implicit sync solved, and explicit sync doesn’t bring major performance improvements for everyone, why is it such big news then?

The answer is simple: The proprietary NVidia driver doesn’t support implicit sync at all, and neither commonly used compositors nor the NVidia driver support the first explicit sync protocol, which means on Wayland you get significant flickering and frame pacing issues. The driver also ships with some workarounds, but they don’t exactly fix the problem either:

  • it delays Wayland commits until rendering is completed, but it goes against how graphics APIs work on Wayland and can cause serious issues, even crash apps in extreme cases
  • it delays X11 presentation until rendering is completed, but as Xwayland copies window contents sometimes, that still often causes glitches if Xwayland is also using the NVidia GPU for those copies

There’s been a lot of discussions around the internet between people experiencing the issues constantly, and others not seeing any, and now you should know why it doesn’t seem to affect everyone: It’s not a deterministic “this doesn’t work” problem but a lack of synchronization, which means that a lot of factors - like the apps you use, the CPU and GPU you have, the driver version, the kernel, compositor and so on - decide whether or not you actually see the issue.

With the explicit sync protocol being implemented in compositors and very soon in Xwayland and the proprietary NVidia driver, all those problems will finally be a thing of the past, and the biggest remaining blocker for NVidia users to switch to Wayland will be gone.


  1. this was referred to as “explicit sync through a backdoor” in an earlier version of this post 

If you have used a moderately complex application there are chances that you have interacted with what is called a “modal” dialog. A modal dialog is a dialog that requires you to close/address it before you can continue interacting with the main application window. This can be implemented by the application in a straightforward manner but compositor didn’t know if a dialog was modal or not.

That is until now the new xdg-dialog-v1 protocol allows applications to mark their dialogs as modal or not modal. This allows the compositor to adapt its behavior according to this hint. For example when trying to activate the main window it can activate the modal dialog instead. It also enables KWin to use the darkening effect on the parent window on Wayland.

I implemented support for the protocol into KWin and Qt which will be part of the Plasma 6.1 and Qt 6.8 releases respectively. The protocol was created from functionality in GTK and Mutter by Carlos Garnacho and I am happy seeing the overall Wayland eco-system now being able to benefit from it.

Tuesday, 2 April 2024

Use Compute Shader in Qt Quick

With this blog post, we introduce the QtQuickComputeItem - a Qt Quick item that allows you to easily integrate compute shader into your Qt Quick Code.
Compute
Shader are used to perform arbitrary computations on the GPU. For
example, the screenshot below shows a Qt Quick application that
generates Gray Scott Reaction Diffusion patterns.  The simulation is executed by a compute shader that is configured directly in QML.

Continue reading Use Compute Shader in Qt Quick at basysKom GmbH.

Monday, 1 April 2024

Marknote 1.1.0 🔗

Carl Schwan CarlSchwan 15:05 +00:00
RSS

Marknote 1.1.0 is out! Marknote is the new WYSIWYG note-taking application from KDE. Despite the latest release being just a few days ago, we have been hard at work and added a few new features and, more importantly, fixed some bugs.

Marknote now boasts broader Markdown support, and can now display images and task lists in the editor. And once you are done editing your notes, you can export them to various formats, including PDF, HTML and ODT.

Export to PDF, HTML and ODT
Export to PDF, HTML and ODT

Marknote’s interface now seamlessly integrates the colors assigned to your notebooks, enhancing its visual coherence and making it easier to distinguish one notebook from another. Additionally, your notebooks remember the last opened note, automatically reopening it upon selection.

Accent color in list delegate
Accent color in list delegate

We’ve also introduced a convenient command bar similar to the one in Merkuro. This provides quick access to essential actions within Marknote. Currently it only creates a new notebook and note, but we plan to make more actions available in the future. Finally we have reworked all the dialogs in Markdown to use the newly introduced FormCardDialog from KirigamiAddons.

Command bar
Command bar

We have created a small feature roadmap with features we would like to add in the future. Contributions are welcome!

Packager section

You can find the package on download.kde.org and it has been signed with my GPG key.

Note that this release introduce a new recommanded dependencies: md4c and require the latest Kirigami Addons release (published a few hours ago).

It’s again time for a new Kirigami Addons release. Kirigami Addons is a collection of helpful components for your QML and Kirigami applications.

FormCard

I added a new FormCard delegate: FormColorDelegate which allow to select a color and a new delegate container: FormCardDialog which is a new type of dialog.

FormCardDialog containing a FormColorDelegate in Marknote
FormCardDialog containing a FormColorDelegate in Marknote

Aside from these new components, Joshua fixed a newline bug in the AboutKDE component and I updated the code examples in the API documentation.

TableView

This new component is intended to provide a powerful table view on top of the barebone one provided by QtQuick and similar to the one we have in our QtWidgets application.

This was contributed by Evgeny Chesnokov. Thanks!

TableView with resizable and sortable columns
TableView with resizable and sortable columns

Other components

The default size of MessageDialog was decreased and is now more appropriate.

MessageDialog new default size
MessageDialog new default size

James Graham fixed the autoplay of the video delegate for the maximized album component.

Packager section

You can find the package on download.kde.org and it has been signed with my GPG key.

While everyone is busy analyzing the highly complex technical details of the recently discovered xz-utils compromise that is currently rocking the internet, it is worth looking at the underlying non-technical problems that make such a compromise possible. A very good write-up can be found on the blog of Rob Mensching...

"A Microcosm of the interactions in Open Source projects"