Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into qt6-category
Browse files Browse the repository at this point in the history
  • Loading branch information
Silarn committed Sep 5, 2023
2 parents 002cf74 + b300926 commit c7065ee
Show file tree
Hide file tree
Showing 113 changed files with 14,132 additions and 13,949 deletions.
41 changes: 41 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
# We'll use defaults from the LLVM style, but with 4 columns indentation.
BasedOnStyle: LLVM
IndentWidth: 2
---
Language: Cpp
DeriveLineEnding: false
UseCRLF: true
DerivePointerAlignment: false
PointerAlignment: Left
AlignConsecutiveAssignments: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Empty
AlwaysBreakTemplateDeclarations: Yes
AccessModifierOffset: -2
AlignTrailingComments: true
SpacesBeforeTrailingComments: 2
NamespaceIndentation: Inner
MaxEmptyLinesToKeep: 1
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: false
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: true
ColumnLimit: 88
ForEachMacros: ['Q_FOREACH', 'foreach']
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
218607a6ce4d41112bd3995ba319255aec3c5c2e
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.cpp text eol=crlf
*.h text eol=crlf
15 changes: 15 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Build UIBase
on:
push:
branches: master
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
runs-on: windows-2022
steps:
- name: Build UI Base
uses: ModOrganizer2/build-with-mob-action@master
with:
mo2-third-parties: fmt gtest spdlog boost
mo2-dependencies: cmake_common
15 changes: 15 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Lint UIBase
on:
push:
pull_request:
types: [opened, synchronize, reopened]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run clang-format
uses: jidicula/[email protected]
with:
clang-format-version: "15"
check-path: "."
107 changes: 49 additions & 58 deletions src/delayedfilewriter.cpp
Original file line number Diff line number Diff line change
@@ -1,58 +1,49 @@
#include "delayedfilewriter.h"
#include "log.h"


using namespace MOBase;


DelayedFileWriterBase::DelayedFileWriterBase(int delay)
: m_TimerDelay(delay)
, m_Timer()
{
QObject::connect(&m_Timer, &QTimer::timeout, this, &DelayedFileWriter::timerExpired);
m_Timer.setSingleShot(true);
}

DelayedFileWriterBase::~DelayedFileWriterBase()
{
if (m_Timer.isActive()) {
log::error("delayed file save timer active at shutdown");
}
}

void DelayedFileWriterBase::write()
{
m_Timer.start(m_TimerDelay);
}

void DelayedFileWriterBase::cancel()
{
m_Timer.stop();
}

void DelayedFileWriterBase::writeImmediately(bool ifOnTimer)
{
if (!ifOnTimer || m_Timer.isActive()) {
m_Timer.stop();
doWrite();
}
}

void DelayedFileWriterBase::timerExpired()
{
doWrite();
}



DelayedFileWriter::DelayedFileWriter(DelayedFileWriter::WriterFunc func
, int delay)
: DelayedFileWriterBase(delay)
, m_Func(func)
{
}

void DelayedFileWriter::doWrite()
{
m_Func();
}
#include "delayedfilewriter.h"
#include "log.h"

using namespace MOBase;

DelayedFileWriterBase::DelayedFileWriterBase(int delay) : m_TimerDelay(delay), m_Timer()
{
QObject::connect(&m_Timer, &QTimer::timeout, this, &DelayedFileWriter::timerExpired);
m_Timer.setSingleShot(true);
}

DelayedFileWriterBase::~DelayedFileWriterBase()
{
if (m_Timer.isActive()) {
log::error("delayed file save timer active at shutdown");
}
}

void DelayedFileWriterBase::write()
{
m_Timer.start(m_TimerDelay);
}

void DelayedFileWriterBase::cancel()
{
m_Timer.stop();
}

void DelayedFileWriterBase::writeImmediately(bool ifOnTimer)
{
if (!ifOnTimer || m_Timer.isActive()) {
m_Timer.stop();
doWrite();
}
}

