Skip to content

Commit b0b83b2

Browse files
committed
Qt improvements
1 parent ee389c5 commit b0b83b2

32 files changed

+507
-80
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,11 @@ if (WIN32)
805805
set (PLATFORM_OS_WINDOWS_NATIVE 1)
806806
endif()
807807

808-
set (HAVE_HARPOON ON)
808+
if (WITH_UI_QT)
809+
set (HAVE_HARPOON OFF)
810+
else()
811+
set (HAVE_HARPOON ON)
812+
endif()
809813

810814
if (NOT MSVC)
811815
find_program(MSYS2_SHELL

libs/utils/src/Paths.cc

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ using namespace workrave::utils;
4949

5050
namespace
5151
{
52+
using namespace std::string_view_literals;
53+
54+
#ifdef HAVE_APP_QT
55+
constexpr std::string_view app_name = "WorkraveQt"sv;
56+
#else
57+
constexpr std::string_view app_name = "Workrave"sv;
58+
#endif
59+
5260
std::filesystem::path portable_directory;
5361

5462
#if defined(PLATFORM_OS_WINDOWS)
@@ -230,7 +238,7 @@ Paths::get_config_directories()
230238
try
231239
{
232240
#if defined(PLATFORM_OS_WINDOWS)
233-
directories.push_back(get_home_directory() / "Workrave");
241+
directories.push_back(get_home_directory() / app_name);
234242
directories.push_back(get_application_directory() / "etc");
235243
#endif
236244

@@ -266,7 +274,7 @@ Paths::get_state_directories()
266274
{
267275
#if defined(PLATFORM_OS_WINDOWS)
268276
directories.push_back(get_application_directory() / "etc");
269-
directories.push_back(get_home_directory() / "Workrave");
277+
directories.push_back(get_home_directory() / app_name);
270278
#endif
271279

272280
#if defined(HAVE_GLIB)
@@ -378,7 +386,7 @@ Paths::get_state_directory()
378386
{
379387
TRACE_MSG("Using preferred directory");
380388
#if defined(PLATFORM_OS_WINDOWS)
381-
ret = get_home_directory() / "Workrave";
389+
ret = get_home_directory() / app_name;
382390
#elif defined(HAVE_GLIB)
383391
# if GLIB_CHECK_VERSION(2, 72, 0)
384392
const gchar *user_state_dir = g_get_user_state_dir();
@@ -469,7 +477,7 @@ Paths::get_log_directory()
469477
std::filesystem::path dir = get_home_directory();
470478
if (!dir.empty())
471479
{
472-
dir /= std::filesystem::path("Library") / "Logs" / "Workrave";
480+
dir /= std::filesystem::path("Library") / "Logs" / app_name;
473481
return dir;
474482
}
475483

@@ -484,7 +492,7 @@ Paths::get_log_directory()
484492
std::filesystem::path dir = get_special_folder(FOLDERID_LocalAppData);
485493
if (!dir.empty())
486494
{
487-
dir /= std::filesystem::path("Workrave") / "Logs";
495+
dir /= std::filesystem::path(app_name) / "Logs";
488496
return dir;
489497
}
490498

ui/app/Application.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,9 @@ Application::init_dbus()
284284
// dialog.set_secondary_text(_("Is Workrave already running?"));
285285
// dialog.show();
286286
// dialog.run();
287+
#if !defined(HAVE_APP_QT)
287288
exit(1);
289+
#endif
288290
}
289291

290292
try

ui/app/GenericDBusApplet.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
namespace
3535
{
36-
constexpr const char *WORKRAVE_APPLET_SERVICE_NAME = "org.workrave.Workrave";
3736
constexpr const char *WORKRAVE_APPLET_SERVICE_IFACE = "org.workrave.AppletInterface";
3837
constexpr const char *WORKRAVE_APPLET_SERVICE_OBJ = "/org/workrave/Workrave/UI";
3938
} // namespace

ui/app/platforms/windows/WindowsHarpoonLocker.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
//
1717

18-
#include <cstdint>
1918
#ifdef HAVE_CONFIG_H
2019
# include "config.h"
2120
#endif
2221

22+
#include <cstdint>
23+
2324
#include "ui/windows/WindowsHarpoonLocker.hh"
2425

2526
#include "input-monitor/Harpoon.hh"
@@ -58,6 +59,7 @@ WindowsHarpoonLocker::prepare_lock()
5859
text.resize(GetWindowTextLengthA(active_window));
5960
GetWindowTextA(active_window, text.data(), text.size() + 1);
6061
TRACE_MSG("Save active window: {}", text);
62+
spdlog::info("Save active window: {} {}", text, reinterpret_cast<intptr_t>(active_window));
6163
}
6264

6365
void
@@ -78,6 +80,7 @@ WindowsHarpoonLocker::unlock()
7880
text.resize(GetWindowTextLengthA(active_window));
7981
GetWindowTextA(active_window, text.data(), text.size() + 1);
8082
TRACE_MSG("Restore active window: {}", text);
83+
spdlog::info("Restore active window: {} {}", text, reinterpret_cast<intptr_t>(active_window));
8184
SetForegroundWindow(active_window);
8285
active_window = nullptr;
8386
}

ui/app/toolkits/qt/AutoUpdater.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ AutoUpdater::init_preferences()
218218
->when(&workrave::updater::Config::proxy_type(),
219219
[](unfold::ProxyType t) { return t == unfold::ProxyType::Custom; }));
220220

221-
context->get_preferences_registry()->add_page("auto-update", N_("Software updates"), "workrave-update-symbolic");
221+
// TODO: image is toolkit specific
222+
context->get_preferences_registry()->add_page("auto-update", N_("Software updates"), "update.svg");
222223
context->get_preferences_registry()->add(auto_update_def);
223224
}
224225

