added helper method for generating window title
This commit is contained in:
parent
ee83d6c8b7
commit
bb9bc4eb5d
|
@ -0,0 +1,32 @@
|
||||||
|
#include "dialogutils.h"
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
namespace Dialogs {
|
||||||
|
|
||||||
|
QString generateWindowTitle(DocumentStatus documentStatus, const QString &documentPath)
|
||||||
|
{
|
||||||
|
switch(documentStatus) {
|
||||||
|
case DocumentStatus::Saved:
|
||||||
|
if(documentPath.isEmpty()) {
|
||||||
|
return QCoreApplication::translate("Utilities::windowTitle", "Unsaved - %1").arg(QCoreApplication::applicationName());
|
||||||
|
} else {
|
||||||
|
QFileInfo file(documentPath);
|
||||||
|
return QCoreApplication::translate("Utilities::windowTitle", "%1 - %2 - %3").arg(file.fileName(), file.dir().path(), QCoreApplication::applicationName());
|
||||||
|
}
|
||||||
|
case DocumentStatus::Unsaved:
|
||||||
|
if(documentPath.isEmpty()) {
|
||||||
|
return QCoreApplication::translate("Utilities::windowTitle", "*Unsaved - %1").arg(QCoreApplication::applicationName());
|
||||||
|
} else {
|
||||||
|
QFileInfo file(documentPath);
|
||||||
|
return QCoreApplication::translate("Utilities::windowTitle", "*%1 - %2 - %3").arg(file.fileName(), file.dir().path(), QCoreApplication::applicationName());
|
||||||
|
}
|
||||||
|
case DocumentStatus::NoDocument:
|
||||||
|
return QCoreApplication::applicationName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Dialogs
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
#ifndef DIALOGS_DIALOGUTILS_H
|
||||||
|
#define DIALOGS_DIALOGUTILS_H
|
||||||
|
|
||||||
|
#include <c++utilities/application/global.h>
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QString;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Dialogs {
|
||||||
|
|
||||||
|
enum class DocumentStatus {
|
||||||
|
NoDocument,
|
||||||
|
Saved,
|
||||||
|
Unsaved
|
||||||
|
};
|
||||||
|
|
||||||
|
QString LIB_EXPORT generateWindowTitle(DocumentStatus documentStatus, const QString &documentPath);
|
||||||
|
|
||||||
|
} // namespace Dialogs
|
||||||
|
|
||||||
|
#endif // DIALOGS_DIALOGUTILS_H
|
|
@ -28,7 +28,8 @@ contains(DEFINES, PLATFORM_SPECIFIC_CAPSLOCK_DETECTION) {
|
||||||
|
|
||||||
SOURCES += resources/resources.cpp \
|
SOURCES += resources/resources.cpp \
|
||||||
models/checklistmodel.cpp \
|
models/checklistmodel.cpp \
|
||||||
resources/qtconfigarguments.cpp
|
resources/qtconfigarguments.cpp \
|
||||||
|
misc/dialogutils.cpp
|
||||||
|
|
||||||
contains(DEFINES, GUI_QTWIDGETS) {
|
contains(DEFINES, GUI_QTWIDGETS) {
|
||||||
SOURCES += aboutdialog/aboutdialog.cpp \
|
SOURCES += aboutdialog/aboutdialog.cpp \
|
||||||
|
@ -52,7 +53,8 @@ contains(DEFINES, GUI_QTWIDGETS) {
|
||||||
|
|
||||||
HEADERS += resources/resources.h \
|
HEADERS += resources/resources.h \
|
||||||
models/checklistmodel.h \
|
models/checklistmodel.h \
|
||||||
resources/qtconfigarguments.h
|
resources/qtconfigarguments.h \
|
||||||
|
misc/dialogutils.h
|
||||||
|
|
||||||
contains(DEFINES, GUI_QTWIDGETS) {
|
contains(DEFINES, GUI_QTWIDGETS) {
|
||||||
HEADERS += aboutdialog/aboutdialog.h \
|
HEADERS += aboutdialog/aboutdialog.h \
|
||||||
|
|
Loading…
Reference in New Issue