void DelayedFileWriterBase::timerExpired()
{
doWrite();
}

DelayedFileWriter::DelayedFileWriter(DelayedFileWriter::WriterFunc func, int delay)
: DelayedFileWriterBase(delay), m_Func(func)
{}

void DelayedFileWriter::doWrite()
{
m_Func();
}
145 changes: 74 additions & 71 deletions src/delayedfilewriter.h
Original file line number Diff line number Diff line change
@@ -1,71 +1,74 @@
#ifndef DELAYEDFILEWRITER_H
#define DELAYEDFILEWRITER_H


#include "dllimport.h"
#include <QString>
#include <QTimer>
#include <functional>


namespace MOBase {

/**
* The purpose of this class is to aggregate changes to a file before writing it out
*/
class QDLLEXPORT DelayedFileWriterBase : public QObject {

Q_OBJECT

public:
/**
* @brief constructor
* @param fileName
* @param delay delay (in milliseconds) before we call the actual write function
*/
DelayedFileWriterBase(int delay = 200);
~DelayedFileWriterBase();

public slots:
/**
* @brief write with delay
*/
void write();

/**
* @brief cancel a scheduled write (does nothing if no write is scheduled)
*/
void cancel();

/**
* @brief write immediately without waiting for the timer to expire
* @param ifOnTimer only write if the timer is running
*/
void writeImmediately(bool ifOnTimer);

private slots:
void timerExpired();

private:
virtual void doWrite() = 0;

private:
int m_TimerDelay;
QTimer m_Timer;
};


class QDLLEXPORT DelayedFileWriter : public DelayedFileWriterBase {
public:
typedef std::function<void()> WriterFunc;
public:
DelayedFileWriter(WriterFunc func, int delay = 200);
private:
void doWrite();
private:
WriterFunc m_Func;
};

}

#endif // DELAYEDFILEWRITER_H
#ifndef DELAYEDFILEWRITER_H
#define DELAYEDFILEWRITER_H

#include "dllimport.h"
#include <QString>
#include <QTimer>
#include <functional>

namespace MOBase
{

/**
* The purpose of this class is to aggregate changes to a file before writing it out
*/
class QDLLEXPORT DelayedFileWriterBase : public QObject
{

Q_OBJECT

public:
/**
* @brief constructor
* @param fileName
* @param delay delay (in milliseconds) before we call the actual write function
*/
DelayedFileWriterBase(int delay = 200);
~DelayedFileWriterBase();

public slots:
/**
* @brief write with delay
*/
void write();

/**
* @brief cancel a scheduled write (does nothing if no write is scheduled)
*/
void cancel();

/**
* @brief write immediately without waiting for the timer to expire
* @param ifOnTimer only write if the timer is running
*/
void writeImmediately(bool ifOnTimer);

private slots:
void timerExpired();

private:
virtual void doWrite() = 0;

private:
int m_TimerDelay;
QTimer m_Timer;
};

class QDLLEXPORT DelayedFileWriter : public DelayedFileWriterBase
{
public:
typedef std::function<void()> WriterFunc;

public:
DelayedFileWriter(WriterFunc func, int delay = 200);

private:
void doWrite();

private:
WriterFunc m_Func;
};

} // namespace MOBase

#endif // DELAYEDFILEWRITER_H
49 changes: 25 additions & 24 deletions src/diagnosisreport.cpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
/*
Mod Organizer shared UI functionality
Copyright (C) 2012 Sebastian Herbord. 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 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; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "diagnosisreport.h"

namespace MOBase {
} // namespace MOBase
/*
Mod Organizer shared UI functionality
Copyright (C) 2012 Sebastian Herbord. 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 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; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "diagnosisreport.h"

namespace MOBase
{
} // namespace MOBase
Loading

0 comments on commit c7065ee

Please sign in to comment.