Skip to content

Commit

Permalink
[linux] fixed ubuntu 18.04 system tray icon color
Browse files Browse the repository at this point in the history
  • Loading branch information
ffiirree committed Apr 13, 2023
1 parent 52fdfeb commit f182212
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 24 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ git submodule update --init --recursive
cd Capturer

cmake -S. -Bbuild -DCMAKE_INSTALL_PREFIX=D:\\"Program Files"\\Capturer
cmake --build build --target install
cmake --build build --target install --config Release
```

### Linux (Ubuntu)
Expand Down Expand Up @@ -163,7 +163,7 @@ sudo apt install libxrandr-dev
cd Capturer && mkdir build && cd build

# Ubuntu 18.4 上的 CMake 版本过低,请先安装更高版本的CMake(>=3.16), 参见下一小节
cmake ..
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j8

# package 'xx.deb'
Expand All @@ -188,6 +188,20 @@ make -j8
sudo make install
```

### Install GCC/G++-11 on Ubuntu 18.04

Ubuntu 18.04 上的 GCC-7 不支持 `<filesystem>`, 更新一下GCC:

```bash
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install gcc-11 g++-11

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70 --slave /usr/bin/g++ g++ /usr/bin/g++-7
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110 --slave /usr/bin/g++ g++ /usr/bin/g++-11
sudo update-alternatives --config gcc
```

## FFmpeg代码示例

可以参考 [ffmpeg_examples](https://github.com/ffiirree/ffmpeg_examples),有不少`FFmpeg`的基础用法。
12 changes: 6 additions & 6 deletions languages/capturer_en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@
<context>
<name>Capturer</name>
<message>
<location filename="../src/capturer.cpp" line="106"/>
<location filename="../src/capturer.cpp" line="108"/>
<source>Screenshot</source>
<translation></translation>
</message>
<message>
<location filename="../src/capturer.cpp" line="107"/>
<location filename="../src/capturer.cpp" line="109"/>
<source>Record Video</source>
<translation></translation>
</message>
<message>
<location filename="../src/capturer.cpp" line="108"/>
<location filename="../src/capturer.cpp" line="110"/>
<source>Record GIF</source>
<translation></translation>
</message>
<message>
<location filename="../src/capturer.cpp" line="110"/>
<location filename="../src/capturer.cpp" line="112"/>
<source>Open Camera</source>
<translation></translation>
</message>
<message>
<location filename="../src/capturer.cpp" line="112"/>
<location filename="../src/capturer.cpp" line="114"/>
<source>Settings</source>
<translation></translation>
</message>
<message>
<location filename="../src/capturer.cpp" line="114"/>
<location filename="../src/capturer.cpp" line="116"/>
<source>Quit</source>
<translation></translation>
</message>
Expand Down
12 changes: 6 additions & 6 deletions languages/capturer_zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@
<context>
<name>Capturer</name>
<message>
<location filename="../src/capturer.cpp" line="106"/>
<location filename="../src/capturer.cpp" line="108"/>
<source>Screenshot</source>
<translation>截图</translation>
</message>
<message>
<location filename="../src/capturer.cpp" line="107"/>
<location filename="../src/capturer.cpp" line="109"/>
<source>Record Video</source>
<translation>录屏</translation>
</message>
<message>
<location filename="../src/capturer.cpp" line="108"/>
<location filename="../src/capturer.cpp" line="110"/>
<source>Record GIF</source>
<translation>录GIF</translation>
</message>
<message>
<location filename="../src/capturer.cpp" line="110"/>
<location filename="../src/capturer.cpp" line="112"/>
<source>Open Camera</source>
<translation>打开摄像头</translation>
</message>
<message>
<location filename="../src/capturer.cpp" line="112"/>
<location filename="../src/capturer.cpp" line="114"/>
<source>Settings</source>
<translation>设置</translation>
</message>
<message>
<location filename="../src/capturer.cpp" line="114"/>
<location filename="../src/capturer.cpp" line="116"/>
<source>Quit</source>
<translation>退出</translation>
</message>
Expand Down
15 changes: 10 additions & 5 deletions src/capturer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,13 @@ void Capturer::setupSystemTray()
// SystemTrayIcon
auto update_tray_menu = [=]() {
QString icon_color = (Config::theme() == "dark") ? "light" : "dark";

#ifdef __linux__
// <= ubuntu 2004, system trays are always light
if (platform::system::os_version() <= platform::version_t{ 20, 4, 0, 0 }) {
icon_color = "dark";
if (platform::system::os_name().find("Ubuntu") != std::string::npos) {
auto ver = platform::system::os_version();
if (ver.major == 20 && ver.minor == 4)
icon_color = "dark"; // ubuntu 2004, system trays are always light
else if (ver.major == 18 && ver.minor == 4)
icon_color = "light"; // ubuntu 1804, system trays are always dark
}
#endif
menu->clear();
Expand All @@ -122,7 +124,10 @@ void Capturer::setupSystemTray()
sys_tray_icon_->show();
sys_tray_icon_->setToolTip("Capturer Settings");

connect(sys_tray_icon_, &QSystemTrayIcon::activated, [this](auto&& r) { if (r == QSystemTrayIcon::DoubleClick) sniper_->start(); });
connect(sys_tray_icon_, &QSystemTrayIcon::activated, [this](auto&& r) {
if (r == QSystemTrayIcon::DoubleClick)
sniper_->start();
});
}

void Capturer::showMessage(const QString &title, const QString &msg, QSystemTrayIcon::MessageIcon icon, int msecs)
Expand Down
5 changes: 5 additions & 0 deletions src/core/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ namespace platform
return numeric_combined(patch, build) <= numeric_combined(r.patch, r.build);
}

bool version_t::operator == (const version_t& r) const
{
return major == r.major && minor == r.minor && patch == r.patch && build == r.build;
}

template<> vendor_t vendor_cast(uint32_t id)
{
switch (id)
Expand Down
11 changes: 6 additions & 5 deletions src/core/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ namespace platform
{
struct version_t
{
uint32_t major;
uint32_t minor;
uint32_t patch;
uint32_t build;
uint32_t major{};
uint32_t minor{};
uint32_t patch{};
uint32_t build{};

std::string codename;
std::string codename{};

bool operator >= (const version_t&) const;
bool operator <= (const version_t&) const;
bool operator == (const version_t&) const;
};

#ifdef _WIN32
Expand Down

0 comments on commit f182212

Please sign in to comment.