diff --git a/Tarsnap.pro b/Tarsnap.pro index 8bfd3095..f9b474de 100644 --- a/Tarsnap.pro +++ b/Tarsnap.pro @@ -27,6 +27,7 @@ SOURCES += \ lib/core/TSettings.cpp \ lib/util/optparse.c \ lib/util/optparse_helper.c \ + lib/widgets/TAsideLabel.cpp \ lib/widgets/TBusyLabel.cpp \ lib/widgets/TElidedLabel.cpp \ lib/widgets/TOkLabel.cpp \ @@ -111,6 +112,7 @@ HEADERS += \ lib/core/warnings-disable.h \ lib/util/optparse.h \ lib/util/optparse_helper.h \ + lib/widgets/TAsideLabel.h \ lib/widgets/TBusyLabel.h \ lib/widgets/TElidedLabel.h \ lib/widgets/TOkLabel.h \ diff --git a/forms/setupwizard_intro.ui b/forms/setupwizard_intro.ui index dd64df5f..8001759a 100644 --- a/forms/setupwizard_intro.ui +++ b/forms/setupwizard_intro.ui @@ -82,33 +82,10 @@ - - - - 0 - 0 - - - - - true - - - - QLabel { - margin-left: 0.125em; - border-width: 0 0 0 0.1em; - border-style: solid; - border-color: "#999"; - padding-left: 0.25em; -} - + You can also skip this wizard and set up everything inside the application. - - true - @@ -154,6 +131,11 @@ + + TAsideLabel + QLabel +
TAsideLabel.h
+
TWizardPage QWidget diff --git a/forms/setupwizard_register.ui b/forms/setupwizard_register.ui index 2ee6c6d6..cf402c05 100644 --- a/forms/setupwizard_register.ui +++ b/forms/setupwizard_register.ui @@ -57,33 +57,10 @@ - - - - 0 - 17 - - - - - true - - - - QLabel { - margin-left: 0.125em; - border-width: 0 0 0 0.1em; - border-style: solid; - border-color: "#999"; - padding-left: 0.25em; -} - + Don't have an account? Register on <a href="http://tarsnap.com">tarsnap.com</a>. - - true - true @@ -418,6 +395,11 @@ + + TAsideLabel + QLabel +
TAsideLabel.h
+
TBusyLabel QLabel diff --git a/lib/plugins/TAsideLabelPlugin.cpp b/lib/plugins/TAsideLabelPlugin.cpp new file mode 100644 index 00000000..c09222ec --- /dev/null +++ b/lib/plugins/TAsideLabelPlugin.cpp @@ -0,0 +1,53 @@ +#include "TAsideLabelPlugin.h" + +WARNINGS_DISABLE +#include +WARNINGS_ENABLE + +class QWidget; + +#include "TAsideLabel.h" + +TAsideLabelPlugin::TAsideLabelPlugin(QObject *parent) : QObject(parent) +{ +} + +QIcon TAsideLabelPlugin::icon() const +{ + return (QIcon()); +} + +QString TAsideLabelPlugin::group() const +{ + return (QStringLiteral("Display Widgets")); +} + +QString TAsideLabelPlugin::includeFile() const +{ + return (QStringLiteral("TAsideLabel.h")); +} + +QString TAsideLabelPlugin::name() const +{ + return (QStringLiteral("TAsideLabel")); +} + +QString TAsideLabelPlugin::toolTip() const +{ + return (QString()); +} + +QString TAsideLabelPlugin::whatsThis() const +{ + return (QString()); +} + +QWidget *TAsideLabelPlugin::createWidget(QWidget *parent) +{ + return (new TAsideLabel(parent)); +} + +bool TAsideLabelPlugin::isContainer() const +{ + return (false); +} diff --git a/lib/plugins/TAsideLabelPlugin.h b/lib/plugins/TAsideLabelPlugin.h new file mode 100644 index 00000000..a42ce378 --- /dev/null +++ b/lib/plugins/TAsideLabelPlugin.h @@ -0,0 +1,34 @@ +#ifndef TASIDELABELPLUGIN_H +#define TASIDELABELPLUGIN_H + +#include "warnings-disable.h" + +WARNINGS_DISABLE +#include +#include +#include +#include +WARNINGS_ENABLE + +/* Forward declaration(s). */ +class QWidget; + +class TAsideLabelPlugin : public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) + +public: + explicit TAsideLabelPlugin(QObject *parent = nullptr); + + QIcon icon() const override; + QString group() const override; + QString includeFile() const override; + QString name() const override; + QString toolTip() const override; + QString whatsThis() const override; + QWidget *createWidget(QWidget *parent) override; + bool isContainer() const override; +}; + +#endif /* !TASIDELABELPLUGIN_H */ diff --git a/lib/plugins/plugins.cpp b/lib/plugins/plugins.cpp index 3a939eb1..2c367731 100644 --- a/lib/plugins/plugins.cpp +++ b/lib/plugins/plugins.cpp @@ -1,5 +1,6 @@ #include "plugins.h" +#include "TAsideLabelPlugin.h" #include "TBusyLabelPlugin.h" #include "TElidedLabelPlugin.h" #include "TOkLabelPlugin.h" @@ -12,6 +13,7 @@ TarsnapPlugins::TarsnapPlugins(QObject *parent) : QObject(parent) { + widgets.append(new TAsideLabelPlugin(this)); widgets.append(new TBusyLabelPlugin(this)); widgets.append(new TElidedLabelPlugin(this)); widgets.append(new TOkLabelPlugin(this)); diff --git a/lib/plugins/plugins.pro b/lib/plugins/plugins.pro index 8673cdb7..bd97ba7e 100644 --- a/lib/plugins/plugins.pro +++ b/lib/plugins/plugins.pro @@ -5,6 +5,7 @@ QT += widgets uiplugin HEADERS = plugins.h \ ../core/warnings-disable.h \ + ../widgets/TAsideLabel.h \ ../widgets/TBusyLabel.h \ ../widgets/TElidedLabel.h \ ../widgets/TOkLabel.h \ @@ -14,6 +15,7 @@ HEADERS = plugins.h \ ../widgets/TTabWidget.h \ ../widgets/TTextView.h \ ../widgets/TWizardPage.h \ + TAsideLabelPlugin.h \ TBusyLabelPlugin.h \ TElidedLabelPlugin.h \ TOkLabelPlugin.h \ @@ -25,6 +27,7 @@ HEADERS = plugins.h \ TWizardPagePlugin.h SOURCES = plugins.cpp \ + ../widgets/TAsideLabel.cpp \ ../widgets/TBusyLabel.cpp \ ../widgets/TElidedLabel.cpp \ ../widgets/TOkLabel.cpp \ @@ -34,6 +37,7 @@ SOURCES = plugins.cpp \ ../widgets/TTabWidget.cpp \ ../widgets/TTextView.cpp \ ../widgets/TWizardPage.cpp \ + TAsideLabelPlugin.cpp \ TBusyLabelPlugin.cpp \ TElidedLabelPlugin.cpp \ TOkLabelPlugin.cpp \ diff --git a/lib/widgets/TAsideLabel.cpp b/lib/widgets/TAsideLabel.cpp new file mode 100644 index 00000000..a823c6bc --- /dev/null +++ b/lib/widgets/TAsideLabel.cpp @@ -0,0 +1,26 @@ +#include "TAsideLabel.h" + +WARNINGS_DISABLE +#include +WARNINGS_ENABLE + +#define SHEET_ASIDE \ + "margin-left: 0.125em;" \ + "border-width: 0 0 0 0.1em;" \ + "border-style: solid;" \ + "border-color: palette(mid);" \ + "padding-left: 0.25em;" + +TAsideLabel::TAsideLabel(QWidget *parent) : QLabel(parent) +{ + // Make it italic. + QFont font = this->font(); + font.setStyle(QFont::StyleItalic); + setFont(font); + + // Add the border and padding. + setStyleSheet(SHEET_ASIDE); + + // Word wrap. + setWordWrap(true); +} diff --git a/lib/widgets/TAsideLabel.h b/lib/widgets/TAsideLabel.h new file mode 100644 index 00000000..66bf22db --- /dev/null +++ b/lib/widgets/TAsideLabel.h @@ -0,0 +1,27 @@ +#ifndef TASIDELABEL_H +#define TASIDELABEL_H + +#include "warnings-disable.h" + +WARNINGS_DISABLE +#include +#include +WARNINGS_ENABLE + +/* Forward declaration(s). */ +class QWidget; + +/*! + * \ingroup lib-widgets + * \brief The TAsideLabel widget is a QLabel which is similar to \. + */ +class TAsideLabel : public QLabel +{ + Q_OBJECT + +public: + //! Constructor. + explicit TAsideLabel(QWidget *parent = nullptr); +}; + +#endif // TASIDELABEL_H diff --git a/tests/app-setup/test-app-setup.pro b/tests/app-setup/test-app-setup.pro index bea34bce..6b844f5a 100644 --- a/tests/app-setup/test-app-setup.pro +++ b/tests/app-setup/test-app-setup.pro @@ -21,6 +21,7 @@ SOURCES += test-app-setup.cpp \ ../../lib/core/TSettings.cpp \ ../../lib/util/optparse.c \ ../../lib/util/optparse_helper.c \ + ../../lib/widgets/TAsideLabel.cpp \ ../../lib/widgets/TBusyLabel.cpp \ ../../lib/widgets/TElidedLabel.cpp \ ../../lib/widgets/TOkLabel.cpp \ @@ -68,6 +69,7 @@ HEADERS += \ ../../lib/core/TSettings.h \ ../../lib/util/optparse.h \ ../../lib/util/optparse_helper.h \ + ../../lib/widgets/TAsideLabel.h \ ../../lib/widgets/TBusyLabel.h \ ../../lib/widgets/TElidedLabel.h \ ../../lib/widgets/TOkLabel.h \ diff --git a/tests/lib-widgets/test-lib-widgets.cpp b/tests/lib-widgets/test-lib-widgets.cpp index 20d19b03..2d435b1a 100644 --- a/tests/lib-widgets/test-lib-widgets.cpp +++ b/tests/lib-widgets/test-lib-widgets.cpp @@ -20,6 +20,7 @@ WARNINGS_ENABLE #include "../qtest-platform.h" #include "LogEntry.h" +#include "TAsideLabel.h" #include "TBusyLabel.h" #include "TElidedLabel.h" #include "TOkLabel.h" @@ -43,6 +44,7 @@ private slots: void okLabel(); void busylabel(); void busylabel_on_off(); + void tasidelabel(); void pathlinebrowse(); void pathcombobrowse(); void ttabwidget_basic(); @@ -161,6 +163,19 @@ void TestLibWidgets::busylabel_on_off() delete bw; } +void TestLibWidgets::tasidelabel() +{ + TAsideLabel *lab = new TAsideLabel(); + lab->setMinimumWidth(200); + + VISUAL_INIT(lab); + + lab->setText("message"); + VISUAL_WAIT; + + delete lab; +} + void TestLibWidgets::pathlinebrowse() { TPathLineBrowse *plb = new TPathLineBrowse(); diff --git a/tests/lib-widgets/test-lib-widgets.pro b/tests/lib-widgets/test-lib-widgets.pro index 366738ef..f2514742 100644 --- a/tests/lib-widgets/test-lib-widgets.pro +++ b/tests/lib-widgets/test-lib-widgets.pro @@ -13,6 +13,7 @@ RESOURCES += ../../lib/resources/lib-resources.qrc \ ../../resources/resources.qrc HEADERS += \ + ../../lib/widgets/TAsideLabel.h \ ../../lib/widgets/TBusyLabel.h \ ../../lib/widgets/TElidedLabel.h \ ../../lib/widgets/TOkLabel.h \ @@ -26,6 +27,7 @@ HEADERS += \ SOURCES += test-lib-widgets.cpp \ ../../lib/core/TSettings.cpp \ + ../../lib/widgets/TAsideLabel.cpp \ ../../lib/widgets/TBusyLabel.cpp \ ../../lib/widgets/TElidedLabel.cpp \ ../../lib/widgets/TOkLabel.cpp \ diff --git a/tests/setupwizard/test-setupwizard.pro b/tests/setupwizard/test-setupwizard.pro index f970417e..7b99206c 100644 --- a/tests/setupwizard/test-setupwizard.pro +++ b/tests/setupwizard/test-setupwizard.pro @@ -16,6 +16,7 @@ FORMS += \ HEADERS += \ compare-settings.h \ ../../lib/core/TSettings.h \ + ../../lib/widgets/TAsideLabel.h \ ../../lib/widgets/TBusyLabel.h \ ../../lib/widgets/TElidedLabel.h \ ../../lib/widgets/TOkLabel.h \ @@ -35,6 +36,7 @@ HEADERS += \ SOURCES += test-setupwizard.cpp \ compare-settings.cpp \ ../../lib/core/TSettings.cpp \ + ../../lib/widgets/TAsideLabel.cpp \ ../../lib/widgets/TBusyLabel.cpp \ ../../lib/widgets/TElidedLabel.cpp \ ../../lib/widgets/TOkLabel.cpp \