Fix decoration for static builds

- Also fix finding static web view and JavaScript provider
This commit is contained in:
Martchus 2016-08-29 15:41:11 +02:00
parent 72296a2768
commit 7f9afcda73
33 changed files with 935 additions and 904 deletions

View File

@ -75,6 +75,7 @@ set(WIDGETS_UI_FILES
set(CMAKE_MODULE_FILES set(CMAKE_MODULE_FILES
cmake/modules/QtConfig.cmake cmake/modules/QtConfig.cmake
cmake/modules/QtGuiConfig.cmake cmake/modules/QtGuiConfig.cmake
cmake/modules/QtLinkage.cmake
cmake/modules/JsProviderConfig.cmake cmake/modules/JsProviderConfig.cmake
cmake/modules/WebViewProviderConfig.cmake cmake/modules/WebViewProviderConfig.cmake
) )

View File

@ -1,76 +1,76 @@
#include "./aboutdialog.h" #include "./aboutdialog.h"
#include "../misc/dialogutils.h" #include "../misc/dialogutils.h"
#include "ui_aboutdialog.h" #include "ui_aboutdialog.h"
#include <QGraphicsPixmapItem> #include <QGraphicsPixmapItem>
#include <QApplication> #include <QApplication>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QStyle> #include <QStyle>
/*! /*!
\namespace Dialogs \namespace Dialogs
\brief Provides common dialogs such as AboutDialog, EnterPasswordDialog and SettingsDialog. \brief Provides common dialogs such as AboutDialog, EnterPasswordDialog and SettingsDialog.
*/ */
namespace Dialogs { namespace Dialogs {
/*! /*!
* \class Dialogs::AboutDialog * \class Dialogs::AboutDialog
* \brief The AboutDialog class provides a simple about dialog. * \brief The AboutDialog class provides a simple about dialog.
*/ */
/*! /*!
* \brief Constructs an about dialog with the provided information. * \brief Constructs an about dialog with the provided information.
* \param parent Specifies the parent widget. * \param parent Specifies the parent widget.
* \param applicationName Specifies the name of the application. If empty, QApplication::applicationName() will be used. * \param applicationName Specifies the name of the application. If empty, QApplication::applicationName() will be used.
* \param creator Specifies the creator of the application. If empty, QApplication::organizationName() will be used. * \param creator Specifies the creator of the application. If empty, QApplication::organizationName() will be used.
* \param version Specifies the version of the application. If empty, QApplication::applicationVersion() will be used. * \param version Specifies the version of the application. If empty, QApplication::applicationVersion() will be used.
* \param description Specifies a short description about the application. * \param description Specifies a short description about the application.
* \param website Specifies the URL to the website of the application. If empty, QApplication::organizationDomain() will be used. * \param website Specifies the URL to the website of the application. If empty, QApplication::organizationDomain() will be used.
* \param image Specifies the application icon. If the image is null, the standard information icon will be used. * \param image Specifies the application icon. If the image is null, the standard information icon will be used.
*/ */
AboutDialog::AboutDialog(QWidget *parent, const QString &applicationName, const QString &creator, const QString &version, const QString &website, const QString &description, const QImage &image) : AboutDialog::AboutDialog(QWidget *parent, const QString &applicationName, const QString &creator, const QString &version, const QString &website, const QString &description, const QImage &image) :
QDialog(parent), QDialog(parent),
m_ui(new Ui::AboutDialog) m_ui(new Ui::AboutDialog)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
makeHeading(m_ui->productNameLabel); makeHeading(m_ui->productNameLabel);
setStyleSheet(dialogStyle()); setStyleSheet(dialogStyle());
setWindowFlags(Qt::Tool); setWindowFlags(Qt::Tool);
if(!applicationName.isEmpty()) { if(!applicationName.isEmpty()) {
m_ui->productNameLabel->setText(applicationName); m_ui->productNameLabel->setText(applicationName);
} else if(!QApplication::applicationDisplayName().isEmpty()) { } else if(!QApplication::applicationDisplayName().isEmpty()) {
m_ui->productNameLabel->setText(QApplication::applicationDisplayName()); m_ui->productNameLabel->setText(QApplication::applicationDisplayName());
} else { } else {
m_ui->productNameLabel->setText(QApplication::applicationName()); m_ui->productNameLabel->setText(QApplication::applicationName());
} }
m_ui->creatorLabel->setText(tr("developed by %1").arg( m_ui->creatorLabel->setText(tr("developed by %1").arg(
creator.isEmpty() ? QApplication::organizationName() : creator)); creator.isEmpty() ? QApplication::organizationName() : creator));
m_ui->versionLabel->setText(version.isEmpty() ? QApplication::applicationVersion() : version); m_ui->versionLabel->setText(version.isEmpty() ? QApplication::applicationVersion() : version);
m_ui->websiteLabel->setText(tr("For updates and bug reports visit the <a href=\"%1\" style=\"text-decoration: underline; color: palette(link);\">project website</a>.").arg( m_ui->websiteLabel->setText(tr("For updates and bug reports visit the <a href=\"%1\" style=\"text-decoration: underline; color: palette(link);\">project website</a>.").arg(
website.isEmpty() ? QApplication::organizationDomain() : website)); website.isEmpty() ? QApplication::organizationDomain() : website));
m_ui->descLabel->setText(description); m_ui->descLabel->setText(description);
m_iconScene = new QGraphicsScene(this); m_iconScene = new QGraphicsScene(this);
auto *item = image.isNull() auto *item = image.isNull()
? new QGraphicsPixmapItem(QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation, nullptr, this).pixmap(128)) ? new QGraphicsPixmapItem(QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation, nullptr, this).pixmap(128))
: new QGraphicsPixmapItem(QPixmap::fromImage(image)); : new QGraphicsPixmapItem(QPixmap::fromImage(image));
m_iconScene->addItem(item); m_iconScene->addItem(item);
m_ui->graphicsView->setScene(m_iconScene); m_ui->graphicsView->setScene(m_iconScene);
setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, size(), parentWidget() ? parentWidget()->geometry() : QApplication::desktop()->availableGeometry())); setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, size(), parentWidget() ? parentWidget()->geometry() : QApplication::desktop()->availableGeometry()));
} }
/*! /*!
* \brief Constructs an about dialog with the specified \a parent, \a description and \a image. * \brief Constructs an about dialog with the specified \a parent, \a description and \a image.
*/ */
AboutDialog::AboutDialog(QWidget *parent, const QString &description, const QImage &image) : AboutDialog::AboutDialog(QWidget *parent, const QString &description, const QImage &image) :
AboutDialog(parent, QString(), QString(), QString(), QString(), description, image) AboutDialog(parent, QString(), QString(), QString(), QString(), description, image)
{} {}
/*! /*!
* \brief Destroys the about dialog. * \brief Destroys the about dialog.
*/ */
AboutDialog::~AboutDialog() AboutDialog::~AboutDialog()
{} {}
} }

View File

@ -1,34 +1,34 @@
#ifndef DIALOGS_ABOUTDIALOG_H #ifndef DIALOGS_ABOUTDIALOG_H
#define DIALOGS_ABOUTDIALOG_H #define DIALOGS_ABOUTDIALOG_H
#include <c++utilities/application/global.h> #include "../global.h"
#include <QDialog> #include <QDialog>
#include <memory> #include <memory>
QT_FORWARD_DECLARE_CLASS(QGraphicsScene) QT_FORWARD_DECLARE_CLASS(QGraphicsScene)
namespace Dialogs { namespace Dialogs {
namespace Ui { namespace Ui {
class AboutDialog; class AboutDialog;
} }
class LIB_EXPORT AboutDialog : public QDialog class QT_UTILITIES_EXPORT AboutDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit AboutDialog(QWidget *parent, const QString &applicationName, const QString &creator, const QString &version, const QString &website = QString(), const QString &description = QString(), const QImage &image = QImage()); explicit AboutDialog(QWidget *parent, const QString &applicationName, const QString &creator, const QString &version, const QString &website = QString(), const QString &description = QString(), const QImage &image = QImage());
explicit AboutDialog(QWidget *parent, const QString &description = QString(), const QImage &image = QImage()); explicit AboutDialog(QWidget *parent, const QString &description = QString(), const QImage &image = QImage());
~AboutDialog(); ~AboutDialog();
private: private:
std::unique_ptr<Ui::AboutDialog> m_ui; std::unique_ptr<Ui::AboutDialog> m_ui;
QGraphicsScene *m_iconScene; QGraphicsScene *m_iconScene;
}; };
} }
#endif // DIALOGS_ABOUTDIALOG_H #endif // DIALOGS_ABOUTDIALOG_H

View File

@ -1,5 +1,7 @@
# determines the JavaScript provider (either Qt Script or Qt Declarative) # determines the JavaScript provider (either Qt Script or Qt Declarative)
include(QtLinkage)
set(JS_PROVIDER "auto" CACHE STRING "specifies the JavaScript provider: auto (default), qml, script or none") set(JS_PROVIDER "auto" CACHE STRING "specifies the JavaScript provider: auto (default), qml, script or none")
if(${JS_PROVIDER} STREQUAL "auto") if(${JS_PROVIDER} STREQUAL "auto")
find_package(Qt5Script) find_package(Qt5Script)

View File

@ -21,21 +21,7 @@ if(DBUS_FILES)
list(APPEND QT_MODULES DBus) list(APPEND QT_MODULES DBus)
endif() endif()
# determine Qt linkage include(QtLinkage)
set(QT_LINKAGE "AUTO_LINKAGE")
if(BUILD_STATIC_LIBS AND BUILD_SHARED_LIBS)
message(FATAL_ERROR "When using Qt/KDE modules it is not possible to build shared and static libraries at the same time.")
endif()
# set USE_STATIC_QT_BUILD variable to ON to use static Qt
# this only works with patched mingw-w64-qt5-* packages found in my PKGBUILDs repository
# in any other environment you must ensure that the available Qt version is in accordance with the specified STATIC_LINKAGE/STATIC_LIBRARY_LINKAGE options
if(BUILD_STATIC_LIBS OR ("${QT_LINKAGE}" STREQUAL "AUTO_LINKAGE" AND ((STATIC_LINKAGE AND "${META_PROJECT_TYPE}" STREQUAL "application") OR (STATIC_LIBRARY_LINKAGE AND ("${META_PROJECT_TYPE}" STREQUAL "" OR "${META_PROJECT_TYPE}" STREQUAL "library")))) OR ("${QT_LINKAGE}" STREQUAL "STATIC"))
set(USE_STATIC_QT_BUILD ON)
message(STATUS "Linking ${META_PROJECT_NAME} statically against Qt 5.")
elseif(("${QT_LINKAGE}" STREQUAL "AUTO_LINKAGE") OR ("${QT_LINKAGE}" STREQUAL "SHARED"))
set(USE_STATIC_QT_BUILD OFF)
message(STATUS "Linking ${META_PROJECT_NAME} dynamically against Qt 5.")
endif()
# actually find the required Qt/KF modules # actually find the required Qt/KF modules
foreach(QT_MODULE ${QT_MODULES}) foreach(QT_MODULE ${QT_MODULES})

View File

@ -0,0 +1,21 @@
# determines the Qt linkage
if(NOT DEFINED QT_LINKAGE_DETERMINED)
set(QT_LINKAGE_DETERMINED true)
set(QT_LINKAGE "AUTO_LINKAGE")
if(BUILD_STATIC_LIBS AND BUILD_SHARED_LIBS)
message(FATAL_ERROR "When using Qt/KDE modules it is not possible to build shared and static libraries at the same time.")
endif()
# set USE_STATIC_QT_BUILD variable to ON to use static Qt
# this only works with patched mingw-w64-qt5-* packages found in my PKGBUILDs repository
# in any other environment you must ensure that the available Qt version is in accordance with the specified STATIC_LINKAGE/STATIC_LIBRARY_LINKAGE options
if(BUILD_STATIC_LIBS OR ("${QT_LINKAGE}" STREQUAL "AUTO_LINKAGE" AND ((STATIC_LINKAGE AND "${META_PROJECT_TYPE}" STREQUAL "application") OR (STATIC_LIBRARY_LINKAGE AND ("${META_PROJECT_TYPE}" STREQUAL "" OR "${META_PROJECT_TYPE}" STREQUAL "library")))) OR ("${QT_LINKAGE}" STREQUAL "STATIC"))
set(USE_STATIC_QT_BUILD ON)
message(STATUS "Linking ${META_PROJECT_NAME} statically against Qt 5.")
elseif(("${QT_LINKAGE}" STREQUAL "AUTO_LINKAGE") OR ("${QT_LINKAGE}" STREQUAL "SHARED"))
set(USE_STATIC_QT_BUILD OFF)
message(STATUS "Linking ${META_PROJECT_NAME} dynamically against Qt 5.")
endif()
endif(NOT DEFINED QT_LINKAGE_DETERMINED)

View File

@ -1,5 +1,7 @@
# determines the web view provider (either Qt WebKit or Qt WebEngine) # determines the web view provider (either Qt WebKit or Qt WebEngine)
include(QtLinkage)
set(WEBVIEW_PROVIDER "auto" CACHE STRING "specifies the web view provider: auto (default), webkit, webengine or none") set(WEBVIEW_PROVIDER "auto" CACHE STRING "specifies the web view provider: auto (default), webkit, webengine or none")
if(${WEBVIEW_PROVIDER} STREQUAL "auto") if(${WEBVIEW_PROVIDER} STREQUAL "auto")
find_package(Qt5WebKitWidgets) find_package(Qt5WebKitWidgets)

View File

