Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SARibbonMainWindow theme not the same of SARibbon #126

Open
jepessen opened this issue Nov 16, 2024 · 1 comment
Open

SARibbonMainWindow theme not the same of SARibbon #126

jepessen opened this issue Nov 16, 2024 · 1 comment

Comments

@jepessen
Copy link

I've created a windows application with SARibbon, but the style of the ribbon bar does not match the style of the main window:

image

I've set Dark2 as theme, and windows is in dark mode, but even in light mode it's the same (the main window is white).

How can I fix it?

MainWindow.hpp

#include "Framework/Desktop/Options/Application.hpp"
#include "Framework/Desktop/Gui/SARibbon.h"
#include "Interfaces/FrontendConcept.hpp"
#include <vector>
#include <string>

class MainWindow : public SARibbonMainWindow, public Interfaces::Frontend {

  Q_OBJECT

public:

  MainWindow() = delete;
  MainWindow(const Options::Application& options, QWidget* parent);
  MainWindow(const MainWindow&) = delete;
  MainWindow(MainWindow&&) = delete;
  virtual ~MainWindow() = default;

public:

  void dummy() override {}

public:

  MainWindow& operator=(const MainWindow&) = delete;
  MainWindow& operator=(MainWindow&&) = delete;

private:

  void setRibbon();
};

MainWindow.cpp

#include "Framework/Desktop/Gui/MainWindow.hpp"
#include "Framework/Desktop/Gui/Ribbon.hpp"
#include <QDockWidget>

////////////////////////////////////////////////////////////////////////////////
// USING SECTION                                                              //
////////////////////////////////////////////////////////////////////////////////

using Interfaces::Frontend;
using std::string_view;

////////////////////////////////////////////////////////////////////////////////
// PUBLIC SECTION                                                             //
////////////////////////////////////////////////////////////////////////////////

MainWindow::MainWindow(const Options::Application& options, QWidget* parent) :
  SARibbonMainWindow(parent),
  Frontend() {
  setRibbon();
}

////////////////////////////////////////////////////////////////////////////////
// PRIVATE SECTION                                                            //
////////////////////////////////////////////////////////////////////////////////

void MainWindow::setRibbon() {
  auto ribbon = new Ribbon(this);
  setRibbonBar(ribbon);
  setRibbonTheme(SARibbonTheme::RibbonThemeDark2);
  sa_set_ribbon_theme(this, SARibbonTheme::RibbonThemeDark2);
}

Ribbon.hpp

#include "SARibbon.h"



class Ribbon : public SARibbonBar {

  Q_OBJECT

public:

  Ribbon() = delete;
  Ribbon(QWidget* parent);
  Ribbon(const Ribbon&) = delete;
  Ribbon(Ribbon&&) = delete;
  virtual ~Ribbon() = default;

public:

  Ribbon& operator=(const Ribbon&) = delete;
  Ribbon& operator=(Ribbon&&) = delete;

private:

  void setRepositoryTab();
};

Ribbon.cpp

#include "Ribbon.hpp"

////////////////////////////////////////////////////////////////////////////////
// PUBLIC SECTION                                                             //
////////////////////////////////////////////////////////////////////////////////

Ribbon::Ribbon(QWidget* parent) :
  SARibbonBar(parent) {
  setRibbonStyle(SARibbonBar::RibbonStyleCompactThreeRow);
  setApplicationButton(nullptr);
  setRepositoryTab();
}

////////////////////////////////////////////////////////////////////////////////
// PRIVATE SECTION                                                            //
////////////////////////////////////////////////////////////////////////////////

void Ribbon::setRepositoryTab() {
  addCategoryPage(tr("Repository"));
}

What I'm doing wrong?

@czyt1988
Copy link
Owner

I don't understand what you mean by "and Windows is in dark mode, but even in light mode it's the same." Based on your screenshot, your window is already set to a dark theme. When setting the theme, you only need to call setRibbonTheme to set the theme; there's no need to call the sa_set_ribbon_theme function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants