summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:13:13 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:13:13 +0200
commit7f23ee90fd545995a29e2175f15e8b97e59ca67a (patch)
treef8d0afac51995032e58b9a475ccbbc73ba207baf /ui
parent3.19 (diff)
downloadFreeFileSync-7f23ee90fd545995a29e2175f15e8b97e59ca67a.tar.gz
FreeFileSync-7f23ee90fd545995a29e2175f15e8b97e59ca67a.tar.bz2
FreeFileSync-7f23ee90fd545995a29e2175f15e8b97e59ca67a.zip
3.20
Diffstat (limited to 'ui')
-rw-r--r--ui/batch_config.cpp2
-rw-r--r--ui/batch_config.h2
-rw-r--r--ui/batch_status_handler.cpp2
-rw-r--r--ui/batch_status_handler.h2
-rw-r--r--ui/check_version.cpp2
-rw-r--r--ui/check_version.h2
-rw-r--r--ui/folder_pair.h2
-rw-r--r--ui/grid_view.cpp2
-rw-r--r--ui/grid_view.h2
-rw-r--r--ui/gui_generated.cpp24
-rw-r--r--ui/gui_status_handler.cpp2
-rw-r--r--ui/gui_status_handler.h2
-rw-r--r--ui/main_dlg.cpp176
-rw-r--r--ui/main_dlg.h14
-rw-r--r--ui/msg_popup.cpp2
-rw-r--r--ui/msg_popup.h2
-rw-r--r--ui/progress_indicator.cpp150
-rw-r--r--ui/progress_indicator.h2
-rw-r--r--ui/search.cpp2
-rw-r--r--ui/search.h2
-rw-r--r--ui/small_dlgs.cpp2
-rw-r--r--ui/small_dlgs.h2
-rw-r--r--ui/sorting.h2
-rw-r--r--ui/switch_to_gui.cpp2
-rw-r--r--ui/switch_to_gui.h2
-rw-r--r--ui/sync_cfg.cpp2
-rw-r--r--ui/sync_cfg.h2
-rw-r--r--ui/tray_icon.cpp104
-rw-r--r--ui/tray_icon.h19
29 files changed, 249 insertions, 284 deletions
diff --git a/ui/batch_config.cpp b/ui/batch_config.cpp
index c6aa4df7..043281e9 100644
--- a/ui/batch_config.cpp
+++ b/ui/batch_config.cpp
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#include "batch_config.h"
#include "../shared/dir_picker_i18n.h"
#include "folder_pair.h"
diff --git a/ui/batch_config.h b/ui/batch_config.h
index 574fef66..9a272261 100644
--- a/ui/batch_config.h
+++ b/ui/batch_config.h
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#ifndef BATCHCONFIG_H_INCLUDED
#define BATCHCONFIG_H_INCLUDED
diff --git a/ui/batch_status_handler.cpp b/ui/batch_status_handler.cpp
index 2cfd43cb..772feaf4 100644
--- a/ui/batch_status_handler.cpp
+++ b/ui/batch_status_handler.cpp
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#include "batch_status_handler.h"
#include "msg_popup.h"
#include <wx/ffile.h>
diff --git a/ui/batch_status_handler.h b/ui/batch_status_handler.h
index 1803019e..61e0f46e 100644
--- a/ui/batch_status_handler.h
+++ b/ui/batch_status_handler.h
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#ifndef BATCHSTATUSHANDLER_H_INCLUDED
#define BATCHSTATUSHANDLER_H_INCLUDED
diff --git a/ui/check_version.cpp b/ui/check_version.cpp
index 03f7e486..491cf3c2 100644
--- a/ui/check_version.cpp
+++ b/ui/check_version.cpp
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#include "check_version.h"
#include <wx/msgdlg.h>
#include <wx/protocol/http.h>
diff --git a/ui/check_version.h b/ui/check_version.h
index b9606987..c1331f7f 100644
--- a/ui/check_version.h
+++ b/ui/check_version.h
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#ifndef UPDATEVERSION_H_INCLUDED
#define UPDATEVERSION_H_INCLUDED
diff --git a/ui/folder_pair.h b/ui/folder_pair.h
index 893acdc7..5ca8d92f 100644
--- a/ui/folder_pair.h
+++ b/ui/folder_pair.h
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#ifndef FOLDERPAIR_H_INCLUDED
#define FOLDERPAIR_H_INCLUDED
diff --git a/ui/grid_view.cpp b/ui/grid_view.cpp
index 59bfb767..ba1738f6 100644
--- a/ui/grid_view.cpp
+++ b/ui/grid_view.cpp
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#include "grid_view.h"
#include "sorting.h"
#include "../synchronization.h"
diff --git a/ui/grid_view.h b/ui/grid_view.h
index edb54ab7..87d5c38d 100644
--- a/ui/grid_view.h
+++ b/ui/grid_view.h
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#ifndef GRIDVIEW_H_INCLUDED
#define GRIDVIEW_H_INCLUDED
diff --git a/ui/gui_generated.cpp b/ui/gui_generated.cpp
index d3c0bb8e..b15689ec 100644
--- a/ui/gui_generated.cpp
+++ b/ui/gui_generated.cpp
@@ -171,7 +171,7 @@ MainDialogGenerated::MainDialogGenerated( wxWindow* parent, wxWindowID id, const
fgSizer12->Add( m_bpButtonSyncConfig, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 3 );
- m_buttonStartSync = new wxButtonWithImage( m_panelTopButtons, wxID_ANY, _("Synchronize..."), wxDefaultPosition, wxSize( -1,42 ), 0 );
+ m_buttonStartSync = new wxButtonWithImage( m_panelTopButtons, wxID_ANY, _("Synchronize..."), wxDefaultPosition, wxSize( 180,42 ), 0 );
m_buttonStartSync->SetFont( wxFont( 14, 74, 90, 92, false, wxEmptyString ) );
m_buttonStartSync->SetToolTip( _("Start synchronization") );
@@ -491,7 +491,7 @@ MainDialogGenerated::MainDialogGenerated( wxWindow* parent, wxWindowID id, const
fgSizer5->Add( m_bitmapCreate, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
- m_textCtrlCreate = new wxTextCtrl( m_panelStatistics, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80,-1 ), wxTE_READONLY );
+ m_textCtrlCreate = new wxTextCtrl( m_panelStatistics, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80,-1 ), wxTE_READONLY|wxTE_RIGHT );
m_textCtrlCreate->SetFont( wxFont( 8, 70, 90, 90, false, wxEmptyString ) );
m_textCtrlCreate->SetBackgroundColour( wxColour( 208, 208, 208 ) );
m_textCtrlCreate->SetToolTip( _("Number of files and directories that will be created") );
@@ -503,7 +503,7 @@ MainDialogGenerated::MainDialogGenerated( wxWindow* parent, wxWindowID id, const
fgSizer5->Add( m_bitmapUpdate, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
- m_textCtrlUpdate = new wxTextCtrl( m_panelStatistics, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80,-1 ), wxTE_READONLY );
+ m_textCtrlUpdate = new wxTextCtrl( m_panelStatistics, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80,-1 ), wxTE_READONLY|wxTE_RIGHT );
m_textCtrlUpdate->SetFont( wxFont( 8, 70, 90, 90, false, wxEmptyString ) );
m_textCtrlUpdate->SetBackgroundColour( wxColour( 208, 208, 208 ) );
m_textCtrlUpdate->SetToolTip( _("Number of files that will be overwritten") );
@@ -522,7 +522,7 @@ MainDialogGenerated::MainDialogGenerated( wxWindow* parent, wxWindowID id, const
fgSizer6->Add( m_bitmapDelete, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 );
- m_textCtrlDelete = new wxTextCtrl( m_panelStatistics, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80,-1 ), wxTE_READONLY );
+ m_textCtrlDelete = new wxTextCtrl( m_panelStatistics, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80,-1 ), wxTE_READONLY|wxTE_RIGHT );
m_textCtrlDelete->SetFont( wxFont( 8, 70, 90, 90, false, wxEmptyString ) );
m_textCtrlDelete->SetBackgroundColour( wxColour( 208, 208, 208 ) );
m_textCtrlDelete->SetToolTip( _("Number of files and directories that will be deleted") );
@@ -534,7 +534,7 @@ MainDialogGenerated::MainDialogGenerated( wxWindow* parent, wxWindowID id, const
fgSizer6->Add( m_bitmapData, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
- m_textCtrlData = new wxTextCtrl( m_panelStatistics, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80,-1 ), wxTE_READONLY );
+ m_textCtrlData = new wxTextCtrl( m_panelStatistics, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80,-1 ), wxTE_READONLY|wxTE_RIGHT );
m_textCtrlData->SetFont( wxFont( 8, 70, 90, 90, false, wxEmptyString ) );
m_textCtrlData->SetBackgroundColour( wxColour( 208, 208, 208 ) );
m_textCtrlData->SetToolTip( _("Total amount of data that will be transferred") );
@@ -3686,7 +3686,7 @@ SyncPreviewDlgGenerated::SyncPreviewDlgGenerated( wxWindow* parent, wxWindowID i
fgSizer5->Add( m_bitmapCreate, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
- m_textCtrlCreateL = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80,-1 ), wxTE_READONLY );
+ m_textCtrlCreateL = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80,-1 ), wxTE_READONLY|wxTE_RIGHT );
m_textCtrlCreateL->SetFont( wxFont( 8, 70, 90, 90, false, wxEmptyString ) );
m_textCtrlCreateL->SetBackgroundColour( wxColour( 208, 208, 208 ) );
m_textCtrlCreateL->SetToolTip( _("Number of files and directories that will be created") );
@@ -3698,7 +3698,7 @@ SyncPreviewDlgGenerated::SyncPreviewDlgGenerated( wxWindow* parent, wxWindowID i
fgSizer5->Add( m_bitmapUpdate, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
- m_textCtrlUpdateL = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80,-1 ), wxTE_READONLY );
+ m_textCtrlUpdateL = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80,-1 ), wxTE_READONLY|wxTE_RIGHT );
m_textCtrlUpdateL->SetFont( wxFont( 8, 70, 90, 90, false, wxEmptyString ) );
m_textCtrlUpdateL->SetBackgroundColour( wxColour( 208, 208, 208 ) );
m_textCtrlUpdateL->SetToolTip( _("Number of files that will be overwritten") );
@@ -3710,7 +3710,7 @@ SyncPreviewDlgGenerated::SyncPreviewDlgGenerated( wxWindow* parent, wxWindowID i
fgSizer5->Add( m_bitmapDelete, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 );
- m_textCtrlDeleteL = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80,-1 ), wxTE_READONLY );
+ m_textCtrlDeleteL = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80,-1 ), wxTE_READONLY|wxTE_RIGHT );
m_textCtrlDeleteL->SetFont( wxFont( 8, 70, 90, 90, false, wxEmptyString ) );
m_textCtrlDeleteL->SetBackgroundColour( wxColour( 208, 208, 208 ) );
m_textCtrlDeleteL->SetToolTip( _("Number of files and directories that will be deleted") );
@@ -3730,21 +3730,21 @@ SyncPreviewDlgGenerated::SyncPreviewDlgGenerated( wxWindow* parent, wxWindowID i
fgSizer51->Add( m_staticText95, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 );
- m_textCtrlCreateR = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80,-1 ), wxTE_READONLY );
+ m_textCtrlCreateR = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80,-1 ), wxTE_READONLY|wxTE_RIGHT );
m_textCtrlCreateR->SetFont( wxFont( 8, 70, 90, 90, false, wxEmptyString ) );
m_textCtrlCreateR->SetBackgroundColour( wxColour( 208, 208, 208 ) );
m_textCtrlCreateR->SetToolTip( _("Number of files and directories that will be created") );
fgSizer51->Add( m_textCtrlCreateR, 0, wxALIGN_CENTER_VERTICAL, 5 );
- m_textCtrlUpdateR = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80,-1 ), wxTE_READONLY );
+ m_textCtrlUpdateR = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80,-1 ), wxTE_READONLY|wxTE_RIGHT );
m_textCtrlUpdateR->SetFont( wxFont( 8, 70, 90, 90, false, wxEmptyString ) );
m_textCtrlUpdateR->SetBackgroundColour( wxColour( 208, 208, 208 ) );
m_textCtrlUpdateR->SetToolTip( _("Number of files that will be overwritten") );
fgSizer51->Add( m_textCtrlUpdateR, 0, wxALIGN_CENTER_VERTICAL, 5 );
- m_textCtrlDeleteR = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80,-1 ), wxTE_READONLY );
+ m_textCtrlDeleteR = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80,-1 ), wxTE_READONLY|wxTE_RIGHT );
m_textCtrlDeleteR->SetFont( wxFont( 8, 70, 90, 90, false, wxEmptyString ) );
m_textCtrlDeleteR->SetBackgroundColour( wxColour( 208, 208, 208 ) );
m_textCtrlDeleteR->SetToolTip( _("Number of files and directories that will be deleted") );
@@ -3769,7 +3769,7 @@ SyncPreviewDlgGenerated::SyncPreviewDlgGenerated( wxWindow* parent, wxWindowID i
bSizer156->Add( 0, 0, 1, wxEXPAND, 5 );
- m_textCtrlData = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80,-1 ), wxTE_READONLY );
+ m_textCtrlData = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80,-1 ), wxTE_CENTRE|wxTE_READONLY );
m_textCtrlData->SetFont( wxFont( 8, 70, 90, 90, false, wxEmptyString ) );
m_textCtrlData->SetBackgroundColour( wxColour( 208, 208, 208 ) );
m_textCtrlData->SetToolTip( _("Total amount of data that will be transferred") );
diff --git a/ui/gui_status_handler.cpp b/ui/gui_status_handler.cpp
index 43293829..c940c76e 100644
--- a/ui/gui_status_handler.cpp
+++ b/ui/gui_status_handler.cpp
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#include "gui_status_handler.h"
#include "small_dlgs.h"
#include "msg_popup.h"
diff --git a/ui/gui_status_handler.h b/ui/gui_status_handler.h
index 45d429b1..b7fbd9be 100644
--- a/ui/gui_status_handler.h
+++ b/ui/gui_status_handler.h
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#ifndef GUISTATUSHANDLER_H_INCLUDED
#define GUISTATUSHANDLER_H_INCLUDED
diff --git a/ui/main_dlg.cpp b/ui/main_dlg.cpp
index 2256329a..197784bd 100644
--- a/ui/main_dlg.cpp
+++ b/ui/main_dlg.cpp
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#include "main_dlg.h"
#include <iterator>
#include <stdexcept>
@@ -52,9 +52,11 @@
#include "../shared/check_exist.h"
#include "../library/lock_holder.h"
#include "../shared/shell_execute.h"
+#include "../shared/localization.h"
using namespace zen;
+
namespace
{
struct wxClientDataString : public wxClientData //we need a wxClientData derived class to tell wxWidgets to take object ownership!
@@ -346,7 +348,7 @@ MainDialog::MainDialog(const wxString& cfgFileName, xmlAccess::XmlGlobalSettings
if (filenames.empty())
{
- if (fileExists(toZ(lastRunConfigName()))) //3. try to load auto-save config
+ if (zen::fileExists(zen::toZ(lastRunConfigName()))) //3. try to load auto-save config
filenames.push_back(lastRunConfigName());
}
}
@@ -542,18 +544,19 @@ void MainDialog::init(const xmlAccess::XmlGuiConfig guiCfg,
#endif
//create language selection menu
- for (std::vector<ExistingTranslations::Entry>::const_iterator i = ExistingTranslations::get().begin(); i != ExistingTranslations::get().end(); ++i)
+ std::for_each(zen::ExistingTranslations::get().begin(), zen::ExistingTranslations::get().end(),
+ [&](const zen::ExistingTranslations::Entry& entry)
{
- wxMenuItem* newItem = new wxMenuItem(m_menuLanguages, wxID_ANY, i->languageName, wxEmptyString, wxITEM_NORMAL );
- newItem->SetBitmap(GlobalResources::instance().getImage(i->languageFlag));
+ wxMenuItem* newItem = new wxMenuItem(m_menuLanguages, wxID_ANY, entry.languageName, wxEmptyString, wxITEM_NORMAL );
+ newItem->SetBitmap(GlobalResources::instance().getImage(entry.languageFlag));
//map menu item IDs with language IDs: evaluated when processing event handler
- languageMenuItemMap.insert(std::map<MenuItemID, LanguageID>::value_type(newItem->GetId(), i->languageID));
+ languageMenuItemMap.insert(std::map<MenuItemID, LanguageID>::value_type(newItem->GetId(), entry.languageID));
//connect event
- Connect(newItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainDialog::OnMenuLanguageSwitch));
+ this->Connect(newItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainDialog::OnMenuLanguageSwitch));
m_menuLanguages->Append(newItem);
- }
+ });
//support for CTRL + C and DEL on grids
m_gridLeft ->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(MainDialog::onGridLeftButtonEvent), NULL, this);
@@ -1030,43 +1033,6 @@ void MainDialog::deleteSelectedFiles(const std::set<size_t>& viewSelectionLeft,
}
-template <SelectedSide side>
-void exstractNames(const FileSystemObject& fsObj, wxString& name, wxString& dir)
-{
- if (!fsObj.isEmpty<side>())
- {
- struct GetNames : public FSObjectVisitor
- {
- GetNames(wxString& nameIn, wxString& dirIn) : name_(nameIn), dir_(dirIn) {}
- virtual void visit(const FileMapping& fileObj)
- {
- name_ = toWx(fileObj.getFullName<side>());
- dir_ = toWx(fileObj.getFullName<side>().BeforeLast(FILE_NAME_SEPARATOR));
- }
- virtual void visit(const SymLinkMapping& linkObj)
- {
- name_ = toWx(linkObj.getFullName<side>());
- dir_ = toWx(linkObj.getFullName<side>().BeforeLast(FILE_NAME_SEPARATOR));
- }
- virtual void visit(const DirMapping& dirObj)
- {
- dir_ = name_ = toWx(dirObj.getFullName<side>());
- }
-
- wxString& name_;
- wxString& dir_;
- ;
- } getNames(name, dir);
- fsObj.accept(getNames);
- }
- else
- {
- name.clear();
- dir.clear();
- }
-}
-
-
void MainDialog::openExternalApplication(const wxString& commandline)
{
if (m_gridLeft->isLeadGrid() || m_gridRight->isLeadGrid())
@@ -1082,66 +1048,85 @@ void MainDialog::openExternalApplication(const wxString& commandline)
}
+template <SelectedSide side>
+wxString extractLastValidDir(const FileSystemObject& fsObj)
+{
+ Zstring fullname = fsObj.getBaseDirPf<side>() + fsObj.getObjRelativeName(); //full name even if FileSystemObject::isEmpty<side>() == true
+
+ while (!fullname.empty() && !dirExists(fullname)) //bad algorithm: this one should better retrieve the status from fsObj
+ fullname = beforeLast(fullname, FILE_NAME_SEPARATOR);
+
+ return toWx(fullname);
+}
+
+bool tryReplace(const wxString& phrase, const wxString& replacement, wxString& command) //return false on error
+{
+ if (command.find(phrase) != wxString::npos)
+ {
+ if (replacement.empty())
+ return false;
+ replace(command, phrase, replacement);
+ }
+ return true;
+}
+
+
void MainDialog::openExternalApplication(size_t rowNumber, bool leftSide, const wxString& commandline)
{
if (commandline.empty())
return;
- wxString command = commandline;
-
wxString name;
- wxString dir;
wxString nameCo;
+ wxString dir;
wxString dirCo;
- const FileSystemObject* fsObj = gridDataView->getObject(rowNumber);
- if (fsObj)
{
- if (leftSide)
- {
- exstractNames<LEFT_SIDE>( *fsObj, name, dir);
- exstractNames<RIGHT_SIDE>(*fsObj, nameCo, dirCo);
- }
- else
- {
- exstractNames<RIGHT_SIDE>(*fsObj, name, dir);
- exstractNames<LEFT_SIDE>( *fsObj, nameCo, dirCo);
- }
-#ifdef FFS_WIN
- if (name.empty())
+ const FileSystemObject* fsObj = gridDataView->getObject(rowNumber);
+ if (fsObj)
{
- if (leftSide)
- zen::shellExecute(wxString(L"\"") + fsObj->getBaseDirPf<LEFT_SIDE>() + "\"");
- //zen::shellExecute(wxString(wxT("explorer ")) + L"\"" + zToWx(fsObj->getBaseDirPf<LEFT_SIDE>()) + L"\"");
- else
- zen::shellExecute(wxString(L"\"") + fsObj->getBaseDirPf<RIGHT_SIDE>() + "\"");
- //zen::shellExecute(wxString(wxT("explorer ")) + L"\"" + zToWx(fsObj->getBaseDirPf<RIGHT_SIDE>()) + L"\"");
- return;
+ name = toWx(fsObj->getFullName<LEFT_SIDE>()); //empty if obj not existing
+ dir = toWx(beforeLast(fsObj->getFullName<LEFT_SIDE>(), FILE_NAME_SEPARATOR)); //small issue: if obj does not exist but parent exists, this one erronously returns empty
+
+ nameCo = toWx(fsObj->getFullName<RIGHT_SIDE>());
+ dirCo = toWx(beforeLast(fsObj->getFullName<RIGHT_SIDE>(), FILE_NAME_SEPARATOR));
}
-#endif
}
- else
+
+ if (!leftSide)
{
- //fallback
- dir = toWx(zen::getFormattedDirectoryName(toZ(firstFolderPair->getLeftDir())));
- dirCo = toWx(zen::getFormattedDirectoryName(toZ(firstFolderPair->getRightDir())));
+ std::swap(name, nameCo);
+ std::swap(dir, dirCo);
+ }
- if (!leftSide)
- std::swap(dir, dirCo);
+ wxString command = commandline;
+ if (tryReplace(L"%nameCo", nameCo, command) && //attention: replace %nameCo, %dirCo BEFORE %name, %dir to handle dependency
+ tryReplace(L"%dirCo", dirCo, command) &&
+ tryReplace(L"%name", name, command) &&
+ tryReplace(L"%dir", dir, command))
+ zen::shellExecute(command);
+ else //fallback
+ {
+ wxString fallbackDir;
+ const FileSystemObject* fsObj = gridDataView->getObject(rowNumber);
+ if (fsObj)
+ {
+ fallbackDir = leftSide ?
+ extractLastValidDir<LEFT_SIDE>(*fsObj) :
+ extractLastValidDir<RIGHT_SIDE>(*fsObj);
+ }
+
+ if (fallbackDir.empty())
+ fallbackDir = leftSide ?
+ toWx(zen::getFormattedDirectoryName(toZ(firstFolderPair->getLeftDir()))) :
+ toWx(zen::getFormattedDirectoryName(toZ(firstFolderPair->getRightDir())));
#ifdef FFS_WIN
- zen::shellExecute(wxString(L"\"") + dir + L"\""); //default
- //zen::shellExecute(wxString(wxT("explorer ")) + L"\"" + dir + L"\""); //default
- return;
+ zen::shellExecute(wxString(L"\"") + fallbackDir + L"\""); //default
+#elif defined FFS_LINUX
+ zen::shellExecute(wxString(L"xdg-open \"") + fallbackDir + L"\""); //default
#endif
}
-
- command.Replace(wxT("%nameCo"), nameCo, true); //attention: replace %nameCo, %dirCo BEFORE %name, %dir to handle dependency
- command.Replace(wxT("%dirCo"), dirCo, true);
- command.Replace(wxT("%name"), name, true);
- command.Replace(wxT("%dir"), dir, true);
-
- zen::shellExecute(command);
}
@@ -1157,7 +1142,7 @@ void MainDialog::pushStatusInformation(const wxString& text)
void MainDialog::clearStatusBar()
{
- while (stackObjects.size() > 0)
+ while (!stackObjects.empty())
stackObjects.pop();
m_staticTextStatusMiddle->SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); //reset color
@@ -1188,7 +1173,6 @@ void MainDialog::disableAllElements(bool enableAbort)
if (enableAbort)
{
-
//show abort button
m_buttonAbort->Enable();
m_buttonAbort->Show();
@@ -1907,8 +1891,8 @@ void MainDialog::OnContextExcludeExtension(wxCommandEvent& event)
updateFilterButtons();
//do not fully apply filter, just exclude new items
- std::for_each(gridDataView->getDataTentative().begin(), gridDataView->getDataTentative().end(),
- [&](BaseDirMapping& baseMap) { addHardFiltering(baseMap, newExclude); });
+ std::for_each(gridDataView->getDataTentative().begin(), gridDataView->getDataTentative().end(),
+ [&](BaseDirMapping& baseMap) { addHardFiltering(baseMap, newExclude); });
//applyFiltering(getConfig().mainCfg, gridDataView->getDataTentative());
updateGuiGrid();
@@ -1950,8 +1934,8 @@ void MainDialog::OnContextExcludeObject(wxCommandEvent& event)
updateFilterButtons();
//do not fully apply filter, just exclude new items
- std::for_each(gridDataView->getDataTentative().begin(), gridDataView->getDataTentative().end(),
- [&](BaseDirMapping& baseMap) { addHardFiltering(baseMap, newExclude); });
+ std::for_each(gridDataView->getDataTentative().begin(), gridDataView->getDataTentative().end(),
+ [&](BaseDirMapping& baseMap) { addHardFiltering(baseMap, newExclude); });
//applyFiltering(getConfig().mainCfg, gridDataView->getDataTentative());
updateGuiGrid();
@@ -2555,11 +2539,12 @@ bool MainDialog::saveOldConfig() //return false on user abort
&dontShowAgain))
{
case ReturnQuestionDlg::BUTTON_YES:
- if (!trySaveConfig())
- return false;
- break;
+ return trySaveConfig();
case ReturnQuestionDlg::BUTTON_NO:
globalSettings->optDialogs.popupOnConfigChange = !dontShowAgain;
+ //by choosing "no" user actively discards current config selection
+ //this ensures next app start will load <last session> instead of the original non-modified config selection
+ setLastUsedConfig(std::vector<wxString>(), getConfig());
break;
case ReturnQuestionDlg::BUTTON_CANCEL:
return false;
@@ -3258,7 +3243,6 @@ void MainDialog::updateStatistics()
void MainDialog::OnSwitchView(wxCommandEvent& event)
{
- //toggle view
syncPreview->enablePreview(!syncPreview->previewIsEnabled());
}
diff --git a/ui/main_dlg.h b/ui/main_dlg.h
index 47adf4a9..44d7ef62 100644
--- a/ui/main_dlg.h
+++ b/ui/main_dlg.h
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#ifndef MAINDIALOG_H
#define MAINDIALOG_H
@@ -254,27 +254,27 @@ private:
xmlAccess::XmlGlobalSettings* globalSettings; //always bound
//UI view of FolderComparison structure
- std::auto_ptr<zen::GridView> gridDataView;
+ std::unique_ptr<zen::GridView> gridDataView;
//-------------------------------------
//functional configuration
xmlAccess::XmlGuiConfig currentCfg;
//folder pairs:
- std::auto_ptr<DirectoryPairFirst> firstFolderPair; //always bound!!!
+ std::unique_ptr<DirectoryPairFirst> firstFolderPair; //always bound!!!
std::vector<DirectoryPair*> additionalFolderPairs; //additional pairs to the first pair
//-------------------------------------
//***********************************************
- std::auto_ptr<wxMenu> contextMenu;
+ std::unique_ptr<wxMenu> contextMenu;
//status information
wxLongLong lastStatusChange;
std::stack<wxString> stackObjects;
//compare status panel (hidden on start, shown when comparing)
- std::auto_ptr<CompareStatus> compareStatus; //always bound
+ std::unique_ptr<CompareStatus> compareStatus; //always bound
bool cleanedUp;
@@ -283,7 +283,7 @@ private:
const wxGrid* lastSortGrid;
//update icons periodically: one updater instance for both left and right grids
- std::auto_ptr<IconUpdater> updateFileIcons;
+ std::unique_ptr<IconUpdater> updateFileIcons;
bool processingGlobalKeyEvent; //indicator to notify recursion in OnGlobalKeyEvent()
@@ -304,7 +304,7 @@ private:
bool syncPreviewEnabled; //toggle to display configuration preview instead of comparison result
bool synchronizationEnabled; //determines whether synchronization should be allowed
};
- std::auto_ptr<SyncPreview> syncPreview; //always bound
+ std::unique_ptr<SyncPreview> syncPreview; //always bound
wxAuiManager auiMgr; //implement dockable GUI design
diff --git a/ui/msg_popup.cpp b/ui/msg_popup.cpp
index 7e35e19b..900ab683 100644
--- a/ui/msg_popup.cpp
+++ b/ui/msg_popup.cpp
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#include "msg_popup.h"
#include "../library/resources.h"
#include "../shared/mouse_move_dlg.h"
diff --git a/ui/msg_popup.h b/ui/msg_popup.h
index f6c2e5d2..b6e1a1a7 100644
--- a/ui/msg_popup.h
+++ b/ui/msg_popup.h
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#ifndef MESSAGEPOPUP_H_INCLUDED
#define MESSAGEPOPUP_H_INCLUDED
diff --git a/ui/progress_indicator.cpp b/ui/progress_indicator.cpp
index e244877a..3cf78fbb 100644
--- a/ui/progress_indicator.cpp
+++ b/ui/progress_indicator.cpp
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#include "progress_indicator.h"
#include <memory>
#include "gui_generated.h"
@@ -19,10 +19,7 @@
#include "../shared/mouse_move_dlg.h"
#include "../library/error_log.h"
#include "../shared/toggle_button.h"
-
-#ifdef FFS_WIN
#include "../shared/taskbar.h"
-#endif
using namespace zen;
@@ -97,9 +94,7 @@ private:
CurrentStatus status;
-#ifdef FFS_WIN
- std::auto_ptr<util::TaskbarProgress> taskbar_;
-#endif
+ std::unique_ptr<util::Taskbar> taskbar_;
//remaining time
std::auto_ptr<Statistics> statistics;
@@ -179,13 +174,11 @@ void CompareStatus::CompareStatusImpl::init()
{
titleTextBackup = parentWindow_.GetTitle();
-#ifdef FFS_WIN
- try //try to get access to Windows 7 Taskbar
+ try //try to get access to Windows 7/Ubuntu taskbar
{
- taskbar_.reset(new util::TaskbarProgress(parentWindow_));
+ taskbar_.reset(new util::Taskbar(parentWindow_));
}
catch (const util::TaskbarNotAvailable&) {}
-#endif
status = SCANNING;
@@ -223,10 +216,7 @@ void CompareStatus::CompareStatusImpl::init()
void CompareStatus::CompareStatusImpl::finalize() //hide again
{
-#ifdef FFS_WIN
taskbar_.reset();
-#endif
-
parentWindow_.SetTitle(titleTextBackup);
}
@@ -288,7 +278,6 @@ void CompareStatus::CompareStatusImpl::showProgressExternally(const wxString& pr
parentWindow_.SetTitle(progressText);
//show progress on Windows 7 taskbar
-#ifdef FFS_WIN
using namespace util;
if (taskbar_.get())
@@ -298,15 +287,14 @@ void CompareStatus::CompareStatusImpl::showProgressExternally(const wxString& pr
switch (status)
{
case SCANNING:
- taskbar_->setStatus(TaskbarProgress::STATUS_INDETERMINATE);
+ taskbar_->setStatus(Taskbar::STATUS_INDETERMINATE);
break;
case COMPARING_CONTENT:
- taskbar_->setStatus(TaskbarProgress::STATUS_NORMAL);
+ taskbar_->setStatus(Taskbar::STATUS_NORMAL);
taskbar_->setProgress(current, total);
break;
}
}
-#endif
}
@@ -489,7 +477,7 @@ public:
void incProgressIndicator_NoUpdate(int objectsProcessed, zen::Int64 dataProcessed);
void incScannedObjects_NoUpdate(int number);
void setStatusText_NoUpdate(const wxString& text);
- void updateStatusDialogNow();
+ void updateStatusDialogNow(bool allowYield = true);
void setCurrentStatus(SyncStatus::SyncStatusID id);
void processHasFinished(SyncStatus::SyncStatusID id, const ErrorLogging& log); //essential to call this in StatusUpdater derived class destructor at the LATEST(!) to prevent access to currentStatusUpdater
@@ -505,6 +493,8 @@ private:
virtual void OnIconize(wxIconizeEvent& event);
void resumeFromSystray();
+ void OnResumeFromTray(wxCommandEvent& event);
+
bool currentProcessIsRunning();
void showProgressExternally(const wxString& progressText, float percent = 0); //percent may already be included in progressText
@@ -528,9 +518,7 @@ private:
bool processPaused;
SyncStatus::SyncStatusID currentStatus;
-#ifdef FFS_WIN
- std::unique_ptr<util::TaskbarProgress> taskbar_;
-#endif
+ std::unique_ptr<util::Taskbar> taskbar_;
//remaining time
std::unique_ptr<Statistics> statistics;
@@ -539,11 +527,7 @@ private:
wxString titelTextBackup;
- //save last used systray icon description
- wxString progressTextLast;
- float progressPercentLast;
-
- std::shared_ptr<MinimizeToTray> minimizedToSysTray; //optional: if filled, hides all visible windows, shows again if destroyed
+ std::unique_ptr<FfsTrayIcon> trayIcon; //optional: if filled all other windows should be hidden and conversely
};
@@ -560,7 +544,7 @@ SyncStatus::SyncStatus(AbortCallback& abortCb,
else
{
pimpl->Show();
- pimpl->updateStatusDialogNow(); //update visual statistics to get rid of "dummy" texts
+ pimpl->updateStatusDialogNow(false); //update visual statistics to get rid of "dummy" texts
}
}
@@ -639,8 +623,7 @@ SyncStatus::SyncStatusImpl::SyncStatusImpl(AbortCallback& abortCb,
processPaused(false),
currentStatus(SyncStatus::ABORTED),
lastStatCallSpeed(-1000000), //some big number
- lastStatCallRemTime(-1000000),
- progressPercentLast(0)
+ lastStatCallRemTime(-1000000)
{
#ifdef FFS_WIN
new zen::MouseMoveWindow(*this); //allow moving main dialog by clicking (nearly) anywhere...; ownership passed to "this"
@@ -670,13 +653,11 @@ SyncStatus::SyncStatusImpl::SyncStatusImpl(AbortCallback& abortCb,
timeElapsed.Start(); //measure total time
-#ifdef FFS_WIN
- try //try to get access to Windows 7 Taskbar
+ try //try to get access to Windows 7/Ubuntu taskbar
{
- taskbar_.reset(new util::TaskbarProgress(mainDialog != NULL ? *static_cast<wxTopLevelWindow*>(mainDialog) : *this));
+ taskbar_.reset(new util::Taskbar(mainDialog != NULL ? *static_cast<wxTopLevelWindow*>(mainDialog) : *this));
}
catch (const util::TaskbarNotAvailable&) {}
-#endif
//hide "processed" statistics until end of process
bSizerObjectsProcessed->Show(false);
@@ -703,9 +684,6 @@ SyncStatus::SyncStatusImpl::~SyncStatusImpl()
mainDialog->Raise();
mainDialog->SetFocus();
}
-
- if (minimizedToSysTray.get())
- minimizedToSysTray->keepHidden(); //prevent window from flashing shortly before it is destroyed
}
@@ -782,13 +760,8 @@ void SyncStatus::SyncStatusImpl::setStatusText_NoUpdate(const wxString& text)
void SyncStatus::SyncStatusImpl::showProgressExternally(const wxString& progressText, float percent)
{
//write status information to systray, if window is minimized
- if (minimizedToSysTray.get())
- minimizedToSysTray->setToolTip(progressText, percent);
- //minimizedToSysTray may be a zombie... so set title text anyway
-
- //save progress text for later use (e.g. set systray icon tooltip in paused mode)
- progressTextLast = progressText;
- progressPercentLast = percent;
+ if (trayIcon.get())
+ trayIcon->setToolTip(progressText, percent);
wxString progressTextFmt = progressText;
progressTextFmt.Replace(wxT("\n"), wxT(" - "));
@@ -804,7 +777,7 @@ void SyncStatus::SyncStatusImpl::showProgressExternally(const wxString& progress
this->SetTitle(progressTextFmt);
}
-#ifdef FFS_WIN
+
using namespace util;
//show progress on Windows 7 taskbar
@@ -816,30 +789,29 @@ void SyncStatus::SyncStatusImpl::showProgressExternally(const wxString& progress
switch (currentStatus)
{
case SyncStatus::SCANNING:
- taskbar_->setStatus(TaskbarProgress::STATUS_INDETERMINATE);
+ taskbar_->setStatus(Taskbar::STATUS_INDETERMINATE);
break;
case SyncStatus::FINISHED_WITH_SUCCESS:
case SyncStatus::COMPARING_CONTENT:
case SyncStatus::SYNCHRONIZING:
- taskbar_->setStatus(TaskbarProgress::STATUS_NORMAL);
+ taskbar_->setStatus(Taskbar::STATUS_NORMAL);
taskbar_->setProgress(current, total);
break;
case SyncStatus::PAUSE:
- taskbar_->setStatus(TaskbarProgress::STATUS_PAUSED);
+ taskbar_->setStatus(Taskbar::STATUS_PAUSED);
taskbar_->setProgress(current, total);
break;
case SyncStatus::ABORTED:
case SyncStatus::FINISHED_WITH_ERROR:
- taskbar_->setStatus(TaskbarProgress::STATUS_ERROR);
+ taskbar_->setStatus(Taskbar::STATUS_ERROR);
taskbar_->setProgress(current, total);
break;
}
}
-#endif
}
-void SyncStatus::SyncStatusImpl::updateStatusDialogNow()
+void SyncStatus::SyncStatusImpl::updateStatusDialogNow(bool allowYield)
{
//static RetrieveStatistics statistic;
//statistic.writeEntry(currentData.ToDouble(), currentObjects);
@@ -940,27 +912,29 @@ void SyncStatus::SyncStatusImpl::updateStatusDialogNow()
}
}
-
- //support for pause button
- if(processPaused)
+ if (allowYield)
{
- if (statistics.get()) statistics->pauseTimer();
-
- while (processPaused && currentProcessIsRunning())
+ //support for pause button
+ if(processPaused)
{
- wxMilliSleep(UI_UPDATE_INTERVAL);
- updateUiNow();
+ if (statistics.get()) statistics->pauseTimer();
+
+ while (processPaused && currentProcessIsRunning())
+ {
+ wxMilliSleep(UI_UPDATE_INTERVAL);
+ updateUiNow();
+ }
+
+ if (statistics.get()) statistics->resumeTimer();
}
- if (statistics.get()) statistics->resumeTimer();
+ /*
+ /|\
+ | keep this order to ensure one full statistics update before entering pause mode
+ \|/
+ */
+ updateUiNow();
}
-
- /*
- /|\
- | keep this order to ensure one full statistics update before entering pause mode
- \|/
- */
- updateUiNow();
}
@@ -1057,7 +1031,7 @@ void SyncStatus::SyncStatusImpl::processHasFinished(SyncStatus::SyncStatusID id,
m_staticTextDataProcessed->SetLabel(zen::formatFilesizeToShortString(to<zen::UInt64>(currentData)));
}
- updateStatusDialogNow(); //keep this sequence to avoid display distortion, if e.g. only 1 item is sync'ed
+ updateStatusDialogNow(false); //keep this sequence to avoid display distortion, if e.g. only 1 item is sync'ed
//hide progress text control and show log control instead
m_textCtrlInfo->Hide();
@@ -1140,17 +1114,51 @@ void SyncStatus::SyncStatusImpl::OnIconize(wxIconizeEvent& event)
{
if (event.IsIconized()) //ATTENTION: iconize event is also triggered on "Restore"! (at least under Linux)
minimizeToTray();
+ else
+ resumeFromSystray(); //may be initiated by "show desktop" although all windows are hidden!
+}
+
+
+void SyncStatus::SyncStatusImpl::OnResumeFromTray(wxCommandEvent& event)
+{
+ resumeFromSystray();
}
void SyncStatus::SyncStatusImpl::minimizeToTray()
{
- minimizedToSysTray.reset(new MinimizeToTray(this, mainDialog));
- minimizedToSysTray->setToolTip(progressTextLast, progressPercentLast); //set tooltip: in pause mode there is no statistics update, so this is the only chance
+ if (!trayIcon.get())
+ {
+ trayIcon.reset(new FfsTrayIcon);
+ trayIcon->Connect(FFS_REQUEST_RESUME_TRAY_EVENT, wxCommandEventHandler(SyncStatus::SyncStatusImpl::OnResumeFromTray), NULL, this);
+ //tray icon has shorter lifetime than this => no need to disconnect event later
+ }
+
+ updateStatusDialogNow(false); //set tooltip: in pause mode there is no statistics update, so this is the only chance
+
+ Hide();
+ if (mainDialog)
+ mainDialog->Hide();
}
void SyncStatus::SyncStatusImpl::resumeFromSystray()
{
- minimizedToSysTray.reset();
+ trayIcon.reset();
+
+ if (mainDialog)
+ {
+ if (mainDialog->IsIconized()) //caveat: if window is maximized calling Iconize(false) will erroneously un-maximize!
+ mainDialog->Iconize(false);
+ mainDialog->Show();
+ mainDialog->Raise();
+ }
+
+ if (IsIconized()) //caveat: if window is maximized calling Iconize(false) will erroneously un-maximize!
+ Iconize(false);
+ Show();
+ Raise();
+ SetFocus();
+
+ updateStatusDialogNow(false); //restore Windows 7 task bar status (e.g. required in pause mode)
}
diff --git a/ui/progress_indicator.h b/ui/progress_indicator.h
index 9bb0eed0..71a975f6 100644
--- a/ui/progress_indicator.h
+++ b/ui/progress_indicator.h
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#ifndef PROGRESSINDICATOR_H_INCLUDED
#define PROGRESSINDICATOR_H_INCLUDED
diff --git a/ui/search.cpp b/ui/search.cpp
index 7fdaec03..d0b24299 100644
--- a/ui/search.cpp
+++ b/ui/search.cpp
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#include "search.h"
#include "gui_generated.h"
#include <wx/msgdlg.h>
diff --git a/ui/search.h b/ui/search.h
index ce7e479a..93c3159f 100644
--- a/ui/search.h
+++ b/ui/search.h
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#ifndef SEARCH_H_INCLUDED
#define SEARCH_H_INCLUDED
diff --git a/ui/small_dlgs.cpp b/ui/small_dlgs.cpp
index ed28a166..ee82bbcc 100644
--- a/ui/small_dlgs.cpp
+++ b/ui/small_dlgs.cpp
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#include "gui_generated.h"
#include "small_dlgs.h"
#include "msg_popup.h"
diff --git a/ui/small_dlgs.h b/ui/small_dlgs.h
index 31fd4548..93c90445 100644
--- a/ui/small_dlgs.h
+++ b/ui/small_dlgs.h
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#ifndef SMALLDIALOGS_H_INCLUDED
#define SMALLDIALOGS_H_INCLUDED
diff --git a/ui/sorting.h b/ui/sorting.h
index d2bafd1d..fa4e9973 100644
--- a/ui/sorting.h
+++ b/ui/sorting.h
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#ifndef SORTING_H_INCLUDED
#define SORTING_H_INCLUDED
diff --git a/ui/switch_to_gui.cpp b/ui/switch_to_gui.cpp
index 4bfdfd1f..7bd28c59 100644
--- a/ui/switch_to_gui.cpp
+++ b/ui/switch_to_gui.cpp
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#include "switch_to_gui.h"
#include "main_dlg.h"
diff --git a/ui/switch_to_gui.h b/ui/switch_to_gui.h
index 03e18324..cbbff20c 100644
--- a/ui/switch_to_gui.h
+++ b/ui/switch_to_gui.h
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#ifndef SWITCHTOGUI_H_INCLUDED
#define SWITCHTOGUI_H_INCLUDED
diff --git a/ui/sync_cfg.cpp b/ui/sync_cfg.cpp
index 59d4d689..5e78e97a 100644
--- a/ui/sync_cfg.cpp
+++ b/ui/sync_cfg.cpp
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#include "sync_cfg.h"
#include "../library/resources.h"
#include "../shared/dir_name.h"
diff --git a/ui/sync_cfg.h b/ui/sync_cfg.h
index bd52984b..7612d29b 100644
--- a/ui/sync_cfg.h
+++ b/ui/sync_cfg.h
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#ifndef SYNCCONFIG_H_INCLUDED
#define SYNCCONFIG_H_INCLUDED
diff --git a/ui/tray_icon.cpp b/ui/tray_icon.cpp
index 278f1888..90893c9f 100644
--- a/ui/tray_icon.cpp
+++ b/ui/tray_icon.cpp
@@ -3,7 +3,7 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#include "tray_icon.h"
#include "../library/resources.h"
#include "small_dlgs.h"
@@ -14,6 +14,10 @@
#include <wx/menu.h>
#include <wx/icon.h> //req. by Linux
+
+const wxEventType FFS_REQUEST_RESUME_TRAY_EVENT = wxNewEventType();
+
+
namespace
{
inline
@@ -22,7 +26,6 @@ int roundNum(double d) //little rounding function
return static_cast<int>(d < 0 ? d - .5 : d + .5);
}
-
void fillRange(wxImage& img, int pixelFirst, int pixelLast, const wxColor& col)
{
const int pixelCount = img.GetWidth() >= 0 ? img.GetWidth() * img.GetHeight() : -1;
@@ -147,15 +150,13 @@ enum Selection
};
-class MinimizeToTray::TaskBarImpl : public wxTaskBarIcon
+class FfsTrayIcon::TaskBarImpl : public wxTaskBarIcon
{
public:
- TaskBarImpl(MinimizeToTray* parent) : parent_(parent) {}
+ TaskBarImpl(FfsTrayIcon& parent) : parent_(&parent) {}
+
+ void parentHasDied() { parent_ = NULL; }
- void parentHasDied()
- {
- parent_ = NULL;
- }
private:
virtual wxMenu* CreatePopupMenu()
{
@@ -167,96 +168,67 @@ private:
contextMenu->AppendSeparator();
contextMenu->Append(CONTEXT_RESTORE, _("&Restore"));
//event handling
- contextMenu->Connect(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MinimizeToTray::OnContextMenuSelection), NULL, parent_);
+ contextMenu->Connect(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(FfsTrayIcon::OnContextMenuSelection), NULL, parent_);
return contextMenu; //ownership transferred to caller
}
- MinimizeToTray* parent_;
+ FfsTrayIcon* parent_;
};
-MinimizeToTray::MinimizeToTray(wxTopLevelWindow* callerWnd, wxTopLevelWindow* secondWnd) :
- callerWnd_(callerWnd),
- secondWnd_(secondWnd),
- trayIcon(new TaskBarImpl(this))
+FfsTrayIcon::FfsTrayIcon() :
+ trayIcon(new TaskBarImpl(*this))
{
trayIcon->SetIcon(generateIcon(0), wxT("FreeFileSync"));
- trayIcon->Connect(wxEVT_TASKBAR_LEFT_DCLICK, wxCommandEventHandler(MinimizeToTray::OnDoubleClick), NULL, this); //register double-click
-
- if (callerWnd_)
- callerWnd_->Hide();
- if (secondWnd_)
- secondWnd_->Hide();
+ trayIcon->Connect(wxEVT_TASKBAR_LEFT_DCLICK, wxCommandEventHandler(FfsTrayIcon::OnDoubleClick), NULL, this); //register double-click
}
-MinimizeToTray::~MinimizeToTray()
+FfsTrayIcon::~FfsTrayIcon()
{
- resumeFromTray();
-}
+ trayIcon->RemoveIcon(); //hide icon until final deletion takes place
+ trayIcon->Disconnect(wxEVT_TASKBAR_LEFT_DCLICK, wxCommandEventHandler(FfsTrayIcon::OnDoubleClick), NULL, this);
+ trayIcon->parentHasDied(); //TaskBarImpl (potentially) has longer lifetime than FfsTrayIcon: avoid callback!
-
-void MinimizeToTray::resumeFromTray() //remove trayIcon and restore windows: MinimizeToTray is now a zombie object...
-{
- if (trayIcon)
- {
- if (secondWnd_)
- {
- secondWnd_->Iconize(false);
- secondWnd_->Show();
- }
-
- if (callerWnd_) //usecase: avoid dialog flashing in batch silent mode
- {
- callerWnd_->Iconize(false);
- callerWnd_->Show();
- callerWnd_->Raise();
- callerWnd_->SetFocus();
- }
- trayIcon->RemoveIcon(); //hide icon until final deletion takes place
- trayIcon->Disconnect(wxEVT_TASKBAR_LEFT_DCLICK, wxCommandEventHandler(MinimizeToTray::OnDoubleClick), NULL, this);
- trayIcon->parentHasDied(); //TaskBarImpl (potentially) has longer lifetime than MinimizeToTray: avoid callback!
-
- //use wxWidgets delayed destruction: delete during next idle loop iteration (handle late window messages, e.g. when double-clicking)
- if (!wxPendingDelete.Member(trayIcon))
- wxPendingDelete.Append(trayIcon);
-
- trayIcon = NULL; //avoid reentrance
- }
-}
-
-
-void MinimizeToTray::setToolTip(const wxString& toolTipText, double percent)
-{
- if (trayIcon)
- trayIcon->SetIcon(generateIcon(percent), toolTipText);
+ //use wxWidgets delayed destruction: delete during next idle loop iteration (handle late window messages, e.g. when double-clicking)
+ if (!wxPendingDelete.Member(trayIcon))
+ wxPendingDelete.Append(trayIcon);
}
-void MinimizeToTray::keepHidden()
+void FfsTrayIcon::setToolTip(const wxString& toolTipText, double percent)
{
- callerWnd_ = NULL;
- secondWnd_ = NULL;
+ trayIcon->SetIcon(generateIcon(percent), toolTipText);
}
-void MinimizeToTray::OnContextMenuSelection(wxCommandEvent& event)
+void FfsTrayIcon::OnContextMenuSelection(wxCommandEvent& event)
{
const Selection eventId = static_cast<Selection>(event.GetId());
switch (eventId)
{
case CONTEXT_ABOUT:
+ {
+ //ATTENTION: the modal dialog below does NOT disable all GUI input, e.g. user may still double-click on tray icon
+ //which will implicitly destroy the tray icon while still showing the modal dialog
+ trayIcon->SetEvtHandlerEnabled(false);
zen::showAboutDialog();
- break;
+ trayIcon->SetEvtHandlerEnabled(true);
+ }
+ break;
case CONTEXT_RESTORE:
- resumeFromTray();
+ {
+ wxCommandEvent dummy(FFS_REQUEST_RESUME_TRAY_EVENT);
+ ProcessEvent(dummy);
+ }
}
}
-void MinimizeToTray::OnDoubleClick(wxCommandEvent& event)
+void FfsTrayIcon::OnDoubleClick(wxCommandEvent& event)
{
- resumeFromTray();
+ wxCommandEvent dummy(FFS_REQUEST_RESUME_TRAY_EVENT);
+ ProcessEvent(dummy);
}
diff --git a/ui/tray_icon.h b/ui/tray_icon.h
index 8b5b5851..a615c091 100644
--- a/ui/tray_icon.h
+++ b/ui/tray_icon.h
@@ -3,30 +3,31 @@
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
-//
+
#ifndef TRAYICON_H_INCLUDED
#define TRAYICON_H_INCLUDED
#include <wx/event.h>
-#include <wx/toplevel.h>
+//show tray icon with progress during lifetime of this instance
+//emits the following wxCommandEvent in case user double-clicks on tray icon or selects corresponding context menu item:
+extern const wxEventType FFS_REQUEST_RESUME_TRAY_EVENT;
-class MinimizeToTray : private wxEvtHandler
+class FfsTrayIcon : public wxEvtHandler
{
public:
- MinimizeToTray(wxTopLevelWindow* callerWnd, wxTopLevelWindow* secondWnd = NULL); //ensure both windows have longer lifetime than this instance!
- ~MinimizeToTray(); //show windows again
+ FfsTrayIcon();
+ ~FfsTrayIcon();
void setToolTip(const wxString& toolTipText, double percent = 0); //percent (optional), number between [0, 100], for small progress indicator
- void keepHidden(); //do not show windows again: avoid window flashing shortly before it is destroyed
private:
+ FfsTrayIcon(const FfsTrayIcon&);
+ FfsTrayIcon& operator=(const FfsTrayIcon&);
+
void OnContextMenuSelection(wxCommandEvent& event);
void OnDoubleClick(wxCommandEvent& event);
- void resumeFromTray();
- wxTopLevelWindow* callerWnd_;
- wxTopLevelWindow* secondWnd_;
class TaskBarImpl;
TaskBarImpl* trayIcon; //actual tray icon (don't use inheritance to enable delayed deletion)
};
bgstack15