@ -1,332 +1,332 @@
#include "./enterpassworddialog.h" #include "./enterpassworddialog.h"
#include "../misc/dialogutils.h" #include "../misc/dialogutils.h"
#include "ui_enterpassworddialog.h" #include "ui_enterpassworddialog.h"
#include <QEvent> #include <QEvent>
#include <QGraphicsPixmapItem> #include <QGraphicsPixmapItem>
#include <QKeyEvent> #include <QKeyEvent>
#include <QMessageBox> #include <QMessageBox>
#include <QGuiApplication> #include <QGuiApplication>
#ifdef PLATFORM_SPECIFIC_CAPSLOCK_DETECTION #ifdef PLATFORM_SPECIFIC_CAPSLOCK_DETECTION
# if defined(Q_OS_WIN32) # if defined(Q_OS_WIN32)
# include <windows.h> # include <windows.h>
# elif defined(X_AVAILABLE) # elif defined(X_AVAILABLE)
# include <X11/XKBlib.h> # include <X11/XKBlib.h>
# undef KeyPress # undef KeyPress
# undef KeyRelease # undef KeyRelease
# undef FocusIn # undef FocusIn
# undef FocusOut # undef FocusOut
# endif # endif
#endif #endif
namespace Dialogs { namespace Dialogs {
/*! /*!
* \class Dialogs::EnterPasswordDialog * \class Dialogs::EnterPasswordDialog
* \brief The EnterPasswordDialog class provides a simple dialog to ask the user for a password. * \brief The EnterPasswordDialog class provides a simple dialog to ask the user for a password.
*/ */
/*! /*!
* \brief Constructs a password dialog. * \brief Constructs a password dialog.
* \param parent Specifies the parent widget. * \param parent Specifies the parent widget.
*/ */
EnterPasswordDialog::EnterPasswordDialog(QWidget *parent) : EnterPasswordDialog::EnterPasswordDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
m_ui(new Ui::EnterPasswordDialog) m_ui(new Ui::EnterPasswordDialog)
{ {
// setup ui // setup ui
m_ui->setupUi(this); m_ui->setupUi(this);
makeHeading(m_ui->instructionLabel); makeHeading(m_ui->instructionLabel);
setStyleSheet(dialogStyle()); setStyleSheet(dialogStyle());
setDescription(); setDescription();
setPromptForUserName(false); setPromptForUserName(false);
setVerificationRequired(false); setVerificationRequired(false);
setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
installEventFilter(this); installEventFilter(this);
m_ui->userNameLineEdit->installEventFilter(this); m_ui->userNameLineEdit->installEventFilter(this);
m_ui->password1LineEdit->installEventFilter(this); m_ui->password1LineEdit->installEventFilter(this);
m_ui->password2LineEdit->installEventFilter(this); m_ui->password2LineEdit->installEventFilter(this);
// capslock key detection // capslock key detection
#ifdef PLATFORM_SPECIFIC_CAPSLOCK_DETECTION #ifdef PLATFORM_SPECIFIC_CAPSLOCK_DETECTION
m_capslockPressed = isCapslockPressed(); m_capslockPressed = isCapslockPressed();
#else #else
m_capslockPressed = false; m_capslockPressed = false;
#endif #endif
m_ui->capslockWarningWidget->setVisible(m_capslockPressed); m_ui->capslockWarningWidget->setVisible(m_capslockPressed);
// draw icon to capslock warning graphics view // draw icon to capslock warning graphics view
QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning, nullptr, this); QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning, nullptr, this);
QGraphicsScene* scene = new QGraphicsScene(); QGraphicsScene* scene = new QGraphicsScene();
QGraphicsPixmapItem* item = new QGraphicsPixmapItem(icon.pixmap(16, 16)); QGraphicsPixmapItem* item = new QGraphicsPixmapItem(icon.pixmap(16, 16));
scene->addItem(item); scene->addItem(item);
m_ui->capslockWarningGraphicsView->setScene(scene); m_ui->capslockWarningGraphicsView->setScene(scene);
// connect signals and slots // connect signals and slots
connect(m_ui->showPasswordCheckBox, &QCheckBox::clicked, this, &EnterPasswordDialog::updateShowPassword); connect(m_ui->showPasswordCheckBox, &QCheckBox::clicked, this, &EnterPasswordDialog::updateShowPassword);
connect(m_ui->noPwCheckBox, &QCheckBox::clicked, this, &EnterPasswordDialog::updateShowPassword); connect(m_ui->noPwCheckBox, &QCheckBox::clicked, this, &EnterPasswordDialog::updateShowPassword);
connect(m_ui->confirmPushButton, &QPushButton::clicked, this, &EnterPasswordDialog::confirm); connect(m_ui->confirmPushButton, &QPushButton::clicked, this, &EnterPasswordDialog::confirm);
connect(m_ui->abortPushButton, &QPushButton::clicked, this, &EnterPasswordDialog::abort); connect(m_ui->abortPushButton, &QPushButton::clicked, this, &EnterPasswordDialog::abort);
// grab the keyboard // grab the keyboard
grabKeyboard(); grabKeyboard();
} }
/*! /*!
* \brief Destroys the password dialog. * \brief Destroys the password dialog.
*/ */
EnterPasswordDialog::~EnterPasswordDialog() EnterPasswordDialog::~EnterPasswordDialog()
{} {}
/*! /*!
* \brief Returns the description. The description is shown under the instruction text. * \brief Returns the description. The description is shown under the instruction text.
* \sa setDescription() * \sa setDescription()
*/ */
QString EnterPasswordDialog::description() const QString EnterPasswordDialog::description() const
{ {
return m_ui->descLabel->text(); return m_ui->descLabel->text();
} }
/*! /*!
* \brief Sets the description. * \brief Sets the description.
* \sa description() * \sa description()
*/ */
void EnterPasswordDialog::setDescription(const QString &description) void EnterPasswordDialog::setDescription(const QString &description)
{ {
m_ui->descLabel->setText(description); m_ui->descLabel->setText(description);
m_ui->descLabel->setHidden(description.isEmpty()); m_ui->descLabel->setHidden(description.isEmpty());
adjustSize(); adjustSize();
} }
/*! /*!
* \brief Returns whether the dialogs prompts for a user name as well. * \brief Returns whether the dialogs prompts for a user name as well.
* *
* The dialog does not prompt for a user name by default. * The dialog does not prompt for a user name by default.
* *
* \sa setPromptForUserName() * \sa setPromptForUserName()
*/ */
bool EnterPasswordDialog::promtForUserName() const bool EnterPasswordDialog::promtForUserName() const
{ {
return !m_ui->userNameLineEdit->isHidden(); return !m_ui->userNameLineEdit->isHidden();
} }
/*! /*!
* \brief Sets whethere the dialog prompts for a user name as well. * \brief Sets whethere the dialog prompts for a user name as well.
* \sa promptForUserName() * \sa promptForUserName()
*/ */
void EnterPasswordDialog::setPromptForUserName(bool prompt) void EnterPasswordDialog::setPromptForUserName(bool prompt)
{ {
m_ui->userNameLineEdit->setHidden(!prompt); m_ui->userNameLineEdit->setHidden(!prompt);
adjustSize(); adjustSize();
} }
/*! /*!
* \brief Returns an indication whether a verification (password has to be entered twice) is required. * \brief Returns an indication whether a verification (password has to be entered twice) is required.
* *
* \sa EnterPasswordDialog::setVerificationRequired() * \sa EnterPasswordDialog::setVerificationRequired()
*/ */
bool EnterPasswordDialog::isVerificationRequired() const bool EnterPasswordDialog::isVerificationRequired() const
{ {
return !m_ui->password2LineEdit->isHidden(); return !m_ui->password2LineEdit->isHidden();
} }
/*! /*!
* \brief Returns an indication whether the user is force to enter a password. * \brief Returns an indication whether the user is force to enter a password.
* *
* If no password is required, the user is allowed to skip the dialog without entering * If no password is required, the user is allowed to skip the dialog without entering
* a password. * a password.
* *
* \sa EnterPasswordDialog::setPasswordRequired() * \sa EnterPasswordDialog::setPasswordRequired()
*/ */
bool EnterPasswordDialog::isPasswordRequired() const bool EnterPasswordDialog::isPasswordRequired() const
{ {
return m_ui->noPwCheckBox->isHidden(); return m_ui->noPwCheckBox->isHidden();
} }
/*! /*!
* \brief Sets whether the user is force to enter a password. * \brief Sets whether the user is force to enter a password.
* *
* If no password is required, the user is allowed to skip the dialog without entering * If no password is required, the user is allowed to skip the dialog without entering
* a password. * a password.
* *
* \sa EnterPasswordDialog::isPasswordRequired() * \sa EnterPasswordDialog::isPasswordRequired()
*/ */
void EnterPasswordDialog::setPasswordRequired(bool value) void EnterPasswordDialog::setPasswordRequired(bool value)
{ {
m_ui->noPwCheckBox->setHidden(value); m_ui->noPwCheckBox->setHidden(value);
m_ui->noPwCheckBox->setChecked(false); m_ui->noPwCheckBox->setChecked(false);
adjustSize(); adjustSize();
} }
/*! /*!
* \brief Updates the relevant controls to show entered characters or to mask them them. * \brief Updates the relevant controls to show entered characters or to mask them them.
* *
* This private slot is called when m_ui->showPasswordCheckBox is clicked. * This private slot is called when m_ui->showPasswordCheckBox is clicked.
*/ */
void EnterPasswordDialog::updateShowPassword() void EnterPasswordDialog::updateShowPassword()
{ {
m_ui->password1LineEdit->setEchoMode(m_ui->showPasswordCheckBox->isChecked() m_ui->password1LineEdit->setEchoMode(m_ui->showPasswordCheckBox->isChecked()
? QLineEdit::Normal ? QLineEdit::Normal
: QLineEdit::Password); : QLineEdit::Password);
m_ui->password1LineEdit->setEnabled(!m_ui->noPwCheckBox->isChecked()); m_ui->password1LineEdit->setEnabled(!m_ui->noPwCheckBox->isChecked());
m_ui->password2LineEdit->setEnabled(!(m_ui->showPasswordCheckBox->isChecked() || m_ui->noPwCheckBox->isChecked())); m_ui->password2LineEdit->setEnabled(!(m_ui->showPasswordCheckBox->isChecked() || m_ui->noPwCheckBox->isChecked()));
} }
/*! /*!
* \brief Sets whether a verification (password has to be entered twice) is required. * \brief Sets whether a verification (password has to be entered twice) is required.
* *
* \sa EnterPasswordDialog::isVerificationRequired() * \sa EnterPasswordDialog::isVerificationRequired()
*/ */
void EnterPasswordDialog::setVerificationRequired(bool value) void EnterPasswordDialog::setVerificationRequired(bool value)
{ {
if(m_instruction.isEmpty()) { if(m_instruction.isEmpty()) {
m_ui->instructionLabel->setText(value ? tr("Enter the new password") : tr("Enter the password")); m_ui->instructionLabel->setText(value ? tr("Enter the new password") : tr("Enter the password"));
} }
m_ui->password2LineEdit->setHidden(!value); m_ui->password2LineEdit->setHidden(!value);
adjustSize(); adjustSize();
} }
/*! /*!
* \brief Sets the instruction text. * \brief Sets the instruction text.
* *
* \sa EnterPasswordDialog::instruction() * \sa EnterPasswordDialog::instruction()
*/ */
void EnterPasswordDialog::setInstruction(const QString &value) void EnterPasswordDialog::setInstruction(const QString &value)
{ {
m_instruction = value; m_instruction = value;
if(m_instruction.isEmpty()) { if(m_instruction.isEmpty()) {
m_ui->instructionLabel->setText(isVerificationRequired() ? tr("Enter the new password") : tr("Enter the password")); m_ui->instructionLabel->setText(isVerificationRequired() ? tr("Enter the new password") : tr("Enter the password"));
} else { } else {
m_ui->instructionLabel->setText(value); m_ui->instructionLabel->setText(value);
} }
adjustSize(); adjustSize();
} }
bool EnterPasswordDialog::event(QEvent *event) bool EnterPasswordDialog::event(QEvent *event)
{ {
switch(event->type()) { switch(event->type()) {
case QEvent::KeyPress: { case QEvent::KeyPress: {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if(keyEvent->key() == Qt::Key_CapsLock) { if(keyEvent->key() == Qt::Key_CapsLock) {
m_capslockPressed = !m_capslockPressed; m_capslockPressed = !m_capslockPressed;
} }
m_ui->capslockWarningWidget->setVisible(m_capslockPressed); m_ui->capslockWarningWidget->setVisible(m_capslockPressed);
break; break;
} }
default: default:
; ;
} }
return QDialog::event(event); return QDialog::event(event);
} }
/*! /*!
* \brief Internal method to notice when the capslock key is pressed by the user. * \brief Internal method to notice when the capslock key is pressed by the user.
* *
* Invocation of this method is done by installing the event filter in the constructor. * Invocation of this method is done by installing the event filter in the constructor.
*/ */
bool EnterPasswordDialog::eventFilter(QObject *sender, QEvent *event) bool EnterPasswordDialog::eventFilter(QObject *sender, QEvent *event)
{ {
switch(event->type()) { switch(event->type()) {
case QEvent::KeyPress: { case QEvent::KeyPress: {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if(keyEvent->key() == Qt::Key_CapsLock) { if(keyEvent->key() == Qt::Key_CapsLock) {
m_capslockPressed = !m_capslockPressed; m_capslockPressed = !m_capslockPressed;
} else { } else {
QString text = keyEvent->text(); QString text = keyEvent->text();
if(text.length()) { if(text.length()) {
QChar firstChar = text.at(0); QChar firstChar = text.at(0);
bool shiftPressed = (keyEvent->modifiers() & Qt::ShiftModifier) != 0; bool shiftPressed = (keyEvent->modifiers() & Qt::ShiftModifier) != 0;
if((shiftPressed && firstChar.isLower()) || (!shiftPressed && firstChar.isUpper())) { if((shiftPressed && firstChar.isLower()) || (!shiftPressed && firstChar.isUpper())) {
m_capslockPressed = true; m_capslockPressed = true;
} else if(firstChar.isLetter()) { } else if(firstChar.isLetter()) {
m_capslockPressed = false; m_capslockPressed = false;
} }
} }
} }
m_ui->capslockWarningWidget->setVisible(m_capslockPressed); m_ui->capslockWarningWidget->setVisible(m_capslockPressed);
} }
break; break;
case QEvent::FocusIn: case QEvent::FocusIn:
if(sender == m_ui->userNameLineEdit || sender == m_ui->password1LineEdit || sender == m_ui->password2LineEdit) { if(sender == m_ui->userNameLineEdit || sender == m_ui->password1LineEdit || sender == m_ui->password2LineEdit) {
releaseKeyboard(); releaseKeyboard();
qobject_cast<QWidget *>(sender)->grabKeyboard(); qobject_cast<QWidget *>(sender)->grabKeyboard();
} }
break; break;
case QEvent::FocusOut: case QEvent::FocusOut:
if(sender == m_ui->userNameLineEdit || sender == m_ui->password1LineEdit || sender == m_ui->password2LineEdit) { if(sender == m_ui->userNameLineEdit || sender == m_ui->password1LineEdit || sender == m_ui->password2LineEdit) {
qobject_cast<QWidget *>(sender)->releaseKeyboard(); qobject_cast<QWidget *>(sender)->releaseKeyboard();
grabKeyboard(); grabKeyboard();
} }
break; break;
default: default:
; ;
} }
return false; return false;
} }
/*! /*!
* \brief Sets the dialog status to QDialog::Accepted if a valid password has been enterd. * \brief Sets the dialog status to QDialog::Accepted if a valid password has been enterd.
* Displays an error message otherwise. * Displays an error message otherwise.
* *
* This private slot is called when m_ui->confirmPushButton is clicked. * This private slot is called when m_ui->confirmPushButton is clicked.
*/ */
void EnterPasswordDialog::confirm() void EnterPasswordDialog::confirm()
{ {
if(!isPasswordRequired() && m_ui->noPwCheckBox->isChecked()) { if(!isPasswordRequired() && m_ui->noPwCheckBox->isChecked()) {
m_password.clear(); m_password.clear();
done(QDialog::Accepted); done(QDialog::Accepted);
} else { } else {
QString userName = m_ui->userNameLineEdit->text(); QString userName = m_ui->userNameLineEdit->text();
QString password = m_ui->password1LineEdit->text(); QString password = m_ui->password1LineEdit->text();
QString repeatedPassword = m_ui->password2LineEdit->text(); QString repeatedPassword = m_ui->password2LineEdit->text();
if(promtForUserName() && userName.isEmpty()) { if(promtForUserName() && userName.isEmpty()) {
QMessageBox::warning(this, windowTitle(), tr("You didn't enter a user name.")); QMessageBox::warning(this, windowTitle(), tr("You didn't enter a user name."));
} else if(password.isEmpty()) { } else if(password.isEmpty()) {
QMessageBox::warning(this, windowTitle(), tr("You didn't enter a password.")); QMessageBox::warning(this, windowTitle(), tr("You didn't enter a password."));
} else { } else {
if(isVerificationRequired() && (password != repeatedPassword) && !m_ui->showPasswordCheckBox->isChecked()) { if(isVerificationRequired() && (password != repeatedPassword) && !m_ui->showPasswordCheckBox->isChecked()) {
if(repeatedPassword.isEmpty()) { if(repeatedPassword.isEmpty()) {
QMessageBox::warning(this, windowTitle(), tr("You have to enter the new password twice to ensure you enterd it correct.")); QMessageBox::warning(this, windowTitle(), tr("You have to enter the new password twice to ensure you enterd it correct."));
} else { } else {
QMessageBox::warning(this, windowTitle(), tr("You mistyped the password.")); QMessageBox::warning(this, windowTitle(), tr("You mistyped the password."));
} }
} else { } else {
m_userName = userName; m_userName = userName;
m_password = password; m_password = password;
done(QDialog::Accepted); done(QDialog::Accepted);
} }
} }
} }
} }
/*! /*!
* \brief Returns an indication whether the capslock key is pressed using platform specific functions. * \brief Returns an indication whether the capslock key is pressed using platform specific functions.
* *
* \remarks - Returns always false for unsupported platforms. * \remarks - Returns always false for unsupported platforms.
* - This method always returns false when not built with * - This method always returns false when not built with
* PLATFORM_SPECIFIC_CAPSLOCK_DETECTION defined. * PLATFORM_SPECIFIC_CAPSLOCK_DETECTION defined.
* - This static function will be used internally to detect whether the capslock key is pressed * - This static function will be used internally to detect whether the capslock key is pressed
* when initializing the dialog if available. * when initializing the dialog if available.
* - The function requires the application to be linked against X11 on Linux/Unix. * - The function requires the application to be linked against X11 on Linux/Unix.
*/ */
bool EnterPasswordDialog::isCapslockPressed() bool EnterPasswordDialog::isCapslockPressed()
{ {
#ifdef PLATFORM_SPECIFIC_CAPSLOCK_DETECTION #ifdef PLATFORM_SPECIFIC_CAPSLOCK_DETECTION
// platform dependent method of determining if CAPS LOCK is pressed // platform dependent method of determining if CAPS LOCK is pressed
# if defined(Q_OS_WIN32) # if defined(Q_OS_WIN32)
return GetKeyState(VK_CAPITAL) == 1; return GetKeyState(VK_CAPITAL) == 1;
# elif defined(X_AVAILABLE) # elif defined(X_AVAILABLE)
Display *d = XOpenDisplay((char*)0); Display *d = XOpenDisplay((char*)0);
bool caps_state = false; bool caps_state = false;
if (d) { if (d) {
unsigned n; unsigned n;
XkbGetIndicatorState(d, XkbUseCoreKbd, &n); XkbGetIndicatorState(d, XkbUseCoreKbd, &n);
caps_state = (n & 0x01) == 1; caps_state = (n & 0x01) == 1;
} }
return caps_state; return caps_state;
# else # else
return false; return false;
# endif # endif
return false; return false;
#endif #endif
} }
} }

