diff --git a/src/ccInstHelper.cpp b/src/ccInstHelper.cpp --- a/src/ccInstHelper.cpp +++ b/src/ccInstHelper.cpp @@ -9,11 +9,9 @@ //#define __stdcall -#ifndef KREPLACEMENTS_H // For compilation download the NSIS source package and modify the following // line to point to the exdll.h-file #include "C:/Programme/NSIS/Contrib/ExDll/exdll.h" -#endif struct ReplacementItem { const char* fileType; @@ -285,8 +283,6 @@ return 0; } -#ifndef KREPLACEMENTS_H - extern "C" void __declspec(dllexport) nsisPlugin(HWND hwndParent, int string_size, char* variables, stack_t** stacktop, extra_parameters* extra) @@ -309,7 +305,6 @@ } } -#endif /* int _tmain(int argc, _TCHAR* argv[]) { diff --git a/src/kreplacements/README b/src/kreplacements/README deleted file mode 100644 --- a/src/kreplacements/README +++ /dev/null @@ -1,30 +0,0 @@ -About the "kreplacements"-directory: -==================================== - -I want to be able to compile and use KDiff3 without KDE too. -Since KDiff3 is a KDE program, which uses many KDE-classes and -functions there must be some replacement. - -In many cases this is just the corresponding Qt-class, but often -I wrote something myself. For several very KDE-specific functions -there is no real replacement, but only stub functions that allow -the program to compile and link. - -This stuff is not intended to be used for anything else but KDiff3. -Think of it rather as a big hack, that only has the advantage -that I need not mess up the normal program with many ugly -#ifdef/#endif-clauses. - -Most include files in this directory only include kreplacements.h -where the actual declarations are. The implementions are in -kreplacements.cpp. - -The *.moc-files are dummies. The new KDE-philosophy seems to be -that *.moc-files are directly included into the sources. -The Qt-philosophy still is to generate moc*.cpp files which will -be compiled seperately. With these dummy-moc-files both versions -can be compiled. - - -Joachim -(2003-10-02) diff --git a/src/kreplacements/ShellContextMenu.h b/src/kreplacements/ShellContextMenu.h deleted file mode 100644 --- a/src/kreplacements/ShellContextMenu.h +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************** - ShellContextMenu.h - description - ------------------- - begin : Sat Mar 4 2006 - copyright : (C) 2005-2007 by Joachim Eibl - email : joachim dot eibl at gmx dot de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -// ShellContextMenu.h: Schnittstelle fr die Klasse CShellContextMenu. -// -////////////////////////////////////////////////////////////////////// - -#ifndef SHELLCONTEXTMENU_H -#define SHELLCONTEXTMENU_H - -///////////////////////////////////////////////////////////////////// -// class to show shell contextmenu of files/folders/shell objects -// developed by R. Engels 2003 -///////////////////////////////////////////////////////////////////// - -class CShellContextMenu -{ -public: - HMENU GetMenu (); - void SetObjects (IShellFolder * psfFolder, LPITEMIDLIST pidlItem); - void SetObjects (IShellFolder * psfFolder, LPITEMIDLIST * pidlArray, int nItemCount); - void SetObjects (LPITEMIDLIST pidl); - void SetObjects (const QString& strObject); - void SetObjects (const QStringList& strList); - UINT ShowContextMenu (QWidget* pParent, QPoint pt, QMenu* pMenu); - CShellContextMenu(); - virtual ~CShellContextMenu(); - -private: - int nItems; - BOOL bDelete; - HMENU m_hMenu; - IShellFolder * m_psfFolder; - LPITEMIDLIST * m_pidlArray; - - void InvokeCommand (LPCONTEXTMENU pContextMenu, UINT idCommand); - BOOL GetContextMenu (void ** ppContextMenu, int & iMenuType); - HRESULT SHBindToParentEx (LPCITEMIDLIST pidl, REFIID riid, VOID **ppv, LPCITEMIDLIST *ppidlLast); - static LRESULT CALLBACK HookWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); - void FreePIDLArray (LPITEMIDLIST * pidlArray); - LPITEMIDLIST CopyPIDL (LPCITEMIDLIST pidl, int cb = -1); - UINT GetPIDLSize (LPCITEMIDLIST pidl); - LPBYTE GetPIDLPos (LPCITEMIDLIST pidl, int nPos); - int GetPIDLCount (LPCITEMIDLIST pidl); -}; - -#endif diff --git a/src/kreplacements/ShellContextMenu.cpp b/src/kreplacements/ShellContextMenu.cpp deleted file mode 100644 --- a/src/kreplacements/ShellContextMenu.cpp +++ /dev/null @@ -1,505 +0,0 @@ -/*************************************************************************** - ShellContextMenu.cpp - description - ------------------- - begin : Sat Mar 4 2006 - copyright : (C) 2005-2007 by Joachim Eibl - email : joachim dot eibl at gmx dot de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -// ShellContextMenu.cpp: Implementierung der Klasse CShellContextMenu. -// http://www.codeproject.com/Articles/4025/Use-Shell-ContextMenu-in-your-applications -// -////////////////////////////////////////////////////////////////////// -#ifdef Q_OS_WIN -#include - -#include - -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8 ) /* Test for GCC > 4.8.0 */ -#define INITGUID // needed for MinGW 4.8 otherwise IID_IContextMenu etc. produce undefined references during linking. -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ShellContextMenu.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char THIS_FILE[]=__FILE__; -#define new DEBUG_NEW -#endif - -////////////////////////////////////////////////////////////////////// -// Konstruktion/Destruktion -////////////////////////////////////////////////////////////////////// - -#define MIN_ID 100 -#define MAX_ID 10000 - - -void showShellContextMenu( const QString& itemPath, QPoint pt, QWidget* pParentWidget, QMenu* pMenu ) -{ - CShellContextMenu scm; - scm.SetObjects(QDir::toNativeSeparators(QDir::cleanPath(itemPath))); - int id = scm.ShowContextMenu (pParentWidget, pt, pMenu); - if (id>=1) - pMenu->actions().value(id-1)->trigger(); -} - -IContextMenu2 * g_IContext2 = NULL; -IContextMenu3 * g_IContext3 = NULL; -static WNDPROC OldWndProc = 0; - -CShellContextMenu::CShellContextMenu() -{ - m_psfFolder = NULL; - m_pidlArray = NULL; - m_hMenu = NULL; -} - -CShellContextMenu::~CShellContextMenu() -{ - // free all allocated datas - if (m_psfFolder && bDelete) - m_psfFolder->Release (); - m_psfFolder = NULL; - FreePIDLArray (m_pidlArray); - m_pidlArray = NULL; - - if (m_hMenu) - DestroyMenu( m_hMenu ); -} - - - -// this functions determines which version of IContextMenu is avaibale for those objects (always the highest one) -// and returns that interface -BOOL CShellContextMenu::GetContextMenu (void ** ppContextMenu, int & iMenuType) -{ - *ppContextMenu = NULL; - LPCONTEXTMENU icm1 = NULL; - - if ( m_psfFolder==0 ) - return FALSE; - - // first we retrieve the normal IContextMenu interface (every object should have it) - m_psfFolder->GetUIObjectOf (NULL, nItems, (LPCITEMIDLIST *) m_pidlArray, IID_IContextMenu, NULL, (void**) &icm1); - - if (icm1) - { // since we got an IContextMenu interface we can now obtain the higher version interfaces via that - if (icm1->QueryInterface (IID_IContextMenu3, ppContextMenu) == NOERROR) - iMenuType = 3; - else if (icm1->QueryInterface (IID_IContextMenu2, ppContextMenu) == NOERROR) - iMenuType = 2; - - if (*ppContextMenu) - icm1->Release(); // we can now release version 1 interface, cause we got a higher one - else - { - iMenuType = 1; - *ppContextMenu = icm1; // since no higher versions were found - } // redirect ppContextMenu to version 1 interface - } - else - return (FALSE); // something went wrong - - return (TRUE); // success -} - - -LRESULT CALLBACK CShellContextMenu::HookWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_MENUCHAR: // only supported by IContextMenu3 - if (g_IContext3) - { - LRESULT lResult = 0; - g_IContext3->HandleMenuMsg2 (message, wParam, lParam, &lResult); - return (lResult); - } - break; - - case WM_DRAWITEM: - case WM_MEASUREITEM: - if (wParam) - break; // if wParam != 0 then the message is not menu-related - - case WM_INITMENUPOPUP: - if (g_IContext2) - g_IContext2->HandleMenuMsg (message, wParam, lParam); - else // version 3 - g_IContext3->HandleMenuMsg (message, wParam, lParam); - return (message == WM_INITMENUPOPUP ? 0 : TRUE); // inform caller that we handled WM_INITPOPUPMENU by ourself - break; - - default: - break; - } - - // call original WndProc of window to prevent undefined bevhaviour of window - return ::CallWindowProc (OldWndProc, hWnd, message, wParam, lParam); -} - -UINT CShellContextMenu::ShowContextMenu(QWidget * pParentWidget, QPoint pt, QMenu* pMenu ) -{ - HWND hWnd = (HWND)pParentWidget->winId(); - int iMenuType = 0; // to know which version of IContextMenu is supported - LPCONTEXTMENU pContextMenu; // common pointer to IContextMenu and higher version interface - - if (!GetContextMenu ((void**) &pContextMenu, iMenuType)) - return (0); // something went wrong - - if (!m_hMenu) - { - DestroyMenu( m_hMenu ); - m_hMenu = CreatePopupMenu (); - } - - int i; - QList actionList = pMenu->actions(); - for( i=0; itext(); - if (!s.isEmpty()) - AppendMenuW( m_hMenu, MF_STRING, i+1, (LPCWSTR)s.utf16() ); - } - AppendMenuW( m_hMenu, MF_SEPARATOR, i+1, L"" ); - - // lets fill the our popupmenu - pContextMenu->QueryContextMenu (m_hMenu, GetMenuItemCount (m_hMenu), MIN_ID, MAX_ID, CMF_NORMAL | CMF_EXPLORE); - - // subclass window to handle menurelated messages in CShellContextMenu - - if (iMenuType > 1) // only subclass if its version 2 or 3 - { - OldWndProc = (WNDPROC) SetWindowLongPtr (hWnd, GWLP_WNDPROC, (LONG_PTR) HookWndProc); - if (iMenuType == 2) - g_IContext2 = (LPCONTEXTMENU2) pContextMenu; - else // version 3 - g_IContext3 = (LPCONTEXTMENU3) pContextMenu; - } - else - OldWndProc = NULL; - - UINT idCommand = TrackPopupMenu (m_hMenu,TPM_RETURNCMD | TPM_LEFTALIGN, pt.x(), pt.y(), 0, (HWND)pParentWidget->winId(), 0); - - if (OldWndProc) // unsubclass - SetWindowLongPtr (hWnd, GWLP_WNDPROC, (LONG_PTR) OldWndProc); - - if (idCommand >= MIN_ID && idCommand <= MAX_ID) // see if returned idCommand belongs to shell menu entries - { - InvokeCommand (pContextMenu, idCommand - MIN_ID); // execute related command - idCommand = 0; - } - - pContextMenu->Release(); - g_IContext2 = NULL; - g_IContext3 = NULL; - - return (idCommand); -} - - -void CShellContextMenu::InvokeCommand (LPCONTEXTMENU pContextMenu, UINT idCommand) -{ - CMINVOKECOMMANDINFO cmi = {0}; - cmi.cbSize = sizeof (CMINVOKECOMMANDINFO); - cmi.lpVerb = (LPSTR) MAKEINTRESOURCE (idCommand); - cmi.nShow = SW_SHOWNORMAL; - - pContextMenu->InvokeCommand (&cmi); -} - - -void CShellContextMenu::SetObjects(const QString& strObject) -{ - // only one object is passed - QStringList strArray; - strArray << strObject; // create a CStringArray with one element - - SetObjects (strArray); // and pass it to SetObjects (CStringArray &strArray) - // for further processing -} - - -void CShellContextMenu::SetObjects(const QStringList &strList) -{ - // free all allocated datas - if (m_psfFolder && bDelete) - m_psfFolder->Release (); - m_psfFolder = NULL; - FreePIDLArray (m_pidlArray); - m_pidlArray = NULL; - - // get IShellFolder interface of Desktop (root of shell namespace) - IShellFolder * psfDesktop = NULL; - SHGetDesktopFolder (&psfDesktop); // needed to obtain full qualified pidl - - // ParseDisplayName creates a PIDL from a file system path relative to the IShellFolder interface - // but since we use the Desktop as our interface and the Desktop is the namespace root - // that means that it's a fully qualified PIDL, which is what we need - LPITEMIDLIST pidl = NULL; - - psfDesktop->ParseDisplayName (NULL, 0, (LPOLESTR)strList[0].utf16(), NULL, &pidl, NULL); - - // now we need the parent IShellFolder interface of pidl, and the relative PIDL to that interface - LPITEMIDLIST pidlItem = NULL; // relative pidl - SHBindToParentEx (pidl, IID_IShellFolder, (void **) &m_psfFolder, NULL); - free (pidlItem); - // get interface to IMalloc (need to free the PIDLs allocated by the shell functions) - LPMALLOC lpMalloc = NULL; - SHGetMalloc (&lpMalloc); - lpMalloc->Free (pidl); - - // now we have the IShellFolder interface to the parent folder specified in the first element in strArray - // since we assume that all objects are in the same folder (as it's stated in the MSDN) - // we now have the IShellFolder interface to every objects parent folder - - IShellFolder * psfFolder = NULL; - nItems = strList.size (); - for (int i = 0; i < nItems; i++) - { - pidl=0; - psfDesktop->ParseDisplayName (NULL, 0, (LPOLESTR)strList[i].utf16(), NULL, &pidl, NULL); - if (pidl) - { - m_pidlArray = (LPITEMIDLIST *) realloc (m_pidlArray, (i + 1) * sizeof (LPITEMIDLIST)); - // get relative pidl via SHBindToParent - SHBindToParentEx (pidl, IID_IShellFolder, (void **) &psfFolder, (LPCITEMIDLIST *) &pidlItem); - m_pidlArray[i] = CopyPIDL (pidlItem); // copy relative pidl to pidlArray - free (pidlItem); - lpMalloc->Free (pidl); // free pidl allocated by ParseDisplayName - psfFolder->Release (); - } - } - lpMalloc->Release (); - psfDesktop->Release (); - - bDelete = TRUE; // indicates that m_psfFolder should be deleted by CShellContextMenu -} - - -// only one full qualified PIDL has been passed -void CShellContextMenu::SetObjects(LPITEMIDLIST /*pidl*/) -{ -/* - // free all allocated datas - if (m_psfFolder && bDelete) - m_psfFolder->Release (); - m_psfFolder = NULL; - FreePIDLArray (m_pidlArray); - m_pidlArray = NULL; - - // full qualified PIDL is passed so we need - // its parent IShellFolder interface and its relative PIDL to that - LPITEMIDLIST pidlItem = NULL; - SHBindToParent ((LPCITEMIDLIST) pidl, IID_IShellFolder, (void **) &m_psfFolder, (LPCITEMIDLIST *) &pidlItem); - - m_pidlArray = (LPITEMIDLIST *) malloc (sizeof (LPITEMIDLIST)); // allocate ony for one elemnt - m_pidlArray[0] = CopyPIDL (pidlItem); - - - // now free pidlItem via IMalloc interface (but not m_psfFolder, that we need later - LPMALLOC lpMalloc = NULL; - SHGetMalloc (&lpMalloc); - lpMalloc->Free (pidlItem); - lpMalloc->Release(); - - nItems = 1; - bDelete = TRUE; // indicates that m_psfFolder should be deleted by CShellContextMenu -*/ -} - - -// IShellFolder interface with a relative pidl has been passed -void CShellContextMenu::SetObjects(IShellFolder *psfFolder, LPITEMIDLIST pidlItem) -{ - // free all allocated datas - if (m_psfFolder && bDelete) - m_psfFolder->Release (); - m_psfFolder = NULL; - FreePIDLArray (m_pidlArray); - m_pidlArray = NULL; - - m_psfFolder = psfFolder; - - m_pidlArray = (LPITEMIDLIST *) malloc (sizeof (LPITEMIDLIST)); - m_pidlArray[0] = CopyPIDL (pidlItem); - - nItems = 1; - bDelete = FALSE; // indicates wheter m_psfFolder should be deleted by CShellContextMenu -} - -void CShellContextMenu::SetObjects(IShellFolder * psfFolder, LPITEMIDLIST *pidlArray, int nItemCount) -{ - // free all allocated datas - if (m_psfFolder && bDelete) - m_psfFolder->Release (); - m_psfFolder = NULL; - FreePIDLArray (m_pidlArray); - m_pidlArray = NULL; - - m_psfFolder = psfFolder; - - m_pidlArray = (LPITEMIDLIST *) malloc (nItemCount * sizeof (LPITEMIDLIST)); - - for (int i = 0; i < nItemCount; i++) - m_pidlArray[i] = CopyPIDL (pidlArray[i]); - - nItems = nItemCount; - bDelete = FALSE; // indicates wheter m_psfFolder should be deleted by CShellContextMenu -} - - -void CShellContextMenu::FreePIDLArray(LPITEMIDLIST *pidlArray) -{ - if (!pidlArray) - return; - - int iSize = _msize (pidlArray) / sizeof (LPITEMIDLIST); - - for (int i = 0; i < iSize; i++) - free (pidlArray[i]); - free (pidlArray); -} - - -LPITEMIDLIST CShellContextMenu::CopyPIDL (LPCITEMIDLIST pidl, int cb) -{ - if (cb == -1) - cb = GetPIDLSize (pidl); // Calculate size of list. - - LPITEMIDLIST pidlRet = (LPITEMIDLIST) calloc (cb + sizeof (USHORT), sizeof (BYTE)); - if (pidlRet) - CopyMemory(pidlRet, pidl, cb); - - return (pidlRet); -} - - -UINT CShellContextMenu::GetPIDLSize (LPCITEMIDLIST pidl) -{ - if (!pidl) - return 0; - int nSize = 0; - LPITEMIDLIST pidlTemp = (LPITEMIDLIST) pidl; - while (pidlTemp->mkid.cb) - { - nSize += pidlTemp->mkid.cb; - pidlTemp = (LPITEMIDLIST) (((LPBYTE) pidlTemp) + pidlTemp->mkid.cb); - } - return nSize; -} - -HMENU CShellContextMenu::GetMenu() -{ - if (!m_hMenu) - { - m_hMenu = CreatePopupMenu(); // create the popupmenu (its empty) - } - return (m_hMenu); -} - - -// this is workaround function for the Shell API Function SHBindToParent -// SHBindToParent is not available under Win95/98 -HRESULT CShellContextMenu::SHBindToParentEx (LPCITEMIDLIST pidl, REFIID riid, VOID **ppv, LPCITEMIDLIST *ppidlLast) -{ - HRESULT hr = 0; - if (!pidl || !ppv) - return E_POINTER; - - int nCount = GetPIDLCount (pidl); - if (nCount == 0) // desktop pidl of invalid pidl - return E_POINTER; - - IShellFolder * psfDesktop = NULL; - SHGetDesktopFolder (&psfDesktop); - if (nCount == 1) // desktop pidl - { - if ((hr = psfDesktop->QueryInterface(riid, ppv)) == S_OK) - { - if (ppidlLast) - *ppidlLast = CopyPIDL (pidl); - } - psfDesktop->Release (); - return hr; - } - - LPBYTE pRel = GetPIDLPos (pidl, nCount - 1); - LPITEMIDLIST pidlParent = NULL; - pidlParent = CopyPIDL (pidl, pRel - (LPBYTE) pidl); - IShellFolder * psfFolder = NULL; - - if ((hr = psfDesktop->BindToObject (pidlParent, NULL, IID_IShellFolder, (void **) &psfFolder)) != S_OK) - { - free (pidlParent); - psfDesktop->Release (); - return hr; - } - if ((hr = psfFolder->QueryInterface (riid, ppv)) == S_OK) - { - if (ppidlLast) - *ppidlLast = CopyPIDL ((LPCITEMIDLIST) pRel); - } - free (pidlParent); - psfFolder->Release (); - psfDesktop->Release (); - return hr; -} - - -LPBYTE CShellContextMenu::GetPIDLPos (LPCITEMIDLIST pidl, int nPos) -{ - if (!pidl) - return 0; - int nCount = 0; - - BYTE * pCur = (BYTE *) pidl; - while (((LPCITEMIDLIST) pCur)->mkid.cb) - { - if (nCount == nPos) - return pCur; - nCount++; - pCur += ((LPCITEMIDLIST) pCur)->mkid.cb; // + sizeof(pidl->mkid.cb); - } - if (nCount == nPos) - return pCur; - return NULL; -} - - -int CShellContextMenu::GetPIDLCount (LPCITEMIDLIST pidl) -{ - if (!pidl) - return 0; - - int nCount = 0; - BYTE* pCur = (BYTE *) pidl; - while (((LPCITEMIDLIST) pCur)->mkid.cb) - { - nCount++; - pCur += ((LPCITEMIDLIST) pCur)->mkid.cb; - } - return nCount; -} - -#endif - diff --git a/src/kreplacements/config-kdiff3.h b/src/kreplacements/config-kdiff3.h deleted file mode 100644 --- a/src/kreplacements/config-kdiff3.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kaboutdata.h b/src/kreplacements/kaboutdata.h deleted file mode 100644 --- a/src/kreplacements/kaboutdata.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kaccel.h b/src/kreplacements/kaccel.h deleted file mode 100644 --- a/src/kreplacements/kaccel.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kaction.h b/src/kreplacements/kaction.h deleted file mode 100644 --- a/src/kreplacements/kaction.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kactioncollection.h b/src/kreplacements/kactioncollection.h deleted file mode 100644 --- a/src/kreplacements/kactioncollection.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kapplication.h b/src/kreplacements/kapplication.h deleted file mode 100644 --- a/src/kreplacements/kapplication.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kcmdlineargs.h b/src/kreplacements/kcmdlineargs.h deleted file mode 100644 --- a/src/kreplacements/kcmdlineargs.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kcolorbutton.h b/src/kreplacements/kcolorbutton.h deleted file mode 100644 --- a/src/kreplacements/kcolorbutton.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kcomponentdata.h b/src/kreplacements/kcomponentdata.h deleted file mode 100644 --- a/src/kreplacements/kcomponentdata.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kconfig.h b/src/kreplacements/kconfig.h deleted file mode 100644 --- a/src/kreplacements/kconfig.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kdialogbase.h b/src/kreplacements/kdialogbase.h deleted file mode 100644 --- a/src/kreplacements/kdialogbase.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kedittoolbar.h b/src/kreplacements/kedittoolbar.h deleted file mode 100644 --- a/src/kreplacements/kedittoolbar.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kfiledialog.h b/src/kreplacements/kfiledialog.h deleted file mode 100644 --- a/src/kreplacements/kfiledialog.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kfontdialog.h b/src/kreplacements/kfontdialog.h deleted file mode 100644 --- a/src/kreplacements/kfontdialog.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kglobal.h b/src/kreplacements/kglobal.h deleted file mode 100644 --- a/src/kreplacements/kglobal.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kiconloader.h b/src/kreplacements/kiconloader.h deleted file mode 100644 --- a/src/kreplacements/kiconloader.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kinstance.h b/src/kreplacements/kinstance.h deleted file mode 100644 --- a/src/kreplacements/kinstance.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kio/copyjob.h b/src/kreplacements/kio/copyjob.h deleted file mode 100644 --- a/src/kreplacements/kio/copyjob.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kio/global.h b/src/kreplacements/kio/global.h deleted file mode 100644 --- a/src/kreplacements/kio/global.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kio/job.h b/src/kreplacements/kio/job.h deleted file mode 100644 --- a/src/kreplacements/kio/job.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kio/jobclasses.h b/src/kreplacements/kio/jobclasses.h deleted file mode 100644 --- a/src/kreplacements/kio/jobclasses.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kio/jobuidelegate.h b/src/kreplacements/kio/jobuidelegate.h deleted file mode 100644 --- a/src/kreplacements/kio/jobuidelegate.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/klibloader.h b/src/kreplacements/klibloader.h deleted file mode 100644 --- a/src/kreplacements/klibloader.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/klocale.h b/src/kreplacements/klocale.h deleted file mode 100644 --- a/src/kreplacements/klocale.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kmainwindow.h b/src/kreplacements/kmainwindow.h deleted file mode 100644 --- a/src/kreplacements/kmainwindow.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kmenu.h b/src/kreplacements/kmenu.h deleted file mode 100644 --- a/src/kreplacements/kmenu.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kmenubar.h b/src/kreplacements/kmenubar.h deleted file mode 100644 --- a/src/kreplacements/kmenubar.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kmessagebox.h b/src/kreplacements/kmessagebox.h deleted file mode 100644 --- a/src/kreplacements/kmessagebox.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/konq_popupmenu.h b/src/kreplacements/konq_popupmenu.h deleted file mode 100644 --- a/src/kreplacements/konq_popupmenu.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kpagedialog.h b/src/kreplacements/kpagedialog.h deleted file mode 100644 --- a/src/kreplacements/kpagedialog.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kparts/factory.h b/src/kreplacements/kparts/factory.h deleted file mode 100644 --- a/src/kreplacements/kparts/factory.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kparts/mainwindow.h b/src/kreplacements/kparts/mainwindow.h deleted file mode 100644 --- a/src/kreplacements/kparts/mainwindow.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kparts/part.h b/src/kreplacements/kparts/part.h deleted file mode 100644 --- a/src/kreplacements/kparts/part.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kprinter.h b/src/kreplacements/kprinter.h deleted file mode 100644 --- a/src/kreplacements/kprinter.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kprogress.h b/src/kreplacements/kprogress.h deleted file mode 100644 --- a/src/kreplacements/kprogress.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kprogressdialog.h b/src/kreplacements/kprogressdialog.h deleted file mode 100644 --- a/src/kreplacements/kprogressdialog.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kreplacements.h b/src/kreplacements/kreplacements.h deleted file mode 100644 --- a/src/kreplacements/kreplacements.h +++ /dev/null @@ -1,617 +0,0 @@ -/*************************************************************************** - kreplacements.h - description - ------------------- - begin : Sat Aug 3 2002 - copyright : (C) 2002-2006 by Joachim Eibl - email : joachim.eibl at gmx.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef KREPLACEMENTS_H -#define KREPLACEMENTS_H -#ifndef __OS2__ -#pragma once -#endif - -#include "common.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//Added by qt3to4: -#include -#include -#include -#include - -class QTabWidget; -class QLabel; - -#include -#include - -QString getTranslationDir(const QString&); - -class KMainWindow; -class KAction; -class KIcon; - -typedef QString KGuiItem; - -inline QString i18n( const char* x ){ return QObject::tr(x); } - -template -inline QString i18n (const char *text, const A1 &a1) -{ return QObject::tr(text).arg(a1); } - -template -inline QString i18n (const char *text, const A1 &a1, const A2 &a2) -{ return QObject::tr(text).arg(a1).arg(a2); } - -template -inline QString i18n (const char *text, const A1 &a1, const A2 &a2, const A3 &a3) -{ return QObject::tr(text).arg(a1).arg(a2).arg(a3); } - -template -inline QString i18n (const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) -{ return QObject::tr(text).arg(a1).arg(a2).arg(a3).arg(a4); } - - -typedef QString KLocalizedString; -#define ki18n(x) QObject::tr(x) -#define I18N_NOOP(x) x -#define RESTORE(x) -#define _UNLOAD(x) - -class KUrl -{ -public: - KUrl(){} - KUrl(const QString& s){ m_s = s; } - static KUrl fromPathOrUrl( const QString& s ){ return KUrl(s); } - QString url() const { return m_s; } - bool isEmpty() const { return m_s.isEmpty(); } - QString prettyUrl() const { return m_s; } - bool isLocalFile() const { return true; } - bool isRelative() const { return true; } - bool isValid() const { return true; } - QString path() const { return m_s; } - void setPath( const QString& s ){ m_s=s; } - QString fileName() const { return m_s; } // not really needed - void addPath( const QString& s ){ m_s += "/" + s; } -private: - QString m_s; -}; - -typedef QString KGuiItem; - -class KStandardGuiItem -{ -public: - static QString cont() { return i18n("Continue"); } - static QString cancel() { return i18n("Cancel"); } - static QString quit() { return i18n("Quit"); } -}; - -class KMessageBox -{ -public: - static void error( QWidget* parent, const QString& text, const QString& caption=QString() ); - static int warningContinueCancel( QWidget* parent, const QString& text, const QString& caption=QString(), - const QString& button1=QString("Continue") ); - static void sorry( QWidget* parent, const QString& text, const QString& caption=QString() ); - static void information( QWidget* parent, const QString& text, const QString& caption=QString() ); - static int warningYesNo( QWidget* parent, const QString& text, const QString& caption, - const QString& button1, const QString& button2 ); - static int warningYesNoCancel( - QWidget* parent, const QString& text, const QString& caption, - const QString& button1, const QString& button2 ); - - enum {Cancel=-1, No=0, Yes=1, Continue=1}; -}; - - - -typedef QMenu KMenu; - -class KPageWidgetItem : public QObject -{ -public: - QWidget* m_pWidget; - QString m_title; - - KPageWidgetItem( QWidget* pPage, const QString& title ) - { - m_pWidget = pPage; - m_title = title; - } - void setHeader( const QString& ) {} - void setIcon( const KIcon& ) {} -}; - - -class KPageDialog : public QDialog -{ - Q_OBJECT - QTabWidget* m_pTabWidget; -public: - KPageDialog( QWidget* parent ); - ~KPageDialog(); - - void incrementInitialSize ( const QSize& ); - void setHelp(const QString& helpfilename, const QString& ); - enum {IconList, Help, Default, Apply, Ok, Cancel }; - - int BarIcon(const QString& iconName, int ); - - void addPage( KPageWidgetItem* ); - QFrame* addPage( const QString& name, const QString& info, int ); - int spacingHint(); - - enum FaceType { List }; - void setFaceType(FaceType){} - void setButtons(int){} - void setDefaultButton(int){} - void showButtonSeparator(bool){} -private slots: - void slotHelpClicked(); -signals: - void applyClicked(); - void okClicked(); - void helpClicked(); - void defaultClicked(); -}; - -class KFileDialog //: public QFileDialog -{ -public: - static KUrl getSaveUrl( const QString &startDir=QString::null, - const QString &filter=QString::null, - QWidget *parent=0, const QString &caption=QString::null); - static KUrl getOpenUrl( const QString & startDir = QString::null, - const QString & filter = QString::null, - QWidget * parent = 0, - const QString & caption = QString::null ); - static KUrl getExistingDirectoryUrl( const QString & startDir = QString::null, - QWidget * parent = 0, - const QString & caption = QString::null ); - static QString getSaveFileName (const QString &startDir=QString::null, - const QString &filter=QString::null, - QWidget *parent=0, - const QString &caption=QString::null); -}; - -typedef QStatusBar KStatusBar; - -class KToolBar : public QToolBar -{ -public: - KToolBar(QMainWindow* parent); - - enum BarPosition {Top, Bottom, Left, Right}; - BarPosition barPos(); - void setBarPos(BarPosition); -private: - QMainWindow* m_pMainWindow; -}; - -class KActionCollection -{ -public: - KMainWindow* m_pMainWindow; - KActionCollection( KMainWindow* p){ m_pMainWindow=p; } - void addAction(const QString& name, QAction* ); - KAction* addAction(const QString& name ); -}; - -typedef QKeySequence KShortcut; - -class KShortcutsEditor -{ -public: - enum { LetterShortcutsAllowed }; -}; - -class KShortcutsDialog -{ -public: - static void configure(KActionCollection*){} - static void configureKeys(KActionCollection*, const QString&){} - static void configure(KActionCollection*, int, QWidget*){} -}; - -namespace KParts -{ - class ReadWritePart; -} - -class KMainWindow : public QMainWindow -{ - Q_OBJECT -private: - KActionCollection m_actionCollection; -protected: - virtual bool queryClose() = 0; - virtual bool queryExit() = 0; -public: - QMenu* fileMenu; - QMenu* editMenu; - QMenu* directoryMenu; - QMenu* dirCurrentItemMenu; - QMenu* dirCurrentSyncItemMenu; - QMenu* movementMenu; - QMenu* mergeMenu; - QMenu* diffMenu; - QMenu* windowsMenu; - QMenu* settingsMenu; - QMenu* helpMenu; - - KToolBar* m_pToolBar; - - KMainWindow( QWidget* parent ); - KToolBar* toolBar(const QString& s = QString::null); - KActionCollection* actionCollection(); - void createGUI(); - void createGUI(KParts::ReadWritePart*){createGUI();} - - QList* memberList; -public slots: - void appHelpActivated(); - void slotAbout(); -}; - -class KConfigGroupData : public ValueMap, public QSharedData -{ -public: - QString m_fileName; - ~KConfigGroupData(); -}; - -class KConfigGroup -{ -private: - QExplicitlySharedDataPointer d; -public: - KConfigGroup(const KConfigGroup*, const QString& ){} - KConfigGroup(); - ~KConfigGroup(); - void readConfigFile(const QString& configFileName); - - void setGroup(const QString&); - KConfigGroup& group( const QString& groupName ); - - template void writeEntry(const QString& s, const T& v){ d->writeEntry(s,v); } - void writeEntry(const QString& s, const QStringList& v, char separator ){ d->writeEntry(s,v,separator); } - void writeEntry(const QString& s, const char* v){ d->writeEntry(s,v); } - - template T readEntry (const QString& s, const T& defaultVal ){ return d->readEntry(s,defaultVal); } - QString readEntry (const QString& s, const char* defaultVal ){ return d->readEntry(s,defaultVal); } - QStringList readEntry (const QString& s, const QStringList& defaultVal, char separator=',' ){ return d->readEntry(s,defaultVal,separator); } -}; - -typedef KConfigGroup* KSharedConfigPtr; - -class KAction : public QAction -{ - Q_OBJECT -public: - KAction( KActionCollection* actionCollection ); - KAction(const QString& text, KActionCollection* actionCollection ); - KAction(const QString& text, const QIcon& icon, int accel, QObject* receiver, const char* slot, KActionCollection* actionCollection, const char* name, bool bToggle=false, bool bMenu=true); - KAction(const QString& text, int accel, QObject* receiver, const char* slot, KActionCollection* actionCollection, const char* name, bool bToggle=false, bool bMenu=true); - void setStatusText(const QString&); - void plug(QMenu*); - void setIcon( const QIcon& icon ); -}; - -class KToggleAction : public KAction -{ -public: - KToggleAction(KActionCollection* actionCollection); - KToggleAction(const QString& text, const QIcon& icon, int accel, QObject* receiver, const char* slot, KActionCollection* actionCollection, const char* name, bool bMenu=true); - KToggleAction(const QString& text, int accel, QObject* receiver, const char* slot, KActionCollection* actionCollection, const char* name, bool bMenu=true); - KToggleAction(const QString& text, const QIcon& icon, int accel, KActionCollection* actionCollection, const char* name, bool bMenu=true); - void setChecked(bool); -}; - - -class KStandardAction -{ -public: - static KAction* open( QWidget* parent, const char* slot, KActionCollection* ); - static KAction* save( QWidget* parent, const char* slot, KActionCollection* ); - static KAction* saveAs( QWidget* parent, const char* slot, KActionCollection* ); - static KAction* print( QWidget* parent, const char* slot, KActionCollection* ); - static KAction* quit( QWidget* parent, const char* slot, KActionCollection* ); - static KAction* cut( QWidget* parent, const char* slot, KActionCollection* ); - static KAction* copy( QWidget* parent, const char* slot, KActionCollection* ); - static KAction* paste( QWidget* parent, const char* slot, KActionCollection* ); - static KAction* selectAll( QWidget* parent, const char* slot, KActionCollection* ); - static KToggleAction* showToolbar( QWidget* parent, const char* slot, KActionCollection* ); - static KToggleAction* showStatusbar( QWidget* parent, const char* slot, KActionCollection* ); - static KAction* preferences( QWidget* parent, const char* slot, KActionCollection* ); - static KAction* about( QWidget* parent, const char* slot, KActionCollection* ); - static KAction* aboutQt( KActionCollection* ); - static KAction* help( QWidget* parent, const char* slot, KActionCollection* ); - static KAction* find( QWidget* parent, const char* slot, KActionCollection* ); - static KAction* findNext( QWidget* parent, const char* slot, KActionCollection* ); - static KAction* keyBindings( QWidget* parent, const char* slot, KActionCollection* ); -}; - -class KIcon -{ -public: - enum {SizeMedium,Small}; - KIcon( const QString& ) {} -}; - -class KColorButton : public QPushButton -{ - Q_OBJECT - QColor m_color; -public: - KColorButton(QWidget* parent); - QColor color(); - void setColor(const QColor&); - virtual void paintEvent(QPaintEvent* e); -public slots: - void slotClicked(); -}; - -#ifndef QT_NO_PRINTER -class KPrinter : public QPrinter -{ -public: - KPrinter(); - enum e_PageSelection {ApplicationSide}; - QList pageList(); - void setCurrentPage(int); - void setPageSelection(e_PageSelection); -}; -#endif - -class KStandardDirs -{ -public: - QString findResource(const QString& resource, const QString& appName); -}; - -class KCmdLineOptions -{ -public: - KCmdLineOptions& add( const QString& name, const QString& description = 0 ); -}; - -#define KCmdLineLastOption {0,0,0} - -class KAboutData -{ -public: - enum LicenseKey { License_GPL, License_GPL_V2, License_Unknown }; - - //KAboutData( const QString& name, const QString& appName, const QString& version, - // const QString& description, int licence, - // const QString& copyright, int w, const QString& homepage, const QString& email); - - KAboutData (const QByteArray &appName, const QByteArray &catalogName, const KLocalizedString &programName, - const QByteArray &version, const KLocalizedString &shortDescription, LicenseKey licenseType, - const KLocalizedString ©rightStatement, const KLocalizedString &text, - const QByteArray &homePageAddress, const QByteArray &bugsEmailAddress); - KAboutData( const QString& name, const QString& appName, const QString& appName2, const QString& version ); - void addAuthor(const QString& name, const QString& task=0, const QString& email=0, const QString& weblink=0); - void addCredit(const QString& name, const QString& task=0, const QString& email=0, const QString& weblink=0); - - struct AboutDataEntry - { - AboutDataEntry(const QString& name, const QString& task, const QString& email, const QString& weblink) - : m_name(name), m_task(task), m_email(email), m_weblink(weblink) - {} - QString m_name; - QString m_task; - QString m_email; - QString m_weblink; - }; - - std::list m_authorList; - std::list m_creditList; -}; - -typedef QList QCStringList; - -class KCmdLineArgs -{ -public: - static KCmdLineArgs* parsedArgs(); - static void init( int argc, char**argv, KAboutData* ); - static void addCmdLineOptions( const KCmdLineOptions& options ); // Add our own options. - - int count(); - QString arg(int); - KUrl url(int i){ return KUrl(arg(i)); } - void clear(); - QString getOption(const QString&); - QStringList getOptionList( const QString& ); - bool isSet(const QString&); -}; - -class KIconLoader -{ -public: - enum { Small, NoGroup }; - QPixmap loadIcon(const QString& name, int, int =0); - static KIconLoader* global() { return 0; } -}; - -class KApplication : public QApplication -{ - KConfigGroup m_config; - KIconLoader m_iconLoader; -public: - KApplication(); - static KApplication* kApplication(); - KIconLoader* iconLoader(); - KConfigGroup* config(); - bool isRestored(); - void parseOptions(); -}; - -extern KApplication* kapp; - -class KLibFactory : public QObject -{ - Q_OBJECT -public: - QObject* create(QObject*,const QString&,const QString&); -}; - -class KLibLoader -{ -public: - static KLibLoader* self(); - KLibFactory* factory(const QString&); -}; - -class KEditToolBar : public QDialog -{ -public: - KEditToolBar( int ){} -}; - -class KGlobal -{ -public: - static KConfigGroup* config() { return 0; } -}; - -class KJobUiDelegate -{ -public: - void showErrorMessage() {} -}; - -class KJob : public QObject -{ -public: - bool error() {return false;} - enum KillVerbosity { Quietly }; - bool kill( KillVerbosity ){return false;} - KJobUiDelegate* uiDelegate() {return 0;} -}; - -namespace KIO -{ - enum { Overwrite, DefaultFlags, Resume, HideProgressInfo, NoReload }; - enum UDSEntry {}; - typedef QList UDSEntryList; - class Job : public KJob - { - }; - class SimpleJob : public KJob {}; - SimpleJob* mkdir( KUrl ); - SimpleJob* rmdir( KUrl ); - SimpleJob* file_delete( KUrl, int ); - class FileCopyJob : public KJob {}; - FileCopyJob* file_move( KUrl, KUrl, int, int ); - FileCopyJob* file_copy( KUrl, KUrl, int, int ); - class CopyJob : public KJob {}; - CopyJob* link( KUrl, KUrl, bool ); - class ListJob : public KJob {}; - ListJob* listRecursive( KUrl, bool, bool ); - ListJob* listDir( KUrl, bool, bool ); - class StatJob : public KJob { - public: - enum {SourceSide,DestinationSide}; - UDSEntry statResult(){ return (UDSEntry)0; } - }; - StatJob* stat( KUrl, bool, int, int ); - class TransferJob : public KJob {}; - TransferJob* get( KUrl, int ); - TransferJob* put( KUrl, int, int ); -}; - -typedef QProgressBar KProgress; - -class KInstance : public QObject -{ -public: - KInstance(KAboutData*){} -}; - -class KComponentData : public QObject -{ -public: - KComponentData(KAboutData*){} - KConfigGroup* config() {return 0;} -}; - -namespace KParts -{ - class MainWindow : public KMainWindow - { - Q_OBJECT - public: - MainWindow( QWidget* parent=0 ) : KMainWindow(parent) {} - void setXMLFile(const QString&){} - void setAutoSaveSettings(){} - void saveMainWindowSettings(KConfigGroup&){} - void applyMainWindowSettings(KConfigGroup&){} - int factory(){return 0;} - }; - - class Part : public QObject - { - public: - KActionCollection* actionCollection(); - KApplication* instance(); - void setWidget( QWidget* w ){ m_pWidget=w; } - QWidget* widget(){return m_pWidget;} - void setXMLFile(const QString&){} - private: - QWidget* m_pWidget; - }; - - class ReadOnlyPart : public Part - { - public: - ReadOnlyPart(){} - ReadOnlyPart(QObject*,const QString&){} - QString localFilePath() {return QString(); } - void setComponentData(const KComponentData&){} // actually member of PartBase - KComponentData& componentData() { return NULL;} - QString m_file; - }; - - class ReadWritePart : public ReadOnlyPart - { - public: - ReadWritePart(QObject*){} - void setReadWrite(bool){} - }; - - class Factory : public KLibFactory - { - Q_OBJECT - public: - virtual KParts::Part* createPartObject( QWidget* /*parentWidget*/, const char * /*widgetName*/, - QObject* /*parent*/, const char * /*name*/, - const char* /*classname*/, const QStringList& /*args*/ ){return 0;} - }; -}; -#endif - - diff --git a/src/kreplacements/kreplacements.cpp b/src/kreplacements/kreplacements.cpp deleted file mode 100644 --- a/src/kreplacements/kreplacements.cpp +++ /dev/null @@ -1,1189 +0,0 @@ -/*************************************************************************** - kreplacements.cpp - description - ------------------- - begin : Sat Aug 3 2002 - copyright : (C) 2002-2006 by Joachim Eibl - email : joachim.eibl at gmx.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - - -#include "kreplacements.h" -#include "common.h" - -#include //namespace -#include -#include -#include -#include - -#ifndef QT_NO_COLORDIALOG -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - - -static QString s_copyright; -static QString s_email; -static QString s_description; -static QString s_appName; -static QString s_version; -static QString s_homepage; -static KAboutData* s_pAboutData; - - -#ifdef Q_OS_WIN -#include -#include -#include -#endif - -static void showHelp() -{ - #if defined(Q_OS_WIN) - QString exePath = QCoreApplication::applicationDirPath(); - - QFileInfo helpFile( exePath + "\\doc\\en\\index.html" ); - if ( ! helpFile.exists() ) { helpFile.setFile( exePath + "\\..\\doc\\en\\index.html" ); } - if ( ! helpFile.exists() ) { helpFile.setFile( exePath + "\\doc\\index.html" ); } - if ( ! helpFile.exists() ) { helpFile.setFile( exePath + "\\..\\doc\\index.html" ); } - if ( ! helpFile.exists() ) - { - QMessageBox::warning( 0, "KDiff3 documentation not found", - "Couldn't find the documentation. \n\n" - "The documentation can also be found at the homepage:\n\n " - " http://kdiff3.sourceforge.net/"); - return; - } - -#ifndef Q_OS_OS2 - char buf[256]; - HINSTANCE hi = FindExecutableA( helpFile.fileName().toLatin1(), helpFile.absolutePath().toLatin1(), buf ); - if ( (quintptr)hi<=32 ) - { -#endif - static QTextBrowser* pBrowser = 0; - if (pBrowser==0) - { - pBrowser = new QTextBrowser( 0 ); - pBrowser->setMinimumSize( 600, 400 ); - } - pBrowser->setSource(QUrl("file:///"+helpFile.filePath())); - pBrowser->show(); -#ifndef Q_OS_OS2 - } - else - { - QFileInfo prog( buf ); - QProcess::startDetached ( prog.filePath(), QStringList( "file:///"+helpFile.absoluteFilePath() ) ); - } -#endif - #else - static QTextBrowser* pBrowser = 0; - if (pBrowser==0) - { - pBrowser = new QTextBrowser( 0 ); - pBrowser->setMinimumSize( 600, 400 ); - } - pBrowser->setSource(QUrl("file://usr/local/share/doc/kdiff3/en/index.html")); - pBrowser->show(); - #endif -} - -QString getTranslationDir(const QString& locale) -{ - #if defined(Q_OS_WIN) - QUNUSED(locale); - QString exePath; - exePath = QCoreApplication::applicationDirPath(); - return exePath+"/translations"; - #elif defined(Q_OS_MAC) - QUNUSED(locale); - - QString exePath = QCoreApplication::applicationDirPath(); - return exePath+"/../Resources/translations"; - #else - return (QString)"/usr/share/locale/" + locale + "/LC_MESSAGES"; - #endif -} - -// static -void KMessageBox::error( QWidget* parent, const QString& text, const QString& caption ) -{ - QMessageBox::critical( parent, caption, text ); -} - -int KMessageBox::warningContinueCancel( QWidget* parent, const QString& text, const QString& caption, - const QString& button1 ) -{ - return 0 == QMessageBox::warning( parent, caption, text, button1, "Cancel" ) ? Continue : Cancel; -} - -void KMessageBox::sorry( QWidget* parent, const QString& text, const QString& caption ) -{ - QMessageBox::information( parent, caption, text ); -} - -void KMessageBox::information( QWidget* parent, const QString& text, const QString& caption ) -{ - QMessageBox::information( parent, caption, text ); -} - -int KMessageBox::warningYesNo( QWidget* parent, const QString& text, const QString& caption, - const QString& button1, const QString& button2 ) -{ - return 0 == QMessageBox::warning( parent, caption, text, button1, button2, QString::null, 1, 1 ) ? Yes : No; -} - -int KMessageBox::warningYesNoCancel( QWidget* parent, const QString& text, const QString& caption, - const QString& button1, const QString& button2 ) -{ - int val = QMessageBox::warning( parent, caption, text, - button1, button2, i18n("Cancel") ); - if ( val==0 ) return Yes; - if ( val==1 ) return No; - else return Cancel; -} - - -KPageDialog::KPageDialog( QWidget* parent ) -: QDialog( parent ) -{ - setModal(true); - QVBoxLayout *pMainLayout = new QVBoxLayout(this); - m_pTabWidget = new QTabWidget(); - pMainLayout->addWidget(m_pTabWidget,1); - - QHBoxLayout* pButtonLayout = new QHBoxLayout(); - pMainLayout->addLayout( pButtonLayout ); - - pButtonLayout->addStretch(1); - QPushButton* pOk = new QPushButton( i18n("Ok") ); - connect( pOk, SIGNAL( clicked() ), this, SIGNAL(okClicked()) ); - pButtonLayout->addWidget( pOk ); - - QPushButton* pHelp = new QPushButton( i18n("Help") ); - connect( pHelp, SIGNAL( clicked() ), this, SLOT(slotHelpClicked())); - pButtonLayout->addWidget( pHelp ); - - QPushButton* pDefaults = new QPushButton( i18n("Defaults") ); - connect( pDefaults, SIGNAL( clicked() ), this, SIGNAL(defaultClicked()) ); - pButtonLayout->addWidget( pDefaults ); - - QPushButton* pCancel = new QPushButton( i18n("Cancel") ); - connect( pCancel, SIGNAL( clicked() ), this, SLOT(reject())); - pButtonLayout->addWidget( pCancel ); -} - -KPageDialog::~KPageDialog() -{ -} - -void KPageDialog::incrementInitialSize ( const QSize& ) -{ -} - -void KPageDialog::setHelp(const QString&, const QString& ) -{ -} - -void KPageDialog::slotHelpClicked() -{ - showHelp(); -} - -int KPageDialog::BarIcon(const QString& /*iconName*/, int ) -{ - return 0; // Not used for replacement. -} - - -QFrame* KPageDialog::addPage( const QString& name, const QString& /*info*/, int ) -{ - QFrame* p = new QFrame(); - p->setObjectName( name ); - m_pTabWidget->addTab( p, name ); - return p; -} - -void KPageDialog::addPage( KPageWidgetItem * p ) -{ - m_pTabWidget->addTab( p->m_pWidget, p->m_title ); -} - -int KPageDialog::spacingHint() -{ - return 3; -} - -KUrl KFileDialog::getSaveUrl( const QString &startDir, - const QString &filter, - QWidget *parent, const QString &caption) -{ - QString s = QFileDialog::getSaveFileName(parent, caption, startDir, filter, 0/*, QFileDialog::DontUseNativeDialog*/); - return KUrl(s); -} - -KUrl KFileDialog::getOpenUrl( const QString & startDir, - const QString & filter, - QWidget * parent, - const QString & caption ) -{ - QString s = QFileDialog::getOpenFileName(parent, caption, startDir, filter ); - return KUrl(s); -} - -KUrl KFileDialog::getExistingDirectoryUrl( const QString & startDir, - QWidget * parent, - const QString & caption) -{ - QString s = QFileDialog::getExistingDirectory(parent, caption, startDir); - return KUrl(s); -} - -QString KFileDialog::getSaveFileName (const QString &startDir, - const QString &filter, - QWidget *parent, - const QString &caption) -{ - return QFileDialog::getSaveFileName( parent, caption, startDir, filter ); -} - - -KToolBar::BarPosition KToolBar::barPos() -{ - if ( m_pMainWindow->toolBarArea(this)==Qt::LeftToolBarArea ) return Left; - if ( m_pMainWindow->toolBarArea(this)==Qt::RightToolBarArea ) return Right; - if ( m_pMainWindow->toolBarArea(this)==Qt::BottomToolBarArea ) return Bottom; - if ( m_pMainWindow->toolBarArea(this)==Qt::TopToolBarArea ) return Top; - return Top; -} - -void KToolBar::setBarPos(BarPosition bp) -{ - if ( bp == Left ) m_pMainWindow->addToolBar ( Qt::LeftToolBarArea, this ); - else if ( bp == Right ) m_pMainWindow->addToolBar ( Qt::RightToolBarArea, this ); - else if ( bp == Bottom ) m_pMainWindow->addToolBar ( Qt::BottomToolBarArea, this ); - else if ( bp == Top ) m_pMainWindow->addToolBar ( Qt::TopToolBarArea, this ); -} - -KToolBar::KToolBar( QMainWindow* parent ) -: QToolBar( parent ) -{ - m_pMainWindow = parent; -} - - -KMainWindow::KMainWindow( QWidget* parent ) -: QMainWindow( parent ), m_actionCollection(this) -{ - fileMenu = menuBar()->addMenu( i18n("&File") ); - editMenu = menuBar()->addMenu(i18n("&Edit") ); - directoryMenu = menuBar()->addMenu(i18n("&Directory") ); - dirCurrentItemMenu = 0; - dirCurrentSyncItemMenu = 0; - movementMenu = menuBar()->addMenu(i18n("&Movement") ); - diffMenu = menuBar()->addMenu(i18n("D&iffview") ); - mergeMenu = menuBar()->addMenu(i18n("&Merge") ); - windowsMenu = menuBar()->addMenu(i18n("&Window") ); - settingsMenu = menuBar()->addMenu(i18n("&Settings") ); - helpMenu = menuBar()->addMenu(i18n("&Help") ); - - m_pToolBar = new KToolBar(this); - addToolBar( m_pToolBar ); - - memberList = new QList; - memberList->append(this); - - raise(); -} - -KToolBar* KMainWindow::toolBar(const QString&) -{ - return m_pToolBar; -} - -KActionCollection* KMainWindow::actionCollection() -{ - return &m_actionCollection; -} - -void KMainWindow::createGUI() -{ - KStandardAction::help(this, SLOT(appHelpActivated()), actionCollection()); - KStandardAction::about(this, SLOT(slotAbout()), actionCollection()); - KStandardAction::aboutQt(actionCollection()); -} - -void KMainWindow::slotAbout() -{ - QDialog d; - QVBoxLayout* l = new QVBoxLayout( &d ); - QTabWidget* pTabWidget = new QTabWidget; - l->addWidget( pTabWidget ); - - QPushButton* pOkButton = new QPushButton(i18n("Ok")); - connect( pOkButton, SIGNAL(clicked()), &d, SLOT(accept())); - l->addWidget( pOkButton ); - - d.setWindowTitle("About " + s_appName); - QTextBrowser* tb1 = new QTextBrowser(); - tb1->setWordWrapMode( QTextOption::NoWrap ); - tb1->setText( - s_appName + " Version " + s_version + - "\n\n" + s_description + - "\n\n" + s_copyright + - "\n\nHomepage: " + s_homepage + - "\n\nLicence: GNU GPL Version 2" - ); - pTabWidget->addTab(tb1,i18n("&About")); - - std::list::iterator i; - - QString s2; - for( i=s_pAboutData->m_authorList.begin(); i!=s_pAboutData->m_authorList.end(); ++i ) - { - if ( !i->m_name.isEmpty() ) s2 += i->m_name + "\n"; - if ( !i->m_task.isEmpty() ) s2 += " " + i->m_task + "\n"; - if ( !i->m_email.isEmpty() ) s2 += " " + i->m_email + "\n"; - if ( !i->m_weblink.isEmpty() ) s2 += " " + i->m_weblink + "\n"; - s2 += "\n"; - } - QTextBrowser* tb2 = new QTextBrowser(); - tb2->setWordWrapMode( QTextOption::NoWrap ); - tb2->setText(s2); - pTabWidget->addTab(tb2,i18n("A&uthor")); - - QString s3; - for( i=s_pAboutData->m_creditList.begin(); i!=s_pAboutData->m_creditList.end(); ++i ) - { - if ( !i->m_name.isEmpty() ) s3 += i->m_name + "\n"; - if ( !i->m_task.isEmpty() ) s3 += " " + i->m_task + "\n"; - if ( !i->m_email.isEmpty() ) s3 += " " + i->m_email + "\n"; - if ( !i->m_weblink.isEmpty() ) s3 += " " + i->m_weblink + "\n"; - s3 += "\n"; - } - QTextBrowser* tb3 = new QTextBrowser(); - tb3->setWordWrapMode( QTextOption::NoWrap ); - tb3->setText(s3); - pTabWidget->addTab(tb3,i18n("&Thanks To")); - - d.resize(400,300); - d.exec(); -/* - QMessageBox::information( - this, - "About " + s_appName, - s_appName + " Version " + s_version + - "\n\n" + s_description + - "\n\n" + s_copyright + - "\n\nHomepage: " + s_homepage + - "\n\nLicence: GNU GPL Version 2" - ); -*/ -} - -void KMainWindow::appHelpActivated() -{ - showHelp(); -} - - -QString KStandardDirs::findResource(const QString& resource, const QString& /*appName*/) -{ - if (resource=="config") - { -#if defined(Q_OS_WIN) - QString exePath = QCoreApplication::applicationDirPath(); - QString configPath = exePath + "/.kdiff3rc"; // This is useful for portable installations (e.g. on USB-Stick) - if ( QFile::exists( configPath ) ) - return configPath; -#endif - QString home = QDir::homePath(); - return home + "/.kdiff3rc"; - } - return QString(); -} - -KConfigGroupData::~KConfigGroupData() -{ - QFile f(m_fileName); - if ( f.open( QIODevice::WriteOnly | QIODevice::Text ) ) - { // file opened successfully - QTextStream t( &f ); // use a text stream - save(t); - f.close(); - } -} - -KConfigGroup::KConfigGroup() -{ - d = new KConfigGroupData; -} - -void KConfigGroup::readConfigFile( const QString& configFileName ) -{ - if ( !configFileName.isEmpty() ) - { - d->m_fileName = configFileName; - } - else - { - d->m_fileName = KStandardDirs().findResource("config","kdiff3rc"); - } - - QFile f( d->m_fileName ); - if ( f.open(QIODevice::ReadOnly) ) - { // file opened successfully - QTextStream t( &f ); // use a text stream - d->load(t); - f.close(); - } -} - -KConfigGroup::~KConfigGroup() -{ -} - -void KConfigGroup::setGroup(const QString&) -{ -} - -KConfigGroup& KConfigGroup::group( const QString& ) -{ - KApplication* pKApp = static_cast(QApplication::instance()); - return *pKApp->config(); -} - -static void initAction( QAction* pAction, QObject* receiver, const char* slot, KActionCollection* actionCollection, - const QString& name, bool bToggle, bool bMenu) -{ - QString n(name); - KMainWindow* p = actionCollection->m_pMainWindow; - if( slot!=0 ) - { - if (!bToggle) - QObject::connect(pAction, SIGNAL(triggered()), receiver, slot); - else - { - QObject::connect(pAction, SIGNAL(toggled(bool)), receiver, slot); - } - } - - if (bMenu) - { - if( n[0]=='g') p->movementMenu->addAction( pAction ); - else if( n.left(16)=="dir_current_sync") - { - if ( p->dirCurrentItemMenu==0 ) - { - p->dirCurrentItemMenu = p->directoryMenu->addMenu( i18n("Current Item Merge Operation") ); - p->dirCurrentSyncItemMenu = p->directoryMenu->addMenu( i18n("Current Item Sync Operation") ); - } - p->dirCurrentItemMenu->addAction( pAction ); - } - else if( n.left(11)=="dir_current") - { - if ( p->dirCurrentItemMenu==0 ) - { - p->dirCurrentItemMenu = p->directoryMenu->addMenu( i18n("Current Item Merge Operation") ); - p->dirCurrentSyncItemMenu = p->directoryMenu->addMenu( i18n("Current Item Sync Operation") ); - } - p->dirCurrentSyncItemMenu->addAction( pAction ); - } - else if( n.left(4)=="diff") p->diffMenu->addAction( pAction ); - else if( name[0]=='d') p->directoryMenu->addAction( pAction ); - else if( name[0]=='f') p->fileMenu->addAction( pAction ); - else if( name[0]=='w') p->windowsMenu->addAction( pAction ); - else p->mergeMenu->addAction( pAction ); - } -} - -KAction::KAction(const QString& name, KActionCollection* actionCollection ) -: QAction ( actionCollection->m_pMainWindow ) -{ - initAction( this, 0,0, actionCollection, name, false, true ); -} - -KAction::KAction( KActionCollection* actionCollection ) -: QAction ( actionCollection->m_pMainWindow ) -{ -} - -KAction::KAction(const QString& text, const QIcon& icon, int accel, - QObject* receiver, const char* slot, KActionCollection* actionCollection, - const char* name, bool bToggle, bool bMenu - ) -: QAction ( icon, text, actionCollection->m_pMainWindow ) -{ - setObjectName(name); - setShortcut( accel ); - setCheckable( bToggle ); - KMainWindow* p = actionCollection->m_pMainWindow; - if ( !icon.isNull() && p ) p->m_pToolBar->addAction( this ); - - initAction(this, receiver,slot,actionCollection,name,bToggle,bMenu); -} - -KAction::KAction(const QString& text, int accel, - QObject* receiver, const char* slot, KActionCollection* actionCollection, - const char* name, bool bToggle, bool bMenu - ) -: QAction ( text, actionCollection->m_pMainWindow ) -{ - setObjectName(name); - setShortcut( accel ); - setCheckable( bToggle ); - initAction(this,receiver,slot,actionCollection,name,bToggle,bMenu); -} - -void KAction::setStatusText(const QString&) -{ -} - -void KAction::plug(QMenu* menu) -{ - menu->addAction( this ); -} - -void KAction::setIcon( const QIcon& icon ) -{ - QAction::setIcon(icon); - if ( !icon.isNull() ) - { - KMainWindow* pMW = static_cast( parent() ); - pMW->toolBar()->addAction(this); - } -} - - -KToggleAction::KToggleAction( KActionCollection* actionCollection ) -: KAction( actionCollection ) -{ - setCheckable(true); -} - -KToggleAction::KToggleAction(const QString& text, int accel, QObject* receiver, const char* slot, KActionCollection* actionCollection, const char* name, bool bMenu) -: KAction( text, accel, receiver, slot, actionCollection, name, true, bMenu) -{ -} - -KToggleAction::KToggleAction(const QString& text, const QIcon& icon, int accel, KActionCollection* actionCollection, const char* name, bool bMenu) -: KAction( text, icon, accel, 0, 0, actionCollection, name, true, bMenu) -{ -} - -void KToggleAction::setChecked(bool bChecked) -{ - blockSignals( true ); - QAction::setChecked( bChecked ); - blockSignals( false ); -} - - -//static -KAction* KStandardAction::open( QWidget* parent, const char* slot, KActionCollection* actionCollection) -{ - #include "../xpm/fileopen.xpm" - KMainWindow* p = actionCollection->m_pMainWindow; - KAction* a = new KAction( i18n("Open"), QIcon(QPixmap(fileopen)), Qt::CTRL+Qt::Key_O, parent, slot, actionCollection, "open", false, false); - if(p){ p->fileMenu->addAction( a ); } - return a; -} - -KAction* KStandardAction::save( QWidget* parent, const char* slot, KActionCollection* actionCollection ) -{ - #include "../xpm/filesave.xpm" - KMainWindow* p = actionCollection->m_pMainWindow; - KAction* a = new KAction( i18n("Save"), QIcon(QPixmap(filesave)), Qt::CTRL+Qt::Key_S, parent, slot, actionCollection, "save", false, false); - if(p){ p->fileMenu->addAction( a ); } - return a; -} - -KAction* KStandardAction::saveAs( QWidget* parent, const char* slot, KActionCollection* actionCollection) -{ - KMainWindow* p = actionCollection->m_pMainWindow; - KAction* a = new KAction( i18n("Save As..."), 0, parent, slot, actionCollection, "saveas", false, false); - if(p) p->fileMenu->addAction( a ); - return a; -} - -KAction* KStandardAction::print( QWidget* parent, const char* slot, KActionCollection* actionCollection) -{ - #include "../xpm/fileprint.xpm" - KMainWindow* p = actionCollection->m_pMainWindow; - KAction* a = new KAction( i18n("Print..."), QIcon(QPixmap(fileprint)),Qt::CTRL+Qt::Key_P, parent, slot, actionCollection, "print", false, false); - if(p) p->fileMenu->addAction( a ); - return a; -} - -KAction* KStandardAction::quit( QWidget* parent, const char* slot, KActionCollection* actionCollection) -{ - KMainWindow* p = actionCollection->m_pMainWindow; - KAction* a = new KAction( i18n("Quit"), Qt::CTRL+Qt::Key_Q, parent, slot, actionCollection, "quit", false, false); - if(p) p->fileMenu->addAction( a ); - return a; -} - -KAction* KStandardAction::cut( QWidget* parent, const char* slot, KActionCollection* actionCollection) -{ - KMainWindow* p = actionCollection->m_pMainWindow; - KAction* a = new KAction( i18n("Cut"), Qt::CTRL+Qt::Key_X, parent, slot, actionCollection, "cut", false, false ); - if(p) p->editMenu->addAction( a ); - return a; -} - -KAction* KStandardAction::copy( QWidget* parent, const char* slot, KActionCollection* actionCollection) -{ - KMainWindow* p = actionCollection->m_pMainWindow; - KAction* a = new KAction( i18n("Copy"), Qt::CTRL+Qt::Key_C, parent, slot, actionCollection, "copy", false, false ); - if(p) p->editMenu->addAction( a ); - return a; -} - -KAction* KStandardAction::paste( QWidget* parent, const char* slot, KActionCollection* actionCollection) -{ - KMainWindow* p = actionCollection->m_pMainWindow; - KAction* a = new KAction( i18n("Paste"), Qt::CTRL+Qt::Key_V, parent, slot, actionCollection, "paste", false, false ); - if(p) p->editMenu->addAction( a ); - return a; -} - -KAction* KStandardAction::selectAll( QWidget* parent, const char* slot, KActionCollection* actionCollection) -{ - KMainWindow* p = actionCollection->m_pMainWindow; - KAction* a = new KAction( i18n("Select All"), Qt::CTRL+Qt::Key_A, parent, slot, actionCollection, "selectall", false, false ); - if(p) p->editMenu->addAction( a ); - return a; -} - -KToggleAction* KStandardAction::showToolbar( QWidget* parent, const char* slot, KActionCollection* actionCollection) -{ - KMainWindow* p = actionCollection->m_pMainWindow; - KToggleAction* a = new KToggleAction( i18n("Show Toolbar"), 0, parent, slot, actionCollection, "showtoolbar", false ); - if(p) p->settingsMenu->addAction( a ); - return a; -} - -KToggleAction* KStandardAction::showStatusbar( QWidget* parent, const char* slot, KActionCollection* actionCollection) -{ - KMainWindow* p = actionCollection->m_pMainWindow; - KToggleAction* a = new KToggleAction( i18n("Show &Status Bar"), 0, parent, slot, actionCollection, "showstatusbar", false ); - if(p) p->settingsMenu->addAction( a ); - return a; -} - -KAction* KStandardAction::preferences( QWidget* parent, const char* slot, KActionCollection* actionCollection) -{ - KMainWindow* p = actionCollection->m_pMainWindow; - KAction* a = new KAction( i18n("&Configure %1...",QString("KDiff3")), 0, parent, slot, actionCollection, "settings", false, false ); - if(p) p->settingsMenu->addAction( a ); - return a; -} -KAction* KStandardAction::keyBindings( QWidget*, const char*, KActionCollection*) -{ - return 0; -} - -KAction* KStandardAction::about( QWidget* parent, const char* slot, KActionCollection* actionCollection) -{ - KMainWindow* p = actionCollection->m_pMainWindow; - KAction* a = new KAction( i18n("About")+" KDiff3", 0, parent, slot, actionCollection, "about_kdiff3", false, false ); - if(p) p->helpMenu->addAction( a ); - return a; -} - -KAction* KStandardAction::aboutQt( KActionCollection* actionCollection ) -{ - KMainWindow* p = actionCollection->m_pMainWindow; - KAction* a = new KAction( i18n("About")+" Qt", 0, qApp, SLOT(aboutQt()), actionCollection, "about_qt", false, false ); - if(p) p->helpMenu->addAction( a ); - return a; -} - -KAction* KStandardAction::help( QWidget* parent, const char* slot, KActionCollection* actionCollection) -{ - KMainWindow* p = actionCollection->m_pMainWindow; - KAction* a = new KAction( i18n("Help"), Qt::Key_F1, parent, slot, actionCollection, "help-contents", false, false ); - if(p) p->helpMenu->addAction( a ); - return a; -} -KAction* KStandardAction::find( QWidget* parent, const char* slot, KActionCollection* actionCollection) -{ - KMainWindow* p = actionCollection->m_pMainWindow; - KAction* a = new KAction( i18n("Find"), Qt::CTRL+Qt::Key_F, parent, slot, actionCollection, "edit-find", false, false ); - if(p) p->editMenu->addAction( a ); - return a; -} - -KAction* KStandardAction::findNext( QWidget* parent, const char* slot, KActionCollection* actionCollection) -{ - KMainWindow* p = actionCollection->m_pMainWindow; - KAction* a = new KAction( i18n("Find Next"), Qt::Key_F3, parent, slot, actionCollection, "findNext", false, false ); - if(p) p->editMenu->addAction( a ); - return a; -} - -KAction* KActionCollection::addAction(const QString& name ) -{ - return new KAction( name, this ); -} - -void KActionCollection::addAction( const QString& name, QAction* pAction ) -{ - initAction( pAction, 0,0,this,name,false,true); -} - -KColorButton::KColorButton(QWidget* parent) -: QPushButton(parent) -{ - connect( this, SIGNAL(clicked()), this, SLOT(slotClicked())); -} - -QColor KColorButton::color() -{ - return m_color; -} - -void KColorButton::setColor( const QColor& color ) -{ - m_color = color; - update(); -} - -void KColorButton::paintEvent( QPaintEvent* e ) -{ - QPushButton::paintEvent(e); - QPainter p(this); - - int w = width(); - int h = height(); - p.fillRect( 10, 5, w-20, h-10, m_color ); - p.drawRect( 10, 5, w-20, h-10 ); -} - -void KColorButton::slotClicked() -{ -#ifndef QT_NO_COLORDIALOG - // Under Windows ChooseColor() should be used. (Nicer if few colors exist.) - QColor c = QColorDialog::getColor ( m_color, this ); - if ( c.isValid() ) m_color = c; -#endif - update(); -} - -#ifndef QT_NO_PRINTER -KPrinter::KPrinter() -{ -} -QList KPrinter::pageList() -{ - QList vl; - int to = toPage(); - for(int i=fromPage(); i<=to; ++i) - { - vl.push_back(i); - } - return vl; -} -void KPrinter::setCurrentPage(int) -{ -} -void KPrinter::setPageSelection(e_PageSelection) -{ -} -#endif - -QPixmap KIconLoader::loadIcon( const QString&, int, int ) -{ - return QPixmap(); -} - -KAboutData::KAboutData(const QByteArray &appName, const QByteArray & /*catalogName*/, const KLocalizedString & /*programName*/, - const QByteArray &version, const KLocalizedString &shortDescription, LicenseKey /*licenseType*/, - const KLocalizedString ©rightStatement, const KLocalizedString & /*text*/, - const QByteArray &homePageAddress, const QByteArray &bugsEmailAddress) -{ - s_copyright = copyrightStatement; - s_email = bugsEmailAddress; - s_appName = appName; - s_description = shortDescription; - s_version = version; - s_homepage = homePageAddress; -} - -KAboutData::KAboutData( const QString& /*name*/, const QString& /*appName*/, const QString& /*appName2*/, const QString& /*version*/ ) -{ -} - -void KAboutData::addAuthor(const QString& name, const QString& task, const QString& email, const QString& weblink) -{ - m_authorList.push_back( AboutDataEntry( name, task, email, weblink) ); -} - -void KAboutData::addCredit(const QString& name, const QString& task, const QString& email, const QString& weblink) -{ - m_creditList.push_back( AboutDataEntry( name, task, email, weblink) ); -} - -/* Option structure: e.g.: - { "m", 0, 0 }, - { "merge", I18N_NOOP("Automatically merge the input."), 0 }, - { "o", 0, 0 }, - { "output file", I18N_NOOP("Output file. Implies -m. E.g.: -o newfile.txt"), 0 }, - { "+[File1]", I18N_NOOP("file1 to open (base)"), 0 }, - { "+[File2]", I18N_NOOP("file2 to open"), 0 }, - { "+[File3]", I18N_NOOP("file3 to open"), 0 }, -*/ -//////////////// -static KCmdLineArgs s_cmdLineArgs; -static int s_argc; -static char** s_argv; - -struct KCmdLineOptionsItem -{ - QString name; - QString description; - int def; -}; -static QList s_options; - -static std::vector s_vOption; -static std::vector s_vArg; - -KCmdLineOptions& KCmdLineOptions::add( const QString& name, const QString& description ) -{ - KCmdLineOptionsItem i; - i.name = name; - i.description = description; - i.def = 0; - s_options.push_back(i); - return *this; -} - -KCmdLineArgs* KCmdLineArgs::parsedArgs() // static -{ - return &s_cmdLineArgs; -} - -void KCmdLineArgs::init( int argc, char**argv, KAboutData* pAboutData ) // static -{ - s_argc = argc; - s_argv = argv; - s_pAboutData = pAboutData; -} - -void KCmdLineArgs::addCmdLineOptions( const KCmdLineOptions& /*options*/ ) // static -{ - //s_pOptions = &options; -} - -int KCmdLineArgs::count() -{ - return s_vArg.size(); -} - -QString KCmdLineArgs::arg(int idx) -{ - return s_vArg[idx]; -} - -void KCmdLineArgs::clear() -{ -} - -QString KCmdLineArgs::getOption( const QString& s ) -{ - // Find the option - int j=0; - for( j=0; j<(int)s_vOption.size(); ++j ) - { - QString optName = s_options[j].name; - int pos = optName.indexOf( ' ' ); - int len = pos==-1 ? optName.length() : pos; - - if( s == optName.left( len ) ) - { - return s_vOption[j].isEmpty() ? QString() : s_vOption[j].last(); - } - } - - return QString(); -} - -QStringList KCmdLineArgs::getOptionList( const QString& s ) -{ - // Find the option - int j=0; - for( j=0; j<(int)s_vOption.size(); ++j ) - { - QString optName = s_options[j].name; - int pos = optName.indexOf( ' ' ); - int len = pos==-1 ? optName.length() : pos; - - if( s == optName.left( len ) ) - { - return s_vOption[j]; - } - } - - return QStringList(); -} - -bool KCmdLineArgs::isSet(const QString& s) -{ - // Find the option - int j=0; - for( j=0; j<(int)s_vOption.size(); ++j ) - { - QString optName = s_options[j].name; - if( s == optName ) - { - return ! s_vOption[j].isEmpty(); - } - } - - return false; -} - - -/////////////////// -KApplication* kapp; - -KApplication::KApplication() -: QApplication( s_argc,s_argv ) -{ - kapp = this; - #if ! ( defined(Q_OS_WIN) ) - parseOptions(); - #endif -} - -void KApplication::parseOptions() -{ - //setStyle( new QWindowsStyle ); // doesn't show checkmarks on checkable icons in menu - - int nofOptions=0; - int nofArgs=0; - int i=0; - while( i < s_options.size() ) - { - if ( s_options[i].name[0]=='[' ) - nofArgs++; - else - nofOptions++; - - ++i; - } - - QStringList args = QCoreApplication::arguments(); - // First find the option "-config" or "--config" to allow loading of options - QString configFileName; - for( i=1; i0 && ( (arg[1]=='-' && len2-2==len && optName.left(len) == arg.mid(2,len)) || - (len2-1==len && optName.left(len) == arg.mid(1,len)) )) - { - if (s_options[j].description == 0) // alias, because without description. - { - ++j; - optName = s_options[j].name; - pos = optName.indexOf( ' ' ); - } - if (pos!=-1){ ++i; s_vOption[j].append( args[i] ); } //use param - else { s_vOption[j].append("1"); } //set state - break; - } - } - if (j==nofOptions) - { - QString s; - s = QString("Unknown option: ") + arg + "\n"; - s += "If KDiff3 should ignore this option, run KDiff3 normally and edit\n" - "the \"Command line options to ignore\" in the \"Integration Settings\".\n\n"; - - s += "KDiff3-Usage when starting via commandline: \n"; - s += "- Comparing 2 files:\t\tkdiff3 file1 file2\n"; - s += "- Merging 2 files: \t\tkdiff3 file1 file2 -o outputfile\n"; - s += "- Comparing 3 files:\t\tkdiff3 file1 file2 file3\n"; - s += "- Merging 3 files: \t\tkdiff3 file1 file2 file3 -o outputfile\n"; - s += " Note that file1 will be treated as base of file2 and file3.\n"; - s += "\n"; - s += "If you start without arguments, then a dialog will appear\n"; - s += "where you can select your files via a filebrowser.\n"; - s += "\n"; - - s += "Options:\n"; - - j=0; - int pos=s.length(); - for( j=0; j1 ) s += "-"; - } - s += s_options[j].name; - s += QString().fill(' ', minMaxLimiter( 20 - ((int)s.length()-pos), 3, 20 ) ); - s += s_options[j].description; - s +="\n"; - pos=s.length(); - } - else - { - s += "-"; - if ( s_options[j].name.length()>1 ) s += "-"; - s += s_options[j].name; - s += ", "; - } - } - - s += "\n"+i18n("For more documentation, see the help-menu or the subdirectory doc.")+"\n"; -#if defined(Q_OS_WIN) - // A windows program has no console - if ( 0==QMessageBox::information(0, i18n("KDiff3-Usage"), s, i18n("Ignore"),i18n("Exit") ) ) - continue; -#else - fprintf(stderr, "%s\n", s.toLatin1().constData()); -#endif - - ::exit(-1); - } - } - else - s_vArg.push_back( arg ); - } -} - -KConfigGroup* KApplication::config() -{ - return &m_config; -} - -bool KApplication::isRestored() -{ - return false; -} - -KApplication* KApplication::kApplication() -{ - return kapp; -} - -KIconLoader* KApplication::iconLoader() -{ - return &m_iconLoader; -} - - -namespace KIO -{ - SimpleJob* mkdir( KUrl ){return 0;} - SimpleJob* rmdir( KUrl ){return 0;} - SimpleJob* file_delete( KUrl, int ){return 0;} - FileCopyJob* file_move( KUrl, KUrl, int, int ) {return 0;} - FileCopyJob* file_copy( KUrl, KUrl, int, int ) {return 0;} - CopyJob* link( KUrl, KUrl, bool ) {return 0;} - ListJob* listRecursive( KUrl, bool, bool ){return 0;} - ListJob* listDir( KUrl, bool, bool ){return 0;} - StatJob* stat( KUrl, bool, int, int ){return 0;} - TransferJob* get( KUrl, int ){return (TransferJob*)0;} - TransferJob* put( KUrl, int, int ){return (TransferJob*)0;} -}; - -KActionCollection* KParts::Part::actionCollection() -{ - return 0; -} - -KApplication* KParts::Part::instance() -{ - return kapp; -} - - -KLibLoader* KLibLoader::self() -{ - static KLibLoader ll; - return ≪ -} - -extern "C" void* init_libkdiff3part(); -KLibFactory* KLibLoader::factory(QString const&) -{ - return (KLibFactory*) init_libkdiff3part(); -} - -QObject* KLibFactory::create(QObject* pParent, const QString& name, const QString& classname ) -{ - KParts::Factory* f = qobject_cast(this); - if (f!=0) - return f->createPartObject( (QWidget*)pParent, name.toLatin1(), - pParent, name.toLatin1(), - classname.toLatin1(), QStringList() ); - else - return 0; -} - - - - -#include "kreplacements.moc" diff --git a/src/kreplacements/kshortcutsdialog.h b/src/kreplacements/kshortcutsdialog.h deleted file mode 100644 --- a/src/kreplacements/kshortcutsdialog.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kstandardaction.h b/src/kreplacements/kstandardaction.h deleted file mode 100644 --- a/src/kreplacements/kstandardaction.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kstandarddirs.h b/src/kreplacements/kstandarddirs.h deleted file mode 100644 --- a/src/kreplacements/kstandarddirs.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kstatusbar.h b/src/kreplacements/kstatusbar.h deleted file mode 100644 --- a/src/kreplacements/kstatusbar.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/ktemporaryfile.h b/src/kreplacements/ktemporaryfile.h deleted file mode 100644 --- a/src/kreplacements/ktemporaryfile.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/ktoggleaction.h b/src/kreplacements/ktoggleaction.h deleted file mode 100644 --- a/src/kreplacements/ktoggleaction.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/ktoolbar.h b/src/kreplacements/ktoolbar.h deleted file mode 100644 --- a/src/kreplacements/ktoolbar.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kunload.h b/src/kreplacements/kunload.h deleted file mode 100644 --- a/src/kreplacements/kunload.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/kreplacements/kurl.h b/src/kreplacements/kurl.h deleted file mode 100644 --- a/src/kreplacements/kurl.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "kreplacements.h" - diff --git a/src/main.cpp b/src/main.cpp --- a/src/main.cpp +++ b/src/main.cpp @@ -101,21 +101,6 @@ } #endif -#if defined(KREPLACEMENTS_H) && !defined(QT_NO_TRANSLATION) -class ContextFreeTranslator : public QTranslator -{ - public: - ContextFreeTranslator(QObject* pParent) : QTranslator(pParent) {} - QString translate(const char* context, const char* sourceText, const char* disambiguation, int /*n*/) const /*override*/ - { - if(context != 0) - return QTranslator::translate(0, sourceText, disambiguation); - else - return QString(); - } -}; -#endif - int main(int argc, char* argv[]) { QApplication app(argc, argv); // KAboutData and QCommandLineParser depend on this being setup. @@ -215,25 +200,6 @@ app.setOrganizationDomain(aboutData.organizationDomain()); app.setApplicationVersion(aboutData.version()); -#if defined(KREPLACEMENTS_H) && !defined(QT_NO_TRANSLATION) - QString locale; - - locale = app.config()->readEntry("Language", "Auto"); - int spacePos = locale.indexOf(' '); - if(spacePos > 0) locale = locale.left(spacePos); - ContextFreeTranslator kdiff3Translator(0); - QTranslator qtTranslator(0); - if(locale != "en_orig") - { - QString translationDir = getTranslationDir(locale); - kdiff3Translator.load(QLocale::system(), QString("kdiff3_"), translationDir); - app.installTranslator(&kdiff3Translator); - - qtTranslator.load(QLocale::system(), QString("qt_"), translationDir); - app.installTranslator(&qtTranslator); - } -#endif - KDiff3Shell* p = new KDiff3Shell(); p->show(); //p->setWindowState( p->windowState() | Qt::WindowActive ); // Patch for ubuntu: window not active on startup diff --git a/src/optiondialog.cpp b/src/optiondialog.cpp --- a/src/optiondialog.cpp +++ b/src/optiondialog.cpp @@ -1465,153 +1465,6 @@ QLabel* label; -#ifdef KREPLACEMENTS_H - - static const char* countryMap[] = { - "af Afrikaans", - "ar Arabic", - "az Azerbaijani", - "be Belarusian", - "bg Bulgarian", - "bn Bengali", - "bo Tibetan", - "br Breton", - "bs Bosnian", - "ca Catalan", - "ca@valencia Catalan (Valencian)", - "cs Czech", - "cy Welsh", - "da Danish", - "de German", - "el Greek", - "en_GB British English", - "eo Esperanto", - "es Spanish", - "et Estonian", - "eu Basque", - "fa Farsi (Persian)", - "fi Finnish", - "fo Faroese", - "fr French", - "ga Irish Gaelic", - "gl Galician", - "gu Gujarati", - "he Hebrew", - "hi Hindi", - "hne Chhattisgarhi", - "hr Croatian", - "hsb Upper Sorbian", - "hu Hungarian", - "id Indonesian", - "is Icelandic", - "it Italian", - "ja Japanese", - "ka Georgian", - "ko Korean", - "ku Kurdish", - "lo Lao", - "lt Lithuanian", - "lv Latvian", - "mi Maori", - "mk Macedonian", - "ml Malayalam" - "mn Mongolian", - "ms Malay", - "mt Maltese", - "nb Norwegian Bookmal", - "nds Low Saxon", - "nl Dutch", - "nn Norwegian Nynorsk", - "nso Northern Sotho", - "oc Occitan", - "pl Polish", - "pt Portuguese", - "pt_BR Brazilian Portuguese", - "ro Romanian", - "ru Russian", - "rw Kinyarwanda", - "se Northern Sami", - "sk Slovak", - "sl Slovenian", - "sq Albanian", - "sr Serbian", - "sr@Latn Serbian", - "ss Swati", - "sv Swedish", - "ta Tamil", - "tg Tajik", - "th Thai", - "tr Turkish", - "uk Ukrainian", - "uz Uzbek", - "ven Venda", - "vi Vietnamese", - "wa Walloon", - "xh Xhosa", - "zh_CN Chinese Simplified", - "zh_TW Chinese Traditional", - "zu Zulu"}; - - label = new QLabel(i18n("Language (restart required)"), page); - gbox->addWidget(label, line, 0); - OptionComboBox* pLanguage = new OptionComboBox(0, "Language", &m_options.m_language, page, this); - gbox->addWidget(pLanguage, line, 1); - pLanguage->addItem("Auto"); // Must not translate, won't work otherwise! - pLanguage->addItem("en_orig"); - -#if !defined(Q_OS_WIN) && !defined(Q_OS_MAC) - // Read directory: Find all kdiff3_*.qm-files and insert the found files here - QDir localeDir("/usr/share/locale"); // See also kreplacements.cpp: getTranslationDir() - QStringList dirList = localeDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); - - for(int i = 0; i < dirList.size(); ++i) - { - QString languageId = dirList[i]; - if(!QFile::exists("/usr/share/locale/" + languageId + "/LC_MESSAGES/kdiff3.qm")) - continue; -#else - // Read directory: Find all kdiff3_*.qm-files and insert the found files here - - QDir localeDir(getTranslationDir(QString())); - QStringList fileList = localeDir.entryList(QStringList("kdiff3_*.qm"), QDir::Files, QDir::Name); - for(int i = 0; i < fileList.size(); ++i) - { - QString fileName = fileList[i]; - // Skip the "kdiff3_" and omit the .qm - QString languageId = fileName.mid(7, fileName.length() - 10); -#endif - - unsigned int countryIdx = 0; - for(countryIdx = 0; countryIdx < sizeof(countryMap) / sizeof(countryMap[0]); ++countryIdx) - { - QString fullName = countryMap[countryIdx]; - if(QString(languageId + " ") == fullName.left(languageId.length() + 1)) - { - languageId += " (" + fullName.mid(languageId.length() + 1) + ")"; - } - } - - pLanguage->addItem(languageId); - } - - label->setToolTip(i18n( - "Choose the language of the GUI strings or \"Auto\".\n" - "For a change of language to take place, quit and restart KDiff3.")); - ++line; -/* - label = new QLabel( i18n("Codec for file contents"), page ); - gbox->addWidget( label, line, 0 ); - OptionComboBox* pFileCodec = new OptionComboBox( 0, "FileCodec", &m_options.m_fileCodec, page, this ); - gbox->addWidget( pFileCodec, line, 1 ); - insertCodecs( pFileCodec ); - label->setToolTip( i18n( - "Choose the codec that should be used for your input files\n" - "or \"Auto\" if unsure." ) - ); - ++line; -*/ -#endif - m_pSameEncoding = new OptionCheckBox(i18n("Use the same encoding for everything:"), true, "SameEncoding", &m_options.m_bSameEncoding, page, this); gbox->addWidget(m_pSameEncoding, line, 0, 1, 2); m_pSameEncoding->setToolTip(i18n(