Make source compile with QT5

qt5
Thomas Hooge 7 years ago
parent e78117f906
commit 06b7abe50f
  1. 2
      src/Kdb3Database.cpp
  2. 6
      src/KpxConfig.h
  3. 2
      src/dialogs/DatabaseSettingsDlg.cpp
  4. 2
      src/dialogs/DatabaseSettingsDlg.h
  5. 2
      src/dialogs/EditEntryDlg.h
  6. 4
      src/dialogs/EditGroupDlg.cpp
  7. 4
      src/dialogs/EditGroupDlg.h
  8. 2
      src/dialogs/PasswordGenDlg.cpp
  9. 2
      src/dialogs/PasswordGenDlg.h
  10. 2
      src/dialogs/SelectIconDlg.cpp
  11. 2
      src/dialogs/SelectIconDlg.h
  12. 2
      src/dialogs/SettingsDlg.cpp
  13. 2
      src/dialogs/SimplePasswordDlg.cpp
  14. 2
      src/dialogs/SimplePasswordDlg.h
  15. 2
      src/import/Import_KeePassX_Xml.cpp
  16. 4
      src/import/Import_PwManager.cpp
  17. 11
      src/lib/EntryView.cpp
  18. 4
      src/lib/FileDialogs.cpp
  19. 2
      src/lib/GroupView.cpp
  20. 10
      src/lib/ShortcutWidget.cpp
  21. 4
      src/lib/ShortcutWidget.h
  22. 2
      src/lib/UrlLabel.cpp
  23. 2
      src/lib/UrlLabel.h
  24. 12
      src/lib/random.cpp
  25. 21
      src/lib/tools.cpp
  26. 26
      src/main.cpp
  27. 2
      src/main.h
  28. 54
      src/mainwindow.cpp
  29. 2
      src/mainwindow.h
  30. 2
      src/src.pro

