From 06b7abe50fc86696c347f9f2ed019062beb27d6e Mon Sep 17 00:00:00 2001 From: Thomas Hooge Date: Sun, 15 Apr 2018 13:37:23 +0200 Subject: [PATCH] Make source compile with QT5 --- src/Kdb3Database.cpp | 2 +- src/KpxConfig.h | 6 ++-- src/dialogs/DatabaseSettingsDlg.cpp | 2 +- src/dialogs/DatabaseSettingsDlg.h | 2 +- src/dialogs/EditEntryDlg.h | 2 +- src/dialogs/EditGroupDlg.cpp | 4 +-- src/dialogs/EditGroupDlg.h | 4 +-- src/dialogs/PasswordGenDlg.cpp | 2 +- src/dialogs/PasswordGenDlg.h | 2 +- src/dialogs/SelectIconDlg.cpp | 2 +- src/dialogs/SelectIconDlg.h | 2 +- src/dialogs/SettingsDlg.cpp | 2 +- src/dialogs/SimplePasswordDlg.cpp | 2 +- src/dialogs/SimplePasswordDlg.h | 2 +- src/import/Import_KeePassX_Xml.cpp | 2 +- src/import/Import_PwManager.cpp | 4 +-- src/lib/EntryView.cpp | 11 +++--- src/lib/FileDialogs.cpp | 4 +-- src/lib/GroupView.cpp | 2 ++ src/lib/ShortcutWidget.cpp | 10 +++--- src/lib/ShortcutWidget.h | 4 +-- src/lib/UrlLabel.cpp | 2 +- src/lib/UrlLabel.h | 2 +- src/lib/random.cpp | 12 ++++--- src/lib/tools.cpp | 21 ++++++----- src/main.cpp | 26 +++++++------- src/main.h | 2 +- src/mainwindow.cpp | 54 ++++++++++++++--------------- src/mainwindow.h | 2 +- src/src.pro | 2 ++ 30 files changed, 104 insertions(+), 92 deletions(-) diff --git a/src/Kdb3Database.cpp b/src/Kdb3Database.cpp index e7c1e8b..6318fa9 100644 --- a/src/Kdb3Database.cpp +++ b/src/Kdb3Database.cpp @@ -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; diff --git a/src/KpxConfig.h b/src/KpxConfig.h index 2de2c15..1924a06 100644 --- a/src/KpxConfig.h +++ b/src/KpxConfig.h @@ -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() diff --git a/src/dialogs/DatabaseSettingsDlg.cpp b/src/dialogs/DatabaseSettingsDlg.cpp index a9439f1..f93d950 100644 --- a/src/dialogs/DatabaseSettingsDlg.cpp +++ b/src/dialogs/DatabaseSettingsDlg.cpp @@ -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); diff --git a/src/dialogs/DatabaseSettingsDlg.h b/src/dialogs/DatabaseSettingsDlg.h index a141fc9..4796db1 100644 --- a/src/dialogs/DatabaseSettingsDlg.h +++ b/src/dialogs/DatabaseSettingsDlg.h @@ -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 *); diff --git a/src/dialogs/EditEntryDlg.h b/src/dialogs/EditEntryDlg.h index 4567786..7a68be0 100644 --- a/src/dialogs/EditEntryDlg.h +++ b/src/dialogs/EditEntryDlg.h @@ -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); diff --git a/src/dialogs/EditGroupDlg.cpp b/src/dialogs/EditGroupDlg.cpp index 42f5ab1..f32d32b 100644 --- a/src/dialogs/EditGroupDlg.cpp +++ b/src/dialogs/EditGroupDlg.cpp @@ -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; diff --git a/src/dialogs/EditGroupDlg.h b/src/dialogs/EditGroupDlg.h index 53a5ecc..4a5c234 100644 --- a/src/dialogs/EditGroupDlg.h +++ b/src/dialogs/EditGroupDlg.h @@ -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: diff --git a/src/dialogs/PasswordGenDlg.cpp b/src/dialogs/PasswordGenDlg.cpp index 91d8831..28462a4 100644 --- a/src/dialogs/PasswordGenDlg.cpp +++ b/src/dialogs/PasswordGenDlg.cpp @@ -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); diff --git a/src/dialogs/PasswordGenDlg.h b/src/dialogs/PasswordGenDlg.h index 7707b49..70990af 100644 --- a/src/dialogs/PasswordGenDlg.h +++ b/src/dialogs/PasswordGenDlg.h @@ -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: diff --git a/src/dialogs/SelectIconDlg.cpp b/src/dialogs/SelectIconDlg.cpp index 67f18db..b054546 100644 --- a/src/dialogs/SelectIconDlg.cpp +++ b/src/dialogs/SelectIconDlg.cpp @@ -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; diff --git a/src/dialogs/SelectIconDlg.h b/src/dialogs/SelectIconDlg.h index 3b037e1..4bd76ca 100644 --- a/src/dialogs/SelectIconDlg.h +++ b/src/dialogs/SelectIconDlg.h @@ -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(); diff --git a/src/dialogs/SettingsDlg.cpp b/src/dialogs/SettingsDlg.cpp index 55334d7..d5a0edb 100644 --- a/src/dialogs/SettingsDlg.cpp +++ b/src/dialogs/SettingsDlg.cpp @@ -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 diff --git a/src/dialogs/SimplePasswordDlg.cpp b/src/dialogs/SimplePasswordDlg.cpp index 585716e..3cfe939 100644 --- a/src/dialogs/SimplePasswordDlg.cpp +++ b/src/dialogs/SimplePasswordDlg.cpp @@ -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); diff --git a/src/dialogs/SimplePasswordDlg.h b/src/dialogs/SimplePasswordDlg.h index 80d0bfd..ade9b48 100644 --- a/src/dialogs/SimplePasswordDlg.h +++ b/src/dialogs/SimplePasswordDlg.h @@ -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; diff --git a/src/import/Import_KeePassX_Xml.cpp b/src/import/Import_KeePassX_Xml.cpp index 788691d..bede39d 100644 --- a/src/import/Import_KeePassX_Xml.cpp +++ b/src/import/Import_KeePassX_Xml.cpp @@ -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; diff --git a/src/import/Import_PwManager.cpp b/src/import/Import_PwManager.cpp index 24ff174..9a06343 100644 --- a/src/import/Import_PwManager.cpp +++ b/src/import/Import_PwManager.cpp @@ -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(); diff --git a/src/lib/EntryView.cpp b/src/lib/EntryView.cpp index ae0c8c1..592bafd 100644 --- a/src/lib/EntryView.cpp +++ b/src/lib/EntryView.cpp @@ -18,6 +18,9 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include +#include +#include #include #include #include @@ -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"); diff --git a/src/lib/FileDialogs.cpp b/src/lib/FileDialogs.cpp index aea2341..b19f116 100644 --- a/src/lib/FileDialogs.cpp +++ b/src/lib/FileDialogs.cpp @@ -19,7 +19,7 @@ #include #if QT_VERSION >= 0x040400 - #include + #include #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 diff --git a/src/lib/GroupView.cpp b/src/lib/GroupView.cpp index 47b4151..4859340 100644 --- a/src/lib/GroupView.cpp +++ b/src/lib/GroupView.cpp @@ -22,6 +22,8 @@ #include "GroupView.h" #include "dialogs/EditGroupDlg.h" +#include +#include #include #include diff --git a/src/lib/ShortcutWidget.cpp b/src/lib/ShortcutWidget.cpp index b8c96c1..ecdfe56 100644 --- a/src/lib/ShortcutWidget.cpp +++ b/src/lib/ShortcutWidget.cpp @@ -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 #include @@ -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(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(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(keysym)); } #endif -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC if (ctrl) text.append(kControlUnicode); if (shift) diff --git a/src/lib/ShortcutWidget.h b/src/lib/ShortcutWidget.h index de0a5f8..7228964 100644 --- a/src/lib/ShortcutWidget.h +++ b/src/lib/ShortcutWidget.h @@ -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); diff --git a/src/lib/UrlLabel.cpp b/src/lib/UrlLabel.cpp index f452bea..97830fa 100644 --- a/src/lib/UrlLabel.cpp +++ b/src/lib/UrlLabel.cpp @@ -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); diff --git a/src/lib/UrlLabel.h b/src/lib/UrlLabel.h index a9a55ee..5e351fb 100644 --- a/src/lib/UrlLabel.h +++ b/src/lib/UrlLabel.h @@ -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(); diff --git a/src/lib/random.cpp b/src/lib/random.cpp index 1007172..493beb4 100644 --- a/src/lib/random.cpp +++ b/src/lib/random.cpp @@ -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 + #include #include -#elif defined(Q_WS_WIN) +#elif defined(Q_OS_WIN32) #include #include #include @@ -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(); diff --git a/src/lib/tools.cpp b/src/lib/tools.cpp index 38a2760..2a30815 100644 --- a/src/lib/tools.cpp +++ b/src/lib/tools.cpp @@ -22,10 +22,10 @@ #include #include -#if defined(Q_WS_X11) || defined(Q_WS_MAC) +#if defined(Q_OS_LINUX) || defined(Q_OS_MAC) #include #include -#elif defined(Q_WS_WIN) +#elif defined(Q_OS_WIN32) #include #include #include @@ -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; diff --git a/src/main.cpp b/src/main.cpp index 08f6683..4bb6354 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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 #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(event)->file(); if (pMainWindow) { diff --git a/src/main.h b/src/main.h index bb2a1a2..d847e6a 100644 --- a/src/main.h +++ b/src/main.h @@ -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; }; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 91859fd..6bbf9c4 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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(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","
")); - 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","
")).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(); diff --git a/src/mainwindow.h b/src/mainwindow.h index a9b8d67..284cfe8 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -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; }; diff --git a/src/src.pro b/src/src.pro index 240d261..0382c03 100644 --- a/src/src.pro +++ b/src/src.pro @@ -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