Skip to content
This repository has been archived by the owner on Dec 16, 2020. It is now read-only.

Commit

Permalink
added first-start dialog
Browse files Browse the repository at this point in the history
updated changelog
fixed some issues in the default theme
  • Loading branch information
Ende! committed Aug 14, 2014
1 parent dcbdb7e commit 355aa35
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 20 deletions.
34 changes: 34 additions & 0 deletions Config.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2014 athre0z
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#ifndef CONFIG_HPP
#define CONFIG_HPP

#define MAKE_PLUGIN_VERSION(maj, min, rev) ((maj << 16) | (min << 8) | rev)
#define PLUGIN_TEXTUAL_VERSION "v1.2.0"
#define PLUGIN_VERSION MAKE_PLUGIN_VERSION(1, 2, 0)

#define PLUGIN_NAME "IDASkins"

#endif
7 changes: 6 additions & 1 deletion Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@

#include "Settings.hpp"

#include "Config.hpp"

// ========================================================================= //
// [Settings] //
// ========================================================================= //

const QString Settings::kSelectedThemeDir = "selectedThemeDir";
const QString Settings::kFirstStart = "firstStart";

Settings::Settings()
: QSettings("athre0z", "IDASkins")
: QSettings("athre0z", PLUGIN_NAME)
{

}
Expand Down
7 changes: 7 additions & 0 deletions Settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@
class Settings : public QSettings
{
public:
/**
* @brief Default constructor.
*/
Settings();
public:
// Constants.
static const QString kSelectedThemeDir;
static const QString kFirstStart;
};

// ========================================================================= //
Expand Down
3 changes: 2 additions & 1 deletion ThemeSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "Utils.hpp"
#include "ThemeManifest.hpp"
#include "Config.hpp"

#include <memory>
#include <QPixmap>
Expand Down Expand Up @@ -60,7 +61,7 @@ void ThemeSelector::refresh()
}
catch (const ThemeManifest::XInvalidManifest &e)
{
msg("[IDASkins] %s: %s\n", it->toUtf8().data(), e.what());
msg("["PLUGIN_NAME"] %s: %s\n", it->toUtf8().data(), e.what());
}
}