@ -883,7 +883,7 @@ void Kdb3Database::GroupHandle::setIndex(int index){
*/
bool Kdb3Database::convHexToBinaryKey(char* HexKey, char* dst){
QString hex=QString::fromAscii(HexKey,64);
QString hex=QString::fromLatin1(HexKey,64);
for(int i=0; i<64; i+=2){
bool err;
quint8 bin;

@ -25,11 +25,11 @@
#include "lib/AutoType.h"
#if defined(Q_WS_MAC)
#if defined(Q_OS_MAC)
# define DEFAULT_MOUNT_DIR "/Volumes/"
#elif defined(Q_WS_X11)
#elif defined(Q_OS_LINUX)
# define DEFAULT_MOUNT_DIR "/media/"
#elif defined(Q_WS_WIN)
#elif defined(Q_OS_WIN32)
# define DEFAULT_MOUNT_DIR "/"
#else
# define DEFAULT_MOUNT_DIR QString()

@ -23,7 +23,7 @@
#include "Kdb3Database.h"
CDbSettingsDlg::CDbSettingsDlg(QWidget* parent,IDatabase* db, Qt::WFlags fl)
CDbSettingsDlg::CDbSettingsDlg(QWidget* parent,IDatabase* db, Qt::WindowFlags fl)
: QDialog(parent,fl)
{
setupUi(this);

@ -27,7 +27,7 @@ class CDbSettingsDlg : public QDialog, private Ui_DatabaseSettingsDlg
{
Q_OBJECT
public:
CDbSettingsDlg(QWidget* parent,IDatabase* db, Qt::WFlags fl = 0 );
CDbSettingsDlg(QWidget* parent,IDatabase* db, Qt::WindowFlags fl = 0 );
~CDbSettingsDlg();
virtual void paintEvent(QPaintEvent *);

@ -28,7 +28,7 @@ class CEditEntryDlg : public QDialog, private Ui_EditEntryDialog
{
Q_OBJECT
public:
CEditEntryDlg(IDatabase* _db, IEntryHandle* _entry,QWidget* parent = 0, bool newEntry = FALSE);
CEditEntryDlg(IDatabase* _db, IEntryHandle* _entry,QWidget* parent = 0, bool newEntry = false);
~CEditEntryDlg();
void InitGroupComboBox();
static void saveAttachment(IEntryHandle* pEntry, QWidget* ParentWidget=NULL);

@ -22,7 +22,7 @@
#include "EditGroupDlg.h"
#include "SelectIconDlg.h"
CEditGroupDialog::CEditGroupDialog(IDatabase* database,IGroupHandle* Handle,QWidget* parent, Qt::WFlags fl)
CEditGroupDialog::CEditGroupDialog(IDatabase* database,IGroupHandle* Handle,QWidget* parent, Qt::WindowFlags fl)
: QDialog(parent,fl)
{
db = database;
@ -35,7 +35,7 @@ CEditGroupDialog::CEditGroupDialog(IDatabase* database,IGroupHandle* Handle,QWid
}
CEditGroupDialog::CEditGroupDialog(IDatabase* database,CGroup* Group,QWidget* parent, Qt::WFlags fl)
CEditGroupDialog::CEditGroupDialog(IDatabase* database,CGroup* Group,QWidget* parent, Qt::WindowFlags fl)
: QDialog(parent,fl)
{
db = database;

@ -27,8 +27,8 @@ class CEditGroupDialog : public QDialog, private Ui_EditGroupDialog
{
Q_OBJECT
public:
CEditGroupDialog(IDatabase*,IGroupHandle*,QWidget* parent = 0, Qt::WFlags fl = 0 );
CEditGroupDialog(IDatabase*,CGroup*,QWidget* parent = 0, Qt::WFlags fl = 0 );
CEditGroupDialog(IDatabase*,IGroupHandle*,QWidget* parent = 0, Qt::WindowFlags fl = 0 );
CEditGroupDialog(IDatabase*,CGroup*,QWidget* parent = 0, Qt::WindowFlags fl = 0 );
~CEditGroupDialog();
private:

@ -28,7 +28,7 @@
bool CGenPwDialog::EntropyCollected=false;
CGenPwDialog::CGenPwDialog(QWidget* parent, bool StandAloneMode,Qt::WFlags fl)
CGenPwDialog::CGenPwDialog(QWidget* parent, bool StandAloneMode,Qt::WindowFlags fl)
: QDialog(parent,fl)
{
setupUi(this);

@ -28,7 +28,7 @@ class CGenPwDialog : public QDialog, public Ui_GenPwDlg
{
Q_OBJECT
public:
CGenPwDialog(QWidget* parent, bool StandAloneMode, Qt::WFlags fl = 0);
CGenPwDialog(QWidget* parent, bool StandAloneMode, Qt::WindowFlags fl = 0);
~CGenPwDialog();
private:

@ -21,7 +21,7 @@
#include "dialogs/SelectIconDlg.h"
CSelectIconDlg::CSelectIconDlg(IDatabase* database,int CurrentId,QWidget* parent, Qt::WFlags fl):QDialog(parent,fl){
CSelectIconDlg::CSelectIconDlg(IDatabase* database,int CurrentId,QWidget* parent, Qt::WindowFlags fl):QDialog(parent,fl){
setupUi(this);
db=database;
Id=CurrentId;

@ -27,7 +27,7 @@ class CSelectIconDlg:public QDialog, private Ui_SelectIconDlg{
Q_OBJECT
public:
CSelectIconDlg(IDatabase* db,int ImageID,QWidget* parent = 0, Qt::WFlags fl = 0);
CSelectIconDlg(IDatabase* db,int ImageID,QWidget* parent = 0, Qt::WindowFlags fl = 0);
private slots:
void OnAddIcon();

@ -70,7 +70,7 @@ CSettingsDlg::CSettingsDlg(QWidget* parent):QDialog(parent,Qt::Dialog)
Edit_GlobalShortcut->setVisible(false);
CheckBox_EntryTitlesMatch->setVisible(false);
#endif
#ifdef Q_WS_MAC
#ifdef Q_OS_MAC
CheckBox_AlwaysOnTop->setVisible(false);
#endif

@ -21,7 +21,7 @@
#include "SimplePasswordDlg.h"
SimplePasswordDialog::SimplePasswordDialog(QWidget* parent, Qt::WFlags fl)
SimplePasswordDialog::SimplePasswordDialog(QWidget* parent, Qt::WindowFlags fl)
: QDialog(parent,fl)
{
setupUi(this);

@ -28,7 +28,7 @@ class SimplePasswordDialog : public QDialog, private Ui_SimplePasswordDialog
Q_OBJECT
public:
SimplePasswordDialog(QWidget* parent = 0, Qt::WFlags fl = 0 );
SimplePasswordDialog(QWidget* parent = 0, Qt::WindowFlags fl = 0 );
~SimplePasswordDialog();
QString password;

@ -124,7 +124,7 @@ bool Import_KeePassX_Xml::parseEntry(const QDomElement& EntryElement,IGroupHandl
else if(ChildNodes.item(i).toElement().tagName()=="bindesc")
entry->setBinaryDesc(ChildNodes.item(i).toElement().text());
else if(ChildNodes.item(i).toElement().tagName()=="bin")
entry->setBinary(QByteArray::fromBase64(ChildNodes.item(i).toElement().text().toAscii()));
entry->setBinary(QByteArray::fromBase64(ChildNodes.item(i).toElement().text().toLatin1()));
else if(ChildNodes.item(i).toElement().tagName()=="comment"){
QDomNodeList Lines=ChildNodes.item(i).childNodes();
QString comment;

@ -44,7 +44,7 @@ bool Import_PwManager::importDatabase(QWidget* GuiParent, IDatabase* db){
file->read(buffer,len);
file->close();
delete file;
if(QString::fromAscii(buffer,17)!="PWM_PASSWORD_FILE")
if(QString::fromLatin1(buffer,17)!="PWM_PASSWORD_FILE")
{QMessageBox::critical(GuiParent,tr("Import Failed"),tr("File is no valid PwManager file.")); return false;}
offset+=17;
if(buffer[offset]!=0x05)
@ -81,7 +81,7 @@ bool Import_PwManager::importDatabase(QWidget* GuiParent, IDatabase* db){
byte* Key=new byte[pwlen];
byte* xml=new byte[len-offset+1];
xml[len-offset]=0;
memcpy(Key,password.toAscii(),pwlen);
memcpy(Key,password.toLatin1(),pwlen);
QCryptographicHash sha(QCryptographicHash::Sha1);
sha.addData((const char*)Key,pwlen);
QByteArray key_hash = sha.result();

@ -18,6 +18,9 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <QWidget>
#include <QMimeData>
#include <QDrag>
#include <QHeaderView>
#include <QClipboard>
#include <QProcess>
@ -35,9 +38,9 @@ KeepassEntryView* pEntryView;*/
KeepassEntryView::KeepassEntryView(QWidget* parent) : QTreeWidget(parent) {
ViewMode=Normal;
AutoResizeColumns = true;
header()->setResizeMode(QHeaderView::Interactive);
header()->setSectionResizeMode(QHeaderView::Interactive);
header()->setStretchLastSection(false);
header()->setClickable(true);
header()->setSectionsClickable(true);
header()->setCascadingSectionResizes(true);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
retranslateColumns();
@ -338,7 +341,7 @@ void KeepassEntryView::editEntry(EntryViewItem* item){
IEntryHandle* handle = item->EntryHandle;
CEntry old = handle->data();
CEditEntryDlg dlg(db,handle,this,false);
CEditEntryDlg dlg(db,handle,this,true);
int result = dlg.exec();
switch(result){
case 0: //canceled or no changes
@ -483,7 +486,7 @@ void KeepassEntryView::OnClipboardTimeOut(){
if(Clipboard->supportsSelection()){
Clipboard->clear(QClipboard::Selection);
}
#ifdef Q_WS_X11
#ifdef Q_OS_LINUX
QProcess::startDetached("dcop klipper klipper clearClipboardHistory");
QProcess::startDetached("dbus-send --type=method_call --dest=org.kde.klipper /klipper "
"org.kde.klipper.klipper.clearClipboardHistory");

@ -19,7 +19,7 @@
#include <QFileDialog>
#if QT_VERSION >= 0x040400
#include <QDesktopServices>
#include <QStandardPaths>
#endif
IFileDialog* KpxFileDialogs::iFileDialog=NULL;
@ -155,7 +155,7 @@ QString FileDlgHistory::getDir(const QString& name){
Entry e=History.value(name);
if(e.isNull()) {
#if QT_VERSION >= 0x040400
return QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
return QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation).at(0);
#else
return QDir::homePath();
#endif

@ -22,6 +22,8 @@
#include "GroupView.h"
#include "dialogs/EditGroupDlg.h"
#include <QDrag>
#include <QMimeData>
#include <QBrush>
#include <QHeaderView>

@ -19,7 +19,7 @@
#include "ShortcutWidget.h"
#if defined(GLOBAL_AUTOTYPE) && (defined(Q_WS_X11) || defined(Q_WS_MAC))
#if defined(GLOBAL_AUTOTYPE) && (defined(Q_OS_LINUX) || defined(Q_OS_MAC))
#include <QKeyEvent>
#include <QPalette>
@ -62,7 +62,7 @@ void ShortcutWidget::keyEvent(QKeyEvent* event, bool release){
if (release && lock)
return;
#ifdef Q_WS_X11
#ifdef Q_OS_LINUX
AutoTypeGlobalX11* autoTypeGlobal = static_cast<AutoTypeGlobalX11*>(autoType);
unsigned int mods = HelperX11::keyboardModifiers(QX11Info::display());
@ -70,7 +70,7 @@ void ShortcutWidget::keyEvent(QKeyEvent* event, bool release){
mods & ShiftMask, mods & autoTypeGlobal->maskAlt(),
mods & autoTypeGlobal->maskAltGr(), mods & autoTypeGlobal->maskMeta());
#endif
#ifdef Q_WS_MAC
#ifdef Q_OS_MAC
AutoTypeGlobalMacX* autoTypeGlobal = static_cast<AutoTypeGlobalMacX*>(autoType);
quint32 mods = event->nativeModifiers();
// mods >> 16 bits denote outside main keyboard eg keypad, arrow keys, home, end, etc
@ -90,7 +90,7 @@ void ShortcutWidget::keyEvent(QKeyEvent* event, bool release){
void ShortcutWidget::displayShortcut(quint32 key, bool release, bool ctrl, bool shift, bool alt, bool altgr, bool win){
QString text;
#ifdef Q_WS_X11
#ifdef Q_OS_LINUX
if (ctrl)
text.append(tr("Ctrl")).append(" + ");
if (shift)
@ -112,7 +112,7 @@ void ShortcutWidget::displayShortcut(quint32 key, bool release, bool ctrl, bool
text.append(static_cast<quint32>(keysym));
}
#endif
#ifdef Q_WS_MAC
#ifdef Q_OS_MAC
if (ctrl)
text.append(kControlUnicode);
if (shift)

@ -20,7 +20,7 @@
#define SHORTCUT_WIDGET_H
#if defined(GLOBAL_AUTOTYPE) && (defined(Q_WS_X11) || defined(Q_WS_MAC))
#if defined(GLOBAL_AUTOTYPE) && (defined(Q_OS_LINUX) || defined(Q_OS_MAC))
#include "lib/AutoType.h"
#endif
@ -29,7 +29,7 @@ class ShortcutWidget : public QLineEdit{
public:
ShortcutWidget(QWidget* parent = 0);
#if defined(GLOBAL_AUTOTYPE) && (defined(Q_WS_X11) || defined(Q_WS_MAC))
#if defined(GLOBAL_AUTOTYPE) && (defined(Q_OS_LINUX) || defined(Q_OS_MAC))
Shortcut shortcut();
void setShortcut(const Shortcut& s);

@ -21,7 +21,7 @@
#include "UrlLabel.h"
LinkLabel::LinkLabel(QWidget *parent,const QString& text, int x, int y,Qt::WFlags f) : QLabel(parent,f){
LinkLabel::LinkLabel(QWidget *parent,const QString& text, int x, int y,Qt::WindowFlags f) : QLabel(parent,f){
QFont font(parentWidget()->font());
font.setUnderline(true);
setFont(font);

@ -25,7 +25,7 @@ class LinkLabel : public QLabel{
Q_OBJECT
public:
LinkLabel(QWidget *parent,const QString& text=QString::null, int x=0, int y=0,Qt::WFlags f=0);
LinkLabel(QWidget *parent,const QString& text=QString::null, int x=0, int y=0,Qt::WindowFlags f=0);
~LinkLabel();
void setPos(int x,int y);
QString url();

@ -21,9 +21,11 @@
#include "random.h"
#if defined(Q_WS_X11) || defined(Q_WS_MAC)
#if defined(Q_OS_LINUX) || defined(Q_OS_MAC)
#include <sys/types.h>
#include <unistd.h>
#include <QFile>
#elif defined(Q_WS_WIN)
#elif defined(Q_OS_WIN32)
#include <windows.h>
#include <wincrypt.h>
#include <QSysInfo>
@ -57,7 +59,7 @@ quint32 randintRange(quint32 min, quint32 max){
return min + randint(max-min+1);
}
#if defined(Q_WS_X11) || defined(Q_WS_MAC)
#if defined(Q_OS_LINUX) || defined(Q_OS_MAC)
extern bool getNativeEntropy(quint8* buffer, int length) {
QFile dev_urandom("/dev/urandom");
@ -66,7 +68,7 @@ extern bool getNativeEntropy(quint8* buffer, int length) {
return (dev_urandom.read((char*)buffer,length) == length);
}
#elif defined(Q_WS_WIN)
#elif defined(Q_OS_WIN32)
extern bool getNativeEntropy(quint8* buffer, int length) {
HCRYPTPROV handle;
@ -92,7 +94,7 @@ extern void initStdRand(){
stream << QCursor::pos();
stream << QDateTime::currentDateTime().toTime_t();
stream << QTime::currentTime().msec();
#ifdef Q_WS_WIN
#ifdef Q_OS_WIN32
stream << (quint32) GetCurrentProcessId();
#else
stream << getpid();

@ -22,10 +22,10 @@
#include <QProcess>
#include <QTranslator>
#if defined(Q_WS_X11) || defined(Q_WS_MAC)
#if defined(Q_OS_LINUX) || defined(Q_OS_MAC)
#include <sys/mman.h>
#include <unistd.h>
#elif defined(Q_WS_WIN)
#elif defined(Q_OS_WIN32)
#include <QLibrary>
#include <windows.h>
#include <io.h>
@ -48,7 +48,10 @@ void createBanner(QPixmap* Pixmap,const QPixmap* IconAlpha,const QString& Text,i
QPixmap Icon(32,32);
if(IconAlpha){
Icon.fill(TextColor);
Icon.setAlphaChannel(*IconAlpha);
// TODO Hier Fix!
// Icon.setAlphaChannel(*IconAlpha);
// QPainter::setCompositionMode(QPainter::CompositionMode_SourceOver)
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
painter.drawPixmap(10,10,Icon);
}
@ -220,9 +223,9 @@ bool createKeyFile(const QString& filename,QString* error,int length, bool Hex){
}
bool lockPage(void* addr, int len){
#if defined(Q_WS_X11) || defined(Q_WS_MAC)
#if defined(Q_OS_LINUX) || defined(Q_OS_MAC)
return (mlock(addr, len)==0);
#elif defined(Q_WS_WIN)
#elif defined(Q_OS_WIN32)
return VirtualLock(addr, len);
#else
return false;
@ -230,9 +233,9 @@ bool lockPage(void* addr, int len){
}
bool unlockPage(void* addr, int len){
#if defined(Q_WS_X11) || defined(Q_WS_MAC)
#if defined(Q_OS_LINUX) || defined(Q_OS_MAC)
return (munlock(addr, len)==0);
#elif defined(Q_WS_WIN)
#elif defined(Q_OS_WIN)
return VirtualUnlock(addr, len);
#else
return false;
@ -242,9 +245,9 @@ bool unlockPage(void* addr, int len){
bool syncFile(QFile* file) {
if (!file->flush())
return false;
#if defined(Q_WS_X11) || defined(Q_WS_MAC)
#if defined(Q_OS_LINUX) || defined(Q_OS_MAC)
return (fsync(file->handle())==0);
#elif defined(Q_WS_WIN)
#elif defined(Q_OS_WIN32)
return (_commit(file->handle())==0);
#else
return false;

@ -21,10 +21,10 @@
#include "main.h"
#include "mainwindow.h"
#if defined(Q_WS_X11) && defined(GLOBAL_AUTOTYPE)
#if defined(Q_OS_LINUX) && defined(GLOBAL_AUTOTYPE)
#include "Application_X11.h"
#endif
#ifdef Q_WS_WIN
#ifdef Q_OS_WIN32
#include <Windows.h>
#endif
@ -52,7 +52,7 @@ IIconTheme* IconLoader=NULL;
int main(int argc, char **argv)
{
#ifdef Q_WS_WIN
#ifdef Q_OS_WIN32
// Make sure Windows doesn't load DLLs from the current working directory
SetDllDirectoryA("");
SetSearchPathMode(BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE);
@ -60,7 +60,7 @@ int main(int argc, char **argv)
setlocale(LC_CTYPE, "");
#if defined(Q_WS_X11) && defined(AUTOTYPE)
#if defined(Q_OS_LINUX) && defined(AUTOTYPE)
QApplication* app = new KeepassApplication(argc,argv);
#else
QApplication* app = new QApplication(argc,argv);
@ -72,7 +72,7 @@ int main(int argc, char **argv)
AppDir = QApplication::applicationFilePath();
AppDir.truncate(AppDir.lastIndexOf("/"));
#if defined(Q_WS_X11)
#if defined(Q_OS_LINUX)
DataDir = AppDir+"/../share/keepassx";
if (!QFile::exists(DataDir) && QFile::exists(AppDir+"/share"))
DataDir = AppDir+"/share";
@ -88,11 +88,11 @@ int main(int argc, char **argv)
HomeDir = QDir::homePath() + '/' + qenv;
}
HomeDir += "/keepassx";
#elif defined(Q_WS_MAC)
#elif defined(Q_OS_MAC)
HomeDir = QDir::homePath()+"/.keepassx";
DataDir = AppDir+"/../Resources/keepassx";
#else //Q_WS_WIN
HomeDir = qtWindowsConfigPath(CSIDL_APPDATA);
#elif defined(Q_OS_WIN32)
HomeDir = qtWindowsConfigPath(0);
if(!HomeDir.isEmpty() && QFile::exists(HomeDir))
HomeDir = QDir::fromNativeSeparators(HomeDir)+"/KeePassX";
else
@ -126,7 +126,7 @@ int main(int argc, char **argv)
else
IniFilename=args.configLocation();
#ifdef Q_WS_X11
#ifdef Q_OS_LINUX
{
QString OldHomeDir = QDir::homePath()+"/.keepassx";
if (args.configLocation().isEmpty() && QFile::exists(OldHomeDir+"/config") && !QFile::exists(HomeDir+"/config")) {
@ -144,7 +144,7 @@ int main(int argc, char **argv)
// PlugIns
/*
#ifdef Q_WS_X11
#ifdef Q_OS_LINUX
if(config->integrPlugin()!=KpxConfig::NoIntegr){
QString LibName="libkeepassx-";
if(config->integrPlugin()==KpxConfig::KDE)
@ -199,7 +199,7 @@ int main(int argc, char **argv)
installTranslator();
#ifdef Q_WS_MAC
#ifdef Q_OS_MAC
QApplication::processEvents();
if (args.file().isEmpty() && !eventListener->file().isEmpty()) {
args.setFile(eventListener->file());
@ -207,7 +207,7 @@ int main(int argc, char **argv)
#endif
KeepassMainWindow *mainWin = new KeepassMainWindow(args.file(), args.startMinimized(), args.startLocked());
#ifdef Q_WS_MAC
#ifdef Q_OS_MAC
eventListener->setMainWin(mainWin);
#endif
@ -306,7 +306,7 @@ bool EventListener::eventFilter(QObject*, QEvent* event){
EventOccurred = true;
}
#ifdef Q_WS_MAC
#ifdef Q_OS_MAC
if (event->type() == QEvent::FileOpen) {
QString filename = static_cast<QFileOpenEvent*>(event)->file();
if (pMainWindow) {

@ -53,7 +53,7 @@ private:
class EventListener : public QObject {
Q_OBJECT
#ifdef Q_WS_MAC
#ifdef Q_OS_MAC
public:
EventListener() { pMainWindow = NULL; };
inline QString file() { return pFile; };

@ -43,7 +43,7 @@
#include "dialogs/ManageBookmarksDlg.h"
#include "dialogs/HelpDlg.h"
#if defined(GLOBAL_AUTOTYPE) && defined(Q_WS_MAC)
#if defined(GLOBAL_AUTOTYPE) && defined(Q_OS_MAC)
#include "lib/HelperMacX.h"
#endif
@ -53,7 +53,7 @@ Import_KWalletXml import_KWalletXml;
Export_Txt export_Txt;
Export_KeePassX_Xml export_KeePassX_Xml;
KeepassMainWindow::KeepassMainWindow(const QString& ArgFile,bool ArgMin,bool ArgLock,QWidget *parent, Qt::WFlags flags) :QMainWindow(parent,flags){
KeepassMainWindow::KeepassMainWindow(const QString& ArgFile,bool ArgMin,bool ArgLock,QWidget *parent, Qt::WindowFlags flags) :QMainWindow(parent,flags){
ShutingDown=false;
IsLocked=false;
EventOccurred=true;
@ -62,7 +62,7 @@ KeepassMainWindow::KeepassMainWindow(const QString& ArgFile,bool ArgMin,bool Arg
unlockDlg=NULL;
db=NULL;
setupUi(this);
#ifdef Q_WS_MAC
#ifdef Q_OS_MAC
setUnifiedTitleAndToolBarOnMac(true);
#endif
#ifdef AUTOTYPE
@ -89,7 +89,7 @@ KeepassMainWindow::KeepassMainWindow(const QString& ArgFile,bool ArgMin,bool Arg
//statusBar()->addWidget(StatusBarSelection,85);
statusBar()->setVisible(config->showStatusbar());
setStatusBarMsg(StatusBarReady);
#ifndef Q_WS_MAC
#ifndef Q_OS_MAC
if (config->alwaysOnTop())
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
#endif
@ -190,7 +190,7 @@ void KeepassMainWindow::setupConnections(){
connect(ViewToolButtonSize22Action,SIGNAL(toggled(bool)), this, SLOT(OnViewToolbarIconSize22(bool)));
connect(ViewToolButtonSize28Action,SIGNAL(toggled(bool)), this, SLOT(OnViewToolbarIconSize28(bool)));
connect(ViewShowStatusbarAction,SIGNAL(toggled(bool)),statusBar(),SLOT(setVisible(bool)));
#ifdef Q_WS_MAC
#ifdef Q_OS_MAC
connect(ViewMinimizeAction, SIGNAL(triggered()), SLOT(showMinimized()));
#endif
@ -331,7 +331,7 @@ void KeepassMainWindow::setupMenus(){
case 28: ViewToolButtonSize28Action->setChecked(true); break;
}
#ifdef Q_WS_MAC
#ifdef Q_OS_MAC
ViewMenu->addSeparator();
ViewMenu->addAction(ViewMinimizeAction);
#endif
@ -382,7 +382,7 @@ void KeepassMainWindow::setupMenus(){
#ifdef AUTOTYPE
EditAutoTypeAction->setShortcut(tr("Ctrl+V"));
#endif
#ifdef Q_WS_MAC
#ifdef Q_OS_MAC
FileSaveAsAction->setShortcut(tr("Shift+Ctrl+S"));
EditGroupSearchAction->setShortcut(tr("Shift+Ctrl+F"));
ViewMinimizeAction->setShortcut(tr("Ctrl+M"));
@ -437,7 +437,7 @@ bool KeepassMainWindow::openDatabase(QString filename,bool IsAuto){
QPushButton* readOnlyButton = new QPushButton(tr("Open read-only"), &msgBox);
msgBox.addButton(readOnlyButton, QMessageBox::AcceptRole);
msgBox.setDefaultButton(readOnlyButton);
#if defined(GLOBAL_AUTOTYPE) && defined(Q_WS_MAC)
#if defined(GLOBAL_AUTOTYPE) && defined(Q_OS_MAC)
// On MacX, QMessageBox is not brought to foreground on exec() when app not already there
HelperMacX::processToFront(HelperMacX::getKeepassxPID());
#endif
@ -462,7 +462,7 @@ bool KeepassMainWindow::openDatabase(QString filename,bool IsAuto){
dlg.setWindowModality(Qt::WindowModal);
unlockDlg = &dlg;
}
#if defined(GLOBAL_AUTOTYPE) && defined(Q_WS_MAC)
#if defined(GLOBAL_AUTOTYPE) && defined(Q_OS_MAC)
// On MacX, QMessageBox is not brought to foreground on exec() when app not already there
HelperMacX::processToFront(HelperMacX::getKeepassxPID());
#endif
@ -590,7 +590,7 @@ void KeepassMainWindow::OnFileNewKdb(){
IDatabase* db_new=dynamic_cast<IDatabase*>(new Kdb3Database());
db_new->create();
PasswordDialog dlg(this,PasswordDialog::Mode_Set,PasswordDialog::Flag_None,"New Database");
#if defined(GLOBAL_AUTOTYPE) && defined(Q_WS_MAC)
#if defined(GLOBAL_AUTOTYPE) && defined(Q_OS_MAC)
// On MacX, QMessageBox is not brought to foreground on exec()
HelperMacX::processToFront(HelperMacX::getKeepassxPID());
#endif
@ -742,27 +742,27 @@ void KeepassMainWindow::updateDetailView(){
QString templ=DetailViewTemplate;
IEntryHandle* entry=((EntryViewItem*)(EntryView->selectedItems()[0]))->EntryHandle;
templ.replace("%group%", Qt::escape(entry->group()->title()));
templ.replace("%title%", Qt::escape(entry->title()));
templ.replace("%group%", QString(entry->group()->title()).toHtmlEscaped());
templ.replace("%title%", QString(entry->title()).toHtmlEscaped());
if (config->hideUsernames())
templ.replace("%username%","****");
else
templ.replace("%username%", Qt::escape(entry->username()));
templ.replace("%username%", QString(entry->username()).toHtmlEscaped());
if (!config->hidePasswords()) {
SecString password=entry->password();
password.unlock();
templ.replace("%password%", Qt::escape(password.string()));
templ.replace("%password%", QString(password.string()).toHtmlEscaped());
}
else {
templ.replace("%password%","****");
}
templ.replace("%url%", Qt::escape(entry->url()));
templ.replace("%creation%", Qt::escape(entry->creation().toString(Qt::SystemLocaleDate)));
templ.replace("%lastmod%", Qt::escape(entry->lastMod().toString(Qt::SystemLocaleDate)));
templ.replace("%lastaccess%", Qt::escape(entry->lastAccess().toString(Qt::SystemLocaleDate)));
templ.replace("%expire%", Qt::escape(entry->expire().toString(Qt::SystemLocaleDate)));
templ.replace("%comment%", Qt::escape(entry->comment()).replace("\n","<br/>"));
templ.replace("%attachment%", Qt::escape(entry->binaryDesc()));
templ.replace("%url%", QString(entry->url()).toHtmlEscaped());
templ.replace("%creation%", QString(entry->creation().toString(Qt::SystemLocaleDate)).toHtmlEscaped());
templ.replace("%lastmod%", QString(entry->lastMod().toString(Qt::SystemLocaleDate)).toHtmlEscaped());
templ.replace("%lastaccess%", QString(entry->lastAccess().toString(Qt::SystemLocaleDate)).toHtmlEscaped());
templ.replace("%expire%", QString(entry->expire().toString(Qt::SystemLocaleDate)).toHtmlEscaped());
templ.replace("%comment%", QString(entry->comment().replace("\n","<br/>")).toHtmlEscaped());
templ.replace("%attachment%", QString(entry->binaryDesc()).toHtmlEscaped());
if(entry->expire()!=Date_Never){
int secs=QDateTime::currentDateTime().secsTo(entry->expire());
@ -1128,7 +1128,7 @@ void KeepassMainWindow::hideEvent(QHideEvent* event){
if (config->lockOnMinimize() && !IsLocked && FileOpen)
OnUnLockWorkspace();
if (config->showSysTrayIcon() && config->minimizeTray()){
#ifdef Q_WS_WIN
#ifdef Q_OS_WIN32
QTimer::singleShot(100, this, SLOT(hide()));
#else
hide();
@ -1143,7 +1143,7 @@ void KeepassMainWindow::hideEvent(QHideEvent* event){
void KeepassMainWindow::showEvent(QShowEvent* event){
if (IsLocked && !InUnLock && event->spontaneous()){
#ifndef Q_WS_MAC
#ifndef Q_OS_MAC
showNormal(); // workaround for some graphic glitches
#endif
OnUnLockWorkspace();
@ -1171,7 +1171,7 @@ void KeepassMainWindow::OnExtrasSettings(){
EntryView->setAlternatingRowColors(config->alternatingRowColors());
SysTray->setVisible(config->showSysTrayIcon());
menuBookmarks->menuAction()->setVisible(config->featureBookmarks());
#ifndef Q_WS_MAC
#ifndef Q_OS_MAC
if (config->alwaysOnTop() != oldAlwaysOnTop) {
if (config->alwaysOnTop())
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
@ -1271,7 +1271,7 @@ void KeepassMainWindow::OnSysTrayActivated(QSystemTrayIcon::ActivationReason rea
hide();
}
else{
#ifdef Q_WS_WIN
#ifdef Q_OS_WIN32
QTimer::singleShot(100, this, SLOT(restoreWindow()));
#else
restoreWindow();
@ -1281,7 +1281,7 @@ void KeepassMainWindow::OnSysTrayActivated(QSystemTrayIcon::ActivationReason rea
}
void KeepassMainWindow::restoreWindow(){
#ifdef Q_WS_WIN
#ifdef Q_OS_WIN32
if (windowState() & Qt::WindowMaximized)
showMaximized();
else
@ -1339,7 +1339,7 @@ void KeepassMainWindow::OnUnLockWorkspace(){
if(IsLocked){
if (InUnLock) return;
InUnLock = true;
#if defined(GLOBAL_AUTOTYPE) && defined(Q_WS_MAC)
#if defined(GLOBAL_AUTOTYPE) && defined(Q_OS_MAC)
// show in case minimized, especially in another Space
// only needed if invoked from global autotype
show();

@ -33,7 +33,7 @@
class KeepassMainWindow : public QMainWindow, private Ui_MainWindow{
Q_OBJECT
public:
KeepassMainWindow (const QString& ArgFile,bool ArgMin,bool ArgLock,QWidget *parent=0, Qt::WFlags flags=0);
KeepassMainWindow (const QString& ArgFile,bool ArgMin,bool ArgLock,QWidget *parent=0, Qt::WindowFlags flags=0);
IDatabase* db;
inline bool isLocked() { return IsLocked; };
inline bool isOpened() { return FileOpen; };

@ -2,6 +2,8 @@
CONFIG = qt uic resources thread stl warn_on
QT += xml
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
*-g++ : QMAKE_CXXFLAGS_WARN_ON += -Wno-sign-compare
DEPENDPATH += crypto dialogs export forms import lib translations res