fix: readd the newScreenWidget

This commit is contained in:
sithlord48
2025-01-29 23:45:28 -05:00
committed by Nick Bolton
parent 26367635d9
commit e2c3af4e5e
7 changed files with 134 additions and 59 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -62,10 +62,10 @@
<string>Drag a computer from the grid to the trashcan to remove it.</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Shadow::Raised</enum>
</property>
<property name="text">
<string/>
@ -75,7 +75,7 @@
<item>
<spacer name="horizontalSpacer_21">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -103,7 +103,7 @@
<string>Configure the layout of your computer displays by dragging to where you want.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
@ -116,7 +116,7 @@
<item>
<spacer name="horizontalSpacer_22">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -126,6 +126,13 @@
</property>
</spacer>
</item>
<item>
<widget class="NewScreenWidget" name="lblNewScreen">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="m_pLayoutAddComputer">
<property name="spacing">
@ -134,16 +141,6 @@
<property name="leftMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="m_pButtonAddComputer">
<property name="text">
<string>Add computer</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@ -151,10 +148,10 @@
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
<enum>QSizePolicy::Policy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -191,10 +188,10 @@
<bool>false</bool>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<enum>QFrame::Shape::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
<enum>QFrame::Shadow::Sunken</enum>
</property>
</widget>
</item>
@ -252,7 +249,7 @@
<item row="3" column="1">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -312,7 +309,7 @@
<item row="3" column="1">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -396,7 +393,7 @@
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -431,7 +428,7 @@
<item>
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -506,7 +503,7 @@
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -548,7 +545,7 @@
<item>
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -591,7 +588,7 @@
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -655,7 +652,7 @@
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -687,7 +684,7 @@
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -735,7 +732,7 @@
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -788,7 +785,7 @@
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -829,7 +826,7 @@
<item>
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -845,7 +842,7 @@
<item row="2" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -880,7 +877,7 @@
<property name="rightMargin">
<number>120</number>
</property>
<item alignment="Qt::AlignHCenter">
<item alignment="Qt::AlignmentFlag::AlignHCenter">
<widget class="QLabel" name="label_5">
<property name="font">
<font>
@ -892,7 +889,7 @@
<string>Core server config file</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
<enum>Qt::TextFormat::PlainText</enum>
</property>
</widget>
</item>
@ -904,10 +901,10 @@
Enabling this setting will disable the server config GUI.</string>
</property>
<property name="textFormat">
<enum>Qt::MarkdownText</enum>
<enum>Qt::TextFormat::MarkdownText</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
@ -917,10 +914,10 @@ Enabling this setting will disable the server config GUI.</string>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Maximum</enum>
<enum>QSizePolicy::Policy::Maximum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -941,10 +938,10 @@ Enabling this setting will disable the server config GUI.</string>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
<enum>QSizePolicy::Policy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -976,10 +973,10 @@ Enabling this setting will disable the server config GUI.</string>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
<enum>QSizePolicy::Policy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -1002,10 +999,10 @@ Enabling this setting will disable the server config GUI.</string>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
<enum>QSizePolicy::Policy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -1040,10 +1037,10 @@ Enabling this setting will disable the server config GUI.</string>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
<enum>QSizePolicy::Policy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -1103,10 +1100,10 @@ Enabling this setting will disable the server config GUI.</string>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
<enum>QSizePolicy::Policy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -1121,7 +1118,7 @@ Enabling this setting will disable the server config GUI.</string>
<item>
<spacer name="verticalSpacer_1">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -1138,10 +1135,10 @@ Enabling this setting will disable the server config GUI.</string>
<item>
<widget class="QDialogButtonBox" name="m_pButtonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>
@ -1159,10 +1156,14 @@ Enabling this setting will disable the server config GUI.</string>
<extends>QLabel</extends>
<header>widgets/TrashScreenWidget.h</header>
</customwidget>
<customwidget>
<class>NewScreenWidget</class>
<extends>QLabel</extends>
<header>widgets/NewScreenWidget.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>m_pButtonBrowseConfigFile</tabstop>
<tabstop>m_pButtonAddComputer</tabstop>
<tabstop>m_pScreenSetupView</tabstop>
<tabstop>m_pListHotkeys</tabstop>
<tabstop>m_pButtonNewHotkey</tabstop>

View File

@ -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 <vl@fidra.de>
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
*/
#include "NewScreenWidget.h"
#include "ScreenSetupModel.h"
#include <QDrag>
#include <QLabel>
#include <QMimeData>
#include <QMouseEvent>
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);
}

View File

@ -0,0 +1,24 @@
/*
* Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
* SPDX-FileCopyrightText: (C) 2008 Volker Lanz <vl@fidra.de>
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
*/
#pragma once
#include <QLabel>
class QMouseEvent;
class QWidget;
class NewScreenWidget : public QLabel
{
Q_OBJECT
public:
NewScreenWidget(QWidget *parent);
protected:
void mousePressEvent(QMouseEvent *event) override;
};

View File

@ -44,6 +44,13 @@ ScreenSetupModel *ScreenSetupView::model() const
return qobject_cast<ScreenSetupModel *>(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();

View File

@ -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();