View File

@ -1,106 +1,106 @@
#ifndef DIALOGS_ENTERPASSWORDDIALOG_H #ifndef DIALOGS_ENTERPASSWORDDIALOG_H
#define DIALOGS_ENTERPASSWORDDIALOG_H #define DIALOGS_ENTERPASSWORDDIALOG_H
#include <c++utilities/application/global.h> #include "../global.h"
#include <QDialog> #include <QDialog>
#include <memory> #include <memory>
namespace Dialogs { namespace Dialogs {
namespace Ui { namespace Ui {
class EnterPasswordDialog; class EnterPasswordDialog;
} }
class LIB_EXPORT EnterPasswordDialog : public QDialog class QT_UTILITIES_EXPORT EnterPasswordDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString userName READ userName) Q_PROPERTY(QString userName READ userName)
Q_PROPERTY(QString password READ password) Q_PROPERTY(QString password READ password)
Q_PROPERTY(QString description READ description WRITE setDescription) Q_PROPERTY(QString description READ description WRITE setDescription)
Q_PROPERTY(bool promtForUserName READ promtForUserName WRITE setPromptForUserName) Q_PROPERTY(bool promtForUserName READ promtForUserName WRITE setPromptForUserName)
Q_PROPERTY(bool isVerificationRequired READ isVerificationRequired WRITE setVerificationRequired) Q_PROPERTY(bool isVerificationRequired READ isVerificationRequired WRITE setVerificationRequired)
Q_PROPERTY(bool isPasswordRequired READ isPasswordRequired WRITE setPasswordRequired) Q_PROPERTY(bool isPasswordRequired READ isPasswordRequired WRITE setPasswordRequired)
Q_PROPERTY(QString instruction READ instruction WRITE setInstruction) Q_PROPERTY(QString instruction READ instruction WRITE setInstruction)
Q_PROPERTY(bool isCapslockPressed READ isCapslockPressed) Q_PROPERTY(bool isCapslockPressed READ isCapslockPressed)
public: public:
explicit EnterPasswordDialog(QWidget *parent = nullptr); explicit EnterPasswordDialog(QWidget *parent = nullptr);
~EnterPasswordDialog(); ~EnterPasswordDialog();
const QString &userName() const; const QString &userName() const;
const QString &password() const; const QString &password() const;
QString description() const; QString description() const;
void setDescription(const QString &description = QString()); void setDescription(const QString &description = QString());
bool promtForUserName() const; bool promtForUserName() const;
void setPromptForUserName(bool prompt); void setPromptForUserName(bool prompt);
bool isVerificationRequired() const; bool isVerificationRequired() const;
void setVerificationRequired(bool value); void setVerificationRequired(bool value);
bool isPasswordRequired() const; bool isPasswordRequired() const;
void setPasswordRequired(bool value); void setPasswordRequired(bool value);
const QString &instruction() const; const QString &instruction() const;
void setInstruction(const QString &value); void setInstruction(const QString &value);
static bool isCapslockPressed(); static bool isCapslockPressed();
protected: protected:
bool event(QEvent *event); bool event(QEvent *event);
bool eventFilter(QObject *sender, QEvent *event); bool eventFilter(QObject *sender, QEvent *event);
private Q_SLOTS: private Q_SLOTS:
void updateShowPassword(); void updateShowPassword();
void confirm(); void confirm();
void abort(); void abort();
private: private:
std::unique_ptr<Ui::EnterPasswordDialog> m_ui; std::unique_ptr<Ui::EnterPasswordDialog> m_ui;
QString m_userName; QString m_userName;
QString m_password; QString m_password;
QString m_instruction; QString m_instruction;
bool m_capslockPressed; bool m_capslockPressed;
}; };
/*! /*!
* \brief Returns the entered user name. * \brief Returns the entered user name.
*/ */
inline const QString &EnterPasswordDialog::userName() const inline const QString &EnterPasswordDialog::userName() const
{ {
return m_userName; return m_userName;
} }
/*! /*!
* \brief Returns the entered password. * \brief Returns the entered password.
*/ */
inline const QString &EnterPasswordDialog::password() const inline const QString &EnterPasswordDialog::password() const
{ {
return m_password; return m_password;
} }
/*! /*!
* \brief Returns the instruction text. * \brief Returns the instruction text.
* *
* The instruction text is displayed at the top of the dialog. * The instruction text is displayed at the top of the dialog.
* If the instruction text is empty the default text "Enter the new password" * If the instruction text is empty the default text "Enter the new password"
* or "Enter the password" (depending on whether the verification is requried or * or "Enter the password" (depending on whether the verification is requried or
* not) displayed. * not) displayed.
* *
* \sa EnterPasswordDialog::setInstruction() * \sa EnterPasswordDialog::setInstruction()
*/ */
inline const QString &EnterPasswordDialog::instruction() const inline const QString &EnterPasswordDialog::instruction() const
{ {
return m_instruction; return m_instruction;
} }
/*! /*!
* \brief Clears all results and sets the dialog status to QDialog::Rejected. * \brief Clears all results and sets the dialog status to QDialog::Rejected.
* *
* This private slot is called when m_ui->abortPushButton is clicked. * This private slot is called when m_ui->abortPushButton is clicked.
*/ */
inline void EnterPasswordDialog::abort() inline void EnterPasswordDialog::abort()
{ {
m_password.clear(); m_password.clear();
done(QDialog::Rejected); done(QDialog::Rejected);
} }
} }
#endif // DIALOGS_ENTERPASSWORDDIALOG_H #endif // DIALOGS_ENTERPASSWORDDIALOG_H

17
global.h Normal file
View File

@ -0,0 +1,17 @@
// Created via CMake from template global.h.in
// WARNING! Any changes to this file will be overwritten by the next CMake run!
#ifndef QT_UTILITIES_GLOBAL
#define QT_UTILITIES_GLOBAL
#include <c++utilities/application/global.h>
#ifdef QT_UTILITIES_STATIC
# define QT_UTILITIES_EXPORT
# define QT_UTILITIES_IMPORT
#else
# define QT_UTILITIES_EXPORT LIB_EXPORT
# define QT_UTILITIES_IMPORT LIB_IMPORT
#endif
#endif // QT_UTILITIES_GLOBAL

View File

