Skip to content

Commit

Permalink
Merge pull request #124 from sieren/refactor-folders
Browse files Browse the repository at this point in the history
Restructure Folder Structure
  • Loading branch information
sieren committed May 31, 2016
2 parents 27b33db + c1950ad commit 5233c6e
Show file tree
Hide file tree
Showing 43 changed files with 185 additions and 120 deletions.
55 changes: 46 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,52 @@ include_directories(${Qt5Widgets_INCLUDES})
# We need add -DQT_WIDGETS_LIB when using QtWidgets in Qt 5.
add_definitions(${Qt5Widgets_DEFINITIONS})

# qt5_wrap_ui(UI_HEADERS mainwindow.ui)
qt5_add_resources(UI_RESOURCES src/qsyncthing.qrc)
# ____ _ _ __
# | _ \| | __ _| |_ / _| ___ _ __ _ __ ___
# | |_) | |/ _` | __| |_ / _ \| '__| '_ ` _ \
# | __/| | (_| | |_| _| (_) | | | | | | | |
# |_| |_|\__,_|\__|_| \___/|_| |_| |_| |_|
#

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

add_subdirectory(src src-binary)
set(SRC_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/src)
file(GLOB_RECURSE FILES_WP RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${SRC_ROOT}/*.cpp ${SRC_ROOT}/*.h ${SRC_ROOT}/*.hpp)
source_group("Platforms" ${qst_platform_SOURCES})

# ____ _ _
# | _ \ __ _| |_| |__ ___
# | |_) / _` | __| '_ \/ __|
# | __/ (_| | |_| | | \__ \
# |_| \__,_|\__|_| |_|___/
#

# qt5_wrap_ui(UI_HEADERS mainwindow.ui)
qt5_add_resources(UI_RESOURCES resources/qsyncthing.qrc)

include_directories(includes)
add_subdirectory(includes)
add_subdirectory(sources)

set(MACOSX_BUNDLE_ICON_FILE Syncthing.icns)
set(MACOSX_BUNDLE_ICON_FILE resources/Syncthing.icns)
SET_SOURCE_FILES_PROPERTIES(
Syncthing.icns
PROPERTIES
Expand All @@ -62,11 +98,12 @@ SET_SOURCE_FILES_PROPERTIES(

if(APPLE)
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
add_executable(QSyncthingTray MACOSX_BUNDLE src/Syncthing.icns ${UI_HEADERS} ${UI_RESOURCES} ${FILES_WP})
add_executable(QSyncthingTray MACOSX_BUNDLE resources/Syncthing.icns ${UI_HEADERS} ${UI_RESOURCES}
${qst_platform_SOURCES} ${qst_HEADERS} ${qst_SOURCES})
elseif(WIN32)
add_executable(QSyncthingTray WIN32 ${UI_HEADERS} ${UI_RESOURCES} ${FILES_WP})
add_executable(QSyncthingTray WIN32 ${UI_HEADERS} ${UI_RESOURCES} ${qst_platform_SOURCES} ${qst_HEADERS} ${qst_SOURCES})
elseif(UNIX)
add_executable(QSyncthingTray ${UI_HEADERS} ${UI_RESOURCES} ${FILES_WP})
add_executable(QSyncthingTray ${UI_HEADERS} ${UI_RESOURCES} ${qst_platform_SOURCES} ${qst_HEADERS} ${qst_SOURCES})
endif()

if (APPLE)
Expand Down
40 changes: 40 additions & 0 deletions QSyncthingTray.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
HEADERS = includes/qst/window.h \
includes/qst/syncconnector.h \
includes/platforms/darwin/macUtils.hpp \
includes/platforms/windows/winUtils.hpp \
includes/platforms/linux/posixUtils.hpp \
includes/qst/processmonitor.hpp \
includes/qst/platforms.hpp \
includes/qst/apihandler.hpp \
includes/qst/startuptab.hpp \
includes/qst/utilities.hpp \
includes/qst/syncwebview.h \
includes/qst/syncwebpage.h
SOURCES = sources/qst/main.cpp \
sources/qst/window.cpp \
sources/qst/syncconnector.cpp \
sources/qst/processmonitor.cpp \
sources/qst/startuptab.cpp \
sources/qst/syncwebview.cpp \
sources/qst/syncwebpage.cpp
RESOURCES = \
resources/qsyncthing.qrc

QT += widgets
QT += network
QT += webenginewidgets
INCLUDEPATH += $$PWD/includes/
# install
target.path = binary/
INSTALLS += target
CONFIG += c++11
macx {
QMAKE_INFO_PLIST = Info.plist
LIBS += -framework ApplicationServices
}
#QMAKE_CXXFLAGS += /wd4996
ICON = resources/Syncthing.icns
macx {
APP_BINARY_FILES.path = Contents/Resources
QMAKE_BUNDLE_DATA += APP_BINARY_FILES
}
28 changes: 28 additions & 0 deletions includes/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 3.0)
project(QSyncthingTray)

# ____
# / ___|___ _ __ ___
# | | / _ \| '__/ _ \
# | |__| (_) | | | __/
# \____\___/|_| \___|
#

set(qst_include_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/qst)
set(qst_HEADERS
${qst_include_ROOT}/apihandler.hpp
${qst_include_ROOT}/platforms.hpp
${qst_include_ROOT}/processmonitor.hpp
${qst_include_ROOT}/startuptab.hpp
${qst_include_ROOT}/syncconnector.h
${qst_include_ROOT}/syncwebpage.h
${qst_include_ROOT}/syncwebview.h
${qst_include_ROOT}/utilities.hpp
${qst_include_ROOT}/window.h
)



set(qst_HEADERS
${qst_HEADERS}
PARENT_SCOPE)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 4 additions & 2 deletions src/window.h → includes/qst/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@ private slots:
QAction *mpPauseSyncthingAction;
QAction *mpQuitAction;

std::list<QSharedPointer<QAction>> mCurrentFoldersActions;
std::list<QSharedPointer<QAction>> mCurrentSyncedFilesActions;
QList<QAction*> mCurrentFoldersActions;
QMenu *mpFolderMenu = nullptr;
QList<QAction*> mCurrentSyncedFilesActions;
QMenu *mpLastSyncedMenu = nullptr;

std::list<FolderNameFullPath> mCurrentFoldersLocations;
LastSyncedFileList mLastSyncedFiles;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/build_linux.sh → scripts/build_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ if [ -z "$QTDIR" ];
exit 1;
fi

$QTDIR/qmake -config release .
$QTDIR/qmake -config release ../
make

2 changes: 1 addition & 1 deletion src/build_project.sh → 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.5/clang_64/bin/qmake ../
make
~/Qt/5.5/clang_64/bin/macdeployqt QSyncthingTray.app -dmg -verbose=2
File renamed without changes.
5 changes: 5 additions & 0 deletions scripts/generate_msvc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
# For OS X

./clean.sh
/c/Qt/5.5/msvc2013_64/bin/qmake -tp vc ../QSyncthingTray.pro
2 changes: 1 addition & 1 deletion src/generate_xcode.sh → scripts/generate_xcode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# For OS X

./clean.sh
~/Qt/5.5/clang_64/bin/qmake -spec macx-xcode .
~/Qt/5.5/clang_64/bin/qmake -spec macx-xcode ../
open QSyncthingTray.xcodeproj
19 changes: 19 additions & 0 deletions sources/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.0)
project(QSyncthingTray)

set(qst_src_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/qst)

set(qst_SOURCES
${qst_src_ROOT}/main.cpp
${qst_src_ROOT}/processmonitor.cpp
${qst_src_ROOT}/startuptab.cpp
${qst_src_ROOT}/syncconnector.cpp
${qst_src_ROOT}/syncwebpage.cpp
${qst_src_ROOT}/syncwebview.cpp
${qst_src_ROOT}/window.cpp
PARENT_SCOPE
)

include_directories(${CMAKE_CURRENT_SOURCE_DIR})
source_group("Headers" FILES ${qst_HEADERS})
source_group("Sources" FILES ${qst_SOURCES})
2 changes: 1 addition & 1 deletion src/main.cpp → sources/qst/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#ifndef QT_NO_SYSTEMTRAYICON

#include <QMessageBox>
#include "window.h"
#include <qst/window.h>


int main(int argc, char *argv[])
Expand Down
2 changes: 1 addition & 1 deletion src/processmonitor.cpp → sources/qst/processmonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
******************************************************************************/


#include "processmonitor.hpp"
#include <qst/processmonitor.hpp>
#include <QApplication>
#include <QHeaderView>

Expand Down
5 changes: 2 additions & 3 deletions src/startuptab.cpp → sources/qst/startuptab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// License along with this library.
******************************************************************************/

#include "startuptab.hpp"
#include <qst/startuptab.hpp>
#include <QFileDialog>

namespace qst
Expand Down Expand Up @@ -152,7 +152,7 @@ void StartupTab::showFileBrowser()
{
QString filename = QFileDialog::getOpenFileName(this,
tr("Open Syncthing"), "", tr(""));
if (filename.toStdString() != "")
if (!filename.isEmpty())
{
mCurrentSyncthingPath = filename.toStdString();
mpFilePathLine->setText(filename);
Expand Down Expand Up @@ -253,7 +253,6 @@ void StartupTab::loadSettings()

void StartupTab::pathEnterPressed()
{
saveSettings();
mCurrentSyncthingPath = mpFilePathLine->text().toStdString();
mCurrentINotifyPath = mpINotifyFilePath->text().toStdString();
if (mSettings.value("syncthingpath").toString().toStdString() != mCurrentSyncthingPath)
Expand Down
7 changes: 4 additions & 3 deletions src/syncconnector.cpp → sources/qst/syncconnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
// License along with this library.
******************************************************************************/

#include "syncconnector.h"
#include <qst/syncconnector.h>
#include <QtGui>
#include <QObject>
#include <QMessageBox>
#include <QStyleFactory>
#include <cmath>
#include <iostream>
#include "platforms.hpp"
#include "utilities.hpp"
#include <qst/platforms.hpp>
#include <qst/utilities.hpp>

namespace qst
{
Expand Down Expand Up @@ -167,6 +167,7 @@ void SyncConnector::checkConnectionHealth()
QUrl lastSyncedListURL = mCurrentUrl;
lastSyncedListURL.setPath(tr("/rest/stats/folder"));
QNetworkRequest lastSyncedRequest(lastSyncedListURL);
lastSyncedRequest.setRawHeader(QByteArray("X-API-Key"), headerByte);
QNetworkReply *lastSyncreply = network.get(lastSyncedRequest);
requestMap[lastSyncreply] = kRequestMethod::getLastSyncedFiles;

Expand Down
2 changes: 1 addition & 1 deletion src/syncwebpage.cpp → sources/qst/syncwebpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
******************************************************************************/

#include <iostream>
#include "syncwebpage.h"
#include <qst/syncwebpage.h>

//------------------------------------------------------------------------------------//
#define UNUSED(x) (void)(x)
Expand Down
2 changes: 1 addition & 1 deletion src/syncwebview.cpp → sources/qst/syncwebview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
******************************************************************************/


#include "syncwebview.h"
#include <qst/syncwebview.h>
#include <QContextMenuEvent>
#include <QWebEngineProfile>
#include <QWebEngineSettings>
Expand Down
Loading

0 comments on commit 5233c6e

Please sign in to comment.