ui/app/toolkits/qt/BreakWindow.cc

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ BreakWindow::BreakWindow(std::shared_ptr<IApplicationContext> app, QScreen *scre
5252
void
5353
BreakWindow::init()
5454
{
55+
#if defined(HAVE_WAYLAND)
56+
if (Platform::running_on_wayland())
57+
{
58+
auto wm = std::make_shared<WaylandWindowManager>();
59+
bool success = wm->init();
60+
if (success)
61+
{
62+
window_manager = wm;
63+
}
64+
}
65+
#endif
66+
5567
if (block_mode != BlockMode::Off)
5668
{
5769
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::SplashScreen);
@@ -306,19 +318,18 @@ BreakWindow::check_skip_postpone_lock(bool &skip_locked, bool &postpone_locked,
306318
{
307319
for (int id = break_id - 1; id >= 0; id--)
308320
{
309-
IBreak::Ptr b = core->get_break(BreakId(id));
310-
321+
auto b = core->get_break(BreakId(id));
311322
bool overdue = b->get_elapsed_time() > b->get_limit();
312323

313324
if (((break_flags & BREAK_FLAGS_USER_INITIATED) == 0) || b->is_max_preludes_reached())
314325
{
315326
if (!GUIConfig::break_ignorable(BreakId(id))())
316327
{
317-
skip_locked = overdue;
328+
postpone_locked = overdue;
318329
}
319330
if (!GUIConfig::break_skippable(BreakId(id))())
320331
{
321-
postpone_locked = overdue;
332+
skip_locked = overdue;
322333
}
323334
if (skip_locked || postpone_locked)
324335
{
@@ -496,9 +507,6 @@ BreakWindow::stop()
496507
}
497508

498509
hide();
499-
// TODO:
500-
// platform->restore_foreground();
501-
// platform->unlock();
502510
}
503511

504512
void

ui/app/toolkits/qt/BreakWindow.hh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ private:
8080
void on_postpone_button_clicked();
8181
void on_sysoper_combobox_changed(int index);
8282

83-
std::vector<System::SystemOperation> supported_system_operations;
8483
void append_row_to_sysoper_model(System::SystemOperation::SystemOperationType type);
8584
void get_operation_name_and_icon(System::SystemOperation::SystemOperationType type, QString &name, QString &icon_name);
8685

@@ -93,12 +92,16 @@ private:
9392
QScreen *screen{nullptr};
9493
Frame *frame{nullptr};
9594
QWidget *gui{nullptr};
95+
std::vector<System::SystemOperation> supported_system_operations;
9696
QWidget *block_window{nullptr};
9797
QProgressBar *progress_bar{nullptr};
9898
QPushButton *postpone_button{nullptr};
9999
QPushButton *skip_button{nullptr};
100100
QComboBox *sysoper_combo{nullptr};
101101
std::shared_ptr<SizeGroup> size_group;
102+
#if defined(HAVE_WAYLAND)
103+
std::shared_ptr<WaylandWindowManager> window_manager;
104+
#endif
102105
};
103106

104107
#endif // BREAKWINDOW_HH

ui/app/toolkits/qt/CMakeLists.txt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ target_sources(workrave-toolkit-qt PRIVATE
1717
ToolkitFactory.cc
1818
ToolkitMenu.cc
1919
preferences/GeneralUiPreferencesPanel.cc
20+
preferences/MonitoringPreferencesPanel.cc
2021
preferences/SoundsPreferencesPanel.cc
2122
preferences/TimerBoxPreferencesPanel.cc
2223
preferences/TimerPreferencesPanel.cc
@@ -36,7 +37,27 @@ target_sources(workrave-toolkit-qt PRIVATE
3637

3738
if (PLATFORM_OS_UNIX)
3839
target_sources(workrave-toolkit-qt PRIVATE ToolkitLinux.cc)
39-
target_include_directories(workrave-toolkit-qt PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/platforms/unix)
40+
if (HAVE_WAYLAND)
41+
qt_generate_wayland_protocol_client_sources(workrave-toolkit-qt FILES
42+
platforms/unix/protocols/wlr-layer-shell-unstable-v1.xml
43+
platforms/unix/protocols/xdg-shell.xml)
44+
45+
target_sources(workrave-toolkit-qt PRIVATE
46+
platforms/unix/WaylandWindowManager.cc
47+
${CMAKE_CURRENT_BINARY_DIR}/wlr-layer-shell-unstable-v1.c
48+
${CMAKE_CURRENT_BINARY_DIR}/xdg-shell.c)
49+
endif()
50+
51+
if (HAVE_DBUSMENU)
52+
target_sources(workrave-toolkit-qt PRIVATE platforms/unix/DbusMenu.cc)
53+
endif()
54+
55+
if (HAVE_APPINDICATOR)
56+
target_sources(workrave-toolkit-qt PRIVATE platforms/unix/AppIndicatorMenu.cc)
57+
endif()
58+
59+
target_include_directories(workrave-toolkit-qt PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/platforms/unix ${CMAKE_CURRENT_SOURCE_DIR}/platforms/unix/protocols)
60+
target_include_directories(workrave-toolkit-qt PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/platforms/unix)
4061
endif()
4162

4263
if (PLATFORM_OS_WINDOWS)

ui/app/toolkits/qt/DebugDialog.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
using namespace workrave;
3535
using namespace workrave::utils;
3636

37-
DebugDialog::DebugDialog()
37+
DebugDialog::DebugDialog(std::shared_ptr<IApplicationContext> app)
38+
: app(app)
3839
{
3940
setWindowTitle(tr("Debug Workrave"));
4041
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);

ui/app/toolkits/qt/DebugDialog.hh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,17 @@
2121
#include <QtGui>
2222
#include <QtWidgets>
2323

24+
#include "ui/IApplicationContext.hh"
25+
2426
class DebugDialog : public QDialog
2527
{
2628
Q_OBJECT
2729

2830
public:
29-
DebugDialog();
31+
explicit DebugDialog(std::shared_ptr<IApplicationContext> app);
32+
33+
private:
34+
std::shared_ptr<IApplicationContext> app;
3035
};
3136

3237
#endif // DEBUGDIALOG_HH

0 commit comments

Comments
 (0)