@ -1,27 +1,25 @@
#include "desktoputils.h" #include "./desktoputils.h"
#include <c++utilities/application/global.h> #include <QDesktopServices>
#include <QUrl>
#include <QDesktopServices>
#include <QUrl> namespace DesktopUtils {
namespace DesktopUtils { /*!
* \brief Shows the specified file or directory using the default file browser.
/*! * \remarks \a path musn't be specified as URL. (Conversion to URL is the purpose of this function).
* \brief Shows the specified file or directory using the default file browser. */
* \remarks \a path musn't be specified as URL. (Conversion to URL is the purpose of this function). bool openLocalFileOrDir(const QString &path)
*/ {
bool LIB_EXPORT openLocalFileOrDir(const QString &path) #ifdef Q_OS_WIN32
{ // backslashes are commonly used under Windows
#ifdef Q_OS_WIN32 // -> replace backslashes with slashes to support Windows paths
// backslashes are commonly used under Windows QString tmp(path);
// -> replace backslashes with slashes to support Windows paths tmp.replace(QChar('\\'), QChar('/'));
QString tmp(path); return QDesktopServices::openUrl(QUrl(QStringLiteral("file:///") + path, QUrl::TolerantMode));
tmp.replace(QChar('\\'), QChar('/')); #else
return QDesktopServices::openUrl(QUrl(QStringLiteral("file:///") + path, QUrl::TolerantMode)); return QDesktopServices::openUrl(QUrl(QStringLiteral("file://") + path, QUrl::TolerantMode));
#else #endif
return QDesktopServices::openUrl(QUrl(QStringLiteral("file://") + path, QUrl::TolerantMode)); }
#endif
} }
}

View File

@ -1,14 +1,16 @@
#ifndef DESKTOP_UTILS_DESKTOPSERVICES_H #ifndef DESKTOP_UTILS_DESKTOPSERVICES_H
#define DESKTOP_UTILS_DESKTOPSERVICES_H #define DESKTOP_UTILS_DESKTOPSERVICES_H
#include <QtGlobal> #include "../global.h"
QT_FORWARD_DECLARE_CLASS(QString) #include <QtGlobal>
namespace DesktopUtils { QT_FORWARD_DECLARE_CLASS(QString)
bool openLocalFileOrDir(const QString &path); namespace DesktopUtils {
} bool QT_UTILITIES_EXPORT openLocalFileOrDir(const QString &path);
#endif // DESKTOP_UTILS_DESKTOPSERVICES_H }
#endif // DESKTOP_UTILS_DESKTOPSERVICES_H

View File

@ -1,7 +1,7 @@
#ifndef DIALOGS_DIALOGUTILS_H #ifndef DIALOGS_DIALOGUTILS_H
#define DIALOGS_DIALOGUTILS_H #define DIALOGS_DIALOGUTILS_H
#include <c++utilities/application/global.h> #include "../global.h"
#include <QtGlobal> #include <QtGlobal>
@ -20,19 +20,19 @@ enum class DocumentStatus {
Unsaved /**< There is a document opened and there are unsaved modifications. */ Unsaved /**< There is a document opened and there are unsaved modifications. */
}; };
QString LIB_EXPORT generateWindowTitle(DocumentStatus documentStatus, const QString &documentPath); QString QT_UTILITIES_EXPORT generateWindowTitle(DocumentStatus documentStatus, const QString &documentPath);
#ifndef GUI_NONE #ifndef GUI_NONE
# ifdef Q_OS_WIN32 # ifdef Q_OS_WIN32
QColor LIB_EXPORT windowFrameColor(); QColor QT_UTILITIES_EXPORT windowFrameColor();
QColor LIB_EXPORT instructionTextColor(); QColor QT_UTILITIES_EXPORT instructionTextColor();
# endif # endif
const QString LIB_EXPORT &dialogStyle(); const QString QT_UTILITIES_EXPORT &dialogStyle();
# ifdef GUI_QTWIDGETS # ifdef GUI_QTWIDGETS
void LIB_EXPORT centerWidget(QWidget *widget); void QT_UTILITIES_EXPORT centerWidget(QWidget *widget);
void LIB_EXPORT cornerWidget(QWidget *widget); void QT_UTILITIES_EXPORT cornerWidget(QWidget *widget);
void LIB_EXPORT makeHeading(QWidget *widget); void QT_UTILITIES_EXPORT makeHeading(QWidget *widget);
void LIB_EXPORT updateStyle(QWidget *widget); void QT_UTILITIES_EXPORT updateStyle(QWidget *widget);
# endif # endif
#endif #endif

View File

@ -1,168 +1,168 @@
#include "recentmenumanager.h" #include "recentmenumanager.h"
#include <QStringList> #include <QStringList>
#include <QCoreApplication> #include <QCoreApplication>
#include <QMenu> #include <QMenu>
#include <QAction> #include <QAction>
#include <QMessageBox> #include <QMessageBox>
#include <QPushButton> #include <QPushButton>
#include <QFile> #include <QFile>
namespace MiscUtils { namespace MiscUtils {
/*! /*!
* \class RecentMenuManager * \class RecentMenuManager
* \brief The RecentMenuManager class manages the entries for a "recently opened files" menu. * \brief The RecentMenuManager class manages the entries for a "recently opened files" menu.
*/ */
/*! /*!
* \brief Constructs a new recent menu manager. * \brief Constructs a new recent menu manager.
* \param menu Specifies the QMenu instance to operate with. * \param menu Specifies the QMenu instance to operate with.
* \param parent Specifies the parent QObject; might be nullptr. * \param parent Specifies the parent QObject; might be nullptr.
* \remarks * \remarks
* - Menu title and icon are set within the constructor. * - Menu title and icon are set within the constructor.
* - The current menu entries are cleared. * - The current menu entries are cleared.
* - The menu entries shouldn't be manipulated manually by the caller till the manager is destructed. * - The menu entries shouldn't be manipulated manually by the caller till the manager is destructed.
* - The manager does not take ownership over \a menu. * - The manager does not take ownership over \a menu.
*/ */
RecentMenuManager::RecentMenuManager(QMenu *menu, QObject *parent) : RecentMenuManager::RecentMenuManager(QMenu *menu, QObject *parent) :
QObject(parent), QObject(parent),
m_menu(menu) m_menu(menu)
{ {
m_menu->clear(); m_menu->clear();
m_menu->setTitle(tr("&Recent")); m_menu->setTitle(tr("&Recent"));
m_menu->setIcon(QIcon::fromTheme(QStringLiteral("document-open-recent"))); m_menu->setIcon(QIcon::fromTheme(QStringLiteral("document-open-recent")));
m_sep = m_menu->addSeparator(); m_sep = m_menu->addSeparator();
m_clearAction = m_menu->addAction(QIcon::fromTheme(QStringLiteral("edit-clear")), tr("&Clear list"), this, &RecentMenuManager::clearEntries); m_clearAction = m_menu->addAction(QIcon::fromTheme(QStringLiteral("edit-clear")), tr("&Clear list"), this, &RecentMenuManager::clearEntries);
} }
/*! /*!
* \brief Restores the specified entries. * \brief Restores the specified entries.
*/ */
void RecentMenuManager::restore(const QStringList &savedEntries) void RecentMenuManager::restore(const QStringList &savedEntries)
{ {
QAction *action = nullptr; QAction *action = nullptr;
for(const QString &path : savedEntries) { for(const QString &path : savedEntries) {
if(!path.isEmpty()) { if(!path.isEmpty()) {
action = new QAction(path, m_menu); action = new QAction(path, m_menu);
action->setProperty("file_path", path); action->setProperty("file_path", path);
m_menu->insertAction(m_sep, action); m_menu->insertAction(m_sep, action);
connect(action, &QAction::triggered, this, &RecentMenuManager::handleActionTriggered); connect(action, &QAction::triggered, this, &RecentMenuManager::handleActionTriggered);
} }
} }
if(action) { if(action) {
m_menu->actions().front()->setShortcut(QKeySequence(Qt::Key_F6)); m_menu->actions().front()->setShortcut(QKeySequence(Qt::Key_F6));
m_menu->setEnabled(true); m_menu->setEnabled(true);
} }
} }
/*! /*!
* \brief Saves the current entries. * \brief Saves the current entries.
*/ */
QStringList RecentMenuManager::save() QStringList RecentMenuManager::save()
{ {
QStringList existingEntires; QStringList existingEntires;
QList<QAction *> entryActions = m_menu->actions(); QList<QAction *> entryActions = m_menu->actions();
existingEntires.reserve(entryActions.size()); existingEntires.reserve(entryActions.size());
for(const QAction *action : entryActions) { for(const QAction *action : entryActions) {
QVariant path = action->property("file_path"); QVariant path = action->property("file_path");
if(!path.isNull()) { if(!path.isNull()) {
existingEntires << path.toString(); existingEntires << path.toString();
} }
} }
return existingEntires; return existingEntires;
} }
/*! /*!
* \brief Ensures an entry for the specified \a path is present and the first entry in the list. * \brief Ensures an entry for the specified \a path is present and the first entry in the list.
*/ */
void RecentMenuManager::addEntry(const QString &path) void RecentMenuManager::addEntry(const QString &path)
{ {
QList<QAction *> existingEntries = m_menu->actions(); QList<QAction *> existingEntries = m_menu->actions();
QAction *entry = nullptr; QAction *entry = nullptr;
// remove shortcut from existing entries // remove shortcut from existing entries
for(QAction *existingEntry : existingEntries) { for(QAction *existingEntry : existingEntries) {
existingEntry->setShortcut(QKeySequence()); existingEntry->setShortcut(QKeySequence());
// check whether existing entry matches entry to add // check whether existing entry matches entry to add
if(existingEntry->property("file_path").toString() == path) { if(existingEntry->property("file_path").toString() == path) {
entry = existingEntry; entry = existingEntry;
break; break;
} }
} }
if(!entry) { if(!entry) {
// remove old entries to have never more then 10 entries // remove old entries to have never more then 10 entries
for(int i = existingEntries.size() - 1; i > 8; --i) { for(int i = existingEntries.size() - 1; i > 8; --i) {
delete existingEntries[i]; delete existingEntries[i];
} }
existingEntries = m_menu->actions(); existingEntries = m_menu->actions();
// create new action // create new action
entry = new QAction(path, this); entry = new QAction(path, this);
entry->setProperty("file_path", path); entry->setProperty("file_path", path);
connect(entry, &QAction::triggered, this, &RecentMenuManager::handleActionTriggered); connect(entry, &QAction::triggered, this, &RecentMenuManager::handleActionTriggered);
} else { } else {
// remove existing action (will be inserted again as first action) // remove existing action (will be inserted again as first action)
m_menu->removeAction(entry); m_menu->removeAction(entry);
} }
// add shortcut for new entry // add shortcut for new entry
entry->setShortcut(QKeySequence(Qt::Key_F6)); entry->setShortcut(QKeySequence(Qt::Key_F6));
// ensure menu is enabled // ensure menu is enabled
m_menu->setEnabled(true); m_menu->setEnabled(true);
// add action as first action in the recent menu // add action as first action in the recent menu
m_menu->insertAction(m_menu->isEmpty() ? nullptr : m_menu->actions().front(), entry); m_menu->insertAction(m_menu->isEmpty() ? nullptr : m_menu->actions().front(), entry);
} }
/*! /*!
* \brief Clears all entries. * \brief Clears all entries.
*/ */
void RecentMenuManager::clearEntries() void RecentMenuManager::clearEntries()
{ {
QList<QAction *> entries = m_menu->actions(); QList<QAction *> entries = m_menu->actions();
for(auto i = entries.begin(), end = entries.end() - 2; i != end; ++i) { for(auto i = entries.begin(), end = entries.end() - 2; i != end; ++i) {
if(*i != m_clearAction) { if(*i != m_clearAction) {
delete *i; delete *i;
} }
} }
m_menu->setEnabled(false); m_menu->setEnabled(false);
} }
/*! /*!
* \brief Internally called to emit fileSelected() after an action has been triggered. * \brief Internally called to emit fileSelected() after an action has been triggered.
*/ */
void RecentMenuManager::handleActionTriggered() void RecentMenuManager::handleActionTriggered()
{ {
if(QAction *action = qobject_cast<QAction *>(sender())) { if(QAction *action = qobject_cast<QAction *>(sender())) {
const QString path = action->property("file_path").toString(); const QString path = action->property("file_path").toString();
if(!path.isEmpty()) { if(!path.isEmpty()) {
if(QFile::exists(path)) { if(QFile::exists(path)) {
emit fileSelected(path); emit fileSelected(path);
} else { } else {
QMessageBox msg; QMessageBox msg;
msg.setWindowTitle(tr("Recently opened files - ") + QCoreApplication::applicationName()); msg.setWindowTitle(tr("Recently opened files - ") + QCoreApplication::applicationName());
msg.setText(tr("The selected file can't be found anymore. Do you want to delete the obsolete entry from the list?")); msg.setText(tr("The selected file can't be found anymore. Do you want to delete the obsolete entry from the list?"));
msg.setIcon(QMessageBox::Warning); msg.setIcon(QMessageBox::Warning);
QPushButton *keepEntryButton = msg.addButton(tr("keep entry"), QMessageBox::NoRole); QPushButton *keepEntryButton = msg.addButton(tr("keep entry"), QMessageBox::NoRole);
QPushButton *deleteEntryButton = msg.addButton(tr("delete entry"), QMessageBox::YesRole); QPushButton *deleteEntryButton = msg.addButton(tr("delete entry"), QMessageBox::YesRole);
msg.setEscapeButton(keepEntryButton); msg.setEscapeButton(keepEntryButton);
msg.exec(); msg.exec();
if(msg.clickedButton() == deleteEntryButton) { if(msg.clickedButton() == deleteEntryButton) {
delete action; delete action;
QList<QAction *> remainingActions = m_menu->actions(); QList<QAction *> remainingActions = m_menu->actions();
if(!remainingActions.isEmpty() && remainingActions.front() != m_sep && remainingActions.front() != m_clearAction) { if(!remainingActions.isEmpty() && remainingActions.front() != m_sep && remainingActions.front() != m_clearAction) {
remainingActions.front()->setShortcut(QKeySequence(Qt::Key_F6)); remainingActions.front()->setShortcut(QKeySequence(Qt::Key_F6));
m_menu->setEnabled(true); m_menu->setEnabled(true);
} else { } else {
m_menu->setEnabled(false); m_menu->setEnabled(false);
} }
} }
} }
} }
} }
} }
/*! /*!
* \fn RecentMenuManager::fileSelected() * \fn RecentMenuManager::fileSelected()
* \brief Emitted after the user selected a file. * \brief Emitted after the user selected a file.
* \remarks Only emitted when the selected file still existed; otherwise the user is ask whether to keep or delete the entry. * \remarks Only emitted when the selected file still existed; otherwise the user is ask whether to keep or delete the entry.
*/ */
} }

View File

@ -1,40 +1,40 @@
#ifndef MISC_UTILS_RECENTMENUMANAGER_H #ifndef MISC_UTILS_RECENTMENUMANAGER_H
#define MISC_UTILS_RECENTMENUMANAGER_H #define MISC_UTILS_RECENTMENUMANAGER_H
#include <c++utilities/application/global.h> #include "../global.h"
#include <QObject> #include <QObject>
QT_FORWARD_DECLARE_CLASS(QMenu) QT_FORWARD_DECLARE_CLASS(QMenu)
QT_FORWARD_DECLARE_CLASS(QAction) QT_FORWARD_DECLARE_CLASS(QAction)
namespace MiscUtils { namespace MiscUtils {
class LIB_EXPORT RecentMenuManager : public QObject class QT_UTILITIES_EXPORT RecentMenuManager : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
RecentMenuManager(QMenu *menu, QObject *parent = nullptr); RecentMenuManager(QMenu *menu, QObject *parent = nullptr);
public Q_SLOTS: public Q_SLOTS:
void restore(const QStringList &savedEntries); void restore(const QStringList &savedEntries);
QStringList save(); QStringList save();
void addEntry(const QString &path); void addEntry(const QString &path);
void clearEntries(); void clearEntries();
Q_SIGNALS: Q_SIGNALS:
void fileSelected(const QString &path); void fileSelected(const QString &path);
private Q_SLOTS: private Q_SLOTS:
void handleActionTriggered(); void handleActionTriggered();
private: private:
QMenu *m_menu; QMenu *m_menu;
QAction *m_sep; QAction *m_sep;
QAction *m_clearAction; QAction *m_clearAction;
}; };
} }
#endif // MISC_UTILS_RECENTMENUMANAGER_H #endif // MISC_UTILS_RECENTMENUMANAGER_H

View File

