Merge branch 'develop' of github.com:MultiMC/MultiMC5 into develop

This commit is contained in:
Sky 2013-10-18 18:10:41 +01:00
commit b2574542b1
19 changed files with 169 additions and 3 deletions

View File

@ -350,6 +350,15 @@ IF(WIN32)
SET(MULTIMC_RCS multimc.rc) SET(MULTIMC_RCS multimc.rc)
ENDIF() ENDIF()
####### X11 Stuff #######
IF(UNIX AND NOT APPLE)
SET(MultiMC_QT_ADDITIONAL_MODULES ${MultiMC_QT_ADDITIONAL_MODULES} X11Extras)
SET(MultiMC_LINK_ADDITIONAL_LIBS ${MultiMC_LINK_ADDITIONAL_LIBS} xcb)
LIST(APPEND MULTIMC_SOURCES gui/platform_x11.cpp)
ELSE()
LIST(APPEND MULTIMC_SOURCES gui/platform_other.cpp)
ENDIF()
################################ COMPILE ################################ ################################ COMPILE ################################
@ -380,7 +389,7 @@ ADD_EXECUTABLE(MultiMC MACOSX_BUNDLE WIN32
# Link # Link
TARGET_LINK_LIBRARIES(MultiMC xz-embedded unpack200 quazip libUtil libSettings libGroupView ${MultiMC_LINK_ADDITIONAL_LIBS}) TARGET_LINK_LIBRARIES(MultiMC xz-embedded unpack200 quazip libUtil libSettings libGroupView ${MultiMC_LINK_ADDITIONAL_LIBS})
QT5_USE_MODULES(MultiMC Core Widgets Network Xml) QT5_USE_MODULES(MultiMC Core Widgets Network Xml ${MultiMC_QT_ADDITIONAL_MODULES})
ADD_DEPENDENCIES(MultiMC MultiMCLauncher) ADD_DEPENDENCIES(MultiMC MultiMCLauncher)
option(BUILD_KEYRING_TEST "Build the simple keyring test binary" OFF) option(BUILD_KEYRING_TEST "Build the simple keyring test binary" OFF)

View File

@ -1,5 +1,6 @@
#include "EditNotesDialog.h" #include "EditNotesDialog.h"
#include "ui_EditNotesDialog.h" #include "ui_EditNotesDialog.h"
#include "gui/platform.h"
#include <QIcon> #include <QIcon>
#include <QApplication> #include <QApplication>
@ -10,6 +11,7 @@ EditNotesDialog::EditNotesDialog( QString notes, QString name, QWidget* parent )
QDialog(parent), QDialog(parent),
ui(new Ui::EditNotesDialog) ui(new Ui::EditNotesDialog)
{ {
MultiMCPlatform::fixWM_CLASS(this);
ui->setupUi(this); ui->setupUi(this);
ui->noteEditor->setText(notes); ui->noteEditor->setText(notes);
setWindowTitle(tr("Edit notes of %1").arg(m_instance_name)); setWindowTitle(tr("Edit notes of %1").arg(m_instance_name));

View File

@ -3,6 +3,7 @@
#include "instancedelegate.h" #include "instancedelegate.h"
#include "ui_IconPickerDialog.h" #include "ui_IconPickerDialog.h"
#include "logic/lists/IconList.h" #include "logic/lists/IconList.h"
#include "gui/platform.h"
#include <QKeyEvent> #include <QKeyEvent>
#include <QPushButton> #include <QPushButton>
#include <QFileDialog> #include <QFileDialog>
@ -11,6 +12,7 @@ IconPickerDialog::IconPickerDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::IconPickerDialog) ui(new Ui::IconPickerDialog)
{ {
MultiMCPlatform::fixWM_CLASS(this);
ui->setupUi(this); ui->setupUi(this);
setWindowModality(Qt::WindowModal); setWindowModality(Qt::WindowModal);

View File

@ -21,6 +21,7 @@
#include "ui_LegacyModEditDialog.h" #include "ui_LegacyModEditDialog.h"
#include "logic/ModList.h" #include "logic/ModList.h"
#include "logic/lists/ForgeVersionList.h" #include "logic/lists/ForgeVersionList.h"
#include "gui/platform.h"
#include <pathutils.h> #include <pathutils.h>
#include <QFileDialog> #include <QFileDialog>
@ -32,6 +33,7 @@
LegacyModEditDialog::LegacyModEditDialog(LegacyInstance *inst, QWidget *parent) LegacyModEditDialog::LegacyModEditDialog(LegacyInstance *inst, QWidget *parent)
: m_inst(inst), QDialog(parent), ui(new Ui::LegacyModEditDialog) : m_inst(inst), QDialog(parent), ui(new Ui::LegacyModEditDialog)
{ {
MultiMCPlatform::fixWM_CLASS(this);
ui->setupUi(this); ui->setupUi(this);
// Jar mods // Jar mods

View File

@ -20,8 +20,9 @@
#include "logic/OneSixVersion.h" #include "logic/OneSixVersion.h"
#include "logic/EnabledItemFilter.h" #include "logic/EnabledItemFilter.h"
#include "logic/lists/ForgeVersionList.h" #include "logic/lists/ForgeVersionList.h"
#include <logic/ForgeInstaller.h> #include "logic/ForgeInstaller.h"
#include "gui/versionselectdialog.h" #include "gui/versionselectdialog.h"
#include "gui/platform.h"
#include "ProgressDialog.h" #include "ProgressDialog.h"
#include <pathutils.h> #include <pathutils.h>
@ -35,6 +36,7 @@
OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent) OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent)
: m_inst(inst), QDialog(parent), ui(new Ui::OneSixModEditDialog) : m_inst(inst), QDialog(parent), ui(new Ui::OneSixModEditDialog)
{ {
MultiMCPlatform::fixWM_CLASS(this);
ui->setupUi(this); ui->setupUi(this);
// libraries! // libraries!

View File

@ -19,11 +19,13 @@
#include <QKeyEvent> #include <QKeyEvent>
#include "logic/tasks/Task.h" #include "logic/tasks/Task.h"
#include "gui/platform.h"
ProgressDialog::ProgressDialog(QWidget *parent) : ProgressDialog::ProgressDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::ProgressDialog) ui(new Ui::ProgressDialog)
{ {
MultiMCPlatform::fixWM_CLASS(this);
ui->setupUi(this); ui->setupUi(this);
updateSize(); updateSize();

View File

@ -2,11 +2,13 @@
#include "ui_aboutdialog.h" #include "ui_aboutdialog.h"
#include <QIcon> #include <QIcon>
#include <MultiMC.h> #include <MultiMC.h>
#include "gui/platform.h"
AboutDialog::AboutDialog(QWidget *parent) : AboutDialog::AboutDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::AboutDialog) ui(new Ui::AboutDialog)
{ {
MultiMCPlatform::fixWM_CLASS(this);
ui->setupUi(this); ui->setupUi(this);
ui->icon->setPixmap(QIcon(":/icons/multimc/scalable/apps/multimc.svg").pixmap(64)); ui->icon->setPixmap(QIcon(":/icons/multimc/scalable/apps/multimc.svg").pixmap(64));

View File

@ -4,12 +4,15 @@
#include <QScrollBar> #include <QScrollBar>
#include <QMessageBox> #include <QMessageBox>
#include <gui/platform.h>
ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) : ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::ConsoleWindow), ui(new Ui::ConsoleWindow),
m_mayclose(true), m_mayclose(true),
proc(mcproc) proc(mcproc)
{ {
MultiMCPlatform::fixWM_CLASS(this);
ui->setupUi(this); ui->setupUi(this);
connect(mcproc, SIGNAL(ended()), this, SLOT(onEnded())); connect(mcproc, SIGNAL(ended()), this, SLOT(onEnded()));
} }

View File

@ -19,12 +19,14 @@
#include "instancesettings.h" #include "instancesettings.h"
#include "ui_instancesettings.h" #include "ui_instancesettings.h"
#include "gui/platform.h"
InstanceSettings::InstanceSettings( SettingsObject * obj, QWidget *parent) : InstanceSettings::InstanceSettings( SettingsObject * obj, QWidget *parent) :
m_obj(obj), m_obj(obj),
QDialog(parent), QDialog(parent),
ui(new Ui::InstanceSettings) ui(new Ui::InstanceSettings)
{ {
MultiMCPlatform::fixWM_CLASS(this);
ui->setupUi(this); ui->setupUi(this);
loadSettings(); loadSettings();
} }

View File

@ -16,12 +16,14 @@
#include "logindialog.h" #include "logindialog.h"
#include "ui_logindialog.h" #include "ui_logindialog.h"
#include "keyring.h" #include "keyring.h"
#include "gui/platform.h"
#include <logger/QsLog.h> #include <logger/QsLog.h>
LoginDialog::LoginDialog(QWidget *parent, const QString& loginErrMsg) : LoginDialog::LoginDialog(QWidget *parent, const QString& loginErrMsg) :
QDialog(parent), QDialog(parent),
ui(new Ui::LoginDialog) ui(new Ui::LoginDialog)
{ {
MultiMCPlatform::fixWM_CLASS(this);
ui->setupUi(this); ui->setupUi(this);
//: Use offline mode one time //: Use offline mode one time

View File

@ -16,6 +16,7 @@
#include "MultiMC.h" #include "MultiMC.h"
#include "lwjglselectdialog.h" #include "lwjglselectdialog.h"
#include "ui_lwjglselectdialog.h" #include "ui_lwjglselectdialog.h"
#include "gui/platform.h"
#include "logic/lists/LwjglVersionList.h" #include "logic/lists/LwjglVersionList.h"
@ -23,6 +24,7 @@ LWJGLSelectDialog::LWJGLSelectDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::LWJGLSelectDialog) ui(new Ui::LWJGLSelectDialog)
{ {
MultiMCPlatform::fixWM_CLASS(this);
ui->setupUi(this); ui->setupUi(this);
ui->labelStatus->setVisible(false); ui->labelStatus->setVisible(false);
auto lwjgllist = MMC->lwjgllist(); auto lwjgllist = MMC->lwjgllist();

View File

@ -48,6 +48,7 @@
#include "gui/lwjglselectdialog.h" #include "gui/lwjglselectdialog.h"
#include "gui/consolewindow.h" #include "gui/consolewindow.h"
#include "gui/instancesettings.h" #include "gui/instancesettings.h"
#include "gui/platform.h"
#include "logic/lists/InstanceList.h" #include "logic/lists/InstanceList.h"
#include "logic/lists/MinecraftVersionList.h" #include "logic/lists/MinecraftVersionList.h"
@ -72,6 +73,7 @@
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{ {
MultiMCPlatform::fixWM_CLASS(this);
ui->setupUi(this); ui->setupUi(this);
setWindowTitle(QString("MultiMC %1").arg(MMC->version().toString())); setWindowTitle(QString("MultiMC %1").arg(MMC->version().toString()));

View File

@ -13,6 +13,10 @@
<property name="windowTitle"> <property name="windowTitle">
<string>MultiMC 5</string> <string>MultiMC 5</string>
</property> </property>
<property name="windowIcon">
<iconset resource="../multimc.qrc">
<normaloff>:/icons/multimc/scalable/apps/multimc.svg</normaloff>:/icons/multimc/scalable/apps/multimc.svg</iconset>
</property>
<widget class="QWidget" name="centralWidget"> <widget class="QWidget" name="centralWidget">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing"> <property name="spacing">

View File

@ -23,6 +23,7 @@
#include "logic/lists/MinecraftVersionList.h" #include "logic/lists/MinecraftVersionList.h"
#include "logic/tasks/Task.h" #include "logic/tasks/Task.h"
#include "gui/platform.h"
#include "versionselectdialog.h" #include "versionselectdialog.h"
#include "ProgressDialog.h" #include "ProgressDialog.h"
#include "IconPickerDialog.h" #include "IconPickerDialog.h"
@ -33,6 +34,7 @@
NewInstanceDialog::NewInstanceDialog(QWidget *parent) NewInstanceDialog::NewInstanceDialog(QWidget *parent)
: QDialog(parent), ui(new Ui::NewInstanceDialog) : QDialog(parent), ui(new Ui::NewInstanceDialog)
{ {
MultiMCPlatform::fixWM_CLASS(this);
ui->setupUi(this); ui->setupUi(this);
resize(minimumSizeHint()); resize(minimumSizeHint());
layout()->setSizeConstraint(QLayout::SetFixedSize); layout()->setSizeConstraint(QLayout::SetFixedSize);

35
gui/platform.h Normal file
View File

@ -0,0 +1,35 @@
/* Copyright 2013 MultiMC Contributors
*
* Authors: Orochimarufan <orochimarufan.x3@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef PLATFORM_H
#define PLATFORM_H
/**
* @file platform.h
* This file contains platform-specific functions, tweaks and fixes.
*/
#include <QWidget>
class MultiMCPlatform
{
public:
// X11 WM_CLASS
static void fixWM_CLASS(QWidget *widget);
};
#endif // PLATFORM_H

27
gui/platform_other.cpp Normal file
View File

@ -0,0 +1,27 @@
/* Copyright 2013 MultiMC Contributors
*
* Authors: Orochimarufan <orochimarufan.x3@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <gui/platform.h>
/**
* Stub for non-X11 platforms
* @brief MultiMCPlatform::fixWM_CLASS
* @param widget
*/
void MultiMCPlatform::fixWM_CLASS(QWidget *widget)
{
Q_UNUSED(widget);
}

62
gui/platform_x11.cpp Normal file
View File

@ -0,0 +1,62 @@
/* Copyright 2013 MultiMC Contributors
*
* Authors: Orochimarufan <orochimarufan.x3@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <gui/platform.h>
#include <QtX11Extras/QX11Info>
#include <xcb/xcb.h>
static QByteArray WM_CLASS = "MultiMC5\0MultiMC5";
template <typename... ArgTypes, typename... ArgTypes2>
static inline unsigned int XcbCallVoid(xcb_void_cookie_t (*func)(xcb_connection_t *, ArgTypes...), ArgTypes2... args...)
{
return func(QX11Info::connection(), args...).sequence;
}
static void getAtoms(size_t n, xcb_atom_t *atoms, const char *const names[], bool create)
{
xcb_connection_t *conn = QX11Info::connection();
xcb_intern_atom_cookie_t *cookies = (xcb_intern_atom_cookie_t *)malloc(sizeof(xcb_intern_atom_cookie_t) * 2);
for (size_t i = 0; i < n; ++i)
cookies[i] = xcb_intern_atom(conn, create, strlen(names[i]), names[i]);
memset(atoms, 0, sizeof(xcb_atom_t) * n);
for (size_t i = 0; i < n; ++i)
{
xcb_intern_atom_reply_t *r = xcb_intern_atom_reply(conn, cookies[i], 0);
if (r)
{
atoms[i] = r->atom;
free(r);
}
}
free(cookies);
}
static inline xcb_atom_t getAtom(const char *name, bool create=false)
{
xcb_atom_t atom;
getAtoms(1, &atom, &name, create);
return atom;
}
void MultiMCPlatform::fixWM_CLASS(QWidget *widget)
{
static const xcb_atom_t atom = getAtom("WM_CLASS");
XcbCallVoid(xcb_change_property, XCB_PROP_MODE_REPLACE,
widget->winId(), atom, XCB_ATOM_STRING, 8, WM_CLASS.count(),
WM_CLASS.constData());
}

View File

@ -18,6 +18,7 @@
#include "ui_settingsdialog.h" #include "ui_settingsdialog.h"
#include "logic/JavaUtils.h" #include "logic/JavaUtils.h"
#include "gui/versionselectdialog.h" #include "gui/versionselectdialog.h"
#include "gui/platform.h"
#include "logic/lists/JavaVersionList.h" #include "logic/lists/JavaVersionList.h"
#include <settingsobject.h> #include <settingsobject.h>
@ -28,6 +29,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::SettingsDialog) ui(new Ui::SettingsDialog)
{ {
MultiMCPlatform::fixWM_CLASS(this);
ui->setupUi(this); ui->setupUi(this);
loadSettings(MMC->settings().get()); loadSettings(MMC->settings().get());

View File

@ -21,6 +21,7 @@
#include <QDebug> #include <QDebug>
#include <gui/ProgressDialog.h> #include <gui/ProgressDialog.h>
#include "gui/platform.h"
#include <logic/BaseVersion.h> #include <logic/BaseVersion.h>
#include <logic/lists/BaseVersionList.h> #include <logic/lists/BaseVersionList.h>
@ -29,6 +30,7 @@
VersionSelectDialog::VersionSelectDialog(BaseVersionList *vlist, QString title, QWidget *parent, bool cancelable) VersionSelectDialog::VersionSelectDialog(BaseVersionList *vlist, QString title, QWidget *parent, bool cancelable)
: QDialog(parent), ui(new Ui::VersionSelectDialog) : QDialog(parent), ui(new Ui::VersionSelectDialog)
{ {
MultiMCPlatform::fixWM_CLASS(this);
ui->setupUi(this); ui->setupUi(this);
setWindowModality(Qt::WindowModal); setWindowModality(Qt::WindowModal);
setWindowTitle(title); setWindowTitle(title);