Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into feature/timeline-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
NghiaTranUIT committed Aug 9, 2019
2 parents 38bc8c9 + 5ea0790 commit bcd8c55
Show file tree
Hide file tree
Showing 134 changed files with 927 additions and 63,491 deletions.
12 changes: 12 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"files.associations": {
"__functional_03": "cpp",
"__string": "cpp",
"deque": "cpp",
"functional": "cpp",
"list": "cpp",
"string": "cpp",
"system_error": "cpp",
"vector": "cpp"
}
}
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ option(TOGGL_ALLOW_UPDATE_CHECK "Allow the app to check for updates" OFF)
option(USE_BUNDLED_LIBRARIES "Prefer bundled libraries to bundled ones" OFF)
option(INSTALL_HIRES_ICONS "Do not install icons over 512x512" OFF)

if ("${TOGGL_VERSION}" STREQUAL "7.0.0")
find_package (Git)
if (GIT_FOUND)
message("git found: ${GIT_EXECUTABLE} in version ${GIT_VERSION_STRING}")
execute_process(
COMMAND ${GIT_EXECUTABLE} --git-dir=${CMAKE_SOURCE_DIR}/.git --work-tree=${CMAKE_SOURCE_DIR} describe --tags
RESULT_VARIABLE RESULT_GIT
OUTPUT_VARIABLE OUTPUT_GIT
ERROR_VARIABLE ERROR_GIT)
string (REGEX REPLACE "^v" "" OUTPUT_GIT ${OUTPUT_GIT})
string (REGEX REPLACE "-([0-9]+)-.*" ".\\1" OUTPUT_GIT ${OUTPUT_GIT})
string (REGEX REPLACE "\n" "" TOGGL_VERSION ${OUTPUT_GIT})
else(GIT_FOUND)
message(WARNING "Version was not set by the user and it could not be retrieved from git - it will default to 7.0.0.")
endif (GIT_FOUND)
endif()

# Use PkgConfig to look for packages without native CMake support
include(FindPkgConfig)

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,18 @@ If you want to build OpenSSL from sources, refer to [this page](docs/win/build-o

## macOS

Toggl built and signed app for macOS is [available for download](https://www.toggl.com/api/v8/installer?platform=darwin&app=td&channel=stable). Officially macOS 10.11 and newer stable macOS versions are supported.
Toggl built and signed app for macOS is [available for download](https://toggl.github.io/toggldesktop/download/macos-stable/). Officially macOS 10.11 and newer stable macOS versions are supported.

## Windows

Toggl built and signed app for Windows is [available for download](https://www.toggl.com/api/v8/installer?platform=windows&app=td&channel=stable). App has been tested on Windows 7, 8, 8.1 and 10.
Toggl built and signed app for Windows is [available for download](https://toggl.github.io/toggldesktop/download/windows-stable/). App has been tested on Windows 7, 8, 8.1 and 10.

Toggl Desktop Windows app has not been tested on Surface type touchscreen environments.

## Linux (64 bit only)

* [flatpak(recommended)](https://flathub.org/apps/details/com.toggl.TogglDesktop)
* [tarball](https://www.toggl.com/api/v8/installer?app=td&platform=linux&channel=stable)
* [tarball](https://toggl.github.io/toggldesktop/download/linux_tar.gz-stable/)


# Change log
Expand Down
2 changes: 1 addition & 1 deletion src/lib/osx/TogglDesktopLibrary.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "mkdir -p $PROJECT_DIR/build\ncp $TARGET_BUILD_DIR/*.dylib $PROJECT_DIR/build\n";
shellScript = "mkdir -p $PROJECT_DIR/build\ncp $BUILT_PRODUCTS_DIR/*.dylib $PROJECT_DIR/build\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down
22 changes: 0 additions & 22 deletions src/lib/windows/TogglDesktopDLL.sln

This file was deleted.

Binary file removed src/lib/windows/TogglDesktopDLL.v12.suo
Binary file not shown.
Binary file removed src/lib/windows/UpgradeLog.htm
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion src/toggl_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ extern "C" {
char_t *Title;
char_t *Filename;
int64_t Duration;
bool Header;
bool_t Header;
// references subevents
void *Event;
// Next in list
Expand Down
6 changes: 6 additions & 0 deletions src/ui/linux/TogglDesktop/mainwindowcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,12 @@ void MainWindowController::writeSettings() {

void MainWindowController::closeEvent(QCloseEvent *event) {

// Window manager has requested the app to quit so just quit
if (powerManagement->aboutToShutdown()) {
QMainWindow::closeEvent(event);
return;
}

// Save current windows frame
TogglApi::instance->setWindowsFrameSetting(QRect(pos().x(),
pos().y(),
Expand Down
12 changes: 12 additions & 0 deletions src/ui/linux/TogglDesktop/powermanagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@

#include "./toggl.h"

#include <QGuiApplication>

PowerManagement::PowerManagement(QObject *parent)
: QObject(parent)
, available(true)
, commitDataRequested(false)
{
connect(qApp, &QGuiApplication::commitDataRequest, [this](QSessionManager &manager){
Q_UNUSED(manager);
commitDataRequested = true;
});

login1 = new QDBusInterface("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", QDBusConnection::systemBus(), this);

getInhibitor();
Expand All @@ -20,6 +28,10 @@ bool PowerManagement::isAvailable() const {
return available;
}

bool PowerManagement::aboutToShutdown() const {
return commitDataRequested;
}

void PowerManagement::onPrepareForShutdown(bool shuttingDown) {
if (shuttingDown) {
TogglApi::instance->stopEntryOnShutdown();
Expand Down
2 changes: 2 additions & 0 deletions src/ui/linux/TogglDesktop/powermanagement.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class PowerManagement : public QObject
explicit PowerManagement(QObject *parent = nullptr);

bool isAvailable() const;
bool aboutToShutdown() const;

signals:

Expand All @@ -29,6 +30,7 @@ private slots:
QDBusInterface *login1;
bool available;
QDBusUnixFileDescriptor inhibit;
bool commitDataRequested;
};

#endif // POWERMANAGEMENT_H
2 changes: 0 additions & 2 deletions src/ui/osx/TogglDesktop/AboutWindowController.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
//

#import <Cocoa/Cocoa.h>
#import "DisplayCommand.h"
#import <Sparkle/Sparkle.h>

@interface AboutWindowController : NSWindowController <SUUpdaterDelegate>
@property (assign, nonatomic) BOOL windowHasLoad;
@property (assign, nonatomic) BOOL restart;
@property (copy, nonatomic) NSString *updateStatus;

- (BOOL)isVisible;
- (void)checkForUpdates;
@end
1 change: 0 additions & 1 deletion src/ui/osx/TogglDesktop/AboutWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#import "AboutWindowController.h"
#import "UIEvents.h"
#import "toggl_api.h"
#import "DisplayCommand.h"
#import "Utils.h"
#import "UnsupportedNotice.h"
Expand Down
10 changes: 3 additions & 7 deletions src/ui/osx/TogglDesktop/AutocompleteDataSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@
//

#import <Foundation/Foundation.h>
#import "AutocompleteItem.h"

@class AutocompleteItem;

@interface AutocompleteDataSource : NSObject <NSComboBoxDataSource>
@property NSMutableArray *orderedKeys;
@property NSMutableArray *filteredOrderedKeys;
@property NSMutableDictionary *dictionary;
@property NSString *currentFilter;
@property NSInteger textLength;
@property NSComboBox *combobox;
@property (nonatomic, strong) NSComboBox *combobox;
- (NSString *)completedString:(NSString *)partialString;
- (AutocompleteItem *)get:(NSString *)key;
- (NSUInteger)count;
Expand Down
19 changes: 14 additions & 5 deletions src/ui/osx/TogglDesktop/AutocompleteDataSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,19 @@
//

#import "AutocompleteDataSource.h"
#import "toggl_api.h"
#import "UIEvents.h"
#import "AutocompleteItem.h"

@interface AutocompleteDataSource ()

@property (nonatomic, strong) NSMutableArray<NSString *> *orderedKeys;
@property (nonatomic, strong) NSMutableArray<NSString *> *filteredOrderedKeys;
@property (nonatomic, strong) NSMutableDictionary<NSString *, AutocompleteItem *> *dictionary;
@property (nonatomic, copy) NSString *currentFilter;
@property (nonatomic, assign) NSInteger textLength;

@end

@implementation AutocompleteDataSource

extern void *ctx;
Expand All @@ -19,8 +28,8 @@ - (id)initWithNotificationName:(NSString *)notificationName
{
self = [super init];

self.orderedKeys = [[NSMutableArray alloc] init];
self.filteredOrderedKeys = [[NSMutableArray alloc] init];
self.orderedKeys = [NSMutableArray<NSString *> array];
self.filteredOrderedKeys = [NSMutableArray<NSString *> array];
self.dictionary = [[NSMutableDictionary alloc] init];

[[NSNotificationCenter defaultCenter] addObserver:self
Expand All @@ -46,9 +55,9 @@ - (NSString *)completedString:(NSString *)partialString
return @"";
}

- (NSString *)get:(NSString *)key
- (AutocompleteItem *)get:(NSString *)key;
{
NSString *object = nil;
AutocompleteItem *object = nil;

@synchronized(self)
{
Expand Down
36 changes: 18 additions & 18 deletions src/ui/osx/TogglDesktop/AutocompleteItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,30 @@
//

#import <Foundation/Foundation.h>
#import "toggl_api.h"

@class ProjectSnapshot;

@interface AutocompleteItem : NSObject
@property (nonatomic, copy) NSString *Text;
@property (nonatomic, copy) NSString *Description;
@property (nonatomic, copy) NSString *DescriptionTitle; // Fix conflict with description in swift
@property (nonatomic, copy) NSString *ProjectAndTaskLabel;
@property (nonatomic, copy) NSString *TaskLabel;
@property (nonatomic, copy) NSString *ProjectLabel;
@property (nonatomic, copy) NSString *ClientLabel;
@property (nonatomic, copy) NSString *ProjectColor;
@property (nonatomic, copy) NSString *WorkspaceName;
@property (nonatomic, copy) NSString *ProjectGUID;
@property (nonatomic, assign) NSUInteger ID;
@property (nonatomic, assign) NSUInteger ProjectID;
@property (nonatomic, assign) NSUInteger WorkspaceID;
@property (nonatomic, assign) NSUInteger TaskID;
@property (nonatomic, assign) NSInteger Type;
@property (nonatomic, assign) BOOL Billable;
@property (nonatomic, strong) NSArray<NSString *> *tags;

- (instancetype)initWithSnapshot:(ProjectSnapshot *)snapshot;
+ (NSArray<AutocompleteItem *> *)loadAll:(TogglAutocompleteView *)first;
- (void)load:(TogglAutocompleteView *)data;
- (void)save:(TogglAutocompleteView *)data;
@property NSString *Text;
@property NSString *Description;
@property (copy, nonatomic) NSString *DescriptionTitle; // Fix conflict with description in swift
@property NSString *ProjectAndTaskLabel;
@property NSString *TaskLabel;
@property NSString *ProjectLabel;
@property NSString *ClientLabel;
@property NSString *ProjectColor;
@property NSString *WorkspaceName;
@property uint64_t ID;
@property uint64_t ProjectID;
@property (copy, nonatomic) NSString *ProjectGUID;
@property uint64_t WorkspaceID;
@property uint64_t TaskID;
@property int64_t Type;
@property bool Billable;
@property (strong) NSArray *tags;
@end
6 changes: 0 additions & 6 deletions src/ui/osx/TogglDesktop/AutocompleteItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,6 @@ - (void)save:(TogglAutocompleteView *)data
data->Tags = strdup([[self.tags componentsJoinedByString:@"\t"] UTF8String]);
}

- (NSString *)description
{
return [NSString stringWithFormat:@"Text: %@, WID: %llu, PID: %llu, TID: %llu, type: %llu",
self.Text, self.WorkspaceID, self.ProjectID, self.TaskID, self.Type];
}

+ (NSArray<AutocompleteItem *> *)loadAll:(TogglAutocompleteView *)first
{
NSMutableArray *result = [[NSMutableArray alloc] init];
Expand Down
6 changes: 0 additions & 6 deletions src/ui/osx/TogglDesktop/ConsoleViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,4 @@
#import <Cocoa/Cocoa.h>

@interface ConsoleViewController : NSWindowController
{
}
@property (weak) IBOutlet NSTextField *entryTextField;
@property (weak) IBOutlet NSButton *runButton;
@property (unsafe_unretained) IBOutlet NSTextView *resultTextView;
- (IBAction)onRun:(id)sender;
@end
5 changes: 4 additions & 1 deletion src/ui/osx/TogglDesktop/ConsoleViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
//

#import "ConsoleViewController.h"

#import "Utils.h"

@interface ConsoleViewController ()
@property (weak) IBOutlet NSTextField *entryTextField;
@property (weak) IBOutlet NSButton *runButton;
@property (strong) IBOutlet NSTextView *resultTextView;
- (IBAction)onRun:(id)sender;
@end

@implementation ConsoleViewController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ class TimeEntryDatasource: NSObject {

// MARK: Public

func selectFirstItem() {
// Check if there is a least 1 item
guard sections.first?.entries.first != nil else { return }
collectionView.window?.makeFirstResponder(collectionView)

// Deselect all because TE is multiple-selections
collectionView.deselectAll(self)
collectionView.selectItems(at: Set<IndexPath>(arrayLiteral: IndexPath(item: 0, section: 0)),
scrollPosition: .left)
}

func process(_ timeEntries: [TimeEntryViewItem], showLoadMore: Bool) {
isShowLoadMore = showLoadMore

Expand Down Expand Up @@ -412,9 +423,8 @@ extension TimeEntryDatasource {
func collectionView(_ collectionView: NSCollectionView, pasteboardWriterForItemAt indexPath: IndexPath) -> NSPasteboardWriting? {
guard let item = object(at: indexPath) else { return nil }
guard !item.loadMore else { return nil }

// Save indexpath
let data = NSKeyedArchiver.archivedData(withRootObject: indexPath)
let data = NSKeyedArchiver.archivedData(withRootObject: Array(collectionView.selectionIndexPaths))
let pbItem = NSPasteboardItem()
pbItem.setData(data, forType: NSPasteboard.PasteboardType.string)
return pbItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN

@property (strong, nonatomic) NSIndexPath *clickedIndexPath;

- (TimeEntryCell *)getSelectedEntryCell;
- (NSArray<TimeEntryCell *> *)getSelectedEntryCells;

@end

Expand Down
Loading

0 comments on commit bcd8c55

Please sign in to comment.