diff --git a/CHANGELOG.md b/CHANGELOG.md index 83e38eb2..aa9a9bc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,10 @@ This project adheres to [Semantic Versioning](http://semver.org/). - added Vintage View Mode to make sandman UI look just lien sbietrl on the first glance - added alternative tray menu mechanics - added ability to auto generate sandbox icons based on the border color -- added dedicated box group icon + +### Changed +- changed box group icon to a dedicated one +- browse content is now available as a side panel in the main window ### Fixed - fixed DPI issue on Windows 7 diff --git a/SandboxiePlus/SandMan/Forms/FileBrowserWindow.ui b/SandboxiePlus/SandMan/Forms/FileBrowserWindow.ui deleted file mode 100644 index c62fa8df..00000000 --- a/SandboxiePlus/SandMan/Forms/FileBrowserWindow.ui +++ /dev/null @@ -1,46 +0,0 @@ - - - FileBrowserWindow - - - - 0 - 0 - 573 - 451 - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - SandboxiePlus - Snapshots - - - - - - - - - - - - - - diff --git a/SandboxiePlus/SandMan/SandMan.cpp b/SandboxiePlus/SandMan/SandMan.cpp index 3265b212..79495116 100644 --- a/SandboxiePlus/SandMan/SandMan.cpp +++ b/SandboxiePlus/SandMan/SandMan.cpp @@ -25,6 +25,7 @@ #include "Helpers/WinAdmin.h" #include "../MiscHelpers/Common/OtherFunctions.h" #include "../MiscHelpers/Common/Common.h" +#include "Views/FileView.h" CSbiePlusAPI* theAPI = NULL; @@ -280,7 +281,12 @@ void CSandMan::CreateUI() if(iViewMode == 1) CreateToolBar(); - CreateView(iViewMode == 1); + CreateView(iViewMode); + + if (iViewMode != 2) { + m_pMenuBrowse->setChecked(theConf->GetBool("Options/ShowFilePanel", false)); + m_pFileView->setVisible(m_pMenuBrowse->isChecked()); + } foreach(QAction * pAction, m_pViewMode->actions()) pAction->setChecked(pAction->data().toInt() == iViewMode); @@ -399,6 +405,13 @@ void CSandMan::CreateMenus(bool bAdvanced) CreateViewBaseMenu(); + m_pMenuView->addSeparator(); + m_pMenuBrowse = m_pMenuView->addAction(CSandMan::GetIcon("Tree"), tr("Show File Panel"), this, SLOT(OnProcView())); + m_pMenuBrowse->setCheckable(true); + m_pMenuBrowse->setShortcut(QKeySequence("Ctrl+D")); + m_pMenuBrowse->setShortcutContext(Qt::WidgetWithChildrenShortcut); + this->addAction(m_pMenuBrowse); + if(bAdvanced) { m_pMenuView->addSeparator(); @@ -443,6 +456,8 @@ void CSandMan::CreateMenus(bool bAdvanced) m_pEnableMonitoring = m_pMenuView->addAction(CSandMan::GetIcon("SetLogging"), tr("Trace Logging"), this, SLOT(OnMonitoring())); if (bAdvanced) m_pEnableMonitoring->setCheckable(true); + if (!bAdvanced) + m_pMenuView->addAction(CSandMan::GetIcon("Recover"), tr("Recovery Log"), this, SLOT(OnRecoveryLog())); m_pMenuOptions = menuBar()->addMenu(tr("&Options")); @@ -506,10 +521,20 @@ void CSandMan::CreateOldMenus() CreateViewBaseMenu(); m_pMenuView->addSeparator(); - m_pRefreshAll = m_pMenuView->addAction(CSandMan::GetIcon("Refresh"), tr("Refresh View"), this, SLOT(OnRefresh())); - m_pRefreshAll->setShortcut(QKeySequence("F5")); - m_pRefreshAll->setShortcutContext(Qt::WidgetWithChildrenShortcut); - this->addAction(m_pRefreshAll); + QActionGroup* m_pView = new QActionGroup(m_pMenuView); + MakeAction(m_pView, m_pMenuView, tr("Programs"), 0); + MakeAction(m_pView, m_pMenuView, tr("Files and Folders"), 1); + m_pView->actions().first()->setChecked(true); + connect(m_pView, SIGNAL(triggered(QAction*)), this, SLOT(OnView(QAction*))); + m_pMenuView->addSeparator(); + m_pMenuView->addAction(CSandMan::GetIcon("Recover"), tr("Recovery Log"), this, SLOT(OnRecoveryLog())); + + //m_pMenuView->addSeparator(); + //m_pRefreshAll = m_pMenuView->addAction(CSandMan::GetIcon("Refresh"), tr("Refresh View"), this, SLOT(OnRefresh())); + //m_pRefreshAll->setShortcut(QKeySequence("F5")); + //m_pRefreshAll->setShortcutContext(Qt::WidgetWithChildrenShortcut); + //this->addAction(m_pRefreshAll); + m_pRefreshAll = NULL; m_pCleanUpMenu = NULL; m_pCleanUpProcesses = NULL; @@ -525,11 +550,12 @@ void CSandMan::CreateOldMenus() m_pSandbox->addSeparator(); m_pNewBox = m_pSandbox->addAction(CSandMan::GetIcon("NewBox"), tr("Create New Sandbox"), this, SLOT(OnSandBoxAction())); m_pNewGroup = m_pSandbox->addAction(CSandMan::GetIcon("Group"), tr("Create New Group"), this, SLOT(OnSandBoxAction())); + m_pSandbox->addSeparator(); - QAction* m_pSetContainer = m_pSandbox->addAction(CSandMan::GetIcon("Advanced"), tr("Set Container Folder"), this, SLOT(OnSandBoxAction())); + QAction* m_pSetContainer = m_pSandbox->addAction(CSandMan::GetIcon("Advanced"), tr("Set Container Folder"), this, SLOT(OnSettingsAction())); m_pSetContainer->setData(CSettingsWindow::eAdvanced); - m_pArrangeGroups = m_pSandbox->addAction(tr("Set Layout and Groups"), this, SLOT(OnSandBoxAction())); + m_pArrangeGroups = m_pSandbox->addAction(tr("Set Layout and Groups"), this, SLOT(OnSettingsAction())); m_pArrangeGroups->setCheckable(true); m_pShowHidden = m_pSandbox->addAction(tr("Reveal Hidden Boxes")); @@ -542,17 +568,17 @@ void CSandMan::CreateOldMenus() m_pMenuSettings = m_pMenuOptions->addAction(CSandMan::GetIcon("Settings"), tr("Global Settings"), this, SLOT(OnSettings())); m_pMenuOptions->addSeparator(); - QAction* m_pProgramAlert = m_pMenuOptions->addAction(CSandMan::GetIcon("Ampel"), tr("Program Alerts"), this, SLOT(OnSandBoxAction())); + QAction* m_pProgramAlert = m_pMenuOptions->addAction(CSandMan::GetIcon("Ampel"), tr("Program Alerts"), this, SLOT(OnSettingsAction())); m_pProgramAlert->setData(CSettingsWindow::eProgCtrl); - QAction* m_pWindowsShell = m_pMenuOptions->addAction(CSandMan::GetIcon("Shell"), tr("Windows Shell Integration"), this, SLOT(OnSandBoxAction())); + QAction* m_pWindowsShell = m_pMenuOptions->addAction(CSandMan::GetIcon("Shell"), tr("Windows Shell Integration"), this, SLOT(OnSettingsAction())); m_pWindowsShell->setData(CSettingsWindow::eShell); - QAction* m_pCompatibility = m_pMenuOptions->addAction(CSandMan::GetIcon("Compatibility"), tr("Software Compatibility"), this, SLOT(OnSandBoxAction())); + QAction* m_pCompatibility = m_pMenuOptions->addAction(CSandMan::GetIcon("Compatibility"), tr("Software Compatibility"), this, SLOT(OnSettingsAction())); m_pCompatibility->setData(CSettingsWindow::eSoftCompat); m_pMenuResetMsgs = m_pMenuOptions->addAction(tr("Reset all hidden messages"), this, SLOT(OnResetMsgs())); m_pMenuResetGUI = m_pMenuOptions->addAction(tr("Reset all GUI options"), this, SLOT(OnResetGUI())); m_pMenuOptions->addSeparator(); - QAction* m_pConfigLock = m_pMenuOptions->addAction(CSandMan::GetIcon("Lock"), tr("Lock Configuration"), this, SLOT(OnSandBoxAction())); + QAction* m_pConfigLock = m_pMenuOptions->addAction(CSandMan::GetIcon("Lock"), tr("Lock Configuration"), this, SLOT(OnSettingsAction())); m_pConfigLock->setData(CSettingsWindow::eConfigLock); m_pEditIni = m_pMenuOptions->addAction(CSandMan::GetIcon("EditIni"), tr("Edit ini file"), this, SLOT(OnEditIni())); m_pReloadIni = m_pMenuOptions->addAction(CSandMan::GetIcon("ReloadIni"), tr("Reload ini file"), this, SLOT(OnReloadIni())); @@ -561,6 +587,19 @@ void CSandMan::CreateOldMenus() } +void CSandMan::OnView(QAction* pAction) +{ + int iView = pAction->data().toInt(); + if(m_pViewStack) m_pViewStack->setCurrentIndex(iView); + + if (iView == 1) { // files + m_pBoxCombo->clear(); + foreach(const CSandBoxPtr & pBox, theAPI->GetAllBoxes()) + m_pBoxCombo->addItem(tr("Sandbox %1").arg(pBox->GetName().replace("_", "")), pBox->GetName()); + m_pBoxCombo->setCurrentIndex(m_pBoxCombo->findData("DefaultBox")); + } +} + void CSandMan::CreateToolBar() { m_pToolBar = new QToolBar(); @@ -641,13 +680,36 @@ void CSandMan::UpdateLabel() m_pLabel->setToolTip(LabelTip); } -void CSandMan::CreateView(bool bAdvanced) +void CSandMan::CreateView(int iViewMode) { m_pBoxView = new CSbieView(); + m_pFileView = new CFileView(); - if (!bAdvanced) + if (iViewMode != 1) + m_pRecoveryLogWnd = new CRecoveryLogWnd(m_pMainWidget); + else + m_pRecoveryLogWnd = NULL; + + if (iViewMode == 2) { - m_pMainLayout->addWidget(m_pBoxView); + m_pViewStack = new QStackedLayout(); + m_pViewStack->addWidget(m_pBoxView); + + QWidget* pFileView = new QWidget(); + QGridLayout* pFileLayout = new QGridLayout(pFileView); + pFileLayout->setMargin(0); + + pFileLayout->addItem(new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 0, 1, 1); + + m_pBoxCombo = new QComboBox(); + pFileLayout->addWidget(m_pBoxCombo, 0, 1); + + pFileLayout->addWidget(m_pFileView, 1, 0, 1, 2); + + m_pViewStack->addWidget(pFileView); + + + m_pMainLayout->addLayout(m_pViewStack); m_pPanelSplitter = NULL; m_pLogSplitter = NULL; @@ -661,58 +723,80 @@ void CSandMan::CreateView(bool bAdvanced) return; } - m_pLogSplitter = new QSplitter(); - m_pLogSplitter->setOrientation(Qt::Vertical); - m_pMainLayout->addWidget(m_pLogSplitter); + m_pViewStack = NULL; + m_pBoxCombo = NULL; + + if (iViewMode == 1) + { + m_pLogSplitter = new QSplitter(); + m_pLogSplitter->setOrientation(Qt::Vertical); + m_pMainLayout->addWidget(m_pLogSplitter); + } m_pPanelSplitter = new QSplitter(); m_pPanelSplitter->setOrientation(Qt::Horizontal); - m_pLogSplitter->addWidget(m_pPanelSplitter); + if (iViewMode == 1) + m_pLogSplitter->addWidget(m_pPanelSplitter); + else + m_pMainLayout->addWidget(m_pPanelSplitter); m_pPanelSplitter->addWidget(m_pBoxView); + m_pPanelSplitter->addWidget(m_pFileView); - //m_pPanelSplitter->addWidget(); + m_pPanelSplitter->setCollapsible(0, false); + //m_pPanelSplitter->setCollapsible(1, false); + + if (iViewMode == 1) + { + m_pLogTabs = new QTabWidget(); + m_pLogSplitter->addWidget(m_pLogTabs); + + // Message Log + m_pMessageLog = new CPanelWidgetEx(); + + //m_pMessageLog->GetView()->setItemDelegate(theGUI->GetItemDelegate()); + ((QTreeWidgetEx*)m_pMessageLog->GetView())->setHeaderLabels(tr("Time|Message").split("|")); + + m_pMessageLog->GetMenu()->insertAction(m_pMessageLog->GetMenu()->actions()[0], m_pCleanUpMsgLog); + m_pMessageLog->GetMenu()->insertSeparator(m_pMessageLog->GetMenu()->actions()[0]); + + m_pMessageLog->GetView()->setSelectionMode(QAbstractItemView::ExtendedSelection); + m_pMessageLog->GetView()->setSortingEnabled(false); + + m_pLogTabs->addTab(m_pMessageLog, tr("Sbie Messages")); + // + + m_pTraceView = new CTraceView(false, this); + + m_pTraceView->AddAction(m_pCleanUpTrace); + + m_pLogTabs->addTab(m_pTraceView, tr("Trace Log")); - m_pLogTabs = new QTabWidget(); - m_pLogSplitter->addWidget(m_pLogTabs); + // Recovery Log + m_pRecoveryLog = new CPanelWidgetEx(); - // Message Log - m_pMessageLog = new CPanelWidgetEx(); + //m_pRecoveryLog->GetView()->setItemDelegate(theGUI->GetItemDelegate()); + ((QTreeWidgetEx*)m_pRecoveryLog->GetView())->setHeaderLabels(tr("Time|Box Name|File Path").split("|")); - //m_pMessageLog->GetView()->setItemDelegate(theGUI->GetItemDelegate()); - ((QTreeWidgetEx*)m_pMessageLog->GetView())->setHeaderLabels(tr("Time|Message").split("|")); + m_pRecoveryLog->GetMenu()->insertAction(m_pRecoveryLog->GetMenu()->actions()[0], m_pCleanUpRecovery); + m_pRecoveryLog->GetMenu()->insertSeparator(m_pRecoveryLog->GetMenu()->actions()[0]); - m_pMessageLog->GetMenu()->insertAction(m_pMessageLog->GetMenu()->actions()[0], m_pCleanUpMsgLog); - m_pMessageLog->GetMenu()->insertSeparator(m_pMessageLog->GetMenu()->actions()[0]); + m_pRecoveryLog->GetView()->setSelectionMode(QAbstractItemView::ExtendedSelection); + m_pRecoveryLog->GetView()->setSortingEnabled(false); - m_pMessageLog->GetView()->setSelectionMode(QAbstractItemView::ExtendedSelection); - m_pMessageLog->GetView()->setSortingEnabled(false); + m_pLogTabs->addTab(m_pRecoveryLog, tr("Recovery Log")); + // + } + else { + m_pLogSplitter = NULL; - m_pLogTabs->addTab(m_pMessageLog, tr("Sbie Messages")); - // + m_pLogTabs = NULL; - m_pTraceView = new CTraceView(false, this); - - m_pTraceView->AddAction(m_pCleanUpTrace); - - m_pLogTabs->addTab(m_pTraceView, tr("Trace Log")); - - - // Recovery Log - m_pRecoveryLog = new CPanelWidgetEx(); - - //m_pRecoveryLog->GetView()->setItemDelegate(theGUI->GetItemDelegate()); - ((QTreeWidgetEx*)m_pRecoveryLog->GetView())->setHeaderLabels(tr("Time|Box Name|File Path").split("|")); - - m_pRecoveryLog->GetMenu()->insertAction(m_pRecoveryLog->GetMenu()->actions()[0], m_pCleanUpMsgLog); - m_pRecoveryLog->GetMenu()->insertSeparator(m_pRecoveryLog->GetMenu()->actions()[0]); - - m_pRecoveryLog->GetView()->setSelectionMode(QAbstractItemView::ExtendedSelection); - m_pRecoveryLog->GetView()->setSortingEnabled(false); - - m_pLogTabs->addTab(m_pRecoveryLog, tr("Recovery Log")); - // + m_pMessageLog = NULL; + m_pTraceView = NULL; + m_pRecoveryLog = NULL; + } } #include "SandManTray.cpp" @@ -1011,6 +1095,30 @@ void CSandMan::timerEvent(QTimerEvent* pEvent) m_pTraceView->setEnabled(bIsMonitoring); } + CSandBoxPtr pBox; + if (m_pPanelSplitter) { + QList boxes = m_pBoxView->GetSelectedBoxes(); + if (m_pPanelSplitter->sizes().at(1) > 0 && boxes.count() == 1) + pBox = boxes.first(); + } + + // for old menu + if (m_pBoxCombo) { + QString Name = m_pBoxCombo->currentData().toString(); + if (Name.isEmpty()) + Name = "DefaultBox"; + pBox = theAPI->GetBoxByName(Name); + } + + if (!pBox.isNull()) { + if (!m_pFileView->isEnabled()) m_pFileView->setEnabled(true); + if (pBox != m_pFileView->GetBox()) m_pFileView->SetBox(pBox); + } + else if (m_pFileView->isEnabled()) { + m_pFileView->setEnabled(false); + m_pFileView->SetBox(CSandBoxPtr()); + } + QMap Processes = theAPI->GetAllProcesses(); int ActiveProcesses = 0; if (KeepTerminated()) { @@ -1360,42 +1468,9 @@ void CSandMan::OnMenuHover(QAction* action) //m_pMenuStopAll - always enabled } - static QMenu* pEmptyMenu = new QMenu(); if (menuBar()->actions().at(2) == action && m_pSandbox) - { - while (!m_pSandbox->actions().first()->data().toString().isEmpty()) - m_pSandbox->removeAction(m_pSandbox->actions().first()); + CreateBoxMenu(m_pSandbox); - QMap Boxes = theAPI->GetAllBoxes(); - - QAction* pPos = m_pSandbox->actions().first(); - foreach(const CSandBoxPtr & pBox, Boxes) - { - if (!pBox->IsEnabled()) - continue; - - QAction* pBoxAction = new QAction(pBox->GetName().replace("_", " ")); - pBoxAction->setData(pBox->GetName()); - pBoxAction->setMenu(pEmptyMenu); - //pBoxAction->setIcon - //connect(pBoxAction, SIGNAL(triggered()), this, SLOT(OnBoxMenu())); - m_pSandbox->insertAction(pPos, pBoxAction); - } - } - - if (action->data().type() == QVariant::String) { - QString Name = action->data().toString(); - static QPointer pPrev = NULL; - if (pPrev.data() != action) { - if (!pPrev.isNull()) { - pPrev->menu()->close(); - pPrev->setMenu(new QMenu()); - } - pPrev = action; - QMenu* pMenu = theGUI->GetBoxView()->GetMenu(Name); - action->setMenu(pMenu); - } - } } #define HK_PANIC 1 @@ -1608,19 +1683,6 @@ void CSandMan::OnSandBoxAction() else if(pAction == m_pNewGroup) GetBoxView()->AddNewGroup(); - else if (pAction == m_pArrangeGroups) - { - QMessageBox *msgBox = new QMessageBox(this); - msgBox->setAttribute(Qt::WA_DeleteOnClose); - msgBox->setWindowTitle("Sandboxie-Plus"); - msgBox->setText(tr("In the Plus UI this functionality has been integrated into the main sandbox list view.")); - msgBox->setInformativeText(tr("Using the box/group context menu you can move boxes and groups to other groups. You can also use drag an drop to move the items around. " - "Alternatively you can also use the arow keys while holding ALT down to move items up and down within thair group.
" - "You can create new boxes and groups from the Sandbox menu.")); - QPixmap pic(":/Assets/LayoutAndGroups.png"); - msgBox->setIconPixmap(pic.scaled(pic.width() * 3/4, pic.height() * 3/4, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - SafeExec(msgBox); - } // for old menu else { @@ -1898,6 +1960,11 @@ void CSandMan::OnProcView() { if(m_pKeepTerminated) theConf->SetValue("Options/KeepTerminated", m_pKeepTerminated->isChecked()); if(m_pShowAllSessions) theConf->SetValue("Options/ShowAllSessions", m_pShowAllSessions->isChecked()); + + if (m_pMenuBrowse) { + theConf->SetValue("Options/ShowFilePanel", m_pMenuBrowse->isChecked()); + m_pFileView->setVisible(m_pMenuBrowse->isChecked()); + } } void CSandMan::OnSettings() @@ -1914,6 +1981,33 @@ void CSandMan::OnSettings() } } +// for old menu +void CSandMan::OnSettingsAction() +{ + QAction* pAction = qobject_cast(sender()); + + if (pAction == m_pArrangeGroups) + { + QMessageBox *msgBox = new QMessageBox(this); + msgBox->setAttribute(Qt::WA_DeleteOnClose); + msgBox->setWindowTitle("Sandboxie-Plus"); + msgBox->setText(tr("In the Plus UI this functionality has been integrated into the main sandbox list view.")); + msgBox->setInformativeText(tr("Using the box/group context menu you can move boxes and groups to other groups. You can also use drag an drop to move the items around. " + "Alternatively you can also use the arow keys while holding ALT down to move items up and down within thair group.
" + "You can create new boxes and groups from the Sandbox menu.")); + QPixmap pic(":/Assets/LayoutAndGroups.png"); + msgBox->setIconPixmap(pic.scaled(pic.width() * 3/4, pic.height() * 3/4, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + SafeExec(msgBox); + } + else + { + CSettingsWindow* pSettingsWindow = new CSettingsWindow(this); + connect(pSettingsWindow, SIGNAL(OptionsChanged(bool)), this, SLOT(UpdateSettings(bool))); + int Tab = pAction->data().toInt(); + pSettingsWindow->showTab(Tab, true); + } +} + void CSandMan::UpdateSettings(bool bRebuildUI) { if(m_pTrayBoxes) m_pTrayBoxes->clear(); // force refresh diff --git a/SandboxiePlus/SandMan/SandMan.h b/SandboxiePlus/SandMan/SandMan.h index 18ad5df7..3fd52dcf 100644 --- a/SandboxiePlus/SandMan/SandMan.h +++ b/SandboxiePlus/SandMan/SandMan.h @@ -17,6 +17,7 @@ #include "SbiePlusAPI.h" class CSbieView; +class CFileView; class CBoxBorder; class CSbieTemplates; class CTraceView; @@ -180,6 +181,7 @@ private slots: void OnBoxMenuHover(QAction* action); void OnSandBoxAction(); + void OnSettingsAction(); void OnEmptyAll(); void OnWndFinder(); void OnDisableForce(); @@ -188,9 +190,11 @@ private slots: void OnViewMode(QAction* action); void OnAlwaysTop(); + void OnView(QAction* action); void OnRefresh(); void OnCleanUp(); void OnProcView(); + void OnRecoveryLog(); void OnSettings(); void OnResetMsgs(); @@ -229,7 +233,7 @@ private: void CreateViewBaseMenu(); void CreateHelpMenu(bool bAdvanced); void CreateToolBar(); - void CreateView(bool bAdvanced); + void CreateView(int iViewMode); void CreateTrayIcon(); void CreateTrayMenu(); void CreateBoxMenu(QMenu* pMenu, int iOffset = 0, int iSysTrayFilter = 0); @@ -243,19 +247,21 @@ private: QVBoxLayout* m_pMainLayout; QToolBar* m_pToolBar; - QSplitter* m_pPanelSplitter; - QSplitter* m_pLogSplitter; + QStackedLayout* m_pViewStack; + QComboBox* m_pBoxCombo; + CSbieView* m_pBoxView; + CFileView* m_pFileView; QTabWidget* m_pLogTabs; - CPanelWidgetEx* m_pMessageLog; CTraceView* m_pTraceView; CPanelWidgetEx* m_pRecoveryLog; + class CRecoveryLogWnd* m_pRecoveryLogWnd; QMenu* m_pMenuFile; @@ -288,6 +294,7 @@ private: QActionGroup* m_pViewMode; QAction* m_pShowHidden; QAction* m_pWndTopMost; + QAction* m_pMenuBrowse; QAction* m_pRefreshAll; QMenu* m_pCleanUpMenu; QAction* m_pCleanUpProcesses; @@ -297,6 +304,7 @@ private: QToolButton* m_pCleanUpButton; QAction* m_pKeepTerminated; QAction* m_pShowAllSessions; + QAction* m_pArrangeGroups; QMenu* m_pMenuOptions; QAction* m_pMenuSettings; @@ -353,4 +361,27 @@ public: bool m_DarkTheme; }; + +class CRecoveryLogWnd : public QDialog +{ + Q_OBJECT + +public: + CRecoveryLogWnd(QWidget *parent = Q_NULLPTR); + ~CRecoveryLogWnd(); + +private slots: + void OnDblClick(QTreeWidgetItem* pItem); + +signals: + void Closed(); + +protected: + friend class CSandMan; + void closeEvent(QCloseEvent *e); + + CPanelWidgetEx* m_pRecoveryLog; +}; + + extern CSandMan* theGUI; diff --git a/SandboxiePlus/SandMan/SandMan.vcxproj b/SandboxiePlus/SandMan/SandMan.vcxproj index 29683b16..0d37879e 100644 --- a/SandboxiePlus/SandMan/SandMan.vcxproj +++ b/SandboxiePlus/SandMan/SandMan.vcxproj @@ -240,9 +240,9 @@ Create Create + - true @@ -313,8 +313,8 @@ + - @@ -351,7 +351,6 @@ - diff --git a/SandboxiePlus/SandMan/SandMan.vcxproj.filters b/SandboxiePlus/SandMan/SandMan.vcxproj.filters index c725ba05..acda3594 100644 --- a/SandboxiePlus/SandMan/SandMan.vcxproj.filters +++ b/SandboxiePlus/SandMan/SandMan.vcxproj.filters @@ -138,9 +138,6 @@ Windows - - Windows - SandMan @@ -174,6 +171,9 @@ SandMan + + Views + @@ -244,9 +244,6 @@ Windows - - Windows - SandMan @@ -262,6 +259,9 @@ SandMan + + Views + @@ -301,9 +301,6 @@ Form Files - - Form Files - diff --git a/SandboxiePlus/SandMan/SandManRecovery.cpp b/SandboxiePlus/SandMan/SandManRecovery.cpp index 92a18aaf..c4bc37d2 100644 --- a/SandboxiePlus/SandMan/SandManRecovery.cpp +++ b/SandboxiePlus/SandMan/SandManRecovery.cpp @@ -143,16 +143,19 @@ void CSandMan::RecoverFilesAsync(const CSbieProgressPtr& pProgress, const QStrin void CSandMan::AddFileRecovered(const QString& BoxName, const QString& FilePath) { - if (!m_pRecoveryLog) - return; + CPanelWidgetEx* pRecoveryLog = m_pRecoveryLog; + if (pRecoveryLog == NULL) { + pRecoveryLog = m_pRecoveryLogWnd->m_pRecoveryLog; + if (!pRecoveryLog) return; + } QTreeWidgetItem* pItem = new QTreeWidgetItem(); // Time|Box|FilePath pItem->setText(0, QDateTime::currentDateTime().toString("hh:mm:ss.zzz")); pItem->setText(1, BoxName); pItem->setText(2, FilePath); - m_pRecoveryLog->GetTree()->addTopLevelItem(pItem); + pRecoveryLog->GetTree()->addTopLevelItem(pItem); - m_pRecoveryLog->GetView()->verticalScrollBar()->setValue(m_pRecoveryLog->GetView()->verticalScrollBar()->maximum()); + pRecoveryLog->GetView()->verticalScrollBar()->setValue(pRecoveryLog->GetView()->verticalScrollBar()->maximum()); } void CSandMan::OnFileRecovered(const QString& BoxName, const QString& FilePath, const QString& BoxPath) @@ -163,3 +166,73 @@ void CSandMan::OnFileRecovered(const QString& BoxName, const QString& FilePath, if (pBox) pBox.objectCast()->UpdateSize(); } + + +//////////////////////////////////////////////////////////////////////////////////////// +// CRecoveryLogWnd + +CRecoveryLogWnd::CRecoveryLogWnd(QWidget *parent) + : QDialog(parent) +{ + Qt::WindowFlags flags = windowFlags(); + flags |= Qt::CustomizeWindowHint; + //flags &= ~Qt::WindowContextHelpButtonHint; + //flags &= ~Qt::WindowSystemMenuHint; + //flags &= ~Qt::WindowMinMaxButtonsHint; + //flags |= Qt::WindowMinimizeButtonHint; + //flags &= ~Qt::WindowCloseButtonHint; + flags &= ~Qt::WindowContextHelpButtonHint; + //flags &= ~Qt::WindowSystemMenuHint; + setWindowFlags(flags); + + this->setWindowTitle(tr("Sandboxie-Plus - Recovery Log")); + + QGridLayout* pLayout = new QGridLayout(); + //pLayout->setMargin(3); + + m_pRecoveryLog = new CPanelWidgetEx(); + + //m_pRecoveryLog->GetView()->setItemDelegate(theGUI->GetItemDelegate()); + ((QTreeWidgetEx*)m_pRecoveryLog->GetView())->setHeaderLabels(tr("Time|Box Name|File Path").split("|")); + + QAction* pAction = new QAction(tr("Cleanup Recovery Log")); + connect(pAction, SIGNAL(triggered()), m_pRecoveryLog->GetTree(), SLOT(clear())); + m_pRecoveryLog->GetMenu()->insertAction(m_pRecoveryLog->GetMenu()->actions()[0], pAction); + m_pRecoveryLog->GetMenu()->insertSeparator(m_pRecoveryLog->GetMenu()->actions()[0]); + + m_pRecoveryLog->GetView()->setSelectionMode(QAbstractItemView::ExtendedSelection); + m_pRecoveryLog->GetView()->setSortingEnabled(false); + + connect(m_pRecoveryLog->GetTree(), SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(OnDblClick(QTreeWidgetItem*))); + + pLayout->addWidget(new QLabel(tr("the following files were recently recoered and moved oout of a sandbox.")), 0, 0); + pLayout->addWidget(m_pRecoveryLog, 1, 0); + this->setLayout(pLayout); + + restoreGeometry(theConf->GetBlob("RecoveryLogWindow/Window_Geometry")); +} + +CRecoveryLogWnd::~CRecoveryLogWnd() +{ + theConf->SetBlob("RecoveryLogWindow/Window_Geometry", saveGeometry()); +} + +void CRecoveryLogWnd::closeEvent(QCloseEvent *e) +{ + emit Closed(); + //this->deleteLater(); +} + +void CRecoveryLogWnd::OnDblClick(QTreeWidgetItem* pItem) +{ + ShellExecute(NULL, NULL, L"explorer.exe", (L"/select,\"" + pItem->text(2).toStdWString() + L"\"").c_str(), NULL, SW_SHOWNORMAL); +} + +void CSandMan::OnRecoveryLog() +{ + if (!m_pRecoveryLogWnd->isVisible()) { + bool bAlwaysOnTop = theConf->GetBool("Options/AlwaysOnTop", false); + m_pRecoveryLogWnd->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop); + SafeShow(m_pRecoveryLogWnd); + } +} \ No newline at end of file diff --git a/SandboxiePlus/SandMan/Windows/FileBrowserWindow.cpp b/SandboxiePlus/SandMan/Views/FileView.cpp similarity index 77% rename from SandboxiePlus/SandMan/Windows/FileBrowserWindow.cpp rename to SandboxiePlus/SandMan/Views/FileView.cpp index cda11636..1b437b92 100644 --- a/SandboxiePlus/SandMan/Windows/FileBrowserWindow.cpp +++ b/SandboxiePlus/SandMan/Views/FileView.cpp @@ -1,69 +1,60 @@ #include "stdafx.h" -#include "FileBrowserWindow.h" +#include "FileView.h" #include "SandMan.h" #include "../MiscHelpers/Common/Settings.h" #include "../MiscHelpers/Common/TreeItemModel.h" #include "../MiscHelpers/Common/OtherFunctions.h" #include "../QSbieAPI/SbieUtils.h" -CFileBrowserWindow::CFileBrowserWindow(const CSandBoxPtr& pBox, QWidget *parent) - : QDialog(parent) +CFileView::CFileView(QWidget *parent) + : QWidget(parent) { - Qt::WindowFlags flags = windowFlags(); - flags |= Qt::CustomizeWindowHint; - //flags &= ~Qt::WindowContextHelpButtonHint; - //flags &= ~Qt::WindowSystemMenuHint; - //flags &= ~Qt::WindowMinMaxButtonsHint; - flags |= Qt::WindowMinimizeButtonHint; - //flags &= ~Qt::WindowCloseButtonHint; - setWindowFlags(flags); + m_pMainLayout = new QGridLayout(); + m_pMainLayout->setMargin(0); + this->setLayout(m_pMainLayout); - bool bAlwaysOnTop = theConf->GetBool("Options/AlwaysOnTop", false); - this->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop); - - ui.setupUi(this); - this->setWindowTitle(tr("%1 - Files").arg(pBox->GetName())); - - m_pBox = pBox; + m_pTreeView = new QTreeView(); + m_pMainLayout->addWidget(m_pTreeView, 0, 0); m_pFileModel = new QFileSystemModel(this); m_pFileModel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs | QDir::Files | QDir::Hidden | QDir::System); - m_pFileModel->setRootPath(pBox->GetFileRoot()); - ui.treeFiles->setModel(m_pFileModel); - ui.treeFiles->setRootIndex(m_pFileModel->setRootPath(pBox->GetFileRoot())); - ui.treeFiles->setSelectionMode(QAbstractItemView::ExtendedSelection); + m_pTreeView->setModel(m_pFileModel); + m_pTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection); #ifdef WIN32 QStyle* pStyle = QStyleFactory::create("windows"); - ui.treeFiles->setStyle(pStyle); + m_pTreeView->setStyle(pStyle); #endif - ui.treeFiles->setExpandsOnDoubleClick(false); + m_pTreeView->setExpandsOnDoubleClick(false); - ui.treeFiles->setContextMenuPolicy(Qt::CustomContextMenu); - connect(ui.treeFiles, SIGNAL(customContextMenuRequested( const QPoint& )), this, SLOT(OnFileMenu(const QPoint &))); - connect(ui.treeFiles, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(OnFileDblClick(const QModelIndex &))); + m_pTreeView->setContextMenuPolicy(Qt::CustomContextMenu); + connect(m_pTreeView, SIGNAL(customContextMenuRequested( const QPoint& )), this, SLOT(OnFileMenu(const QPoint &))); + connect(m_pTreeView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(OnFileDblClick(const QModelIndex &))); - //statusBar(); - - restoreGeometry(theConf->GetBlob("FileBrowserWindow/Window_Geometry")); - QByteArray Columns = theConf->GetBlob("FileBrowserWindow/FileTree_Columns"); + QByteArray Columns = theConf->GetBlob("MainWindow/FileTree_Columns"); if (!Columns.isEmpty()) - ui.treeFiles->header()->restoreState(Columns); + m_pTreeView->header()->restoreState(Columns); } -CFileBrowserWindow::~CFileBrowserWindow() +CFileView::~CFileView() { - theConf->SetBlob("FileBrowserWindow/Window_Geometry",saveGeometry()); - theConf->SetBlob("FileBrowserWindow/FileTree_Columns", ui.treeFiles->header()->saveState()); + theConf->SetBlob("MainWindow/FileTree_Columns", m_pTreeView->header()->saveState()); } -void CFileBrowserWindow::closeEvent(QCloseEvent *e) +void CFileView::SetBox(const CSandBoxPtr& pBox) { - emit Closed(); - this->deleteLater(); + m_pBox = pBox; + QString Root; + if (!pBox.isNull()) { + Root = pBox->GetFileRoot(); + QDir().mkpath(Root); + } + else + Root = theAPI->GetSbiePath(); + //m_pFileModel->setRootPath(Root); + m_pTreeView->setRootIndex(m_pFileModel->setRootPath(Root)); } - #include #include #include @@ -126,15 +117,15 @@ int openShellContextMenu(const QStringList& Files, void * parentWindow) { addSeparatorToShellContextMenu(hMenu); - std::wstring Str1 = CFileBrowserWindow::tr("Create Shortcut").toStdWString(); + std::wstring Str1 = CFileView::tr("Create Shortcut").toStdWString(); if (Files.count() == 1) { addItemToShellContextMenu(hMenu, Str1.c_str(), MENU_CREATE_SHORTCUT); addSeparatorToShellContextMenu(hMenu); } - std::wstring Str2 = CFileBrowserWindow::tr("Recover to Any Folder").toStdWString(); + std::wstring Str2 = CFileView::tr("Recover to Any Folder").toStdWString(); addItemToShellContextMenu(hMenu, Str2.c_str(), MENU_RECOVER_TO_ANY); - std::wstring Str3 = CFileBrowserWindow::tr("Recover to Same Folder").toStdWString(); + std::wstring Str3 = CFileView::tr("Recover to Same Folder").toStdWString(); addItemToShellContextMenu(hMenu, Str3.c_str(), MENU_RECOVER); POINT point; @@ -163,10 +154,10 @@ int openShellContextMenu(const QStringList& Files, void * parentWindow) } -void CFileBrowserWindow::OnFileMenu(const QPoint&) +void CFileView::OnFileMenu(const QPoint&) { QStringList Files; - foreach(const QModelIndex & Index, ui.treeFiles->selectionModel()->selectedIndexes()) { + foreach(const QModelIndex & Index, m_pTreeView->selectionModel()->selectedIndexes()) { QString BoxedPath = m_pFileModel->fileInfo(Index).absoluteFilePath().replace("/", "\\"); if (m_pFileModel->fileInfo(Index).isDir()) BoxedPath += "\\"; @@ -194,7 +185,7 @@ void CFileBrowserWindow::OnFileMenu(const QPoint&) switch (iCmd) { case MENU_RECOVER_TO_ANY: - RecoveryFolder = QFileDialog::getExistingDirectory(this, CFileBrowserWindow::tr("Select Directory")).replace("/", "\\"); + RecoveryFolder = QFileDialog::getExistingDirectory(this, CFileView::tr("Select Directory")).replace("/", "\\"); if (RecoveryFolder.isEmpty()) break; case MENU_RECOVER: @@ -256,9 +247,52 @@ void CFileBrowserWindow::OnFileMenu(const QPoint&) } -void CFileBrowserWindow::OnFileDblClick(const QModelIndex &) +void CFileView::OnFileDblClick(const QModelIndex &) { - QString BoxedPath = m_pFileModel->fileInfo(ui.treeFiles->currentIndex()).absoluteFilePath(); + QString BoxedPath = m_pFileModel->fileInfo(m_pTreeView->currentIndex()).absoluteFilePath(); ShellExecute(NULL, NULL, BoxedPath.toStdWString().c_str(), NULL, m_pBox->GetFileRoot().toStdWString().c_str(), SW_SHOWNORMAL); } + + +//////////////////////////////////////////////////////////////////////////////////////// +// CFileBrowserWindow + +CFileBrowserWindow::CFileBrowserWindow(const CSandBoxPtr& pBox, QWidget *parent) + : QDialog(parent) +{ + Qt::WindowFlags flags = windowFlags(); + flags |= Qt::CustomizeWindowHint; + //flags &= ~Qt::WindowContextHelpButtonHint; + //flags &= ~Qt::WindowSystemMenuHint; + //flags &= ~Qt::WindowMinMaxButtonsHint; + flags |= Qt::WindowMinimizeButtonHint; + //flags &= ~Qt::WindowCloseButtonHint; + setWindowFlags(flags); + + bool bAlwaysOnTop = theConf->GetBool("Options/AlwaysOnTop", false); + this->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop); + + m_pMainLayout = new QGridLayout(this); + m_FileView = new CFileView(); + m_FileView->SetBox(pBox); + m_pMainLayout->addWidget(m_FileView, 0, 0); + + this->setWindowTitle(tr("%1 - Files").arg(pBox->GetName())); + + + //statusBar(); + + restoreGeometry(theConf->GetBlob("FileBrowserWindow/Window_Geometry")); +} + +CFileBrowserWindow::~CFileBrowserWindow() +{ + theConf->SetBlob("FileBrowserWindow/Window_Geometry",saveGeometry()); +} + +void CFileBrowserWindow::closeEvent(QCloseEvent *e) +{ + emit Closed(); + this->deleteLater(); +} diff --git a/SandboxiePlus/SandMan/Views/FileView.h b/SandboxiePlus/SandMan/Views/FileView.h new file mode 100644 index 00000000..9f9bc00d --- /dev/null +++ b/SandboxiePlus/SandMan/Views/FileView.h @@ -0,0 +1,59 @@ +#pragma once + + +//#include "../../MiscHelpers/Common/PanelView.h" +#include "../../MiscHelpers/Common/TreeviewEx.h" +#include "SbiePlusAPI.h" +#include + +class CFileView : public QWidget +{ + Q_OBJECT + +public: + CFileView(QWidget *parent = Q_NULLPTR); + ~CFileView(); + + void SetBox(const CSandBoxPtr& pBox); + const CSandBoxPtr& GetBox() const { return m_pBox; } + + +private slots: + void OnFileMenu(const QPoint &); + void OnFileDblClick(const QModelIndex &); + +protected: + CSandBoxPtr m_pBox; + +private: + QGridLayout* m_pMainLayout; + QTreeView* m_pTreeView; + QFileSystemModel* m_pFileModel; +}; + + +//////////////////////////////////////////////////////////////////////////////////////// +// CFileBrowserWindow + +class CFileBrowserWindow : public QDialog +{ + Q_OBJECT + +public: + CFileBrowserWindow(const CSandBoxPtr& pBox, QWidget *parent = Q_NULLPTR); + ~CFileBrowserWindow(); + + virtual void accept() {} + virtual void reject() { this->close(); } + +signals: + void Closed(); + +protected: + void closeEvent(QCloseEvent *e); + +private: + + QGridLayout* m_pMainLayout; + CFileView* m_FileView; +}; diff --git a/SandboxiePlus/SandMan/Views/SbieView.cpp b/SandboxiePlus/SandMan/Views/SbieView.cpp index 5e20506a..49021a5e 100644 --- a/SandboxiePlus/SandMan/Views/SbieView.cpp +++ b/SandboxiePlus/SandMan/Views/SbieView.cpp @@ -11,7 +11,7 @@ #include "../../MiscHelpers/Common/CheckableMessageBox.h" #include "../Windows/RecoveryWindow.h" #include "../Windows/NewBoxWindow.h" -#include "../Windows/FileBrowserWindow.h" +#include "../Views/FileView.h" #include "qt_windows.h" #include "qwindowdefs_win.h" @@ -157,8 +157,9 @@ void CSbieView::CreateMenu() m_iMenuRun = m_pMenuRun->actions().count(); m_pMenuEmptyBox = m_pMenu->addAction(CSandMan::GetIcon("EmptyAll"), tr("Terminate All Programs"), this, SLOT(OnSandBoxAction())); m_pMenu->addSeparator(); - m_pMenuBrowse = m_pMenu->addAction(CSandMan::GetIcon("Tree"), tr("Browse Content"), this, SLOT(OnSandBoxAction())); m_pMenuContent = m_pMenu->addMenu(CSandMan::GetIcon("Compatibility"), tr("Box Content")); + m_pMenuBrowse = m_pMenuContent->addAction(CSandMan::GetIcon("Tree"), tr("Browse Files"), this, SLOT(OnSandBoxAction())); + m_pMenuContent->addSeparator(); m_pMenuRefresh = m_pMenuContent->addAction(CSandMan::GetIcon("Refresh"), tr("Refresh Info"), this, SLOT(OnSandBoxAction())); m_pMenuMkLink = m_pMenuContent->addAction(CSandMan::GetIcon("MkLink"), tr("Create Shortcut"), this, SLOT(OnSandBoxAction())); m_pMenuContent->addSeparator(); diff --git a/SandboxiePlus/SandMan/Views/TraceView.cpp b/SandboxiePlus/SandMan/Views/TraceView.cpp index 13a2f10f..543033fb 100644 --- a/SandboxiePlus/SandMan/Views/TraceView.cpp +++ b/SandboxiePlus/SandMan/Views/TraceView.cpp @@ -629,6 +629,9 @@ CTraceWindow::CTraceWindow(QWidget *parent) this->setWindowTitle(tr("Sandboxie-Plus - Trace Monitor")); + bool bAlwaysOnTop = theConf->GetBool("Options/AlwaysOnTop", false); + this->setWindowFlag(Qt::WindowStaysOnTopHint, bAlwaysOnTop); + QGridLayout* pLayout = new QGridLayout(); pLayout->setMargin(3); pLayout->addWidget(new CTraceView(true, this), 0, 0); @@ -641,7 +644,7 @@ CTraceWindow::~CTraceWindow() { theConf->SetBlob("TraceWindow/Window_Geometry", saveGeometry()); - theAPI->EnableMonitor(false); + if(!theAPI) theAPI->EnableMonitor(false); } void CTraceWindow::closeEvent(QCloseEvent *e) diff --git a/SandboxiePlus/SandMan/Windows/FileBrowserWindow.h b/SandboxiePlus/SandMan/Windows/FileBrowserWindow.h deleted file mode 100644 index bfd3dcb3..00000000 --- a/SandboxiePlus/SandMan/Windows/FileBrowserWindow.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#include -#include "ui_FileBrowserWindow.h" -#include "SbiePlusAPI.h" -#include - -class CFileBrowserWindow : public QDialog -{ - Q_OBJECT - -public: - CFileBrowserWindow(const CSandBoxPtr& pBox, QWidget *parent = Q_NULLPTR); - ~CFileBrowserWindow(); - - virtual void accept() {} - virtual void reject() { this->close(); } - -signals: - void Closed(); - -private slots: - void OnFileMenu(const QPoint &); - void OnFileDblClick(const QModelIndex &); - -protected: - void closeEvent(QCloseEvent *e); - - CSandBoxPtr m_pBox; - -private: - Ui::FileBrowserWindow ui; - - QFileSystemModel* m_pFileModel; -}; diff --git a/SandboxiePlus/SandMan/stdafx.h b/SandboxiePlus/SandMan/stdafx.h index dc6603cf..bd2d637b 100644 --- a/SandboxiePlus/SandMan/stdafx.h +++ b/SandboxiePlus/SandMan/stdafx.h @@ -107,6 +107,7 @@ using namespace std; #include #include #include +#include // other includes