Skip to content

Commit

Permalink
Merge pull request #174 from sieren/0.5.5-rc2
Browse files Browse the repository at this point in the history
RC2 Features and Fixes
  • Loading branch information
sieren authored Oct 26, 2016
2 parents e4dc79d + 0b9f224 commit 77dc8fe
Show file tree
Hide file tree
Showing 16 changed files with 388 additions and 97 deletions.
26 changes: 13 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,28 @@ add_definitions(${Qt5Widgets_DEFINITIONS})
#

set(qst_platform_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/includes/platforms)
set(qst_platform_SOURCES)
set(qst_platform_HEADERS)
if(APPLE)
set(qst_platform_SOURCES
${qst_platform_SOURCES}
set(qst_platform_HEADERS
${qst_platform_HEADERS}
${qst_platform_ROOT}/darwin/macUtils.hpp
)
elseif(WIN32)
set(qst_platform_SOURCES
${qst_platform_SOURCES}
set(qst_platform_HEADERS
${qst_platform_HEADERS}
${qst_platform_ROOT}/windows/winUtils.hpp
)
elseif(UNIX)
set(qst_platform_SOURCES
${qst_platform_SOURCES}
set(qst_platform_HEADERS
${qst_platform_HEADERS}
${qst_platform_ROOT}/linux/posixUtils.hpp
)
endif()
set(qst_platform_SOURCES
${qst_platform_SOURCES}
set(qst_platform_HEADERS
${qst_platform_HEADERS}
)

source_group("Platforms" ${qst_platform_SOURCES})
source_group("Platforms" ${qst_platform_HEADERS} ${qst_PLATFORMS_SOURCES})

# ____ _ _
# | _ \ __ _| |_| |__ ___
Expand Down Expand Up @@ -103,11 +103,11 @@ SET_SOURCE_FILES_PROPERTIES(
if(APPLE)
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
add_executable(QSyncthingTray MACOSX_BUNDLE resources/Syncthing.icns ${UI_HEADERS} ${UI_RESOURCES}
${qst_platform_SOURCES} ${qst_HEADERS} ${qst_SOURCES})
${qst_platform_HEADERS} ${qst_PLATFORMS_SOURCES} ${qst_HEADERS} ${qst_SOURCES})
elseif(WIN32)
add_executable(QSyncthingTray WIN32 ${UI_HEADERS} ${UI_RESOURCES} ${qst_platform_SOURCES} ${qst_HEADERS} ${qst_SOURCES})
add_executable(QSyncthingTray WIN32 ${UI_HEADERS} ${UI_RESOURCES} ${qst_platform_HEADERS} ${qst_HEADERS} ${qst_SOURCES})
elseif(UNIX)
add_executable(QSyncthingTray ${UI_HEADERS} ${UI_RESOURCES} ${qst_platform_SOURCES} ${qst_HEADERS} ${qst_SOURCES})
add_executable(QSyncthingTray ${UI_HEADERS} ${UI_RESOURCES} ${qst_platform_HEADERS} ${qst_HEADERS} ${qst_SOURCES})
endif()

if (APPLE)
Expand Down
2 changes: 2 additions & 0 deletions QSyncthingTray.pro
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ CONFIG += c++11
macx {
QMAKE_INFO_PLIST = resources/Info.plist
LIBS += -framework ApplicationServices
LIBS += -framework Cocoa
SOURCES += sources/platforms/darwin/macUtils.mm
}
#QMAKE_CXXFLAGS += /wd4996
ICON = resources/Syncthing.icns
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Written in C++ with Qt.
## Features

+ Shows number of connections at a glance.
+ Traffic statistics and graphs about incoming, outgoing and total throughput.
+ Traffic statistics and graphs about throughput and connections.
+ Launches Syncthing and Syncthing-iNotifier if specified.
+ Quickly pause Syncthing with one click.
+ Last Synced Files - Quickly see the recently synchronised files and open their folder.
Expand Down
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ clone_folder: c:\dev
clone_depth: 5

init:
- set PATH=C:\Qt\5.5\%qt%\bin;%PATH%
- set PATH=C:\Qt\5.65\%qt%\bin;%PATH%
- set ORIGPATH=%PATH%
- set QTDIR=C:\Qt\5.5\%qt%\
- set QTDIR=C:\Qt\5.6\%qt%\
- if not %platform%==mingw call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" %platform%

install:
Expand All @@ -30,7 +30,7 @@ before_build:
build_script:
- cd build
- cmake ..\ -G "Visual Studio 12 2013 Win64"
- msbuild QSyncthingTray.sln
- msbuild QSyncthingTray.sln

after_build:

Expand Down
24 changes: 2 additions & 22 deletions includes/platforms/darwin/macUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <sstream>
#include <string>
#include <iostream>
#include <Carbon/Carbon.h>
#include <QWidget>
#include <QProcessEnvironment>
#include <QString>
#define UNUSED(x) (void)(x)
Expand All @@ -42,27 +42,7 @@ namespace darwin
return '/';
}

void showDockIcon(bool show)
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
ProcessSerialNumber psn;
windowCounter += show ? 1 : -1;
UInt32 transformState = show ? kProcessTransformToForegroundApplication :
kProcessTransformToUIElementApplication;
const bool shouldHideLastWindow =
(transformState == kProcessTransformToUIElementApplication &&
windowCounter == 0) ? true : false;
const bool shouldShowWindow =
(transformState == kProcessTransformToForegroundApplication &&
windowCounter > 0) ? true : false;
if (GetCurrentProcess(&psn) == noErr && (shouldShowWindow || shouldHideLastWindow))
{
TransformProcessType(&psn,
transformState);
}
#pragma clang diagnostic pop
}
void showDockIcon(bool show);

auto getSSLLibraryText() -> std::string
{
Expand Down
2 changes: 1 addition & 1 deletion includes/qst/apihandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace api

auto getCurrentFolderList(QByteArray reply) -> std::list<FolderNameFullPath>
{
std::list<std::pair<QString, QString>> result;
std::list<FolderNameFullPath> result;

if (reply.size() > 0)
{
Expand Down
1 change: 1 addition & 0 deletions includes/qst/settingsmigrator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ void createDefaultSettings()
sysutils::SystemUtility().getDefaultSyncthingINotifyLocation());
checkAndSetValue("lastupdatecheck", QDateTime().currentDateTime());
checkAndSetValue("lastshownupdatenotification", QString("0"));
checkAndSetValue("statsLength", 1);
}


Expand Down
30 changes: 25 additions & 5 deletions includes/qst/statswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
#include "apihandler.hpp"
#include <contrib/qcustomplot.h>

namespace
{
using ConnectionPlotData = std::tuple<std::uint16_t, std::chrono::time_point<std::chrono::system_clock>>;
}
namespace qst
{
namespace stats
Expand All @@ -53,7 +57,9 @@ class StatsWidget : public QWidget
StatsWidget() = delete;
StatsWidget(const QString& title);
void updateTrafficData(const TrafficData& traffData);
void addConnectionPoint(const std::uint16_t& numConn);
void closeEvent(QCloseEvent * event);
void onSettingsChanged();

public slots:
void show();
Expand All @@ -62,16 +68,30 @@ private slots:
void updatePlot();

private:
void configurePlot(QCustomPlot* plot);
void configurePlot(QCustomPlot* plot, const QString& title);
void updateTitle(QCustomPlot* plot, const QString& title);
void updateTrafficPlot();
void updateConnectionsPlot();

template<typename Container, typename Duration>
void cleanupTimeData(Container& vec, const Duration& dur);

template<typename Container>
void zeroMissingTimeData(Container& vec);

QString mTitle;
QSettings mSettings;
QTimer mRedrawTimer;
QLabel *mpLabel;
QString mTitle;
QWidget *mpWidget;
std::mutex mTraffGuard;
std::mutex mDataGuard;
QCustomPlot *mpCustomPlot;
QCustomPlot *mpConnectionPlot;
QSharedPointer<QCPAxisTickerDateTime> mpDateTicker;
std::list<TrafficData> trafficPoints;
static const int kMaxTrafficDataPoints;
std::list<TrafficData> mTrafficPoints;
std::list<ConnectionPlotData> mConnectionPoints;
int mMaxTimeInPlotMins = 60;
static const int kMaxSecBeforeZero;
static const QBrush kBackgroundColor;
static const QColor kForegroundColor;
};
Expand Down
38 changes: 38 additions & 0 deletions includes/qst/utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <string>
#include <iomanip>
#include <iostream>
#include <tuple>
#include <QFile>
#include <QXmlStreamReader>
#include "platforms.hpp"
Expand Down Expand Up @@ -167,6 +168,43 @@ static QString trafficToString(T traffic)
return QString(strTraffic.c_str());
}


//------------------------------------------------------------------------------------//

template<size_t N, typename Container>
auto find_max_tuple_value(Container& c) ->
typename std::tuple_element<N, typename Container::value_type>::type
{
using ContainerValueType = typename Container::value_type;
const auto elem = std::max_element(c.begin(), c.end(),
[](const ContainerValueType& lhs, const ContainerValueType& rhs)
{
return(std::get<N>(lhs) < std::get<N>(rhs));
});
return std::move(std::get<N>(*elem));
}


//------------------------------------------------------------------------------------//
// retrieve index of type in tuple
template <class T, class Tuple>
struct Index;

template <class T, class... Types>
struct Index<T, std::tuple<T, Types...>>
{
static const std::size_t value = 0;
};

template <class T, class U, class... Types>
struct Index<T, std::tuple<U, Types...>>
{
static const std::size_t value = 1 + Index<T, std::tuple<Types...>>::value;
};


//------------------------------------------------------------------------------------//

}
}

Expand Down
2 changes: 2 additions & 0 deletions includes/qst/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ private slots:
QDoubleSpinBox *mpWebViewZoomFactor;
QLabel *mpSyncPollIntervalLabel;
QDoubleSpinBox *mpSyncPollIntervalBox;
QLabel *mpStatsLengthLabel;
QDoubleSpinBox *mpStatsLengthBox;

QAction *mpConnectedState;
QAction *mpNumberOfConnectionsAction;
Expand Down
4 changes: 2 additions & 2 deletions scripts/build_project.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

./clean.sh
~/Qt/5.5/clang_64/bin/qmake ../
~/Qt/5.7/clang_64/bin/qmake ../
make
~/Qt/5.5/clang_64/bin/macdeployqt QSyncthingTray.app -dmg -verbose=2
~/Qt/5.7/clang_64/bin/macdeployqt QSyncthingTray.app -dmg -verbose=2
12 changes: 12 additions & 0 deletions sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ project(QSyncthingTray)

set(qst_src_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/qst)
set(contrib_src_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/contrib)
set(platforms_src_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/platforms)

set(qst_SOURCES
${qst_src_ROOT}/main.cpp
Expand All @@ -15,6 +16,12 @@ set(qst_SOURCES
${contrib_src_ROOT}/qcustomplot.cpp
)

if(APPLE)
set(qst_PLATFORMS_SOURCES
${platforms_src_ROOT}/darwin/macUtils.mm
)
endif()

if (${QST_BUILD_WEBKIT})
set(qst_SOURCES
${qst_SOURCES}
Expand All @@ -32,7 +39,12 @@ set(qst_SOURCES
${qst_SOURCES}
PARENT_SCOPE
)
set(qst_PLATFORMS_SOURCES
${qst_PLATFORMS_SOURCES}
PARENT_SCOPE
)

include_directories(${CMAKE_CURRENT_SOURCE_DIR})
source_group("Headers" FILES ${qst_HEADERS})
source_group("Sources" FILES ${qst_SOURCES})
source_group("Platforms Sources" FILES ${qst_PLATFORMS_SOURCES})
54 changes: 54 additions & 0 deletions sources/platforms/darwin/macUtils.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/******************************************************************************
// QSyncthingTray
// Copyright (c) Matthias Frick, All rights reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3.0 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library.
******************************************************************************/

#include <platforms/darwin/macUtils.hpp>
#include <Cocoa/Cocoa.h>

namespace qst
{
namespace platforms
{
namespace darwin
{
void MacUtils::showDockIcon(bool show)
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
ProcessSerialNumber psn;
windowCounter += show ? 1 : -1;
UInt32 transformState = show ? kProcessTransformToForegroundApplication :
kProcessTransformToUIElementApplication;
const bool shouldHideLastWindow =
(transformState == kProcessTransformToUIElementApplication &&
windowCounter == 0) ? true : false;
const bool shouldShowWindow =
(transformState == kProcessTransformToForegroundApplication &&
windowCounter > 0) ? true : false;
if (GetCurrentProcess(&psn) == noErr && (shouldShowWindow || shouldHideLastWindow))
{
TransformProcessType(&psn,
transformState);
dispatch_async(dispatch_get_main_queue(), ^{
[NSApp activateIgnoringOtherApps:YES];
});
}
#pragma clang diagnostic pop
}
}
}
}
Loading

0 comments on commit 77dc8fe

Please sign in to comment.