Expand Down
4 changes: 2 additions & 2 deletions Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ QString getThemesPath()
bool getCurrentThemeDir(QDir &dir)
{
Settings settings;
QVariant themeDirSetting = settings.value("selectedThemeDir");
QVariant themeDirSetting = settings.value(Settings::kSelectedThemeDir);
if (themeDirSetting.isNull()) return false;
if (!themeDirSetting.canConvert<QString>())
{
settings.remove("selectedThemeDir");
settings.remove(Settings::kSelectedThemeDir);
return false;
}

Expand Down
7 changes: 6 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@
- fixed problems with bad contrasts
- fixed scrollbar issues
- moved style config into extra directory (IDADIR/skin)
- added path constants "<IDADIR>" and "<SKINDIR>" for stylesheets
- added path constants "<IDADIR>" and "<SKINDIR>" for stylesheets

1.1.0 -> 1.2.0:
- altered skin file structure to allow switching between several skins
- added skin selection dialog
- improved default skin
56 changes: 45 additions & 11 deletions idaskins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "Utils.hpp"
#include "Settings.hpp"
#include "ThemeSelector.hpp"
#include "Config.hpp"

#include <QtGui>
#include <QDockWidget>
Expand All @@ -47,22 +48,22 @@ bool applyStylesheet(QDir themeDir)
QFile stylesheet(themeDirPath + "/stylesheet.qss");
if (!stylesheet.open(QFile::ReadOnly))
{
msg("[IDASkins] Unable to load stylesheet file.\n");
msg("["PLUGIN_NAME"] Unable to load stylesheet file.\n");
return false;
}

QString data = stylesheet.readAll();
data.replace("<IDADIR>", idadir(nullptr));
data.replace("<SKINDIR>", themeDirPath);
qApp->setStyleSheet(data);
msg("[IDASkins] Skin file successfully applied!\n");
msg("["PLUGIN_NAME"] Skin file successfully applied!\n");

/*
static bool first = true;
// Information gathering
if (!first)
{
QFile log(themeDir + "/skin/object_log.log");
QFile log(QString(idadir(nullptr)) + "/skin/object_log.log");
log.open(QFile::WriteOnly);
std::function<void(QObject*, int)> helper = [&](QObject *element, int depth)
{
Expand Down Expand Up @@ -96,14 +97,52 @@ bool applyStylesheet(QDir themeDir)
return true;
}

/**
* @brief Opens the theme selection dialog.
*/
void openThemeSelectionDialog()
{
ThemeSelector selector;
selector.exec();

// New theme selected? Save to settings.
if (selector.selectedThemeDir())
{
Settings().setValue(Settings::kSelectedThemeDir,
selector.selectedThemeDir()->dirName());
}
}

/**
* @brief Initialization callback for IDA.
* @return A @c PLUGIN_ constant from loader.hpp.
*/
int idaapi init()
{
if (!is_idaq()) return PLUGIN_SKIP;
msg("IDASkins 1.2.0 by athre0z/Ende! loaded!\n");
msg(PLUGIN_NAME" "PLUGIN_TEXTUAL_VERSION" by athre0z/Ende! loaded!\n");

// If first start with plugin, ask for theme.
Settings settings;
QVariant firstStartVar = settings.value(Settings::kFirstStart, true);
bool firstStart = true;
if (firstStartVar.canConvert<bool>())
firstStart = firstStartVar.toBool();
else
settings.remove(Settings::kFirstStart);

if (firstStartVar.toBool())
{
auto pressedButton = QMessageBox::information(nullptr, PLUGIN_NAME": First start",
PLUGIN_NAME" detected that this is you first IDA startup with this plugin "
"installed. Do you wish to select a theme now?",
QMessageBox::Yes | QMessageBox::No);

if (pressedButton == QMessageBox::Yes)
openThemeSelectionDialog();

settings.setValue(Settings::kFirstStart, false);
}

QDir activeThemeDir;
if (Utils::getCurrentThemeDir(activeThemeDir))
Expand All @@ -125,12 +164,7 @@ void idaapi term()
*/
void idaapi run(int /*arg*/)
{
ThemeSelector selector;
selector.exec();

// New theme selected? Save to settings.
if (selector.selectedThemeDir())
Settings().setValue("selectedThemeDir", selector.selectedThemeDir()->dirName());
openThemeSelectionDialog();

QDir activeThemeDir;
if (Utils::getCurrentThemeDir(activeThemeDir))
Expand All @@ -146,7 +180,7 @@ plugin_t PLUGIN =
run,
"Advanced IDA skinning",
"Plugin providing advanced skinning facilities using Qt stylesheets.",
"IDASkins: Settings",
PLUGIN_NAME": Settings",
"Ctrl-Shift-S"
};

Expand Down
1 change: 1 addition & 0 deletions idaskins.pro
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ HEADERS += ThemeSelector.hpp \
Utils.hpp \
ThemeManifest.hpp \
Settings.hpp \
Config.hpp \

SOURCES += ThemeSelector.cpp \
Utils.cpp \
Expand Down
11 changes: 7 additions & 4 deletions skin/default/stylesheet.qss
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,18 @@ QComboBox::down-arrow {
image: url(<SKINDIR>/icons/expand.png);
}

QToolBar::handle {
image: url(<SKINDIR>/icons/spacer.png);
}

IDADockWidget > QWidget > QAbstractButton {
background-color: #666;
border-radius: 3px;
}

QRadioButton, QLabel, QCheckBox {
background: transparent;
}

TNavBand > QPushButton, RegJumpButton {
min-height: 0;
min-width: 0;
padding: 0 0 0 0;
border: none;
}

0 comments on commit 355aa35

Please sign in to comment.