Changeset 92847 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Dec 9, 2021 12:39:28 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 148775
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r92804 r92847 821 821 src/guestctrl/UIFileManagerOperationsPanel.h \ 822 822 src/guestctrl/UIFileManagerOptionsPanel.h \ 823 src/guestctrl/UIFileManagerGuestSessionPanel.h \824 823 src/guestctrl/UIFileManagerTable.h \ 825 824 src/helpbrowser/UIHelpBrowserDialog.h \ … … 1012 1011 src/guestctrl/UIFileManagerLogPanel.cpp \ 1013 1012 src/guestctrl/UIFileManagerOperationsPanel.cpp \ 1014 src/guestctrl/UIFileManagerGuestSessionPanel.cpp \1015 1013 src/guestctrl/UIFileManagerTable.cpp \ 1016 1014 src/guestctrl/UIFileManagerGuestTable.cpp \ … … 1371 1369 src/guestctrl/UIFileManagerOperationsPanel.cpp \ 1372 1370 src/guestctrl/UIFileManagerOptionsPanel.cpp \ 1373 src/guestctrl/UIFileManagerGuestSessionPanel.cpp \1374 1371 src/guestctrl/UIFileManagerTable.cpp \ 1375 1372 src/helpbrowser/UIHelpBrowserDialog.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.cpp
r92711 r92847 1737 1737 setName(QApplication::translate("UIActionPool", "Session")); 1738 1738 setShortcutScope(QApplication::translate("UIActionPool", "File Manager")); 1739 setStatusTip(QApplication::translate("UIActionPool", " Openguest session panel of the file manager"));1740 setToolTip( QApplication::translate("UIActionPool", " OpenGuest Session Panel")1739 setStatusTip(QApplication::translate("UIActionPool", "Toggle guest session panel of the file manager")); 1740 setToolTip( QApplication::translate("UIActionPool", "Toggle Guest Session Panel") 1741 1741 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString()))); 1742 1742 } -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManager.cpp
r92814 r92847 119 119 , m_pFileTableSplitter(0) 120 120 , m_pToolBar(0) 121 , m_pVerticalToolBar(0) \121 , m_pVerticalToolBar(0) 122 122 , m_pHostFileTable(0) 123 123 , m_pGuestTablesContainer(0) … … 663 663 { 664 664 UIFileManagerGuestTable *pTable = qobject_cast<UIFileManagerGuestTable*>(m_pGuestTablesContainer->widget(i)); 665 if (!pTable) 665 /* Keep the tabs with running guest control session even if the corresponding vm has been de-selected. */ 666 if (!pTable || pTable->isGuestSessionRunning()) 666 667 continue; 667 668 if (machineIdsToRemove.contains(pTable->machineId())) -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.cpp
r92819 r92847 20 20 #include <QFileInfo> 21 21 #include <QHBoxLayout> 22 #include <QPushButton> 22 23 #include <QUuid> 23 24 … … 31 32 #include "UIFileManager.h" 32 33 #include "UIFileManagerGuestTable.h" 33 #include "UIFileManagerGuestSessionPanel.h"34 34 #include "UIMessageCenter.h" 35 35 #include "UIPathOperations.h" 36 #include "UIUserNamePasswordEditor.h" 36 37 #include "UIVirtualBoxEventHandler.h" 38 #include "QILineEdit.h" 37 39 #include "QIToolBar.h" 38 40 … … 46 48 47 49 #include <iprt/path.h> 50 51 /********************************************************************************************************************************* 52 * UIGuestSessionCreateWidget definition. * 53 *********************************************************************************************************************************/ 54 /** A QWidget extension containing text entry fields for password and username and buttons to 55 * start/stop a guest session. */ 56 class UIGuestSessionCreateWidget : public QIWithRetranslateUI<QWidget> 57 { 58 Q_OBJECT; 59 60 signals: 61 62 void sigCreateSession(QString strUserName, QString strPassword); 63 void sigCloseSession(); 64 65 public: 66 67 UIGuestSessionCreateWidget(QWidget *pParent = 0); 68 /** Disables certain widget after a guest session has been created. */ 69 void switchSessionCreateMode(); 70 /** Makes sure certain widgets are enabled so that a guest session can be created. */ 71 void switchSessionCloseMode(); 72 void markForError(bool fMarkForError); 73 74 protected: 75 76 void retranslateUi() /* override */; 77 void keyPressEvent(QKeyEvent * pEvent) /* override */; 78 void showEvent(QShowEvent *pEvent) /* override */; 79 80 private slots: 81 82 void sltButtonClick(); 83 void sltHandleTextChanged(const QString &strText); 84 85 private: 86 87 enum ButtonMode 88 { 89 ButtonMode_Create, 90 ButtonMode_Close 91 }; 92 93 void prepareWidgets(); 94 void updateButton(); 95 96 ButtonMode m_enmButtonMode; 97 QILineEdit *m_pUserNameEdit; 98 UIPasswordLineEdit *m_pPasswordEdit; 99 QPushButton *m_pButton; 100 QHBoxLayout *m_pMainLayout; 101 QColor m_defaultBaseColor; 102 QColor m_errorBaseColor; 103 bool m_fMarkedForError; 104 }; 105 106 107 /********************************************************************************************************************************* 108 * UIGuestSessionCreateWidget implementation. * 109 *********************************************************************************************************************************/ 110 111 UIGuestSessionCreateWidget::UIGuestSessionCreateWidget(QWidget *pParent /* = 0 */) 112 : QIWithRetranslateUI<QWidget>(pParent) 113 , m_enmButtonMode(ButtonMode_Create) 114 , m_pUserNameEdit(0) 115 , m_pPasswordEdit(0) 116 , m_pButton(0) 117 , m_pMainLayout(0) 118 , m_fMarkedForError(0) 119 { 120 prepareWidgets(); 121 } 122 123 void UIGuestSessionCreateWidget::prepareWidgets() 124 { 125 m_pMainLayout = new QHBoxLayout(this); 126 if (!m_pMainLayout) 127 return; 128 129 m_pMainLayout->setContentsMargins(0, 0, 0, 0); 130 131 m_pUserNameEdit = new QILineEdit; 132 if (m_pUserNameEdit) 133 { 134 m_pMainLayout->addWidget(m_pUserNameEdit, 2); 135 m_pUserNameEdit->setPlaceholderText(QApplication::translate("UIFileManager", "User Name")); 136 m_defaultBaseColor = m_pUserNameEdit->palette().color(QPalette::Base); 137 m_errorBaseColor = QColor(m_defaultBaseColor.red(), 138 0.5 * m_defaultBaseColor.green(), 139 0.5 * m_defaultBaseColor.blue()); 140 connect(m_pUserNameEdit, &QILineEdit::textChanged, 141 this, &UIGuestSessionCreateWidget::sltHandleTextChanged); 142 } 143 144 m_pPasswordEdit = new UIPasswordLineEdit; 145 if (m_pPasswordEdit) 146 { 147 m_pMainLayout->addWidget(m_pPasswordEdit, 2); 148 m_pPasswordEdit->setPlaceholderText(QApplication::translate("UIFileManager", "Password")); 149 m_pPasswordEdit->setEchoMode(QLineEdit::Password); 150 connect(m_pPasswordEdit, &UIPasswordLineEdit::textChanged, 151 this, &UIGuestSessionCreateWidget::sltHandleTextChanged); 152 } 153 154 m_pButton = new QPushButton; 155 if (m_pButton) 156 { 157 m_pMainLayout->addWidget(m_pButton); 158 connect(m_pButton, &QPushButton::clicked, this, &UIGuestSessionCreateWidget::sltButtonClick); 159 } 160 161 162 m_pMainLayout->insertStretch(-1, 1); 163 switchSessionCreateMode(); 164 retranslateUi(); 165 } 166 167 void UIGuestSessionCreateWidget::sltButtonClick() 168 { 169 if (m_enmButtonMode == ButtonMode_Create && m_pUserNameEdit && m_pPasswordEdit) 170 emit sigCreateSession(m_pUserNameEdit->text(), m_pPasswordEdit->text()); 171 else if (m_enmButtonMode == ButtonMode_Close) 172 emit sigCloseSession(); 173 } 174 175 void UIGuestSessionCreateWidget::sltHandleTextChanged(const QString &strText) 176 { 177 Q_UNUSED(strText); 178 markForError(false); 179 } 180 181 void UIGuestSessionCreateWidget::retranslateUi() 182 { 183 if (m_pUserNameEdit) 184 { 185 m_pUserNameEdit->setToolTip(QApplication::translate("UIFileManager", "User name to authenticate session creation")); 186 m_pUserNameEdit->setPlaceholderText(QApplication::translate("UIFileManager", "User Name")); 187 188 } 189 if (m_pPasswordEdit) 190 { 191 m_pPasswordEdit->setToolTip(QApplication::translate("UIFileManager", "Password to authenticate session creation")); 192 m_pPasswordEdit->setPlaceholderText(QApplication::translate("UIFileManager", "Password")); 193 } 194 195 if (m_pButton) 196 { 197 if (m_enmButtonMode == ButtonMode_Create) 198 m_pButton->setText(QApplication::translate("UIFileManager", "Create Session")); 199 else 200 m_pButton->setText(QApplication::translate("UIFileManager", "Close Session")); 201 } 202 } 203 204 void UIGuestSessionCreateWidget::keyPressEvent(QKeyEvent * pEvent) 205 { 206 /* Emit sigCreateSession upon enter press: */ 207 if (pEvent->key() == Qt::Key_Enter || pEvent->key() == Qt::Key_Return) 208 { 209 if ((m_pUserNameEdit && m_pUserNameEdit->hasFocus()) || 210 (m_pPasswordEdit && m_pPasswordEdit->hasFocus())) 211 sigCreateSession(m_pUserNameEdit->text(), m_pPasswordEdit->text()); 212 } 213 QWidget::keyPressEvent(pEvent); 214 } 215 216 void UIGuestSessionCreateWidget::showEvent(QShowEvent *pEvent) 217 { 218 QIWithRetranslateUI<QWidget>::showEvent(pEvent); 219 if (m_pUserNameEdit) 220 m_pUserNameEdit->setFocus(); 221 } 222 223 void UIGuestSessionCreateWidget::switchSessionCreateMode() 224 { 225 if (m_pUserNameEdit) 226 m_pUserNameEdit->setEnabled(true); 227 if (m_pPasswordEdit) 228 m_pPasswordEdit->setEnabled(true); 229 m_enmButtonMode = ButtonMode_Create; 230 retranslateUi(); 231 } 232 233 void UIGuestSessionCreateWidget::switchSessionCloseMode() 234 { 235 if (m_pUserNameEdit) 236 m_pUserNameEdit->setEnabled(false); 237 if (m_pPasswordEdit) 238 m_pPasswordEdit->setEnabled(false); 239 m_enmButtonMode = ButtonMode_Close; 240 retranslateUi(); 241 } 242 243 void UIGuestSessionCreateWidget::markForError(bool fMarkForError) 244 { 245 if (m_fMarkedForError == fMarkForError) 246 return; 247 m_fMarkedForError = fMarkForError; 248 249 if (m_pUserNameEdit) 250 { 251 QPalette mPalette = m_pUserNameEdit->palette(); 252 if (m_fMarkedForError) 253 mPalette.setColor(QPalette::Base, m_errorBaseColor); 254 else 255 mPalette.setColor(QPalette::Base, m_defaultBaseColor); 256 m_pUserNameEdit->setPalette(mPalette); 257 } 258 if (m_pPasswordEdit) 259 { 260 QPalette mPalette = m_pPasswordEdit->palette(); 261 if (m_fMarkedForError) 262 mPalette.setColor(QPalette::Base, m_errorBaseColor); 263 else 264 mPalette.setColor(QPalette::Base, m_defaultBaseColor); 265 m_pPasswordEdit->setPalette(mPalette); 266 } 267 } 48 268 49 269 … … 425 645 } 426 646 647 bool UIFileManagerGuestTable::isGuestSessionRunning() const 648 { 649 if (m_comGuestSession.isNull()) 650 return false; 651 if (m_comGuestSession.GetStatus() == KGuestSessionStatus_Starting || 652 m_comGuestSession.GetStatus() == KGuestSessionStatus_Started) 653 return true; 654 return false; 655 } 656 427 657 void UIFileManagerGuestTable::copyGuestToHost(const QString& hostDestinationPath) 428 658 { … … 791 1021 if (m_pMainLayout) 792 1022 { 793 m_pGuestSessionPanel = new UI FileManagerGuestSessionPanel;1023 m_pGuestSessionPanel = new UIGuestSessionCreateWidget; 794 1024 if (m_pGuestSessionPanel) 795 1025 { 796 1026 m_pMainLayout->addWidget(m_pGuestSessionPanel, m_pMainLayout->rowCount(), 0, 1, m_pMainLayout->columnCount()); 797 1027 m_pGuestSessionPanel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); 798 sltHandleGuestSessionPanelShown();799 connect(m_pGuestSessionPanel, &UI FileManagerGuestSessionPanel::sigCreateSession,1028 //sltHandleGuestSessionPanelShown(); 1029 connect(m_pGuestSessionPanel, &UIGuestSessionCreateWidget::sigCreateSession, 800 1030 this, &UIFileManagerGuestTable::sltCreateGuestSession); 801 connect(m_pGuestSessionPanel, &UI FileManagerGuestSessionPanel::sigCloseSession,1031 connect(m_pGuestSessionPanel, &UIGuestSessionCreateWidget::sigCloseSession, 802 1032 this, &UIFileManagerGuestTable::sltHandleCloseSessionRequest); 803 connect(m_pGuestSessionPanel, &UIFileManagerGuestSessionPanel::sigHidePanel,804 this, &UIFileManagerGuestTable::sltHandleGuestSessionPanelHidden);805 connect(m_pGuestSessionPanel, &UIFileManagerGuestSessionPanel::sigShowPanel,806 this, &UIFileManagerGuestTable::sltHandleGuestSessionPanelShown);1033 // connect(m_pGuestSessionPanel, &UIFileManagerGuestSessionPanel::sigHidePanel, 1034 // this, &UIFileManagerGuestTable::sltHandleGuestSessionPanelHidden); 1035 // connect(m_pGuestSessionPanel, &UIFileManagerGuestSessionPanel::sigShowPanel, 1036 // this, &UIFileManagerGuestTable::sltHandleGuestSessionPanelShown); 807 1037 } 808 1038 } … … 856 1086 } 857 1087 858 void UIFileManagerGuestTable::sltHandleGuestSessionPanelHidden()859 {860 if (m_pActionPool && m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession))861 m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession)->setChecked(false);862 }863 864 void UIFileManagerGuestTable::sltHandleGuestSessionPanelShown()865 {866 if (m_pActionPool && m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession))867 m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession)->setChecked(true);868 }1088 // void UIFileManagerGuestTable::sltHandleGuestSessionPanelHidden() 1089 // { 1090 // if (m_pActionPool && m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession)) 1091 // m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession)->setChecked(false); 1092 // } 1093 1094 // void UIFileManagerGuestTable::sltHandleGuestSessionPanelShown() 1095 // { 1096 // if (m_pActionPool && m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession)) 1097 // m_pActionPool->action(UIActionIndex_M_FileManager_T_GuestSession)->setChecked(true); 1098 // } 869 1099 870 1100 void UIFileManagerGuestTable::sltMachineStateChange(const QUuid &uMachineId, const KMachineState enmMachineState) -
trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.h
r92814 r92847 41 41 42 42 /* Forward declarations: */ 43 class CGuestSessionStateChangedEvent; 43 44 class UIActionPool; 44 45 class UICustomFileSystemItem; 45 class UIFileManagerGuestSessionPanel; 46 class CGuestSessionStateChangedEvent; 46 class UIGuestSessionCreateWidget; 47 47 48 48 /** This class scans the guest file system by using the VBox Guest Control API … … 64 64 const QString &strDestination = QString()); 65 65 QUuid machineId(); 66 bool isGuestSessionRunning() const; 66 67 67 68 protected: … … 94 95 95 96 void sltGuestSessionPanelToggled(bool fChecked); 96 void sltHandleGuestSessionPanelHidden();97 void sltHandleGuestSessionPanelShown();97 // void sltHandleGuestSessionPanelHidden(); 98 // void sltHandleGuestSessionPanelShown(); 98 99 void sltGuestSessionUnregistered(CGuestSession guestSession); 99 100 void sltGuestSessionRegistered(CGuestSession guestSession); … … 136 137 void prepareGuestSessionPanel(); 137 138 138 139 139 bool openGuestSession(const QString& strUserName, const QString& strPassword); 140 140 void closeGuestSession(); … … 166 166 CEventListener m_comGuestListener; 167 167 CEventListener m_comConsoleListener; 168 UIFileManagerGuestSessionPanel *m_pGuestSessionPanel; 168 UIGuestSessionCreateWidget *m_pGuestSessionPanel; 169 ; 169 170 CheckMachine m_enmCheckMachine; 170 171 };
Note:
See TracChangeset
for help on using the changeset viewer.