@ -1,7 +1,7 @@
#ifndef MODELS_CHECKLISTMODEL_H #ifndef MODELS_CHECKLISTMODEL_H
#define MODELS_CHECKLISTMODEL_H #define MODELS_CHECKLISTMODEL_H
#include <c++utilities/application/global.h> #include "../global.h"
#include <QAbstractListModel> #include <QAbstractListModel>
#include <QList> #include <QList>
@ -12,7 +12,7 @@ namespace Models {
class ChecklistModel; class ChecklistModel;
class LIB_EXPORT ChecklistItem class QT_UTILITIES_EXPORT ChecklistItem
{ {
friend class ChecklistModel; friend class ChecklistModel;
@ -69,7 +69,7 @@ inline bool ChecklistItem::isChecked() const
return m_checkState == Qt::Checked; return m_checkState == Qt::Checked;
} }
class LIB_EXPORT ChecklistModel : public QAbstractListModel class QT_UTILITIES_EXPORT ChecklistModel : public QAbstractListModel
{ {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -1,7 +1,7 @@
#ifndef WIDGETS_COLORBUTTON_H #ifndef WIDGETS_COLORBUTTON_H
#define WIDGETS_COLORBUTTON_H #define WIDGETS_COLORBUTTON_H
#include <c++utilities/application/global.h> #include "../global.h"
#include <QToolButton> #include <QToolButton>
@ -12,7 +12,7 @@ namespace Widgets {
* *
* This is taken from qttools/src/shared/qtgradienteditor/qtcolorbutton.h. * This is taken from qttools/src/shared/qtgradienteditor/qtcolorbutton.h.
*/ */
class LIB_EXPORT ColorButton : public QToolButton class QT_UTILITIES_EXPORT ColorButton : public QToolButton
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool backgroundCheckered READ isBackgroundCheckered WRITE setBackgroundCheckered) Q_PROPERTY(bool backgroundCheckered READ isBackgroundCheckered WRITE setBackgroundCheckered)

View File

@ -1,6 +1,8 @@
#include "./paletteeditor.h" #include "./paletteeditor.h"
#include "./colorbutton.h" #include "./colorbutton.h"
#include "ui_paletteeditor.h"
#include <QMetaProperty> #include <QMetaProperty>
#include <QPainter> #include <QPainter>
#include <QToolButton> #include <QToolButton>
@ -15,33 +17,33 @@ enum { BrushRole = 33 };
PaletteEditor::PaletteEditor(QWidget *parent) : PaletteEditor::PaletteEditor(QWidget *parent) :
QDialog(parent), QDialog(parent),
m_ui(new Ui::PaletteEditor),
m_currentColorGroup(QPalette::Active), m_currentColorGroup(QPalette::Active),
m_paletteModel(new PaletteModel(this)), m_paletteModel(new PaletteModel(this)),
m_modelUpdated(false), m_modelUpdated(false),
m_paletteUpdated(false), m_paletteUpdated(false),
m_compute(true) m_compute(true)
{ {
m_ui.setupUi(this); m_ui->setupUi(this);
m_ui.paletteView->setModel(m_paletteModel); m_ui->paletteView->setModel(m_paletteModel);
updatePreviewPalette(); updatePreviewPalette();
updateStyledButton(); updateStyledButton();
m_ui.paletteView->setModel(m_paletteModel); m_ui->paletteView->setModel(m_paletteModel);
ColorDelegate *delegate = new ColorDelegate(this); ColorDelegate *delegate = new ColorDelegate(this);
m_ui.paletteView->setItemDelegate(delegate); m_ui->paletteView->setItemDelegate(delegate);
m_ui.paletteView->setEditTriggers(QAbstractItemView::AllEditTriggers); m_ui->paletteView->setEditTriggers(QAbstractItemView::AllEditTriggers);
connect(m_paletteModel, &PaletteModel::paletteChanged, connect(m_paletteModel, &PaletteModel::paletteChanged,
this, &PaletteEditor::paletteChanged); this, &PaletteEditor::paletteChanged);
m_ui.paletteView->setSelectionBehavior(QAbstractItemView::SelectRows); m_ui->paletteView->setSelectionBehavior(QAbstractItemView::SelectRows);
m_ui.paletteView->setDragEnabled(true); m_ui->paletteView->setDragEnabled(true);
m_ui.paletteView->setDropIndicatorShown(true); m_ui->paletteView->setDropIndicatorShown(true);
m_ui.paletteView->setRootIsDecorated(false); m_ui->paletteView->setRootIsDecorated(false);
m_ui.paletteView->setColumnHidden(2, true); m_ui->paletteView->setColumnHidden(2, true);
m_ui.paletteView->setColumnHidden(3, true); m_ui->paletteView->setColumnHidden(3, true);
} }
PaletteEditor::~PaletteEditor() PaletteEditor::~PaletteEditor()
{ {}
}
QPalette PaletteEditor::palette() const QPalette PaletteEditor::palette() const
{ {
@ -104,8 +106,8 @@ void PaletteEditor::on_computeRadio_clicked()
{ {
if (m_compute) if (m_compute)
return; return;
m_ui.paletteView->setColumnHidden(2, true); m_ui->paletteView->setColumnHidden(2, true);
m_ui.paletteView->setColumnHidden(3, true); m_ui->paletteView->setColumnHidden(3, true);
m_compute = true; m_compute = true;
m_paletteModel->setCompute(true); m_paletteModel->setCompute(true);
} }
@ -114,10 +116,10 @@ void PaletteEditor::on_detailsRadio_clicked()
{ {
if (!m_compute) if (!m_compute)
return; return;
const int w = m_ui.paletteView->columnWidth(1); const int w = m_ui->paletteView->columnWidth(1);
m_ui.paletteView->setColumnHidden(2, false); m_ui->paletteView->setColumnHidden(2, false);
m_ui.paletteView->setColumnHidden(3, false); m_ui->paletteView->setColumnHidden(3, false);
QHeaderView *header = m_ui.paletteView->header(); QHeaderView *header = m_ui->paletteView->header();
header->resizeSection(1, w / 3); header->resizeSection(1, w / 3);
header->resizeSection(2, w / 3); header->resizeSection(2, w / 3);
header->resizeSection(3, w / 3); header->resizeSection(3, w / 3);
@ -128,15 +130,16 @@ void PaletteEditor::on_detailsRadio_clicked()
void PaletteEditor::paletteChanged(const QPalette &palette) void PaletteEditor::paletteChanged(const QPalette &palette)
{ {
m_modelUpdated = true; m_modelUpdated = true;
if (!m_paletteUpdated) if (!m_paletteUpdated) {
setPalette(palette); setPalette(palette);
}
m_modelUpdated = false; m_modelUpdated = false;
} }
void PaletteEditor::buildPalette() void PaletteEditor::buildPalette()
{ {
const QColor btn = m_ui.buildButton->color(); const QColor btn(m_ui->buildButton->color());
const QPalette temp = QPalette(btn); const QPalette temp(btn);
setPalette(temp); setPalette(temp);
} }
@ -157,7 +160,7 @@ void PaletteEditor::updatePreviewPalette()
void PaletteEditor::updateStyledButton() void PaletteEditor::updateStyledButton()
{ {
m_ui.buildButton->setColor(palette().color(QPalette::Active, QPalette::Button)); m_ui->buildButton->setColor(palette().color(QPalette::Active, QPalette::Button));
} }
QPalette PaletteEditor::getPalette(QWidget *parent, const QPalette &init, QPalette PaletteEditor::getPalette(QWidget *parent, const QPalette &init,

View File

@ -1,11 +1,14 @@
#ifndef WIDGETS_PALETTEEDITOR_H #ifndef WIDGETS_PALETTEEDITOR_H
#define WIDGETS_PALETTEEDITOR_H #define WIDGETS_PALETTEEDITOR_H
#include "ui_paletteeditor.h" #include "../global.h"
#include <c++utilities/application/global.h> #include <c++utilities/conversion/types.h>
#include <QItemDelegate> #include <QItemDelegate>
#include <QDialog>
#include <memory>
QT_FORWARD_DECLARE_CLASS(QListView) QT_FORWARD_DECLARE_CLASS(QListView)
QT_FORWARD_DECLARE_CLASS(QLabel) QT_FORWARD_DECLARE_CLASS(QLabel)
@ -16,13 +19,17 @@ class ColorButton;
namespace Dialogs { namespace Dialogs {
namespace Ui {
class PaletteEditor;
}
/*! /*!
* \brief The PaletteEditor class provides a dialog to customize a QPalette. * \brief The PaletteEditor class provides a dialog to customize a QPalette.
* *
* This is taken from qttools/src/designer/src/components/propertyeditor/paletteeditor.cpp. * This is taken from qttools/src/designer/src/components/propertyeditor/paletteeditor.cpp.
* In contrast to the original version this version doesn't provide a preview. * In contrast to the original version this version doesn't provide a preview.
*/ */
class LIB_EXPORT PaletteEditor : public QDialog class QT_UTILITIES_EXPORT PaletteEditor : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
@ -57,7 +64,7 @@ private:
return m_currentColorGroup; return m_currentColorGroup;
} }
Ui::PaletteEditor m_ui; std::unique_ptr<Ui::PaletteEditor> m_ui;
QPalette m_editPalette; QPalette m_editPalette;
QPalette m_parentPalette; QPalette m_parentPalette;
QPalette::ColorGroup m_currentColorGroup; QPalette::ColorGroup m_currentColorGroup;
@ -70,7 +77,7 @@ private:
/*! /*!
* \brief The PaletteModel class is used by PaletteEditor. * \brief The PaletteModel class is used by PaletteEditor.
*/ */
class LIB_EXPORT PaletteModel : public QAbstractTableModel class QT_UTILITIES_EXPORT PaletteModel : public QAbstractTableModel
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QPalette::ColorRole colorRole READ colorRole) Q_PROPERTY(QPalette::ColorRole colorRole READ colorRole)
@ -108,7 +115,7 @@ private:
/*! /*!
* \brief The BrushEditor class is used by PaletteEditor. * \brief The BrushEditor class is used by PaletteEditor.
*/ */
class LIB_EXPORT BrushEditor : public QWidget class QT_UTILITIES_EXPORT BrushEditor : public QWidget
{ {
Q_OBJECT Q_OBJECT
@ -133,7 +140,7 @@ private:
/*! /*!
* \brief The RoleEditor class is used by PaletteEditor. * \brief The RoleEditor class is used by PaletteEditor.
*/ */
class LIB_EXPORT RoleEditor : public QWidget class QT_UTILITIES_EXPORT RoleEditor : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
@ -157,7 +164,7 @@ private:
/*! /*!
* \brief The ColorDelegate class is used by PaletteEditor. * \brief The ColorDelegate class is used by PaletteEditor.
*/ */
class LIB_EXPORT ColorDelegate : public QItemDelegate class QT_UTILITIES_EXPORT ColorDelegate : public QItemDelegate
{ {
Q_OBJECT Q_OBJECT

View File

@ -1,11 +1,13 @@
#ifndef APPLICATION_UTILITIES_QTCONFIGARGUMENTS_H #ifndef APPLICATION_UTILITIES_QTCONFIGARGUMENTS_H
#define APPLICATION_UTILITIES_QTCONFIGARGUMENTS_H #define APPLICATION_UTILITIES_QTCONFIGARGUMENTS_H
#include "../global.h"
#include <c++utilities/application/argumentparser.h> #include <c++utilities/application/argumentparser.h>
namespace ApplicationUtilities { namespace ApplicationUtilities {
class LIB_EXPORT QtConfigArguments class QT_UTILITIES_EXPORT QtConfigArguments
{ {
public: public:
QtConfigArguments(); QtConfigArguments();

View File

@ -1,7 +1,7 @@
#ifndef APPLICATION_UTILITIES_RESOURCES_H #ifndef APPLICATION_UTILITIES_RESOURCES_H
#define APPLICATION_UTILITIES_RESOURCES_H #define APPLICATION_UTILITIES_RESOURCES_H
#include <c++utilities/application/global.h> #include "../global.h"
#include <QtGlobal> #include <QtGlobal>
@ -29,36 +29,36 @@ QT_FORWARD_DECLARE_CLASS(QSettings)
namespace QtUtilitiesResources { namespace QtUtilitiesResources {
LIB_EXPORT void init(); QT_UTILITIES_EXPORT void init();
LIB_EXPORT void cleanup(); QT_UTILITIES_EXPORT void cleanup();
} }
namespace TranslationFiles { namespace TranslationFiles {
LIB_EXPORT QString &additionalTranslationFilePath(); QT_UTILITIES_EXPORT QString &additionalTranslationFilePath();
LIB_EXPORT void loadQtTranslationFile(std::initializer_list<QString> repositoryNames); QT_UTILITIES_EXPORT void loadQtTranslationFile(std::initializer_list<QString> repositoryNames);
LIB_EXPORT void loadQtTranslationFile(std::initializer_list<QString> repositoryNames, const QString &localeName); QT_UTILITIES_EXPORT void loadQtTranslationFile(std::initializer_list<QString> repositoryNames, const QString &localeName);
LIB_EXPORT void loadApplicationTranslationFile(const QString &applicationName); QT_UTILITIES_EXPORT void loadApplicationTranslationFile(const QString &applicationName);
LIB_EXPORT void loadApplicationTranslationFile(const QString &applicationName, const QString &localeName); QT_UTILITIES_EXPORT void loadApplicationTranslationFile(const QString &applicationName, const QString &localeName);
} }
namespace ApplicationInstances { namespace ApplicationInstances {
#if defined(GUI_QTWIDGETS) #if defined(GUI_QTWIDGETS)
LIB_EXPORT bool hasWidgetsApp(); QT_UTILITIES_EXPORT bool hasWidgetsApp();
#endif #endif
#if defined(GUI_QTWIDGETS) || defined(GUI_QTQUICK) #if defined(GUI_QTWIDGETS) || defined(GUI_QTQUICK)
LIB_EXPORT bool hasGuiApp(); QT_UTILITIES_EXPORT bool hasGuiApp();
#endif #endif
LIB_EXPORT bool hasCoreApp(); QT_UTILITIES_EXPORT bool hasCoreApp();
} }
namespace ConfigFile { namespace ConfigFile {
LIB_EXPORT QString locateConfigFile(const QString &applicationName, const QString &fileName, const QSettings *settings = nullptr); QT_UTILITIES_EXPORT QString locateConfigFile(const QString &applicationName, const QString &fileName, const QSettings *settings = nullptr);
} }

View File

@ -1,7 +1,7 @@
#ifndef DIALOGS_OPTIONSCATEGORY_H #ifndef DIALOGS_OPTIONSCATEGORY_H
#define DIALOGS_OPTIONSCATEGORY_H #define DIALOGS_OPTIONSCATEGORY_H
#include <c++utilities/application/global.h> #include "../global.h"
#include <QObject> #include <QObject>
#include <QIcon> #include <QIcon>
@ -11,7 +11,7 @@ namespace Dialogs {
class OptionPage; class OptionPage;
class LIB_EXPORT OptionCategory : public QObject class QT_UTILITIES_EXPORT OptionCategory : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString displayName READ displayName WRITE setDisplayName NOTIFY displayNameChanged) Q_PROPERTY(QString displayName READ displayName WRITE setDisplayName NOTIFY displayNameChanged)

View File

@ -1,7 +1,7 @@
#ifndef DIALOGS_OPTIONCATEGORYMODEL_H #ifndef DIALOGS_OPTIONCATEGORYMODEL_H
#define DIALOGS_OPTIONCATEGORYMODEL_H #define DIALOGS_OPTIONCATEGORYMODEL_H
#include <c++utilities/application/global.h> #include "../global.h"
#include <QList> #include <QList>
#include <QAbstractListModel> #include <QAbstractListModel>
@ -11,7 +11,7 @@ namespace Dialogs {
class OptionPage; class OptionPage;
class OptionCategory; class OptionCategory;
class LIB_EXPORT OptionCategoryModel : public QAbstractListModel class QT_UTILITIES_EXPORT OptionCategoryModel : public QAbstractListModel
{ {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -1,7 +1,7 @@
#ifndef DIALOGS_OPTIONSPAGE_H #ifndef DIALOGS_OPTIONSPAGE_H
#define DIALOGS_OPTIONSPAGE_H #define DIALOGS_OPTIONSPAGE_H
#include <c++utilities/application/global.h> #include "../global.h"
#include <QObject> #include <QObject>
#include <QWidget> #include <QWidget>
@ -10,7 +10,7 @@
namespace Dialogs { namespace Dialogs {
class LIB_EXPORT OptionPage class QT_UTILITIES_EXPORT OptionPage
{ {
public: public:
explicit OptionPage(QWidget *parentWindow = nullptr); explicit OptionPage(QWidget *parentWindow = nullptr);
@ -80,7 +80,7 @@ inline QStringList &OptionPage::errors()
* \tparam UiClass Specifies the UI class generated by uic. * \tparam UiClass Specifies the UI class generated by uic.
*/ */
template <class UiClass> template <class UiClass>
class LIB_EXPORT UiFileBasedOptionPage : public OptionPage class QT_UTILITIES_EXPORT UiFileBasedOptionPage : public OptionPage
{ {
public: public:
explicit UiFileBasedOptionPage(QWidget *parentWindow = nullptr); explicit UiFileBasedOptionPage(QWidget *parentWindow = nullptr);
@ -143,7 +143,7 @@ inline UiClass *UiFileBasedOptionPage<UiClass>::ui()
*/ */
#define BEGIN_DECLARE_OPTION_PAGE(SomeClass) \ #define BEGIN_DECLARE_OPTION_PAGE(SomeClass) \
typedef ::Dialogs::OptionPage SomeClass ## Base; \ typedef ::Dialogs::OptionPage SomeClass ## Base; \
class LIB_EXPORT SomeClass : public ::Dialogs::OptionPage \ class QT_UTILITIES_EXPORT SomeClass : public ::Dialogs::OptionPage \
{ \ { \
public: \ public: \
explicit SomeClass(QWidget *parentWidget = nullptr); \ explicit SomeClass(QWidget *parentWidget = nullptr); \
@ -161,7 +161,7 @@ inline UiClass *UiFileBasedOptionPage<UiClass>::ui()
class SomeClass; \ class SomeClass; \
} \ } \
typedef ::Dialogs::UiFileBasedOptionPage<Ui::SomeClass> SomeClass ## Base; \ typedef ::Dialogs::UiFileBasedOptionPage<Ui::SomeClass> SomeClass ## Base; \
class LIB_EXPORT SomeClass : public ::Dialogs::UiFileBasedOptionPage<Ui::SomeClass> \ class QT_UTILITIES_EXPORT SomeClass : public ::Dialogs::UiFileBasedOptionPage<Ui::SomeClass> \
{ \ { \
public: \ public: \
~SomeClass(); \ ~SomeClass(); \

View File

@ -40,7 +40,7 @@ private:
QtSettingsData &m_settings; QtSettingsData &m_settings;
END_DECLARE_OPTION_PAGE END_DECLARE_OPTION_PAGE
class LIB_EXPORT QtSettings class QT_UTILITIES_EXPORT QtSettings
{ {
public: public:
QtSettings(); QtSettings();

View File

@ -1,7 +1,7 @@
#ifndef DIALOGS_SETTINGSDIALOG_H #ifndef DIALOGS_SETTINGSDIALOG_H
#define DIALOGS_SETTINGSDIALOG_H #define DIALOGS_SETTINGSDIALOG_H
#include <c++utilities/application/global.h> #include "../global.h"
#include <QDialog> #include <QDialog>
@ -18,7 +18,7 @@ namespace Ui {
class SettingsDialog; class SettingsDialog;
} }
class LIB_EXPORT SettingsDialog : public QDialog class QT_UTILITIES_EXPORT SettingsDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool tabBarAlwaysVisible READ isTabBarAlwaysVisible WRITE setTabBarAlwaysVisible) Q_PROPERTY(bool tabBarAlwaysVisible READ isTabBarAlwaysVisible WRITE setTabBarAlwaysVisible)

View File

@ -1,7 +1,7 @@
#ifndef WIDGETS_BUTTONOVERLAY_H #ifndef WIDGETS_BUTTONOVERLAY_H
#define WIDGETS_BUTTONOVERLAY_H #define WIDGETS_BUTTONOVERLAY_H
#include <c++utilities/application/global.h> #include "../global.h"
#include <QtGlobal> #include <QtGlobal>
@ -14,7 +14,7 @@ namespace Widgets {
class IconButton; class IconButton;
class LIB_EXPORT ButtonOverlay class QT_UTILITIES_EXPORT ButtonOverlay
{ {
public: public:
explicit ButtonOverlay(QWidget *widget); explicit ButtonOverlay(QWidget *widget);

View File

@ -3,13 +3,11 @@
#include "./buttonoverlay.h" #include "./buttonoverlay.h"
#include <c++utilities/application/global.h>
#include <QComboBox> #include <QComboBox>
namespace Widgets { namespace Widgets {
class LIB_EXPORT ClearComboBox : public QComboBox, public ButtonOverlay class QT_UTILITIES_EXPORT ClearComboBox : public QComboBox, public ButtonOverlay
{ {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -3,19 +3,15 @@
#include "./buttonoverlay.h" #include "./buttonoverlay.h"
#include <c++utilities/application/global.h>
#include <QLineEdit> #include <QLineEdit>
QT_BEGIN_NAMESPACE QT_FORWARD_DECLARE_CLASS(QHBoxLayout)
class QHBoxLayout;
QT_END_NAMESPACE
namespace Widgets { namespace Widgets {
class IconButton; class IconButton;
class LIB_EXPORT ClearLineEdit : public QLineEdit, public ButtonOverlay class QT_UTILITIES_EXPORT ClearLineEdit : public QLineEdit, public ButtonOverlay
{ {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -7,7 +7,7 @@
namespace Widgets { namespace Widgets {
class LIB_EXPORT ClearPlainTextEdit : public QPlainTextEdit, public ButtonOverlay class QT_UTILITIES_EXPORT ClearPlainTextEdit : public QPlainTextEdit, public ButtonOverlay
{ {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -3,20 +3,16 @@
#include "./buttonoverlay.h" #include "./buttonoverlay.h"
#include <c++utilities/application/global.h>
#include <QSpinBox> #include <QSpinBox>
#include <QLineEdit> #include <QLineEdit>
QT_BEGIN_NAMESPACE QT_FORWARD_DECLARE_CLASS(QHBoxLayout)
class QHBoxLayout;
QT_END_NAMESPACE
namespace Widgets { namespace Widgets {
class IconButton; class IconButton;
class LIB_EXPORT ClearSpinBox : public QSpinBox, public ButtonOverlay class QT_UTILITIES_EXPORT ClearSpinBox : public QSpinBox, public ButtonOverlay
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool minimumHidden READ minimumHidden WRITE setMinimumHidden) Q_PROPERTY(bool minimumHidden READ minimumHidden WRITE setMinimumHidden)

View File

@ -1,14 +1,14 @@
#ifndef WIDGETS_ICONBUTTON_H #ifndef WIDGETS_ICONBUTTON_H
#define WIDGETS_ICONBUTTON_H #define WIDGETS_ICONBUTTON_H
#include <c++utilities/application/global.h> #include "../global.h"
#include <QAbstractButton> #include <QAbstractButton>
#include <QPixmap> #include <QPixmap>
namespace Widgets { namespace Widgets {
class LIB_EXPORT IconButton : public QAbstractButton class QT_UTILITIES_EXPORT IconButton : public QAbstractButton
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap) Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)

View File

@ -1,7 +1,7 @@
#ifndef WIDGETS_PATHSELECTION_H #ifndef WIDGETS_PATHSELECTION_H
#define WIDGETS_PATHSELECTION_H #define WIDGETS_PATHSELECTION_H
#include <c++utilities/application/global.h> #include "../global.h"
#include <QFileDialog> #include <QFileDialog>
@ -12,7 +12,7 @@ namespace Widgets {
class ClearLineEdit; class ClearLineEdit;
class LIB_EXPORT PathSelection : public QWidget class QT_UTILITIES_EXPORT PathSelection : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public: