From e2c3af4e5e7a0b3bbda1afd0519a1c588f69e2aa Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Wed, 29 Jan 2025 23:45:28 -0500 Subject: [PATCH] fix: readd the newScreenWidget --- src/apps/deskflow-gui/CMakeLists.txt | 2 + .../dialogs/ServerConfigDialog.cpp | 8 +- .../dialogs/ServerConfigDialog.ui | 105 +++++++++--------- .../deskflow-gui/widgets/NewScreenWidget.cpp | 37 ++++++ .../deskflow-gui/widgets/NewScreenWidget.h | 24 ++++ .../deskflow-gui/widgets/ScreenSetupView.cpp | 14 ++- .../deskflow-gui/widgets/ScreenSetupView.h | 3 + 7 files changed, 134 insertions(+), 59 deletions(-) create mode 100644 src/apps/deskflow-gui/widgets/NewScreenWidget.cpp create mode 100644 src/apps/deskflow-gui/widgets/NewScreenWidget.h diff --git a/src/apps/deskflow-gui/CMakeLists.txt b/src/apps/deskflow-gui/CMakeLists.txt index a8a4ec6c5..eaa6bc72c 100644 --- a/src/apps/deskflow-gui/CMakeLists.txt +++ b/src/apps/deskflow-gui/CMakeLists.txt @@ -96,6 +96,8 @@ add_executable(${target} WIN32 MACOSX_BUNDLE widgets/ClientStateLabel.h widgets/KeySequenceWidget.cpp widgets/KeySequenceWidget.h + widgets/NewScreenWidget.h + widgets/NewScreenWidget.cpp widgets/ScreenSetupView.cpp widgets/ScreenSetupView.h widgets/ServerStateLabel.cpp diff --git a/src/apps/deskflow-gui/dialogs/ServerConfigDialog.cpp b/src/apps/deskflow-gui/dialogs/ServerConfigDialog.cpp index da3ba1c17..bb5f5f3e6 100644 --- a/src/apps/deskflow-gui/dialogs/ServerConfigDialog.cpp +++ b/src/apps/deskflow-gui/dialogs/ServerConfigDialog.cpp @@ -36,6 +36,8 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config, Ap ui->m_pButtonBrowseConfigFile->setIcon(QIcon::fromTheme(QIcon::ThemeIcon::DocumentOpen)); ui->m_pTrashScreenWidget->setPixmap(QIcon::fromTheme("user-trash").pixmap(QSize(64, 64))); + ui->lblNewScreen->setPixmap(QIcon::fromTheme("video-display").pixmap(QSize(64, 64))); + ui->lblNewScreen->setToolTip(tr("Drag to the grid to add a new computer.")); // force the first tab, since qt creator sets the active tab as the last one // the developer was looking at, and it's easy to accidentally save that. @@ -87,7 +89,7 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config, Ap server->markAsServer(); } - ui->m_pButtonAddComputer->setEnabled(!model().isFull()); + ui->lblNewScreen->setEnabled(!model().isFull()); connect(ui->m_pTrashScreenWidget, &TrashScreenWidget::screenRemoved, this, &ServerConfigDialog::onScreenRemoved); onChange(); @@ -418,7 +420,7 @@ void ServerConfigDialog::on_m_pButtonAddComputer_clicked() void ServerConfigDialog::onScreenRemoved() { - ui->m_pButtonAddComputer->setEnabled(true); + ui->lblNewScreen->setEnabled(true); onChange(); } @@ -464,7 +466,7 @@ bool ServerConfigDialog::addComputer(const QString &clientName, bool doSilent) isAccepted = true; } - ui->m_pButtonAddComputer->setEnabled(!model().isFull()); + ui->lblNewScreen->setEnabled(!model().isFull()); return isAccepted; } diff --git a/src/apps/deskflow-gui/dialogs/ServerConfigDialog.ui b/src/apps/deskflow-gui/dialogs/ServerConfigDialog.ui index 6391002be..bad2e2b9e 100644 --- a/src/apps/deskflow-gui/dialogs/ServerConfigDialog.ui +++ b/src/apps/deskflow-gui/dialogs/ServerConfigDialog.ui @@ -62,10 +62,10 @@ Drag a computer from the grid to the trashcan to remove it. - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Raised + QFrame::Shadow::Raised @@ -75,7 +75,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -103,7 +103,7 @@ Configure the layout of your computer displays by dragging to where you want. - Qt::AlignCenter + Qt::AlignmentFlag::AlignCenter true @@ -116,7 +116,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -126,6 +126,13 @@ + + + + + + + @@ -134,16 +141,6 @@ 0 - - - - Add computer - - - true - - - @@ -151,10 +148,10 @@ - Qt::Vertical + Qt::Orientation::Vertical - QSizePolicy::Fixed + QSizePolicy::Policy::Fixed @@ -191,10 +188,10 @@ false - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Sunken + QFrame::Shadow::Sunken @@ -252,7 +249,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -312,7 +309,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -396,7 +393,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -431,7 +428,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -506,7 +503,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -548,7 +545,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -591,7 +588,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -655,7 +652,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -687,7 +684,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -735,7 +732,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -788,7 +785,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -829,7 +826,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -845,7 +842,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -880,7 +877,7 @@ 120 - + @@ -892,7 +889,7 @@ Core server config file - Qt::PlainText + Qt::TextFormat::PlainText @@ -904,10 +901,10 @@ Enabling this setting will disable the server config GUI. - Qt::MarkdownText + Qt::TextFormat::MarkdownText - Qt::AlignCenter + Qt::AlignmentFlag::AlignCenter true @@ -917,10 +914,10 @@ Enabling this setting will disable the server config GUI. - Qt::Vertical + Qt::Orientation::Vertical - QSizePolicy::Maximum + QSizePolicy::Policy::Maximum @@ -941,10 +938,10 @@ Enabling this setting will disable the server config GUI. - Qt::Horizontal + Qt::Orientation::Horizontal - QSizePolicy::Expanding + QSizePolicy::Policy::Expanding @@ -976,10 +973,10 @@ Enabling this setting will disable the server config GUI. - Qt::Horizontal + Qt::Orientation::Horizontal - QSizePolicy::Expanding + QSizePolicy::Policy::Expanding @@ -1002,10 +999,10 @@ Enabling this setting will disable the server config GUI. - Qt::Horizontal + Qt::Orientation::Horizontal - QSizePolicy::Expanding + QSizePolicy::Policy::Expanding @@ -1040,10 +1037,10 @@ Enabling this setting will disable the server config GUI. - Qt::Horizontal + Qt::Orientation::Horizontal - QSizePolicy::Fixed + QSizePolicy::Policy::Fixed @@ -1103,10 +1100,10 @@ Enabling this setting will disable the server config GUI. - Qt::Horizontal + Qt::Orientation::Horizontal - QSizePolicy::Expanding + QSizePolicy::Policy::Expanding @@ -1121,7 +1118,7 @@ Enabling this setting will disable the server config GUI. - Qt::Vertical + Qt::Orientation::Vertical @@ -1138,10 +1135,10 @@ Enabling this setting will disable the server config GUI. - Qt::Horizontal + Qt::Orientation::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok @@ -1159,10 +1156,14 @@ Enabling this setting will disable the server config GUI. QLabel
widgets/TrashScreenWidget.h
+ + NewScreenWidget + QLabel +
widgets/NewScreenWidget.h
+
m_pButtonBrowseConfigFile - m_pButtonAddComputer m_pScreenSetupView m_pListHotkeys m_pButtonNewHotkey diff --git a/src/apps/deskflow-gui/widgets/NewScreenWidget.cpp b/src/apps/deskflow-gui/widgets/NewScreenWidget.cpp new file mode 100644 index 000000000..c375ccad0 --- /dev/null +++ b/src/apps/deskflow-gui/widgets/NewScreenWidget.cpp @@ -0,0 +1,37 @@ +/* + * Deskflow -- mouse and keyboard sharing utility + * SPDX-FileCopyrightText: (C) 2025 Deskflow Developers + * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. + * SPDX-FileCopyrightText: (C) 2008 Volker Lanz + * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception + */ + +#include "NewScreenWidget.h" +#include "ScreenSetupModel.h" + +#include +#include +#include +#include + +NewScreenWidget::NewScreenWidget(QWidget *parent) : QLabel(parent) +{ +} + +void NewScreenWidget::mousePressEvent(QMouseEvent *event) +{ + Screen newScreen(tr("Unnamed")); + + QByteArray itemData; + QDataStream dataStream(&itemData, QIODevice::WriteOnly); + dataStream << -1 << -1 << newScreen; + + QMimeData *pMimeData = new QMimeData; + pMimeData->setData(ScreenSetupModel::mimeType(), itemData); + + QDrag *pDrag = new QDrag(this); + pDrag->setMimeData(pMimeData); + pDrag->setPixmap(pixmap()); + pDrag->setHotSpot(event->pos()); + pDrag->exec(Qt::CopyAction, Qt::CopyAction); +} diff --git a/src/apps/deskflow-gui/widgets/NewScreenWidget.h b/src/apps/deskflow-gui/widgets/NewScreenWidget.h new file mode 100644 index 000000000..63bf37951 --- /dev/null +++ b/src/apps/deskflow-gui/widgets/NewScreenWidget.h @@ -0,0 +1,24 @@ +/* + * Deskflow -- mouse and keyboard sharing utility + * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. + * SPDX-FileCopyrightText: (C) 2008 Volker Lanz + * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception + */ + +#pragma once + +#include + +class QMouseEvent; +class QWidget; + +class NewScreenWidget : public QLabel +{ + Q_OBJECT + +public: + NewScreenWidget(QWidget *parent); + +protected: + void mousePressEvent(QMouseEvent *event) override; +}; diff --git a/src/apps/deskflow-gui/widgets/ScreenSetupView.cpp b/src/apps/deskflow-gui/widgets/ScreenSetupView.cpp index 01930728e..e854d2396 100644 --- a/src/apps/deskflow-gui/widgets/ScreenSetupView.cpp +++ b/src/apps/deskflow-gui/widgets/ScreenSetupView.cpp @@ -44,6 +44,13 @@ ScreenSetupModel *ScreenSetupView::model() const return qobject_cast(QTableView::model()); } +void ScreenSetupView::showScreenConfig(int col, int row) +{ + ScreenSettingsDialog dlg(this, &model()->screen(col, row), &model()->m_Screens); + dlg.exec(); + Q_EMIT model()->screensChanged(); +} + void ScreenSetupView::setTableSize() { for (int i = 0; i < model()->columnCount(); i++) @@ -66,9 +73,7 @@ void ScreenSetupView::mouseDoubleClickEvent(QMouseEvent *event) int row = rowAt(event->pos().y()); if (!model()->screen(col, row).isNull()) { - ScreenSettingsDialog dlg(this, &model()->screen(col, row), &model()->m_Screens); - dlg.exec(); - Q_EMIT model()->screensChanged(); + showScreenConfig(col, row); } } else event->ignore(); @@ -100,8 +105,9 @@ void ScreenSetupView::dragMoveEvent(QDragMoveEvent *event) // a drop from outside is not allowed if there's a screen already there. if (!model()->screen(col, row).isNull()) event->ignore(); - else + else { event->acceptProposedAction(); + } } } else event->ignore(); diff --git a/src/apps/deskflow-gui/widgets/ScreenSetupView.h b/src/apps/deskflow-gui/widgets/ScreenSetupView.h index 395bb847d..3563b0e14 100644 --- a/src/apps/deskflow-gui/widgets/ScreenSetupView.h +++ b/src/apps/deskflow-gui/widgets/ScreenSetupView.h @@ -29,6 +29,9 @@ public: void setModel(QAbstractItemModel *model) override; ScreenSetupModel *model() const; +private: + void showScreenConfig(int col, int row); + protected: void mouseDoubleClickEvent(QMouseEvent *) override; void setTableSize();