# # # patch "guitone/src/Guitone.cpp" # from [5a5e1d7691fe0761c3d97d465597519baa29e769] # to [2db81e5ef26c4f72a4cde8ce650f0b4a7235fbbf] # # patch "guitone/src/Guitone.h" # from [be48ddb461736a277c9f13faba817ae60d4b2fff] # to [56327e1a0da85c66b3d4554aba2d5df01ada618c] # # patch "guitone/src/monotone/Monotone.cpp" # from [fefac914a23090c9e2df57c6dddc229bb69d8417] # to [81070d63938e77c478b2b85c585f995e319d0683] # # patch "guitone/src/util/DebugLog.cpp" # from [0bf89411af60bddec2e3e1e527ecb5d025caa37e] # to [48df0a25b859ada3a174c3a8dbf1f98e83c8629d] # # patch "guitone/src/view/MainWindow.cpp" # from [b95cf564f73f23a921217084ae86f59b240f0340] # to [392fd185e0419f8389dd09a8d02cfe7a1e662b00] # # patch "guitone/src/view/MainWindow.h" # from [45fbbfbc9007550fe3779bc57541663a413a4196] # to [588d778439aa43c66689b35fbcc1b2a0bf154710] # # patch "guitone/src/view/Splitter.cpp" # from [32140eeb5e3a23c776d0ba5474270331393831e8] # to [78cf20ef93dfe83a97ec969f265e87854e37d0e9] # ============================================================ --- guitone/src/Guitone.cpp 5a5e1d7691fe0761c3d97d465597519baa29e769 +++ guitone/src/Guitone.cpp 2db81e5ef26c4f72a4cde8ce650f0b4a7235fbbf @@ -27,7 +27,6 @@ #include #include #include -#include Guitone::Guitone(int argc, char** argv) : QApplication(argc, argv) { @@ -43,7 +42,7 @@ bool Guitone::init() MainWindow * mainWnd = addWindow(); if (!addMonotoneInstance(mainWnd)) { - qWarning("Guitone::init: couldn't initialize monotone"); + W("couldn't initialize monotone"); removeWindow(mainWnd); return false; } @@ -118,35 +117,6 @@ MainWindow * Guitone::addWindow() MainWindow * wnd = new MainWindow(); - // ensure somewhat that new windows do not overdraw current ones - // by adding a little x/y offset to the original position - if (openWindows.size() > 0) - { - MainWindow * lastWnd = openWindows.last(); - QDesktopWidget * desk = desktop(); - - if (desk->numScreens() > 1) - { - qWarning("Guitone::addWindow: No support for window cascading " - "on systems with more than one monitor yet."); - } - else - { - int cascade = 20; - QRect geom = desk->availableGeometry(); - int newX = lastWnd->x() + cascade; - int newY = lastWnd->y() + cascade; - - if (newX + wnd->width() > geom.right() || - newY + wnd->height() > geom.bottom()) - { - newX = geom.x(); - newY = geom.y(); - } - wnd->move(newX, newY); - } - } - connect( wnd, SIGNAL(quitApplication()), this, SLOT(quit()) @@ -347,7 +317,7 @@ bool Guitone::removeMonotoneInstance(Mai return true; } -Monotone * Guitone::monotoneInstance(QObject * obj) +MainWindow * Guitone::findMainWindow(QObject * obj) { do { @@ -356,8 +326,14 @@ Monotone * Guitone::monotoneInstance(QOb } while (obj); Q_ASSERT(obj); - MainWindow * wnd = qobject_cast(obj); + return wnd; +} + +Monotone * Guitone::getMonotoneInstance(QObject * obj) +{ + MainWindow * wnd = findMainWindow(obj); + Q_ASSERT(wnd); Q_ASSERT(monotoneInstances.contains(wnd)); return monotoneInstances.value(wnd); } ============================================================ --- guitone/src/Guitone.h be48ddb461736a277c9f13faba817ae60d4b2fff +++ guitone/src/Guitone.h 56327e1a0da85c66b3d4554aba2d5df01ada618c @@ -21,9 +21,29 @@ #ifndef GUITONE_H #define GUITONE_H +// +// some global definitions +// +#define DEBUG 1 #define APP reinterpret_cast(qApp) -#define MTN(arg) APP->monotoneInstance(arg) +#define MTN(arg) APP->getMonotoneInstance(arg) +// FIXME: uncomment the following lines if you have compile problems +// on Windows using MSVC++ +/* +#ifdef _MSC_VER +#define __FUNCTION__ "" +#endif +*/ +#define D(arg) qDebug("%s:%s:%d: %s", __FILE__, __FUNCTION__, __LINE__, qPrintable(QString(arg))) +#ifndef DEBUG +#define D(arg) void() +#endif +#define W(arg) qWarning("%s:%s:%d: %s", __FILE__, __FUNCTION__, __LINE__, qPrintable(QString(arg))) +#define C(arg) qCritical("%s:%s:%d: %s", __FILE__, __FUNCTION__, __LINE__, qPrintable(QString(arg))) +#define F(arg) qFatal("%s:%s:%d: %s", __FILE__, __FUNCTION__, __LINE__, qPrintable(QString(arg))) + + #include "MainWindow.h" #include "Monotone.h" @@ -42,7 +62,8 @@ public: bool init(); const QList windowList() const; - Monotone * monotoneInstance(QObject *); + MainWindow * findMainWindow(QObject *); + Monotone * getMonotoneInstance(QObject *); signals: void windowListChanged(); ============================================================ --- guitone/src/monotone/Monotone.cpp fefac914a23090c9e2df57c6dddc229bb69d8417 +++ guitone/src/monotone/Monotone.cpp 81070d63938e77c478b2b85c585f995e319d0683 @@ -75,6 +75,7 @@ #include "Monotone.h" #include "SignalWaiter.h" #include "StdioParser.h" +#include "Guitone.h" #include #include @@ -120,7 +121,7 @@ bool Monotone::normalizeWorkspacePath(QS QDir tempDir(workspace); if (!tempDir.exists()) { - qWarning("Cannot find directory %s", qPrintable(workspace)); + W(QString("Cannot find directory %1").arg(workspace)); return false; } @@ -135,7 +136,7 @@ bool Monotone::normalizeWorkspacePath(QS } while (!tempDir.isRoot() && tempDir.cdUp()); - qWarning("Cannot find _MTN directory in or above %s", qPrintable(workspace)); + W(QString("Cannot find _MTN directory in or above %1").arg(workspace)); return false; } @@ -248,10 +249,7 @@ void Monotone::setupNewProcess() args << "--db" << databaseFile; } - qDebug("Monotone::setupNewProcess: %s %s", - qPrintable(mtnBinaryPath), - qPrintable(args.join(" ")) - ); + D(QString("starting %1 %2").arg(mtnBinaryPath).arg(args.join(" "))); process->start(mtnBinaryPath, args); } @@ -311,7 +309,7 @@ void Monotone::processError(QProcess::Pr // QProcess::UnknownError: // yeah, unknown errors, I love these - absolutely no idea what // to do on this or even when it can come up - qCritical("received process error %d", error); + C(QString("received process error %1").arg(error)); } void Monotone::processFinished(int code, QProcess::ExitStatus status) @@ -341,7 +339,7 @@ bool Monotone::executeCommand(const QStr if (process->state() != QProcess::Running && !process->waitForStarted(WaitForMonotoneStart)) { - qDebug("Monotone::executeCommand: Process is not running"); + D("monotone is not running"); return false; } @@ -367,7 +365,7 @@ bool Monotone::triggerCommand(const QStr if (process->state() != QProcess::Running && !process->waitForStarted(WaitForMonotoneStart)) { - qDebug("Monotone::triggerCommand: Process is not running"); + D("monotone is not running"); return false; } @@ -390,7 +388,7 @@ int Monotone::writeStdin(const QStringLi QString fragment = options.at(i); if (fragment.size() == 0) { - qWarning("Monotone::writeStdin: skipping empty option %d", i+1); + W(QString("skipping empty option %1").arg(i+1)); continue; } @@ -410,7 +408,7 @@ int Monotone::writeStdin(const QStringLi QString fragment = command.at(i); if (fragment.size() == 0) { - qWarning("Monotone::writeStdin: skipping empty parameter %d", i+1); + W(QString("skipping empty parameter %1").arg(i+1)); continue; } @@ -420,7 +418,7 @@ int Monotone::writeStdin(const QStringLi } commandLine += "e"; - qDebug("Writing command %s", qPrintable(commandLine)); + D(QString("writing command %1").arg(commandLine)); QTextStream streamStdIn(process); streamStdIn << commandLine; @@ -444,7 +442,7 @@ void Monotone::readAndParseStdout() // if the chunk is not yet complete, try again later if (!parser.parse()) { - qWarning("Monotone::readAndParseStdout: Contents invalid."); + W("contents invalid"); return; } @@ -484,7 +482,7 @@ QByteArray Monotone::getRawData(int comm if (!output.contains(commandNumber)) { - qWarning("Monotone::getRawData: no data for %d available", commandNumber); + W(QString("no data for %1").arg(commandNumber)); return QByteArray(); } @@ -504,7 +502,7 @@ int Monotone::getReturnCode(int commandN if (!completedCommands.contains(commandNumber)) { - qWarning("Monotone::getReturnCode: no return code for %d", commandNumber); + W(QString("no return code for %d").arg(commandNumber)); return -1; } @@ -528,14 +526,14 @@ bool Monotone::runCommand(const QString // could not be started (invalid path, not executable, ...) if (!proc.waitForStarted(5000)) { - qDebug("Monotone::runCommand: process not started"); + D("process not started"); return false; } // process doesn't return, etc... if (!proc.waitForFinished(5000)) { - qDebug("Monotone::runCommand: process not finished"); + D("process not finished"); return false; } @@ -559,8 +557,7 @@ bool Monotone::checkProgramVersion(const if (regex.indexIn(output) == -1) { - qDebug("Monotone::checkProgramVersion: couldn't parse output: %s", - qPrintable(output)); + D(QString("couldn't parse output: %1").arg(output)); return false; } @@ -568,9 +565,10 @@ bool Monotone::checkProgramVersion(const curVersion.pop_front(); QStringList needVersion = RequiredProgramVersion.split("."); - qDebug("Monotone::checkProgramVersion: current: %s, need: %s", - qPrintable(curVersion.join(".")), - qPrintable(RequiredProgramVersion)); + D(QString("monotone version: %1, need: %2") + .arg(curVersion.join(".")) + .arg(RequiredProgramVersion) + ); unsigned int curMajor = curVersion.at(0).toUInt(); unsigned int curMinor = curVersion.at(1).toUInt(); @@ -596,8 +594,7 @@ bool Monotone::checkInterfaceVersion(con if (regex.indexIn(output) == -1) { - qDebug("Monotone::checkInterfaceVersion: couldn't parse output: %s", - qPrintable(output)); + D(QString("couldn't parse output: %1").arg(output)); return false; } @@ -605,9 +602,10 @@ bool Monotone::checkInterfaceVersion(con curVersion.pop_front(); QStringList needVersion = RequiredInterfaceVersion.split("."); - qDebug("Monotone::checkInterfaceVersion: current: %s, need: %s", - qPrintable(curVersion.join(".")), - qPrintable(RequiredInterfaceVersion)); + D(QString("interface version: %1, need: %2") + .arg(curVersion.join(".")) + .arg(RequiredInterfaceVersion) + ); unsigned int curMajor = curVersion.at(0).toUInt(); unsigned int curMinor = curVersion.at(1).toUInt(); ============================================================ --- guitone/src/util/DebugLog.cpp 0bf89411af60bddec2e3e1e527ecb5d025caa37e +++ guitone/src/util/DebugLog.cpp 48df0a25b859ada3a174c3a8dbf1f98e83c8629d @@ -25,7 +25,8 @@ #include #include -#include +#include +#include DebugLog* DebugLog::instance = 0; @@ -53,9 +54,13 @@ DebugLog::DebugLog() } QString sep; - sep.fill('=', 32); + QDate today = QDate::currentDate(); + sep.fill('=', 40); log(Debug, sep); - log(Debug, "| guitone session started |"); + log(Debug, + QString(" guitone session started (%1)") + .arg(today.toString("yyyy-MM-dd")) + ); log(Debug, sep); } @@ -96,12 +101,12 @@ void DebugLog::log(Type t, QString msg) // an endless loop assert(t <= errors.size()); - QDateTime current = QDateTime::currentDateTime(); + QTime now = QTime::currentTime(); QString logStr; logStr.append( QString("%1: %2: %3\n") - .arg(current.toString("yyyy-MM-dd hh:mm:ss.zzz")) + .arg(now.toString("hh:mm:ss.zzz")) .arg(errors[t-1]) .arg(msg) ); ============================================================ --- guitone/src/view/MainWindow.cpp b95cf564f73f23a921217084ae86f59b240f0340 +++ guitone/src/view/MainWindow.cpp 392fd185e0419f8389dd09a8d02cfe7a1e662b00 @@ -41,6 +41,7 @@ #include #include #include +#include MainWindow::MainWindow() : QMainWindow() @@ -282,8 +283,40 @@ void MainWindow::switchMode(Mode m) mode = m; windowMode->setCurrentIndex(mode); restoreGeometry(Settings::getWindowGeometry("MainWindow_mode" + mode)); - updateGeometry(); + QList openWindows = APP->windowList(); + + // ensure somewhat that new windows do not overdraw current ones + // by adding a little x/y offset the original position of the window + // opened before this window + if (openWindows.size() > 1) + { + MainWindow * prevWnd = openWindows.at(openWindows.indexOf(this) - 1); + Q_ASSERT(prevWnd); + QDesktopWidget * desk = APP->desktop(); + + if (desk->numScreens() > 1) + { + qWarning("Guitone::addWindow: No support for window cascading " + "on systems with more than one monitor yet."); + } + else + { + int cascade = 20; + QRect geom = desk->availableGeometry(); + int newX = prevWnd->x() + cascade; + int newY = prevWnd->y() + cascade; + + if (newX + width() > geom.right() || + newY + height() > geom.bottom()) + { + newX = geom.x(); + newY = geom.y(); + } + move(newX, newY); + } + } + if (mode == Database) { menuView->menuAction()->setVisible(false); ============================================================ --- guitone/src/view/MainWindow.h 45fbbfbc9007550fe3779bc57541663a413a4196 +++ guitone/src/view/MainWindow.h 588d778439aa43c66689b35fbcc1b2a0bf154710 @@ -41,7 +41,7 @@ public: ~MainWindow(); void loadRecent(); void switchMode(Mode); - + bool doLoadWorkspace(QString); bool doLoadDatabase(QString); ============================================================ --- guitone/src/view/Splitter.cpp 32140eeb5e3a23c776d0ba5474270331393831e8 +++ guitone/src/view/Splitter.cpp 78cf20ef93dfe83a97ec969f265e87854e37d0e9 @@ -36,7 +36,7 @@ Splitter::~Splitter() Splitter::~Splitter() { - saveState(); + saveState(); } void Splitter::init() @@ -51,6 +51,18 @@ void Splitter::saveState(void) void Splitter::saveState(void) { + // due to a bug in Qt 4.2.2 saveState saves an errornous state for + // splitters which have not yet been shown to the user. we're avoiding + // this problem by checking if the sizes() list sums up to 0 which + // then means that we have just encountered this state + QList s(sizes()); + int sum = 0; + for (int i=0, j=s.size(); i