Skip to content

Commit

Permalink
Theme wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sguionni committed May 23, 2024
1 parent 221052b commit 7cfed15
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 8 deletions.
1 change: 1 addition & 0 deletions lib/io/include/io/internal/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace VTX::IO::Internal::Filesystem
inline const FilePath getLibrariesDir() { return getExecutableDir() / "libraries"; }
inline const FilePath getRepresentationsLibraryDir() { return getLibrariesDir() / "representations"; }
inline const FilePath getRenderEffectPresetsLibraryDir() { return getLibrariesDir() / "render_effects"; }
inline const FilePath getThemesLibraryDir() { return getLibrariesDir() / "themes"; }
inline const FilePath getInternalDataDir() { return getExecutableDir() / "data"; }
inline const FilePath getResidueDataDir() { return getInternalDataDir() / "residue_data"; }

Expand Down
1 change: 1 addition & 0 deletions lib/ui/asset/qt/resources/resources_ui.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
<file>sprite/windows_icon.png</file>
<file>stylesheet_ui.css</file>
<file>stylesheet_ui_linux.css</file>
<file>stylesheet_ui_mac.css</file>
<file>stylesheet_ui_windows.css</file>
<file>video/video_intro.gif</file>
</qresource>
Expand Down
Empty file.
8 changes: 4 additions & 4 deletions lib/ui/include/ui/qt/main_window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace VTX::UI::QT

void addFloatingWindow( QDialog * const p_window, const QSize & p_size, const bool p_visible );

void appendStylesheet( const char * p_stylesheetPath );
// void appendStylesheet( const char * p_stylesheetPath );

protected:
void _setupUi( const QString & p_name ) override;
Expand All @@ -85,16 +85,16 @@ namespace VTX::UI::QT
void closeEvent( QCloseEvent * const p_event ) override;

private:
QT::Widget::MainMenu::MainMenuBar * _mainMenuBar;
QT::Widget::Status::StatusBar* _statusBar;
QT::Widget::MainMenu::MainMenuBar * _mainMenuBar;
QT::Widget::Status::StatusBar * _statusBar;

// Actions.
void _onDockWindowVisibilityChange( bool p_visible );

void _updatePicker() const;

// Functions.
void _loadStyleSheet( const char * p_stylesheetPath );
void _loadTheme();

Core::WindowMode _getWindowModeFromWindowState( const Qt::WindowStates & p_state );
std::string _getWindowTitle() const;
Expand Down
9 changes: 9 additions & 0 deletions lib/ui/include/ui/theme/theme.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <string>

namespace VTX::UI::Theme
{
struct Theme
{
std::string color;
};
} // namespace VTX::UI::Theme
31 changes: 27 additions & 4 deletions lib/ui/src/ui/qt/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace VTX::UI::QT

setDockOptions( DockOption::VerticalTabs | DockOption::AllowNestedDocks | DockOption::AllowTabbedDocks );

_loadStyleSheet( ":/stylesheet_ui.css" );
_loadTheme();
}

void MainWindow::initWindowLayout() {}
Expand All @@ -49,15 +49,37 @@ namespace VTX::UI::QT
);
}

void MainWindow::_loadStyleSheet( const char * p_stylesheetPath )
void MainWindow::_loadTheme()
{
QFile stylesheetFile( p_stylesheetPath );
// TODO: move to style constants.
// Load main stylesheet.
QFile stylesheetFile( ":/stylesheet_ui.css" );
stylesheetFile.open( QFile::ReadOnly );

const QString stylesheet = stylesheetFile.readAll();
QString stylesheet = stylesheetFile.readAll();

// Load os-specific stylesheet.
#if _WIN32
QFile stylesheetOSFile( ":/stylesheet_ui_windows.css" );
#elif __linux__
QFile stylesheetOSFile( ":/stylesheet_ui_linux.css" );
#elif __APPLE__
QFile stylesheetOSFile( ":/stylesheet_ui_mac.css" );
#else
QFile stylesheetOSFile();
assert( true );
#endif

stylesheetOSFile.open( QFile::ReadOnly );
stylesheet += '\n' + stylesheetOSFile.readAll();

// Load theme and apply to stylesheet.

// Set stylesheet to app.
setStyleSheet( stylesheet );
}

/*
void MainWindow::appendStylesheet( const char * p_stylesheetPath )
{
QFile stylesheetFile( p_stylesheetPath );
Expand All @@ -68,6 +90,7 @@ namespace VTX::UI::QT
setStyleSheet( newStylesheet );
}
*/

void MainWindow::_setupSlots() {}
void MainWindow::localize() { setWindowTitle( "VTX" ); }
Expand Down
6 changes: 6 additions & 0 deletions lib/ui/src/ui/qt/tool/scene/widget/scene_tree_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ namespace VTX::UI::QT::Tool::Scene::Widget
static_cast<QTreeWidget *>( nullptr ), QStringList( QString( "item: %1" ).arg( i ) )
) );
insertTopLevelItems( 0, items );

/*
MAIN_REGISTRY().connectSignal<Component::Chemistry::Molecule, &ProxyMolecule::_removeFromRenderer>(
Core::ECS::SIGNAL::DESTROY, this
);
*/
}

void SceneTreeWidget::_setupSlots() {}
Expand Down
10 changes: 10 additions & 0 deletions libraries/themes/Dark
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"DATA": {
"COLOR": #ffffff
},
"_VERSION": {
"MAJOR": 0,
"MINOR": 1,
"REVISION": 0
}
}

0 comments on commit 7cfed15

Please sign in to comment.