10 #include <QVersionNumber>
13 #include "ui_swiftdata.h"
34 using namespace swift::misc::network;
35 using namespace swift::misc::simulation;
41 using namespace swift::config;
46 Q_ASSERT_X(
sGui, Q_FUNC_INFO,
"Need sGui");
52 void CSwiftData::initStyleSheet()
55 CStyleSheetUtility::fileNameStandardWidget(),
56 CStyleSheetUtility::fileNameSwiftData() });
58 this->setStyleSheet(
"");
59 this->setStyleSheet(s);
71 this->performGracefulShutdown();
74 void CSwiftData::onStyleSheetsChanged() { this->initStyleSheet(); }
76 void CSwiftData::init()
78 Q_ASSERT_X(
sGui, Q_FUNC_INFO,
"Need sGui");
80 this->initLogDisplay();
86 this->initStyleSheet();
87 connect(
sGui, &CGuiApplication::styleSheetsChanged,
this, &CSwiftData::onStyleSheetsChanged, Qt::QueuedConnection);
92 if (!s.getDbHomePageUrl().isEmpty())
94 this->setWindowTitle(QStringLiteral(
"%1 %2").arg(this->windowTitle(), s.getDbHomePageUrl().toQString(
true)));
98 QPointer<CSwiftData> myself(
this);
101 this->checkMinimumVersion();
102 this->checkAutoPublishing();
106 void CSwiftData::initLogDisplay()
111 connect(&m_logHistory, &CLogHistoryReplica::elementAdded,
this,
116 CLogHandler::instance()->install(
true);
117 CLogHandler::instance()->enableConsoleOutput(
false);
120 void CSwiftData::initMenu()
124 this->initDynamicMenus();
125 ui->menu_WindowMinimize->setIcon(this->style()->standardIcon(QStyle::SP_TitleBarMinButton));
127 connect(ui->menu_WindowFont, &QAction::triggered,
this, &CSwiftData::onMenuClicked);
128 connect(ui->menu_MappingMaxData, &QAction::triggered,
this, &CSwiftData::onMenuClicked);
129 connect(ui->menu_MappingMaxMapping, &QAction::triggered,
this, &CSwiftData::onMenuClicked);
137 void CSwiftData::performGracefulShutdown()
142 void CSwiftData::consolidationSettingChanged()
144 const int consolidationSecs = m_consolidationSettings.
get();
145 if (consolidationSecs < 0)
149 ui->comp_MainInfoArea->getDataSettingsComponent()->setBackgroundUpdater(
nullptr);
150 disconnect(m_updater);
160 connect(m_updater, &CBackgroundDataUpdater::consolidating, ui->comp_InfoBar,
161 &CInfoBarWebReadersStatusComponent::consolidationRunning, Qt::QueuedConnection);
162 m_updater->
start(QThread::LowestPriority);
163 ui->comp_MainInfoArea->getDataSettingsComponent()->setBackgroundUpdater(m_updater);
169 void CSwiftData::displayLog() { ui->comp_MainInfoArea->displayLog(); }
171 void CSwiftData::checkMinimumVersion()
176 CLogMessage(
this).
info(u
"Checked mapping tool version, required '%1', this version '%2'")
183 u
"Your are using swift version: '%1'. Creating mappings requires at least '%2'.")
185 CLogMessage::preformatted(sm);
190 void CSwiftData::checkAutoPublishing()
192 if (!CAutoPublishData::existAutoPublishFiles()) {
return; }
193 this->showAutoPublishing();
196 void CSwiftData::showAutoPublishing()
SWIFT_CORE_EXPORT swift::core::CApplication * sApp
Single instance of application object.
swift data entry control (aka mapping tool)
virtual void closeEvent(QCloseEvent *event)
virtual ~CSwiftData()
Destructor.
CSwiftData(QWidget *parent=nullptr)
Constructor.
swift::misc::shared_state::CDataLinkDBus * getDataLinkDBus()
Transport mechanism for sharing state between applications.
data::CGlobalSetup getGlobalSetup() const
Global setup.
bool isShuttingDown() const
Is application shutting down?
Global settings for readers, debug flags, etc.
bool isSwiftVersionMinimumMappingVersion() const
Meets the minimum mapping version.
const QString & getMappingMinimumVersionString() const
Creating mappings requires at least this version or higher.
Update and consolidation of DB data.
void registerMainApplicationWidget(QWidget *mainWidget)
Register main application window widget if this is known.
void triggerNewVersionCheck(int delayedMs)
Trigger new version check.
void addMenuHelp(QMenu &menu)
Help operations.
void addMenuFile(QMenu &menu)
File menu.
void addMenuInternals(QMenu &menu)
Internals menu.
const CStyleSheetUtility & getStyleSheetUtility() const
Style sheet handling.
QDialog::DialogCode showCloseDialog(QMainWindow *mainWindow, QCloseEvent *closeEvent)
Show close dialog.
void addMenuWindow(QMenu &menu)
Window operations.
void initMainApplicationWidget(QWidget *mainWidget)
Init the main application window based on information in this application.
void displayStatusMessage(const swift::misc::CStatusMessage &statusMessage)
Display status message.
void initStatusBar(QStatusBar *statusBar=nullptr)
Init.
QString styles(const QStringList &fileNames) const
Multiple styles concatenated.
CManagedStatusBar * m_mwaStatusBar
status bar if any
virtual bool displayInOverlayWindow(const swift::misc::CStatusMessage &message, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Display in overlay window.
components::CLogComponent * m_mwaLogComponent
the log component if any
COverlayMessagesFrame * m_mwaOverlayFrame
overlay messages if any
CAutoPublishComponent as dialog.
int readAndShow()
Read files and show dialog.
T get() const
Get a copy of the current value.
void start(QThread::Priority priority=QThread::InheritPriority)
Starts a thread and moves the worker into it.
void startUpdating(int updateTimeSecs)
Start updating (start/stop timer)
Base class with a member CIdentifier to be inherited by a class which has an identity in the environm...
Class for emitting a log message.
Value class for matching log messages based on their categories.
Derived & info(const char16_t(&format)[N])
Set the severity to info, providing a format string.
Streamable status message, e.g.
void abandonAndWait() noexcept
Convenience to call abandon() followed by waitForFinished().
void setFilter(const U &filter)
Set filter to choose list elements.
virtual void initialize(IDataLink *dataLink)
Subscribe using the given transport mechanism.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
Core data traits (aka cached values) and classes.
Classes interacting with the swift database (aka "datastore").
Backend services of the swift project, like dealing with the network or the simulators.
High level reusable GUI components.
Free functions in swift::misc.
auto singleShot(int msec, QObject *target, F &&task)
Starts a single-shot timer which will call a task in the thread of the given object when it times out...