Update style sheet on palette changes accordingly
This commit is contained in:
parent
a45734de1d
commit
0ead95e749
|
@ -123,7 +123,7 @@ include(BasicConfig)
|
|||
set(CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES
|
||||
"${CONFIGURATION_PACKAGE_SUFFIX}"
|
||||
CACHE STRING "sets the suffix for qtutilities")
|
||||
find_package(qtutilities${CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES} 6.11.0 REQUIRED)
|
||||
find_package(qtutilities${CONFIGURATION_PACKAGE_SUFFIX_QTUTILITIES} 6.12.0 REQUIRED)
|
||||
use_qt_utilities()
|
||||
|
||||
# find passwordfile
|
||||
|
|
|
@ -106,6 +106,19 @@ void MainWindow::setSomethingChanged(bool somethingChanged)
|
|||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Updates the style sheet.
|
||||
*/
|
||||
void MainWindow::updateStyleSheet()
|
||||
{
|
||||
#ifdef Q_OS_WINDOWS
|
||||
const auto p = palette();
|
||||
setStyleSheet(QStringLiteral("%1 #splitter QWidget { background-color: palette(base); color: palette(text); } #splitter QWidget *, #splitter "
|
||||
"QWidget * { background-color: none; } #leftWidget { border-right: 1px solid %2; }")
|
||||
.arg(dialogStyleForPalette(p), windowFrameColorForPalette(p).name()));
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Constructs a new main window.
|
||||
*/
|
||||
|
@ -120,12 +133,9 @@ MainWindow::MainWindow(QSettings &settings, QtUtilities::QtSettings *qtSettings,
|
|||
, m_settingsDlg(nullptr)
|
||||
{
|
||||
// setup ui
|
||||
updateStyleSheet();
|
||||
m_ui->setupUi(this);
|
||||
#ifdef Q_OS_WIN32
|
||||
setStyleSheet(QStringLiteral("%1 #splitter QWidget { background-color: palette(base); color: palette(text); } #splitter QWidget *, #splitter "
|
||||
"QWidget * { background-color: none; } #leftWidget { border-right: 1px solid %2; }")
|
||||
.arg(dialogStyle(), windowFrameColor().name()));
|
||||
#endif
|
||||
|
||||
// set default values
|
||||
setSomethingChanged(false);
|
||||
m_dontUpdateSelection = false;
|
||||
|
@ -240,6 +250,17 @@ MainWindow::~MainWindow()
|
|||
{
|
||||
}
|
||||
|
||||
bool MainWindow::event(QEvent *event)
|
||||
{
|
||||
switch (event->type()) {
|
||||
case QEvent::PaletteChange:
|
||||
updateStyleSheet();
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
return QMainWindow::event(event);
|
||||
}
|
||||
|
||||
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if (obj == m_undoView) {
|
||||
|
|
|
@ -74,6 +74,7 @@ public:
|
|||
bool openFile(const QString &path, Io::PasswordFileOpenFlags openFlags); // can not be a slot in Qt 6 without further effort, see QTBUG-86424
|
||||
|
||||
protected:
|
||||
bool event(QEvent *event) override;
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
void timerEvent(QTimerEvent *event) override;
|
||||
|
@ -108,6 +109,7 @@ private Q_SLOTS:
|
|||
void clearClipboard();
|
||||
void setSomethingChanged();
|
||||
void setSomethingChanged(bool somethingChanged);
|
||||
void updateStyleSheet();
|
||||
|
||||
private:
|
||||
// showing conditional messages/prompts
|
||||
|
|
|
@ -43,11 +43,8 @@ PasswordGeneratorDialog::PasswordGeneratorDialog(QWidget *parent)
|
|||
: QDialog(parent)
|
||||
, m_ui(new Ui::PasswordGeneratorDialog)
|
||||
{
|
||||
updateStyleSheet();
|
||||
m_ui->setupUi(this);
|
||||
#ifdef Q_OS_WIN32
|
||||
setStyleSheet(QStringLiteral("%1 QCommandLinkButton { font-size: 12pt; color: %2; font-weight: normal; }")
|
||||
.arg(dialogStyle(), instructionTextColor().name()));
|
||||
#endif
|
||||
setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
|
||||
|
||||
connect(m_ui->generatePassowordCommandLinkButton, &QCommandLinkButton::clicked, this, &PasswordGeneratorDialog::generateNewPassword);
|
||||
|
@ -75,6 +72,17 @@ PasswordGeneratorDialog::~PasswordGeneratorDialog()
|
|||
{
|
||||
}
|
||||
|
||||
bool PasswordGeneratorDialog::event(QEvent *event)
|
||||
{
|
||||
switch (event->type()) {
|
||||
case QEvent::PaletteChange:
|
||||
updateStyleSheet();
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
return QDialog::event(event);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Generates and shows a new password.
|
||||
*/
|
||||
|
@ -162,6 +170,17 @@ void PasswordGeneratorDialog::handlePasswordChanged()
|
|||
m_ui->copyPasswordCommandLinkButton->setEnabled(m_ui->passwordLineEdit->text().size() > 0);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Updates the style sheet.
|
||||
*/
|
||||
void PasswordGeneratorDialog::updateStyleSheet()
|
||||
{
|
||||
#ifdef Q_OS_WINDOWS
|
||||
setStyleSheet(QStringLiteral("%1 QCommandLinkButton { font-size: 12pt; color: %2; font-weight: normal; }")
|
||||
.arg(dialogStyleForPalette(palette()), instructionTextColor().name()));
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef QT_NO_CLIPBOARD
|
||||
/*!
|
||||
* \brief Copies the current password to the clipboard.
|
||||
|
|
|
@ -21,10 +21,14 @@ public:
|
|||
explicit PasswordGeneratorDialog(QWidget *parent = nullptr);
|
||||
~PasswordGeneratorDialog() override;
|
||||
|
||||
protected:
|
||||
bool event(QEvent *event) override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void generateNewPassword();
|
||||
void handleCheckedCategoriesChanged();
|
||||
void handlePasswordChanged();
|
||||
void updateStyleSheet();
|
||||
#ifndef QT_NO_CLIPBOARD
|
||||
void copyPassword();
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue