From 52fcfaa2926fc9b87ca46a83da3a14a522ce4233 Mon Sep 17 00:00:00 2001 From: Tannin Date: Sun, 9 Aug 2015 12:52:30 +0200 Subject: some code cleanup --- src/main.cpp | 26 ++++++++++++++------------ src/mainwindow.cpp | 13 +++++++++---- src/mainwindow.h | 1 - src/nxmaccessmanager.cpp | 7 ------- 4 files changed, 23 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 8e9b7c9e..76474fd6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -207,22 +207,28 @@ static LONG WINAPI MyUnhandledExceptionFilter(struct _EXCEPTION_POINTERS *except FuncMiniDumpWriteDump funcDump = (FuncMiniDumpWriteDump)::GetProcAddress(dbgDLL, "MiniDumpWriteDump"); if (funcDump) { if (QMessageBox::question(nullptr, QObject::tr("Woops"), - QObject::tr("ModOrganizer has crashed! Should a diagnostic file be created? If you send me this file " - "(%1) to sherb@gmx.net, the bug is a lot more likely to be fixed. " - "Please include a short description of what you were doing when the crash happened").arg(qApp->applicationFilePath().append(".dmp")), - QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { + QObject::tr("ModOrganizer has crashed! " + "Should a diagnostic file be created? " + "If you send me this file (%1) to sherb@gmx.net, " + "the bug is a lot more likely to be fixed. " + "Please include a short description of what you were " + "doing when the crash happened" + ).arg(qApp->applicationFilePath().append(".dmp")), + QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { std::wstring dumpName = ToWString(qApp->applicationFilePath().append(".dmp")); HANDLE dumpFile = ::CreateFile(dumpName.c_str(), - GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); + GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, + CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (dumpFile != INVALID_HANDLE_VALUE) { _MINIDUMP_EXCEPTION_INFORMATION exceptionInfo; exceptionInfo.ThreadId = ::GetCurrentThreadId(); exceptionInfo.ExceptionPointers = exceptionPtrs; exceptionInfo.ClientPointers = false; - BOOL success = funcDump(::GetCurrentProcess(), ::GetCurrentProcessId(), dumpFile, MiniDumpNormal, &exceptionInfo, nullptr, nullptr); + BOOL success = funcDump(::GetCurrentProcess(), ::GetCurrentProcessId(), dumpFile, + MiniDumpNormal, &exceptionInfo, nullptr, nullptr); ::FlushFileBuffers(dumpFile); ::CloseHandle(dumpFile); @@ -337,13 +343,9 @@ int main(int argc, char *argv[]) QString dataPath = instanceID.isEmpty() ? application.applicationDirPath() : QDir::fromNativeSeparators( -#if QT_VERSION >= 0x050000 - QStandardPaths::writableLocation(QStandardPaths::DataLocation) -#else - QDesktopServices::storageLocation(QDesktopServices::DataLocation) -#endif + QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/" + instanceID - ); + ); application.setProperty("dataPath", dataPath); if (!QDir(dataPath).exists()) { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 38e1f66b..a209f00b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -175,8 +175,10 @@ MainWindow::MainWindow(const QString &exeName ui->logList->addAction(ui->actionCopy_Log_to_Clipboard); int splitterSize = this->size().height(); // actually total window size, but the splitter doesn't seem to return the true value ui->topLevelSplitter->setSizes(QList() << splitterSize - 100 << 100); - connect(ui->logList->model(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), ui->logList, SLOT(scrollToBottom())); - connect(ui->logList->model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), ui->logList, SLOT(scrollToBottom())); + connect(ui->logList->model(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), + ui->logList, SLOT(scrollToBottom())); + connect(ui->logList->model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), + ui->logList, SLOT(scrollToBottom())); m_RefreshProgress = new QProgressBar(statusBar()); m_RefreshProgress->setTextVisible(true); @@ -929,7 +931,8 @@ void MainWindow::modPagePluginInvoke() m_IntegratedBrowser.setWindowTitle(plugin->displayName()); m_IntegratedBrowser.openUrl(plugin->pageURL()); } else { - ::ShellExecuteW(nullptr, L"open", ToWString(plugin->pageURL().toString()).c_str(), nullptr, nullptr, SW_SHOWNORMAL); + ::ShellExecuteW(nullptr, L"open", ToWString(plugin->pageURL().toString()).c_str(), + nullptr, nullptr, SW_SHOWNORMAL); } } } @@ -2328,8 +2331,9 @@ void MainWindow::unendorse_clicked() } } -void MainWindow::loginFailed(const QString&) +void MainWindow::loginFailed(const QString &error) { + qDebug("login failed: %s", qPrintable(error)); statusBar()->hide(); } @@ -4757,3 +4761,4 @@ void MainWindow::dropEvent(QDropEvent *event) } event->accept(); } + diff --git a/src/mainwindow.h b/src/mainwindow.h index bfdc3d23..55ae40b9 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -534,7 +534,6 @@ private slots: // ui slots void on_categoriesOrBtn_toggled(bool checked); void on_managedArchiveLabel_linkHovered(const QString &link); void on_manageArchivesBox_toggled(bool checked); - }; diff --git a/src/nxmaccessmanager.cpp b/src/nxmaccessmanager.cpp index 0786a254..e6c11695 100644 --- a/src/nxmaccessmanager.cpp +++ b/src/nxmaccessmanager.cpp @@ -229,17 +229,10 @@ void NXMAccessManager::pageLogin() request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); QByteArray postDataQuery; -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) QUrlQuery postData; postData.addQueryItem("username", m_Username); postData.addQueryItem("password", m_Password); postDataQuery = postData.query(QUrl::FullyEncoded).toUtf8(); -#else - QUrl postData; - postData.addQueryItem("username", m_Username); - postData.addQueryItem("password", m_Password); - postDataQuery = postData.encodedQuery(); -#endif request.setRawHeader("User-Agent", userAgent().toUtf8()); -- cgit v1.3.1