-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathmainwindow.h
More file actions
183 lines (151 loc) · 4.75 KB
/
mainwindow.h
File metadata and controls
183 lines (151 loc) · 4.75 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/*
SPDX-FileCopyrightText: 2007-2013 Urs Wolfer <uwolfer@kde.org>
SPDX-FileCopyrightText: 2009-2010 Tony Murray <murraytony@gmail.com>
SPDX-FileCopyrightText: 2021 Rafał Lalik <rafallalik@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "remoteview.h"
#include "remoteviewfactory.h"
#include <KXmlGuiWindow>
class KComboBox;
class KLineEdit;
class KPushButton;
class KToggleAction;
class KTabWidget;
class BookmarkManager;
class FloatingToolBar;
class RemoteDesktopsModel;
class RemoteView;
class SystemTrayIcon;
class TabbedViewWidget;
class QDockWidget;
class QScrollArea;
class QModelIndex;
class QTableView;
class MainWindow : public KXmlGuiWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow() override;
QMap<QWidget *, RemoteView *> remoteViewList() const;
QList<RemoteViewFactory *> remoteViewFactoriesList() const;
RemoteView *currentRemoteView() const;
public Q_SLOTS:
void newConnection(const QUrl &newUrl = QUrl(), bool switchFullscreenWhenConnected = false, const QString &tabName = QString());
void setFactor(int scale);
protected:
void closeEvent(QCloseEvent *event) override;
void changeEvent(QEvent *event) override;
void saveProperties(KConfigGroup &group) override;
void saveHostPrefs();
void saveHostPrefs(RemoteView *view);
private Q_SLOTS:
void restoreOpenSessions();
void quit(bool systemEvent = false);
void preferences();
void configureNotifications();
void showMenubar();
void resizeTabWidget(int w, int h);
void statusChanged(RemoteView::RemoteStatus status);
void showRemoteViewToolbar();
void takeScreenshot();
void switchFullscreen();
void disconnectHost();
void closeTab(int index);
void openTabSettings(int index);
void tabContextMenu(const QPoint &point);
void viewOnly(bool viewOnly);
void clipboardSharing(bool clipboardSharing);
void showLocalCursor(bool showLocalCursor);
void grabAllKeys(bool grabAllKeys);
void scale(bool scale);
void updateActionStatus();
void updateConfiguration();
void tabChanged(int index);
QWidget *newConnectionWidget();
void newConnectionPage(bool clearInput = true);
void openFromRemoteDesktopsModel(const QModelIndex &index);
void selectFromRemoteDesktopsModel(const QModelIndex &index);
void createDockWidget();
void showConnectionContextMenu(const QPoint &pos);
void saveConnectionListSort(const int logicalindex, const Qt::SortOrder order);
void handleViewError(const QString &title, const QString &message);
private:
void setupActions();
void loadAllPlugins();
void showSettingsDialog(const QString &url);
QScrollArea *createScrollArea(QWidget *parent, RemoteView *remoteView);
QUrl getInputUrl();
QByteArray m_mainWindowGeometry;
KToggleAction *m_menubarAction;
TabbedViewWidget *m_tabWidget;
KComboBox *m_protocolInput;
KLineEdit *m_addressInput;
FloatingToolBar *m_toolBar;
BookmarkManager *m_bookmarkManager;
QMap<QWidget *, RemoteView *> m_remoteViewMap;
QMap<int, RemoteViewFactory *> m_remoteViewFactories;
int m_currentRemoteView;
bool m_switchFullscreenWhenConnected;
SystemTrayIcon *m_systemTrayIcon;
QTableView *m_dockWidgetTableView;
QTableView *m_newConnectionTableView;
RemoteDesktopsModel *m_remoteDesktopsModel;
QWidget *m_newConnectionWidget;
QDockWidget *m_remoteDesktopsDockWidget;
struct GuiItemsState {
bool dockWidget;
bool menuBar;
bool statusBar;
bool toolBar;
};
GuiItemsState m_guiItemsState;
QMap<RemoteView *, bool> m_savedGrabStatesBeforeFullscreen;
Q_SIGNALS:
void scaleUpdated(bool scale); // scale state has changed
void factorUpdated(int factor); // factor havlue has changed
};
#include <QApplication>
#include <QMouseEvent>
#include <QScreen>
class MinimizePixel : public QWidget
{
Q_OBJECT
public:
explicit MinimizePixel(QWidget *parent)
: QWidget(parent)
{
setFixedSize(1, 1);
move(screen()->geometry().width() - 1, 0);
}
Q_SIGNALS:
void rightClicked();
protected:
void mousePressEvent(QMouseEvent *event) override
{
if (event->button() == Qt::RightButton)
Q_EMIT rightClicked();
}
};
#include <QScrollArea>
class RemoteViewScrollArea : public QScrollArea
{
Q_OBJECT
public:
explicit RemoteViewScrollArea(QWidget *parent)
: QScrollArea(parent)
{
}
Q_SIGNALS:
void resized(int w, int h);
protected:
void resizeEvent(QResizeEvent *event) override
{
QScrollArea::resizeEvent(event);
Q_EMIT resized(width() - 2 * frameWidth(), height() - 2 * frameWidth());
}
};
#endif